~/protected-files

Protected Files

CPTS Notes3 min read

TL;DR

A password-protected file hides behind a passphrase, not a login. The move is the same each time: find the file, extract a crackable hash with a *2john tool, then crack it the usual way in Cracking. A couple of formats need a different trick.

Find them first

After a foothold, sweep the filesystem for documents, archives, and keys:

find / -type f \( -name '*.doc*' -o -name '*.xls*' -o -name '*.pdf' -o -name '*.zip' -o -name '*.kdbx' \) 2>/dev/null
grep -rlE '^-{5}BEGIN .*PRIVATE KEY-{5}$' /home /root 2>/dev/null # SSH private keys by header

An SSH key may carry a passphrase. One quick test tells you:

ssh-keygen -yf id_rsa # prints the public key, or prompts for a passphrase when the key is encrypted

Extract then crack

A *2john tool turns a file or key into a crackable hash. Extract, then crack with john or hashcat:

ssh2john id_rsa > ssh.hash # a .py under /usr/share/john on some installs
john --wordlist=/usr/share/wordlists/rockyou.txt ssh.hash
john ssh.hash --show # print the cracked passphrase
Tool File
ssh2john Encrypted SSH private key
zip2john / rar2john / 7z2john Password-protected archive
office2john Word, Excel, PowerPoint
pdf2john PDF
keepass2john KeePass database
bitlocker2john BitLocker volume

Some are binaries on PATH, others scripts under /usr/share/john/. locate '*2john*' finds them all.

OpenSSL-encrypted files

A file with a harmless extension can still be encrypted, and file gives it away:

file backup.gzip # "openssl enc'd data with salted password" means OpenSSL, not a 2john target

OpenSSL has no extractor, so brute it by decrypting with each candidate until one works:

for p in $(cat rockyou.txt); do openssl enc -aes-256-cbc -d -in backup.gzip -k "$p" 2>/dev/null | tar xz 2>/dev/null && echo "key: $p"; done

BitLocker

A BitLocker volume cracks through bitlocker2john. Keep the password hash, drop the recovery-key hashes (random, not guessable):

bitlocker2john -i Backup.vhd > bl.hashes
grep '\$bitlocker\$0\$' bl.hashes > bl.hash
hashcat -a 0 -m 22100 bl.hash /usr/share/wordlists/rockyou.txt # AES, so slow

Once cracked, mount it on Linux with dislocker. It takes two separate mount points: dislocker decrypts the partition into the first (exposing one virtual file, dislocker-file), then you loop-mount that file at the second:

sudo losetup -f -P Backup.vhd # expose the partitions as /dev/loop0pN
lsblk # find the BitLocker partition, often p1 or p2
mkdir bl blmount # two separate mount points
sudo dislocker /dev/loop0p1 -u<password> -- ./bl # decrypt into ./bl
sudo mount -o loop ./bl/dislocker-file ./blmount # mount the clear NTFS
ls ./blmount # browse the files

The second mount point cannot sit inside the first. ./bl is a FUSE mount that holds only dislocker-file, so a mkdir under it fails.