Install John the Ripper on Linux

Kali LinuxBeginner
Practice Now

Introduction

John the Ripper (often abbreviated as JtR) is a popular and powerful open-source password security auditing and password recovery tool available for many operating systems. While it can often be installed from a package manager, compiling it from the source code ensures you have the latest version and allows for custom configurations.

In this lab, you will learn how to install John the Ripper on a Linux system by downloading the source code, compiling it, and adding it to your system's PATH for easy access. All operations will be performed within the ~/project directory.

Download John the Ripper Source Code

In this step, you will download the source code for John the Ripper from its official GitHub repository. We will then extract the downloaded archive to prepare for compilation. Your current working directory is ~/project.

First, use the wget command to download a specific stable version of the "Jumbo" community-enhanced version of John the Ripper.

wget https://github.com/openwall/john/archive/refs/tags/1.9.0-jumbo-1.tar.gz

You should see output indicating the file is being downloaded and saved.

--2023-10-27 10:30:00--  https://github.com/openwall/john/archive/refs/tags/1.9.0-jumbo-1.tar.gz
Resolving github.com (github.com)... 140.82.121.4
Connecting to github.com (github.com)|140.82.121.4|:443... connected.
HTTP request sent, awaiting response... 302 Found
...
Saving to: ‘1.9.0-jumbo-1.tar.gz’

1.9.0-jumbo-1.tar.gz      100%[===================================>]  22.13M  65.4MB/s    in 0.3s

2023-10-27 10:30:01 (65.4 MB/s) - ‘1.9.0-jumbo-1.tar.gz’ saved [23201448/23201448]

Next, extract the contents of the downloaded .tar.gz file using the tar command.

tar -xzvf 1.9.0-jumbo-1.tar.gz

This command will create a new directory containing the source code. You can verify this by listing the contents of your current directory.

ls -l

You should see the newly created directory john-1.9.0-jumbo-1.

total 22668
-rw-r--r-- 1 labex labex 23201448 Jul 25  2021 1.9.0-jumbo-1.tar.gz
drwxr-xr-x 9 labex labex     4096 Jul 25  2021 john-1.9.0-jumbo-1

Install Required Dependencies for Compilation

In this step, you will install the necessary tools and libraries required to compile John the Ripper from source. Compiling software often depends on other packages, such as a compiler and development libraries.

First, it's good practice to update your system's package list to ensure you get the latest versions of the dependencies.

sudo apt-get update

Next, install the essential packages for building software on Debian-based systems like Ubuntu. We need build-essential (which includes the GCC compiler and make), libssl-dev (for cryptographic support), and yasm (an assembler).

sudo apt-get install -y build-essential libssl-dev yasm

The -y flag automatically answers "yes" to any prompts, allowing the installation to proceed without user interaction. You will see a lot of output as the packages are downloaded and installed.

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
...
The following NEW packages will be installed:
  build-essential dpkg-dev g++ g++-11 libssl-dev libstdc++-11-dev make yasm
...
Setting up libssl-dev:amd64 (3.0.2-0ubuntu1.10) ...
Setting up make (4.3-4.1build1) ...
...

With the dependencies installed, you are now ready to compile the source code.

Compile John the Ripper from Source

In this step, you will compile the John the Ripper source code. The compilation process typically involves two main commands: ./configure and make.

First, navigate into the src directory within the extracted source code folder.

cd john-1.9.0-jumbo-1/src/

Now, run the configure script. This script checks your system for the required dependencies and prepares the build environment by creating a Makefile tailored to your system.

./configure

The output will show the results of its checks.

...
checking for yasm... yasm
checking for OpenSSL... yes
...
configure: creating ./config.status
config.status: creating Makefile
config.status: creating common.h
...
Configuration finished. You can now run "make".

Once the configuration is complete, you can start the compilation using the make command. We will use make -s clean to remove any previous build files and make -sj4 to run the compilation using 4 parallel jobs, which speeds up the process.

make -s clean && make -sj4

This process may take a few minutes to complete. Once it's finished, the compiled john executable will be placed in the ../run/ directory. The command prompt will return without any errors if the build was successful.

Verify John the Ripper Installation

In this step, you will verify that John the Ripper was compiled successfully by running the executable and its built-in test suite.

The compiled binary is not in the src directory, but in the run directory. Let's navigate to it.

cd ../run

Now, run the john executable without any arguments to display its usage information. This is a quick way to confirm that it runs.

./john

You should see the version and usage information, which confirms the program is executable.

John the Ripper 1.9.0-jumbo-1 [linux-gnu 64-bit x86_64 AVX2 AC]
Copyright (c) 1996-2019 by Solar Designer and others
Homepage: https://www.openwall.com/john/

Usage: john [OPTIONS] [PASSWORD-FILES]
...

To perform a more thorough check, run the built-in benchmark and self-test. This will test the various hashing algorithms and ensure they are functioning correctly on your system.

./john --test

The test will run for a minute or two and print out benchmark results for many different hash types.

Benchmarking: descrypt, traditional crypt(3) [DES 128/128 SSE2-16]... DONE
Many salts:	12032K c/s real, 12032K c/s virtual
Only one salt:	11141K c/s real, 11141K c/s virtual

...

Benchmarking: LM [DES 128/128 SSE2-16]... DONE
Raw-MD5 [MD5 128/128 SSE2-16]... DONE
...
All tests passed

Seeing "All tests passed" at the end confirms that your build is working correctly.

Add John the Ripper to System PATH

In this step, you will add the directory containing the john executable to your system's PATH environment variable. This will allow you to run john from any location in the terminal without having to type the full path.

The john executable is currently located at ~/project/john-1.9.0-jumbo-1/run. To make it globally accessible for your user, you need to add this path to your shell's configuration file. Since the lab environment uses Zsh, the file is ~/.zshrc.

Use the echo command to append the export command to your ~/.zshrc file.

echo 'export PATH="$HOME/project/john-1.9.0-jumbo-1/run:$PATH"' >> ~/.zshrc

This command adds the run directory to the beginning of your PATH. The change will only take effect in new terminal sessions. To apply it to your current session, you need to "source" the configuration file.

source ~/.zshrc

Now, let's verify that it works. First, move out of the run directory to your home directory.

cd ~

From your home directory, try running john without specifying the path.

john

If the PATH was set correctly, you will see the same usage information as before. This confirms that you can now run John the Ripper from anywhere.

John the Ripper 1.9.0-jumbo-1 [linux-gnu 64-bit x86_64 AVX2 AC]
Copyright (c) 1996-2019 by Solar Designer and others
Homepage: https://www.openwall.com/john/

Usage: john [OPTIONS] [PASSWORD-FILES]
...

Summary

Congratulations! You have successfully installed John the Ripper from its source code on a Linux system.

In this lab, you have learned how to:

  • Download the source code for a software package using wget.
  • Install the necessary build dependencies using apt-get.
  • Configure and compile the source code with ./configure and make.
  • Verify a successful compilation by running the program and its built-in tests.
  • Add the program's location to your system PATH for convenient access from any directory.

This process of compiling from source is a fundamental skill for Linux users and gives you more control over your software installations. You are now ready to explore the powerful features of John the Ripper for password security auditing.