code hacking, zen coding


CSAW 2011 PatchManagement Write-Up

In this Networking challenge, we get a short tcpdump capture file with a SSH session.

Given the capture is really short, we immediately focus on this SSH session. Decrypting SSH without prior knowledge of the private keys is not an easy feat' except in one particular case: if one of the client or server key was generated on a Debian machine during the OpenSSL fiasco.

In 2008, Debian shipped with a flawed openssl package that resulted in keys with very weak entropy, in other words, predictable keys:

Let see if this is the case. First we split this capture file in session file that can be used by our bruteforcer tool. For this job, we use tcpick (available as Debian package)

$ tcpick -wRC -wRS -r capture.pcap
Starting tcpick 0.2.1 at 2011-09-24 03:13 UTC
Timeout for connections is 600
tcpick: reading from capture.pcap
1      SYN-SENT >
1      FIN-WAIT-1 >
1      TIME-WAIT >
1      CLOSED >
tcpick: done reading from capture.pcap

74 packets captured
1 tcp sessions detected

Now we can use one of the SSH bruteforcer specially designed to handle those weak keys. I choose the client mode (-c) because in the capture file you can see that the client's OpenSSH version is much older than the server.

$ ruby ssh_decoder.rb -c -n2 ../tcpick_192.168.0.119_192.168.0.222_ssh.*
* read handshake
cipher: aes128-cbc, mac: hmac-md5, kex_hash: sha1, compr: none
* bruteforce DH
DH shared secret : 028b79a7ee617e11fe3cc5600b93b9423e75c494dcc5e12fed2d99864dd940838c09f77f62356d600c32a37c9e585b21fa0f9c11dc97f7bac6a9a8864fe55a210048c149ae9bf3c6399a8c162bb7cbf1cf7678b34ffe7c118ee34a1239fb4b9d960b6746e60a456a0284c0e2210b837c554c9ef857b6f25ea106422c881c08aa
* derive keys
* decipher streams
* successful authentication packet
\016\371O\332\bw\276\300\367\373\350\3223XX\205\340W\267r\246\f\265\0349}1Q>\245r\021\262\244\004\3437"\377\247\257\344\304\344EP\250\021k'\261$N\346\230\321\273hTq?O\274\335\260)\266[<L \231\b%\367\262\353\307\002\b\026\20148\004\352\036\a]\025\204\300\210W{\035YML>\311\274\024I\307N:\375\264\340\000\346\331\023\301N\002\327\263\026\217p\233\300\230@\351\333"},
* deciphered streams saved to "sshdecrypt.0.client.dat" & "sshdecrypt.0.server.dat"

We have deciphered the SSH exchange and we can know see what the user typed into this SSH terminal:

$ strings sshdecrypt.0.server.dat | grep key


Posted by aXs

Tagged as: , , , Comments Off
Comments (0) Trackbacks (0)

Sorry, the comment form is closed at this time.

Trackbacks are disabled.