How to crack hashes with John the Ripper

Search for a command to run...

No comments yet. Be the first to comment.
In this series, I am going to be talking about the concepts and tools for cyber security from beginner to advanced user.
Whether you want to protect your privacy, run a security test or want to hack the NSA. You want to stay anonymous. This is can be done using a variety of tools like VPNs, proxies and Tor. One of the simplest ways is to use proxychains in conjunction ...
During in the process of reverse engineering binaries, a common problem arises. How do I reverse engineer stripped binaries? There are no symbols to break on, offsets change, scripts don't work, and you ask yourself why am I doing this? Luckily there...

When I was learning how to tackle pwn challenges in CTFs, I had a tough time finding a single, clear guide that could show me the ropes of actually carrying out these exploits. That's why I decided to put together a complete guide that covers everyth...

Using python to capture and project data

Intro This is a write-up for PicoCTF 2022: Buffer Overflow 1. This is one of my favourite challenges to do. I recommend solving it for yourself before you read this write-up. What is a Buffer Overflow? Before we get started we need to first know what...

What is a BadUSB? A BadUSB is a USB device that acts as a keyboard and injects preprogrammed keystrokes into a computer. A BadUSB is Indistinguishable from a generic keyboard, making it near impossible to detect and patch. You can setup reverse shell...

John the Ripper is one of the most loved and versatile hash password-cracking tools out their. It combines speed, ease of use and reliability. But first of what is a hash?
Hashing is taking a data of any length and turning it into a fixed length string that masks it's original value of the data. Their are hundreds of different hashing algorithms and some of the more common ones are MD5, SHA1, SHA3-512, NTLM, CRC32, etc.
Their are two over-arching ways of cracking hashes. One of the methods is a rainbow table. Essentially, you have a precomputed table full of hashes that point to the password. This is what most websites like hashes.com use to crack your has. Although it is incredibly fast, it can take a large amount of storage space and can only use "precomputed" hashes. In addition, developers of hashing algorithms have added something called "salt" that changes the hash output. I will not be covering rainbow tables on this blog post.
Then their is the other way. Hashes are designed in a way to make cracking them near impossible. But it is possible to hash a word and see if it matches. This is the method I am going to be using. Although it is not as quick as a rainbow table, it is funner and will be able to crack nearly all hashes.
You can install John the ripper on your respective systems by using this link. To use john use the syntax bellow:
# Linux
john hash.txt
#Windows
./john.exe hash.txt
This mode makes use of the information already available inside the username. The format for text file is:
username:hash
Some examples of how this would work would be with the word Anonymous:
Anonymous
an0nym0us
AnOnYmOuS
Anonymous1
Syntax: This mode is the default mode the JtR starts with but you can specify it with:
john --single hash.txt
In this mode it computes the hashes of a word list and then compares it to the one given. In JtR you can use any specified word list but it does choose a default one if none is specified. For this post i am going to be using the infamous rockyou wordlist. Example Usage:
john --wordlist=/usr/share/wordlists/rockyou.txt --format=raw-md5 crack.txt
Incremental mode is the most powerful cracking mode. It tries every single possible combination of characters until it completes. This means it will not stop. Example usage:
john --incremental hash.txt
You can specify the option for the incremental mode by:
john --incremental=digits incremental.txt
john --incremental=Alpha incremental.txt
You can see all the options in the john.conf in /etc/john/john.conf
.
John's auto hash detection can be a bit unreliable. Here, is a good script for identifying hashes in python.
john --format=[format] [path to file]
--format= - Input the format of the hash
Example Usage:
john --format=raw-md5 --wordlist=/usr/share/wordlists/rockyou.txt hash_to_crack.txt
If you are unsure about telling John which hash type to crack, use john --list=formats. If you are search for a specific type of hash use john --list=formats | grep -iF "md5", if you are on Linux.
To crack multiple files that have the same encryption just add them both to the end. The syntax for multiple md5 hashes is as so: john [file 1][file 2]
john -form=raw-md5 crack.txt md5.txt
Sometimes the hash is not easy to extract from a file. That is when Jumbo John comes in handy. It has a bunch of different tools for extracting hashes out of other formats. I will cover a few here.
We are going to use zip2john to output a hash in a text file. This can then be attacked like a normal hash.
zip2john [options] [zip file] > [output file]
Example Usage:
zip2john zipfile.zip > zip_hash.txt
Almost identical to the zip2john tool, we can output a RAR file to a hash text file. John will be able to understand this.
rar2john [rar file] > [output file]
Example Usage:
rar2john rarfile.rar > rar_hash.txt
You know, I wonder if their is a pattern to this? You can find your pub id_rsa private key in linux at ~/. ssh/id_rsa
ssh2john [id_rsa private key file] > [output file]
Example Usage:
ssh2john id_rsa > id_rsa_hash.txt
If you want to practice some hash cracking, here are some hashes.
https://tryhackme.com/room/johntheripper0
https://www.hackingarticles.in/beginner-guide-john-the-ripper-part-1/
https://www.varonis.com/blog/john-the-ripper
https://www.openwall.com/john/doc/
https://github.com/openwall/john