Practice Password Cracking without Going to Jail

The purpose of this article is to give a small amount of background on password hashes, how they are cracked, and how to practice password cracking without breaking any laws.

The term "password cracking" can mean a few different things. In this context, I'm referring to the concept of recovering an original password from a hashed/encrypted password.

The term "hash" refers to a one-way checksum that is computed from a piece of data.

The reason passwords are hashed is because it is ultimately safer to store a one-way checksum of a plaintext password than it is to store the password itself.

Here's an example of an LM (LanManager) password hash:

>>> smbpasswd.lmhash('andrew')
'7733BFECC3A7D081AAD3B435B51404EE'  

Password = "andrew"
Hash = "7733BFECC3A7D081AAD3B435B51404EE"

As a red teamer, or penetration tester, it's very common to recover password hashes. Most of the time, the next step after finding password hashes is cracking them.

If you are training to become a red teamer, or if you want benchmark a new password cracking rig without using client data, it can be hard to create realistic-looking password hashes that emulate what real corporate networks look like.

I break into large companies' networks for a living, so I've cracked a lot of passwords. Armed with this knowledge, I wrote a script that generates somewhat realistic password hashes, ready to be cracked.

$ python pug.py 10 word.lst
DGAINES:1288:A46139FEAAF2B9F117306D272A9441BB:6597D9FE8469E21D840E2CBFF8D43C8B:::  
INOEL:1995:552902031BEDE9EFAAD3B435B51404EE:878D8014606CDA29677A44EFA1353FC7:::  
MMATTHEWS:1108:AEBD4DE384C7EC43AAD3B435B51404EE:7A21990FCD3D759941E45C490F143D5F:::  
AWEAVER:1168:D480EA9533C500D4AAD3B435B51404EE:329153F560EB329C0E1DEEA55E88A1E9:::  
CBROOKS:1848:A46139FEAAF2B9F117306D272A9441BB:6597D9FE8469E21D840E2CBFF8D43C8B:::  
LWHITLEY:1068:AEBD4DE384C7EC43AAD3B435B51404EE:7A21990FCD3D759941E45C490F143D5F:::  
HCABRERA:1061:A9C604D244C4E99DAAD3B435B51404EE:ACB98FD0478427CD18949050C5E87B47:::  
KLAWSON:1539:3EACDEE7E4395079417EAF50CFAC29C3:5962CC080506D90BE8943118F968E164:::  
TGRAHAM:1284:552902031BEDE9EFAAD3B435B51404EE:878D8014606CDA29677A44EFA1353FC7:::  
GSHARP:1031:552902031BEDE9EFAAD3B435B51404EE:878D8014606CDA29677A44EFA1353FC7:::  

The script works by rolling a number and deciding on the strength of the password based on the outcome. Most passwords generated will be in the form of (dictionaryword)(two digit number), like "soccer12" or "blueberry99". However, some passwords are more complex and use capital letters. Some passwords are completely random.

You can find the source code and starter word/name files on my github at the following URL-

https://github.com/andrew-morris/PUG

NOTE: This code is very poorly written, but it gets the job done. If there is any interest in this tool, I'll be happy to make improvements.

Here's a snippet of us running some hashes through John the Ripper:

$ sudo /opt/john/run/john hashes.txt
Loaded 13 password hashes with no different salts (LM DES [128/128 BS SSE2-16])  
SECRET           (GSHARP)  
SECRET           (TGRAHAM)  
12345            (LWHITLEY)  
12345            (MMATTHEWS)  
SECRET           (INOEL)  
AAAAAA           (HCABRERA)  
E                (CBROOKS:2)  
E                (DGAINES:2)  
T                (KLAWSON:2)  
ROOT             (AWEAVER)