John The Ripper 1706883159
John The Ripper 1706883159
John The Ripper 1706883159
Ripper
Table of Contents
Abstract................................................................................................................................................... 3
Introduction ............................................................................................................................................ 4
Usage ............................................................................................................................................. 4
Wordlist Crack Mode ............................................................................................................... 6
Cracking the User Credentials............................................................................................. 7
Stopping and Restoring Cracking...................................................................................... 10
SHA1 ............................................................................................................................................ 11
MD5 .............................................................................................................................................. 12
MD4 .............................................................................................................................................. 12
SHA256 ....................................................................................................................................... 13
RIPEMD128 ................................................................................................................................ 13
Whirlpool ................................................................................................................................... 14
View All Formats .................................................................................................................... 14
Abbreviating the Options .................................................................................................... 15
Cracking Multiple Files ......................................................................................................... 16
Password Hash Cracking ...................................................................................................... 17
Cracking the SSH Password Hash ..................................................................................... 18
Cracking the KeepPass2 Password Hash........................................................................ 20
Cracking the RAR Password Hash ..................................................................................... 22
Cracking the ZIP Password Hash ....................................................................................... 24
Cracking the 7-Zip Password Hash................................................................................... 26
Cracking the PDF Password Hash ..................................................................................... 27
Cracking the PuTTY Password Hash ................................................................................ 29
Cracking the “Password Safe” Password Hash ........................................................... 31
Conclusion ............................................................................................................................................ 33
References ........................................................................................................................................... 33
Page | 2
Abstract
We know the importance of John the ripper in penetration testing, as it is quite
popular among password cracking tool. In this report, we are introducing John the
ripper and its various usage for beginners.
Additionally, we will use John the Ripper to crack the password hashes of some of
the file formats like zip, rar, pdf and much more.
Page | 3
Introduction
John the Ripper is a free password cracking software tool developed by Openwall. Originally
developed for Unix Operating Systems but later on developed for other platforms as well. It
is one of the most popular password testings and breaking programs as it combines a number
of password crackers into one package, autodetects password hash types, and includes a
customizable cracker. It can be run against various encrypted password formats including
several crypt password hash types commonly found in Linux or Windows. It can also be to
crack passwords of Compressed files like ZIP and also Documents files like PDF.
John the Ripper can be downloaded from Openwall’s Website, or from the Official John the
Ripper Github Repo.
Usage
John the Ripper comes pre-installed in Linux Kali and can be run from the terminal as shown
below:
Page | 4
John the Ripper works in 3 distinct modes to crack the passwords:
In this mode John the ripper makes use of the information available to it in the form of a
username and other information. This can be used to crack the password files with the format
of
Username:Password
For Example: If the username is “Hacker” it would try the following passwords:
hacker
HACKER
hacker1
h-acker
hacker=
Here we have a text file named crack.txt containing the username and password, where the
password is encrypted in SHA1 encryption so to crack this password we will use:
As you can see in the screenshot that we have successfully cracked the password.
Username: ignite
Password: IgNiTe
Page | 5
Wordlist Crack Mode
In this mode John the ripper uses a wordlist that can also be called a Dictionary and it
compares the hashes of the words present in the Dictionary with the password hash. We can
use any desired wordlist. John also comes in build with a password.lst which contains most of
the common passwords.
Let’s see how John the Ripper cracks passwords in Wordlist Crack Mode:
Here we have a text file named crack.txt containing the username and password, where the
password is encrypted in SHA1 encryption so to crack this password we will use:
As you can see in the screenshot, john the Ripper have cracked our password to be asdfasdf
Page | 6
Cracking the User Credentials
We are going to demonstrate two ways in which we will crack the user credentials of a Linux
user.
In the Linux operating system, a shadow password file is a system file in which encrypted
user password is stored so that they are not available to the people who try to break into the
system. It is located at /etc/shadow.
First Method
Now, for the first method, we will crack the credentials of a particular user “pavan”.
Now to do this First we will open the shadow file as shown in the image.
And we will find the credentials of the user pavan and copy it from here and paste it into a
text file. Here we have the file named crack.txt.
Page | 7
Now we will use john the ripper to crack it.
john crack.txt
As you can see in the image below that john the ripper has successfully cracked the password
for the user pavan.
Second Method
Now, for the second method, we will collectively crack the credentials for all the users.
To do this we will have to use John the ripper utility called “unshadow”.
Page | 8
unshadow /etc/passwd /etc/shadow > crack.txt
Here the unshadow command is combining the /etc/passwd and /etc/shadow files so that John
can use them to crack them. We are using both files so that John can use the information
provided to efficiently crack the credentials of all users.
Now we will use john to crack the user credentials of all the users collectively.
Page | 9
As you can see from the provided image that we have discovered the following credentials:
User Password
Raj 123
Pavan Asdfasdf
Ignite Yellow
While John the ripper is working on cracking some passwords we can interrupt or pause the
cracking and Restore or Resume the Cracking again at our convenience.
So, while John the Ripper is running you can interrupt the cracking by Pressing “q” or Crtl+C
as shown in the given image.
Page | 10
Now to resume or restore the cracking process we will use the –restore option of John the
ripper as shown :
john --restore
SHA1
To decrypt SHA1 encryption we will use RockYou as wordlist and crack the password as
shown below:
As you can see in the given image that we have the username pavan and password as Hacker
Page | 11
MD5
To decrypt MD5 encryption we will use RockYou as wordlist and crack the password as
shown below:
As you can see in the given screenshot that we have the username pavan and password as
P@ssword.
MD4
To decrypt MD4 encryption we will use RockYou as wordlist and crack the password as
shown below:
As you can see in the given screenshot that we have the username pavan and password as
Rockyou
Page | 12
SHA256
To decrypt SHA256 encryption we will use RockYou as wordlist and crack the password as
shown below:
As you can see in the given screenshot that we have the username pavan and password as
pAsSwOrD
RIPEMD128
To decrypt RIPEMD128 encryption we will use RockYou as wordlist and crack the password
as shown below:
As you can see in the given image that we have the username pavan and password as
password123
Page | 13
Whirlpool
To decrypt whirlpool encryption, we will use RockYou as wordlist and crack the password as
shown below:
As you can see in the given screenshot that we have the username pavan and password as
password666
John the Ripper supports much encryption some of which we showed above. To view all the
formats, it supports:
john --list=formats
Page | 14
john --list=formats
Hope, you can take reference of this article while using John the ripper, More on John the
Ripper will be in the Next Part.
We don’t have to type complete option every time we use john the ripper, Developers have
given users the option to abbreviate the options like
Page | 15
Another abbreviation we can use is:
We can also crack multiple hash files if they have the same encryption. Let’s take an
example, we have two files.
1. crack.txt
2. md5.txt
Both contain md5 hashes, so to crack both files in one session, we will run john as follows:
Page | 16
Password Hash Cracking
To crack these password hashes, we are going to use some of the inbuilt and some other
utilities which extract the password hash from the locked file. There are some utilities that
come inbuilt with John which can be found using the following command.
locate *2john
As you can see that we have the following utilities, we will demonstrate some of them here.
Page | 17
Cracking the SSH Password Hash
John the Ripper can crack the SSH private key which is created in RSA Encryption. To test
the cracking of the private key, first, we will have to create a set of new private keys. To do
this we will use a utility that comes with ssh, called “ssh-keygen”.
ssh-keygen
After opening, it asks for the location at which we want the public/private RSA key pair to
store? You can use any location or you can leave it as default.
After that it asks for the passphrase, after entering the password again, we successfully
generate the RSA private key. (Refer the image)
When you will try to open the file, you will be greeted by the following prompt.
Page | 18
Now John cannot directly crack this key, first, we will have to change its format, which can
be done using a john utility called “ssh2john”.
You can see that we converted the key to a crackable hash and then entered it into a text file
named id_rsa.txt.
Page | 19
Great! We have successfully cracked the passphrase used to create the private ssh key to be
“password123”
John the Ripper can crack the KeepPass2 key. To test the cracking of the key, first, we will
have to create a set of new keys. To do this we will use a utility that is called “kpcli”.
kpcli
Now we will create a database file using the command “save as” and naming the database file
as ignite.kdb and entering a passcode to secure it.
When you will try to open the file, you will be greeted by the following prompt.
Page | 20
Now John cannot directly crack this key, first, we will have to change its format, which can
be done using a john utility called “keepass2john”.
Great! We have successfully cracked the passphrase used to create the key to be “12345678”
Page | 21
Cracking the RAR Password Hash
Now we will crack some compressed files, to do that we will have to create a file to be
compressed so let’s do that using echo command as shown in the given screenshot.
You can see that we created a file.txt which we will be using to create compressed files.
John the Ripper can crack the RAR file passwords. To test the cracking of the password, first,
let’s create a compressed encrypted rar file.
Page | 22
• a = Add files to archive
• hp[password] = Encrypt both file data and headers
This will compress and encrypt our file.txt into a file.rar. So, when you will try to open the
file, you will be greeted by the following prompt.
Now John cannot directly crack this key, first, we will have to change it format, which can be
done using a john utility called “rar2john”.
Page | 23
john --wordlist=/usr/share/wordlists/rockyou.txt crack.txt
Great! We have successfully cracked the passphrase used to create the key to be “abc123”
John the Ripper can crack the ZIP file passwords. To test the cracking of the password, first,
let’s create a compressed encrypted zip file.
• e = Encrypt
• r = Recurse into directories
This will compress and encrypt our file.txt into a file.zip. So, when you will try to open the
file, you will be greeted by the following prompt.
Page | 24
Now John cannot directly crack this key, first, we will have to change its format, which can
be done using a john utility called “zip2john”.
Great! We have successfully cracked the passphrase used to create the key to be “654321”
Page | 25
Cracking the 7-Zip Password Hash
John the Ripper can crack the 7-Zip file passwords. To test the cracking of the password,
first, let’s create a compressed encrypted 7z file.
This will compress and encrypt our file.txt into a file.7z. So, when you will try to open the
file, you will be greeted by the following prompt.
Now John cannot directly crack this key, first, we will change its format, which can be done
using a john utility called “7z2john”. This is not inbuilt utility, It can be downloaded from
here.
Page | 26
python 7z2john.py file.7z > crack.txt
Great! We have successfully cracked the passphrase used to create the key to be “password”
John the Ripper can crack the PDF file passwords. You can encrypt your pdf online by using
Soda PDF website. This will compress and encrypt our pdf into a password protected file.pdf.
So, when you will try to open the file, you will be greeted by the following prompt.
Page | 27
Now John cannot directly crack this key, first, we will have to change its format, which can
be done using a john utility called “pdf2john”. This is not an inbuilt utility, it can be
downloaded from here.
Great! We have successfully cracked the passphrase used to create the key to be
“password123”.
Page | 28
Cracking the PuTTY Password Hash
John the Ripper can crack the PuTTY private key which is created in RSA Encryption. To
test the cracking of the private key, first, we will have to create a set of new private keys. To
do this we will use a utility that comes with PuTTY, called “PuTTY Key Generator”.
Click on “Generate”. After Generating the key, we get a window where we will input the key
passphrase as shown in the image.
Page | 29
After entering the passphrase, click on Save private key to get a private key in the form of a
.ppk file
Now John cannot directly crack this key, first, we will have to change its format, which can
be done using a john utility called “putty2john”.
Page | 30
You can see that we converted the key to a crackable hash and then entered it into a text file
named crack.txt.
Great! We have successfully cracked the passphrase used to create the private PuTTY key to
be “password”.
John the Ripper can crack the Password Safe Software’s key. To test the cracking of the key,
first, we will have to create a set of new keys. To do this we will install the Password Safe
Software on our Windows 10 System.
Page | 31
To get a new key, Click on “New”
In this prompt, check the Show Combination Box. After that Enter the passphrase you want
to use to generate the key. This will generate a .psafe3 file.
Now John cannot directly crack this key, first, we will have to change its format, which can
be done using a john utility called “pwsafe2john”.
Page | 32
You can see that we converted the key to a crackable hash and then entered it into a text file
named crack.txt.
Great! We have successfully cracked the passphrase used to create the private pwsafe key to
be “password123”
Conclusion
Hence, one can make use of these commands as a cybersecurity professional to
assess vulnerabilities on systems and keep these systems away from threat.
References
• https://www.hackingarticles.in/beginner-guide-john-the-ripper-part-1/
• https://www.hackingarticles.in/beginners-guide-for-john-the-ripper-part-2/
• https://www.openwall.com/john/
• https://github.com/openwall/john
• https://www.sodapdf.com/password-protect-pdf/
Page | 33