repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
john-extractors.mdMarkdown161 lines8.4 KiBsource raw download

title: "John extractors" description: "Extract encrypted-file hash records, distinguish John and hashcat input formats, and choose modes from the actual container/KDF rather than the file extension." category: password-attacks tags: [password-attacks, hashcat, john, cracking, loot, hashes] tools: [John the Ripper, hashcat] difficulty: intermediate updated: "2026-10-12" references:


John extractors#

John jumbo's *2john helpers convert supported encrypted files into password-verification records. The extractor, cracker and file-opening application are separate steps. Preserve an original copy, identify the format, then select the matching helper.

Basic workflow#

file protected-file
# Example: a supported KeePass database
keepass2john Database.kdbx > database.john
john --wordlist=/usr/share/wordlists/rockyou.txt database.john
john --show database.john

Inspect extraction errors on stderr. An empty output file or an unsupported-format warning is not a successful extraction. Script names and paths vary; common locations are /usr/share/john/ and a jumbo checkout's run/ directory.

Select by format, not extension#

Container Helper Mode/compatibility check
Office office2john.py $office$ version; examples include 9400/9500/9600
KeePass keepass2john 13400 for supported older AES/Twofish formats; KDBX4 requires separate support checks
SSH private key ssh2john.py Format/cipher subtype varies; John is a useful first path
AxCrypt axcrypt2john.py Check container version and the emitted record; verify with AxCrypt
Ansible Vault ansible2john.py 16900 for compatible $ansible$ records
PKCS#12 pfx2john.py KDF/MAC varies; use John or confirm a compatible hashcat conversion
ZIP zip2john $zip2$: WinZip/AES 13600; $pkzip2$: PKZIP 17200-series
RAR rar2john RAR5 13000; older RAR uses other modes
7-Zip 7z2john.pl 11600 where the extracted representation is supported
PDF pdf2john.pl Revision-dependent modes; inspect the $pdf$ record
BitLocker bitlocker2john 22100 for a compatible record

Consult the installed cracker's supported formats before choosing a mode. For SSH/PFX, the extension alone cannot establish that one hashcat mode is correct.

The supplied report runs office2john on a file labelled .one and obtains an Office record. That does not establish general OneNote support: inspect the actual file container and the installed extractor before using it. A renamed Office document and a native OneNote section are not interchangeable.

See AxCrypt and Ansible Vault for complete extract, crack and open workflows.

John labels are not always hashcat-ready#

Extractors can include a filename label and extra trailing fields. hashcat --username ignores the initial username/label field; it does not translate every John-specific record into a compatible hashcat representation.

# Example: an Office 2013 record that matches hashcat's 9600 format
python3 /usr/share/john/office2john.py review.xlsx > review.john
hashcat --identify --username review.john
hashcat -m 9600 --username review.john /usr/share/wordlists/rockyou.txt
hashcat -m 9600 --username --show review.john

Use 9600 only after identifying Office 2013. Identification can return multiple candidate modes; compare the record with the documented examples. Do not assume automatic detection will always pick one, or strip arbitrary colon-separated fields from formats that use them internally.

Encrypted SSH key example#

python3 /usr/share/john/ssh2john.py id_rsa > ssh.john
john --wordlist=/usr/share/wordlists/rockyou.txt ssh.john
john --show ssh.john

An unencrypted key has no passphrase to crack. After recovery, verify the key locally with ssh-keygen -y -f id_rsa; this proves the passphrase opens the key, not that a target accepts the key for login.

Success and next step#

Success: the recovered password opens the original container with its normal application. A potfile hit alone is not the final validation. For a database with a keyfile, retain both components and check the exact combination.

Recent John jumbo source includes KDBX4/Argon2 extraction support, but older packaged builds may not. Successful extraction still does not mean your hashcat build supports that KDF. Prefer a compatible current John format rather than forcing every .kdbx into 13400.

Record the original filename, extractor/version, output prefix, selected format/mode and verification result. Redact recovered secrets from the report.

Keep an extractor manifest#

Field Example role
Original digest Ties the result to the exact encrypted file
Container identification Distinguishes file type from extension
Helper and revision Explains support differences between installations
Record prefix Guides format identification
Cracker and selected format Makes candidate testing reproducible
Opening application/result Validates the recovered passphrase
umask 077
mkdir -p evidence/extractors
file review.xlsx > evidence/extractors/file-type.txt
sha256sum review.xlsx > evidence/extractors/input.sha256
python3 /usr/share/john/office2john.py review.xlsx \
  > evidence/extractors/review.john 2> evidence/extractors/extract-errors.txt
john --list=formats

Use a jumbo build. A helper script found on disk does not guarantee the installed cracker includes the corresponding format.

Choose a session and candidate strategy#

john --session=lab-office --wordlist=lab-candidates.txt evidence/extractors/review.john
john --status=lab-office
# Resume only after interruption of the original run
john --restore=lab-office
john --show evidence/extractors/review.john

Start with an agreed candidate set based on the file's context. Rules mutate those candidates; they cannot fix a wrong extractor or unsupported KDF. Keep separate sessions for unrelated formats so a resume file is associated with the correct source.

Common record traps#

Trap Consequence Repair
Shell expands $ in a pasted record Prefix or fields are corrupted Preserve the extractor file or use single quotes
Word processor wraps/truncates the record Parser error or wrong data Transfer the text file directly
Label contains a path or colon Naive cut corrupts the input Use supported label handling and format-aware conversion
Multiple protected items in an archive More than one verification record Associate each output with the actual protected member
Existing potfile hit Password appears without a new run Validate against the original container
Keyfile required Correct password alone fails to open Retain the original keyfile and reader settings

Validation examples after recovery#

# SSH: prompts locally for the recovered key passphrase
ssh-keygen -y -f id_rsa > evidence/extractors/public-key.txt

# Ansible: reads plaintext without replacing the encrypted file
ansible-vault view encrypted-value.vault --ask-vault-pass

# ZIP: tests archive integrity and may prompt for the member password
unzip -t encrypted.zip

Use the normal compatible reader for Office, KeePass and AxCrypt. An SSH public-key export proves key decryption; an accepted SSH login is a separate permission check. Archive testing can reveal that only some members are encrypted.

Know when to stop#

If the helper reports an unsupported format, inspect its supported headers and use a compatible current tool. If John loads the correct record but exhausts the candidate list, report that result accurately. If the file opens but enclosed credentials are stale, the passphrase recovery is still valid; credential reuse has not been demonstrated.

See Also#

Sources#