John the Ripper
A quick reference for cracking a SHA256 password with John:
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt --format=Raw-SHA256
Identifying Hashes
Sometimes John won't play nicely with automatically recognising and loading hashes, and that's okay. We can use other tools to identify the hash and then set John to use a specific format. There are multiple ways to do this, such as an online hash identifier like this one. I like to use a tool called hash-identifier, a Python tool that is easy to use and tells you what types the hash is likely to be, giving you more options if the first one fails.
To use hash-identifier, pull the Python file from GitLab:
wget https://gitlab.com/kalilinux/packages/hash-identifier/-/raw/kali/master/hash-id.py
Then launch it and enter the hash you're trying to identify, and it will give you possible formats:
python3 hash-id.py
Format-Specific Cracking
Once you've identified the hash, tell John to use that format while cracking:
john --format=[format] --wordlist=[path to wordlist] [path to file]
--format=is the flag to tell John you're giving it a hash of a specific format, and to use the following format to crack it.[format]is the format that the hash is in.
Example Usage
john --format=raw-md5 --wordlist=/usr/share/wordlists/rockyou.txt hash_to_crack.txt
A Note on Formats
When telling John to use formats, if you're dealing with a standard hash type (for example md5, as above), you have to prefix it with raw- to tell John it's just a standard hash type, though this doesn't always apply. To check whether you need the prefix, list all of John's formats with john --list=formats and either check manually or grep for your hash type, for example john --list=formats | grep -iF "md5".
A SHA256 example, D7F4D3CCEE7ACD3DD7FAD3AC2BE2AAE9C44F4E9B7FB802D73136D4C53920140A, uses this John syntax:
john --format=raw-sha256 --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
In case we need a specific flag for --format=, we can find it with grep: john --list=formats | grep -iF "NT".