Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

In a security context course, we need to reproduce the old DES hashing scheme in the crypt program, on an old unix system.

I am actually reading the crypt page on wikipedia:

The traditional implementation uses a modified form of the DES algorithm. The user's password is truncated to eight characters, and those are coerced down to only 7-bits each; this forms the 56-bit DES key. That key is then used to encrypt an all-bits-zero block, and then the ciphertext is encrypted again with the same key, and so on for a total of 25 DES encryptions. A 12-bit salt is used to perturb the encryption algorithm, so standard DES implementations can't be used to implement crypt(). The salt and the final ciphertext are encoded into a printable string in a form of base64.

I am not sure to well completely understand the above definition, and I would like to use an example to show you my questions.

So, considering I use the password: foobar12345678.

I will work in hexadecimal, so the password is: 66 6f 6f 62 61 72 31 32 1.The password will be truncated to foobar12.

2.I remove the first bit (not sure?) of every password byte, so my new password will be:

01100110 01101111 01101111 01100010 01100001 01110010 00110001 00110010
11001101 10111111 01111110 00101100 00111100 10011000 10110010 

The password in hexadecimal is `cd bf 7e 2c 3c 98 b2` and is the 56 bits DES key.

3.The key above is used to encrypt an all-bits-zero block. I imagine the zero block is 56 bits also?

so, using an hypothetical DES scheme encryption function function_DES(hex_message, hex_key), our hash here would be the output of function_DES(00 00 00 00 00 00 00, cd bf 7e 2c 3c 98 b2). imagine that the output is hashOutput1

4.We crypt 25 hashOutput1 with the key cd bf 7e 2c 3c 98 b2 using DES scheme.

A 12-bit salt is used to perturb the encryption algorithm, so standard DES implementations can't be used to implement crypt()

5.What's the 12-bit salt? I imagine it's predefined in linux system? Where can I find it? Imagine the salt is 101010101010 I place it in front of the 25th encrypted DES output?

6.Both hash and salt are comverted to base64 and placed in the /etc/shadow as:


So, during the 56 bits key creation, when we coerce down bits in 64 bits password, is it the first bit of each byte that we need to remove?

Are all-zeros blocks 56 bits (the exact same size than the 56 bits key) ?

What's the salt? Is it predefined in Unix system? Is it the same in all distro?

So, using this technique bruteforce tools should never go over 8 characters?


http://en.wikipedia.org/wiki/Crypt_%28Unix%29 and http://www.kernel.org/doc/man-pages/online/pages/man3/crypt.3.html


for my salt question, I think I found my answer:

When you change your password, the /bin/passwd program selects a salt based on the time of day. The salt is converted into a two-character string and is stored in the /etc/passwd file along with the encrypted "password."[10] In this manner, when you type your password at login time, the same salt is used again. UNIX stores the salt as the first two characters of the encrypted password.


share|improve this question

closed as off topic by AviD Oct 15 '12 at 21:09

Questions on Information Security Stack Exchange are expected to relate to Information security within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Hi @Pier, welcome to Information Security! You posted the identical question on our sister crypto site - crypto.stackexchange.com/questions/5060/…. Please don't cross-post, if it is offtopic or a better fit on another SE site, a moderator could always migrate it. Please check out the FAQ... Thanks! –  AviD Oct 15 '12 at 21:10

Browse other questions tagged or ask your own question.