Brute-force password cracking

Folder: passwords
Files: passwords/summary.txt, cracked1.txt, cracked2.txt, cracked3.txt, passwords.py

Partner or solo, as you wish.

Goals

Rubric

2 - all passwords cracked for part 1 1 - some passwords cracked for part 2 1 - some passwords cracked for part 3 1 - all passwords cracked for part 4 3 - timing reports 6 - analysis

Background

User names on Linux systems are typically stored in a file named /etc/passwd. (Check out this description of the /etc/passwd file format.) This file is world-readable, so if you want to see all the users on a particular system you're logged into, just do cat /etc/passwd.

It used to be that the password hashes were also stored in /etc/passwd, but that changed some years ago for obvious security reasons. These days, it is more typical for the password hashes to be stored in a file named /etc/shadow. (Here's a description of the shadow file format.)

Check out the difference in permissions between these two files on mantis or mirage:

ls -l /etc/passwd ls -l /etc/shadow

For this assignment, you're going to do a little password cracking and thinking about the time and space complexity of password cracking.

Part 1: Unsalted one-word passwords

A typical line in /etc/shadow might look like this:

jondich:182072537ada59e4d6b18034a80302ebae935f66adbdf0f271d3d36309c2d481::0:99999:7:::

This colon-delimited set of fields includes the user name, the SHA-256 hash of the user's password, and then miscellaneous other stuff that won't concern us.

As we'll see, this is not quite a modern format for a variety of reasons, including the fact that the cryptographic hash function has not been explicitly specified and there's no salt included. But this is pretty close to how passwords are stored on most Linux systems.

Consider example password file #1. Your job for Part 1 is to:

A little help

Part 2: Unsalted two-word passwords

Same task as Part 1, but using example password file #2. This time, all the passwords are two random words concatenated (e.g. "cowgecko"). The password for jondich is still "marmot".

Part 3: Salted passwords

Now, let's switch to a slightly different password file format:

jondich:$5$e75fa822$8a604057b98aff07885d29eea97e885e::0:99999:7:::

For this phase, use example password file #3. The passwords in this file are one-word passwords as in Part 1.

In the hash field, we have an 8-digit hexadecimal number known as "salt", then a dollar sign, and then the hash of the salt concatenated with the password (i.e. H(salt || pw)). As before, the "jondich" password is "marmot", so you can use that to check your hash computation code. Also, as before, the hash function we're using is SHA-256.

(WARNING: This hashing technique is designed to introduce you to the basic idea of salted passwords. However, the technique and salt sizes used here are not ready for prime-time. There are a couple more steps we need to take—longer salts, multiple rounds of hashing, etc.—before we're getting close to best practice for password storage.)

As in parts 1 and 2:

Part 4: password-cracking software

There are many password-cracking software packages out there in the world for use by ethical and not-so-ethical hackers. Two of the most popular are hashcat and john the ripper.

For this part of the assignment, read up on one of these tools and then use it to crack the passwords from part 3 above.

NOTE: Sometimes, you need to modify the file format to use hashcat or john on a set of password hashes. Making sure your file format works is part of the job for Part 4.

What to hand in?

In your "passwords" folder, put:

A couple clarifications

Have fun!