I'm trying to analyze a mobile application and I believe it is is using DES. Here is a sample of the authentication handshake.




For simplicity, the password is set to AAAAAAAA.

For authentication, it is identified as "VNC". This leads me to believe that they are using VNC authentication, as defined by RFC 6143.


The documentation states:

The client encrypts the challenge with DES, using a password supplied
by the user as the key.  To form the key, the password is truncated
to eight characters, or padded with null bytes on the right.  The
client then sends the resulting 16-byte response

So if I understand correctly, If I were to encrypt "0xA489C9790FB7C3CE2E56868C788641FC" with the key of "AAAAAAAA" it should equal "0xD33BAD35B07EF500A82329749CEE9192". Is that correct?

Challenge contains:

$ cat  ~/Desktop/challange | xxd -p

I try to run:

$ openssl des -in ~/Desktop/challange  | xxd -p
enter des-cbc encryption password:
Verifying - enter des-cbc encryption password:

Which doesn't prepuce what I am hoping for, which is D33BAD35B07EF500A82329749CEE9192. What am I doing wrong?


I found this online.


I believe this might explain why I'm having issues.




Ok, I got it. Just answering for anyone else who stumbles here. While not documented, RFB mirrors each bit. Using the key of all B's, I was able to get my result, as B is a palindrome.

  • 2
    $\begingroup$ FYI you would still get different results with openssl des because OpenSSL enc defaults to salted password-based encryption (the key is derived from the password, it is not the pw, and is randomized) in CBC mode with padding (both wrong for your case). echo 318E90D502A379A7B1583C35DB772138 |xxd -r -p |openssl des-ecb -nopad -K 4242424242424242 |xxd -p (-K takes hex and ASCII 'B' is hex 42) gives desired result 1d214ef554123712a0dc9bcf003c27f4. $\endgroup$ – dave_thompson_085 Oct 31 '16 at 5:24

To be clear, as Dave Thompson is implying, the challenge response appears to be just a vanilla DES ECB with no nibble swapping as suggested by the original poster (I was also sidetracked by the information on the link). Note that the password BBBBBBBB would translate to $$$$$$$$ if nibble swapped, so is not actually any different than AAAAAAAA in that respect.

I was able to get the challenge response with the python code found at: https://github.com/RobinDavid/pydes

Just change the main to use the test data:

import binascii
key_str = "BBBBBBBB"
data= binascii.unhexlify('318E90D502A379A7B1583C35DB772138')
d = des()
r = d.encrypt(key_str,data)
print binascii.hexlify(r)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.