0xnhl

John the Ripper

/ Update
7 min read

John the Ripper is a free and open-source password-cracking tool. It can crack passwords stored in various formats, including hashes, passwords, and encrypted private keys.
 

  • It supports different cracking modes and understands many ciphertext formats, including several DES variants, MD5, and Blowfish. John the Ripper does not support AES and SHA-2. John the Ripper can also be used to extract Kerberos AFS and Windows passwords.

  • To list the supported formats, you can use the john —list=formats command

  • John the Ripper can be downloaded from https://www.openwall.com/john.
     - Github: https://github.com/openwall/john
     - Seclist GH repo: https://github.com/danielmiessler/SecLists

  • You can customize John the Ripper to allow you to build different configurations. The configuration file can be named either john.conf on Unix and Linux-based systems or john.ini on Windows. For additional information about John the Ripper customization and configuration files, see https://www.openwall.com/john/doc/CONFIG.shtml. The configuration file can include a set of rules, including rules regarding the use of wordlists. The rules syntax can be obtained from https://www.openwall.com/john/doc/RULES.shtml.

  • John the Ripper also keeps a log in the private john “home directory” for the current user ( ~.john ).

  • John the Ripper is supported on many Operating Systems, not just Linux Distributions.

  • There are also multiple versions of John, the standard “core” distribution, and multiple community editions, which extend the feature set of the original John distribution. The most popular of these distributions is “Jumbo John

  • There is a GUI version of John the Ripper called Johnny.

Usage#

Basic Syntax:

john [options] [file path]
shell

Eg:

john --format=raw-sha256 --wordlist=/usr/share/wordlists/rockyou.txt hash1.txt
shell
  • --format=[] specifies the hash format. eg: raw-sha256, raw-md5
  • --wordlist=[] sets the wordlist that we will use
  • hash1.txt is the text file containing the hash value we are trying to crack
  • --incremental to instruct John the Ripper to use only brute force cracking
    John the Ripper switches to incremental strategies (brute force) on remaining hashes if there are hashes it cannot crack with its wordlists.

To show your cracked passwords: john --show [--format=raw-md5] my_pw_hashes.txt

John has built-in features to detect what type of hash it’s being given and to select appropriate rules and formats to crack it for you; this isn’t always the best idea as it can be unreliable, but if you can’t identify what hash type you’re working with and want to try cracking it, it can be a good option! To do this, we use the following syntax: john --wordlist=[path to wordlist] [path to file]

When you tell John to use formats, if you’re dealing with a standard hash type, e.g. md5 as in the example above, you have to prefix it with raw- to tell John you’re just dealing with a standard hash type, though this doesn’t always apply. To check if you need to add the prefix or not, you can list all of John’s formats using john --list=formats and either check manually or grep for your hash type using something like john --list=formats | grep -iF "md5".

Formatting#

To crack the password of other file types, we need to convert the password-protected file into a format that john can attack.
John the Ripper jumbo edition comes with the necessary tools.
The different tools follow the naming style “format2john”. The terminal below shows a few examples.

/opt/john/1password2john.py /opt/john/ethereum2john.py /opt/john/openssl2john.py /opt/john/7z2john.pl /opt/john/filezilla2john.py /opt/john/padlock2john.py /opt/john/DPAPImk2john.py /opt/john/geli2john.py /opt/john/pcap2john.py /opt/john/adxcsouf2john.py /opt/john/gpg2john /opt/john/pdf2john.pl /opt/john/aem2john.py /opt/john/hccap2john /opt/john/pdf2john.py /opt/john/aix2john.pl /opt/john/hccapx2john.py /opt/john/pem2john.py /opt/john/aix2john.py /opt/john/htdigest2john.py /opt/john/pfx2john.py
bash

eg:

  • to crack pdf files : pdf2john.pl private.pdf > pdf_hash.txt
  • to crack zip files : zip2john file.zip > zip_hash.txt
  • to crack ssh password : ssh2john id_rsa > id_rsa_hash.txt

Unshadowing#

To crack /etc/shadow passwords, you must combine it with the /etc/passwd file for John to understand the data it’s being given. To do this, we use a tool built into the John suite of tools called unshadow. The basic syntax of unshadow is as follows:

unshadow [path to passwd] [path to shadow]
shell
  • unshadow: Invokes the unshadow tool
  • [path to passwd]: The file that contains the copy of the /etc/passwd file or required passwd line
  • [path to shadow]: The file that contains the copy of the /etc/shadow file or required shadow line

Example Usage: unshadow local_passwd local_shadow > unshadowed.txt
We can then feed the output from unshadow, in our example use case called unshadowed.txt, directly into John. We should not need to specify a mode here as we have made the input specifically for John; however, in some cases, you will need to specify the format as we have done previously using: --format=sha512crypt
john --wordlist=/usr/share/wordlists/rockyou.txt --format=sha512crypt unshadowed.txt

Single Crack mode#

 In this mode, John uses only the information provided in the username to try and work out possible passwords heuristically by slightly changing the letters and numbers contained within the username (word mangling).
John is building its dictionary based on the information it has been fed and uses a set of rules called “mangling rules,” which define how it can mutate the word it started with to generate a wordlist based on relevant factors for the target you’re trying to crack. This exploits how poor passwords can be based on information about the username or the service they’re logging into.

John’s implementation of word mangling also features compatibility with the GECOS field of the UNIX operating system, as well as other UNIX-like operating systems such as Linux. John can take information stored in those records, such as full name and home directory name, to add to the wordlist it generates when cracking /etc/shadow hashes with single crack mode.
Usage

john --single --format=[format] [path to hash file]
shell

If you’re cracking hashes in single crack mode, you need to change the file format that you’re feeding John for it to understand what data to create a wordlist from. You do this by prepending the hash with the username that the hash belongs to.
Example: we would change the hash in the file From 1efee03cdcb96d90ad48ccc7b8666033 To mike:1efee03cdcb96d90ad48ccc7b8666033.

Rules#

John also has the ability for you to define your own rules, which John will use to create passwords dynamically.
John can start from a long password list and attempt various common derivations from each of the passwords to increase its chances of success. This behaviour can be triggered through the use of rules. Various rules come bundled with John the Ripper’s configuration files; one is suited for lengthy wordlists, --rules=wordlist.

john --format=raw-sha256 --rules=wordlist --wordlist=/usr/share/wordlists/rockyou.txt hash1.txt
shell

Adding the option --rules=wordlist to your john command line generates multiple passwords from each one. For instance, it appends and prepends single digits. It does various common substitutions; for example, a can be replaced with @i can be replaced with !, and s can be replaced with $. Many more mutations and transformations are part of these rules. You can check all the underlying rules by checking the [List.Rules:Wordlist] section in /etc/john/john.conf, John’s configuration file.

Many organisations will require a certain level of password complexity to try and combat dictionary attacks. And will enforce a password rule. But we can exploit the fact that most users will be predictable in following those rules.
eg: Take a rule like the password must contain atleast one of the following: Lowercase letter, Uppercase letter, Number, Symbol.
Consider a password with a capital letter first and a number followed by a symbol at the end. This familiar pattern of the password, appended and prepended by modifiers (such as capital letters or symbols), is a memorable pattern that people use and reuse when creating passwords. This pattern can let us exploit password complexity predictability. So for this we can create a custom rule in john.

Custom rules are defined in the john.conf file. This file can be found in /opt/john/john.conf. Rule Docs.

Basic Syntax#

The first line:
[List.Rules:RuleName] is used to define the name of your rule; this is what you will use to call your custom rule a John argument.

We then use a regex style pattern match to define where the word will be modified; again, we will only cover the primary and most common modifiers here:

  • Az: Takes the word and appends it with the characters you define
  • A0: Takes the word and prepends it with the characters you define
  • c: Capitalises the character positionally

These can be used in combination to define where and what in the word you want to modify.
Lastly, we must define what characters should be appended, prepended or otherwise included. We do this by adding character sets in square brackets [ ] where they should be used. These follow the modifier patterns inside double quotes " ". Here are some common examples:

  • [0-9]: Will include numbers 0-9
  • [0]: Will include only the number 0
  • [A-z]: Will include both upper and lowercase
  • [A-Z]: Will include only uppercase letters
  • [a-z]: Will include only lowercase letters
    Please note that:
  • [a]: Will include only a
  • [!£$%@]: Will include the symbols !£$%, and @

Putting this all together, to generate a wordlist from the rules that would match, we would create a rule entry that looks like this:

[List.Rules:pwdrule]
cAz"[0-9] [!£$%@]"
plaintext

We could then call this custom rule a John argument using the  --rule=pwdrule flag.

Jumbo John already has an extensive list of custom rules containing modifiers for use in almost all cases. Try looking at those rules (around line 678).

John the Ripper
https://nahil.xyz/vault/tools/john/
Author Nahil Rasheed
Published at June 15, 2025
Disclaimer This content is provided strictly for educational purposes only.