ZAMYLA CHAN: All right.
Let's get cracking.
For this walk-through, because this is a more comfortable problem,
I will be going over some of the concepts used
to solve this problem but less so some of the code
that you might use to do it.
Your tasks for this problem are to get the hashed password from the user
and then try to crack that password.
The hashed password will be passed in via a command-line argument.
So make sure to ensure that the user is using your program properly.
If your program is executed without any command-line arguments or, perhaps,
more than one command-line argument, then your program
should print an error of your choice and exit immediately with main returning
one, thereby signifying an error.
All right.
Now that you have the hash, let's try to crack this password.
In order to reasonably solve this problem,
we'll allow you to make several assumptions.
The first of which is that all of these passwords
are hashed with C's DES-based crypt function.
Take a look at the man page for this function.
You'll find that crypt takes in two arguments, key and salt.
And you can find the salt because it's the first two
characters of that hashed password.
Key to solving this problem is remembering that hashing a word
will always return the exact same hash.
The crypt function is deterministic.
So as long as you pass in the same key and salt,
crypt will always return the same hash.
So I want you to try a word.
Hash that try calling the crypt function.
And if those hashes match, then you can assume that you've successfully
cracked the password.
More assumptions that you can make as you're guessing these passwords.
One, that they're no longer than four characters
and that they're composed entirely of alphabetical characters.
So how might you generate the plain text to be hashed?
For the guesses, think of a way to carefully iterate over
every combination of one to four characters where all of the characters
are alphabetic and case sensitive.
Consider an array, perhaps, of five bytes.
And use one to four of those bytes for alphabetical characters
with a trailing backslash 0 to end the string.
And also be sure to left-align the string in the buffer.
Calling crypt on those and checking it against the user
provided hash will, hopefully, get you to crack these passwords.
My name is the Zamyla.
And this was crack.