26.07.2018 Views

hacking-the-art-of-exploitation

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

0x750<br />

Hybrid Ciphers<br />

A hybrid cryptosystem gets <strong>the</strong> best <strong>of</strong> both worlds. An asymmetric cipher<br />

is used to exchange a randomly generated key that is used to encrypt <strong>the</strong><br />

remaining communications with a symmetric cipher. This provides <strong>the</strong><br />

speed and efficiency <strong>of</strong> a symmetric cipher, while solving <strong>the</strong> dilemma <strong>of</strong><br />

secure key exchange. Hybrid ciphers are used by most modern cryptographic<br />

applications, such as SSL, SSH, and PGP.<br />

Since most applications use ciphers that are resistant to cryptanalysis,<br />

attacking <strong>the</strong> cipher usually won’t work. However, if an attacker can intercept<br />

communications between both p<strong>art</strong>ies and masquerade as one or <strong>the</strong><br />

o<strong>the</strong>r, <strong>the</strong> key exchange algorithm can be attacked.<br />

0x751<br />

Man-in-<strong>the</strong>-Middle Attacks<br />

A man-in-<strong>the</strong>-middle (MitM) attack is a clever way to circumvent encryption.<br />

The attacker sits between <strong>the</strong> two communicating p<strong>art</strong>ies, with each p<strong>art</strong>y<br />

believing <strong>the</strong>y are communicating with <strong>the</strong> o<strong>the</strong>r p<strong>art</strong>y, but both are communicating<br />

with <strong>the</strong> attacker.<br />

When an encrypted connection between <strong>the</strong> two p<strong>art</strong>ies is established, a<br />

secret key is generated and transmitted using an asymmetric cipher. Usually,<br />

this key is used to encrypt fur<strong>the</strong>r communication between <strong>the</strong> two p<strong>art</strong>ies.<br />

Since <strong>the</strong> key is securely transmitted and <strong>the</strong> subsequent traffic is secured by<br />

<strong>the</strong> key, all <strong>of</strong> this traffic is unreadable by any would-be attacker sniffing <strong>the</strong>se<br />

packets.<br />

However, in an MitM attack, p<strong>art</strong>y A believes that she is communicating<br />

with B, and p<strong>art</strong>y B believes he is communicating with A, but in reality, both<br />

are communicating with <strong>the</strong> attacker. So, when A negotiates an encrypted<br />

connection with B, A is actually opening an encrypted connection with <strong>the</strong><br />

attacker, which means <strong>the</strong> attacker securely communicates with an asymmetric<br />

cipher and learns <strong>the</strong> secret key. Then <strong>the</strong> attacker just needs to open ano<strong>the</strong>r<br />

encrypted connection with B, and B will believe that he is communicating<br />

with A, as shown in <strong>the</strong> following illustration.<br />

Attacker<br />

Appears to<br />

be System A<br />

Encrypted<br />

Communication<br />

with Key 1<br />

Appears to<br />

be System B<br />

System A<br />

Encrypted<br />

Communication<br />

with Key 2<br />

Systems A and B both believe<br />

<strong>the</strong>y are communicating with<br />

each o<strong>the</strong>r.<br />

System B<br />

406 0x700

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!