Protected Files
CPTS Notes
- Foundations
- Enumeration with Nmap
- Passwords
- Wordlists
- Cracking
- Protected Files
- Spraying and Defaults
- Hunting (Windows)
- Hunting (Linux)
- Hunting (Shares)
- Hunting (Traffic)
- Looting (Windows)
- Looting (Linux)
- File Services
- FTP
- SMB
- NFS
- Rsync
- Network
- DNS
- SNMP
- SMTP
- Mail Retrieval
- Cloud Mail
- Databases
- MySQL
- MSSQL
- Remote Access
- SSH
- R-Services
- RDP
- WinRM
- WMI
- Linux
- Reading Files
- Editing Files
- Searching Files
- Requests and Transfer
- Local Enumeration
- Privesc Primer
- File Transfer
- Choosing a Method
- Serving Files
- Windows Transfers
- Linux Transfers
- Code One-Liners
- Session Transfers
- Protected Transfers
- Detection & Evasion
- Windows
- Reading Files
- Editing Files
- Searching Files
- Requests and Transfer
- Local Enumeration
- Privesc Primer
- Reference
- Port References
- DNS Resolution
- The Mail Pipeline
- SMB & NetBIOS
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/nullgrep -rlE '^-{5}BEGIN .*PRIVATE KEY-{5}$' /home /root 2>/dev/null # SSH private keys by headerAn 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 encryptedExtract 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 installsjohn --wordlist=/usr/share/wordlists/rockyou.txt ssh.hashjohn 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 |
|
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 targetOpenSSL 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"; doneBitLocker
A BitLocker volume cracks through bitlocker2john. Keep the password hash, drop the recovery-key
hashes (random, not guessable):
bitlocker2john -i Backup.vhd > bl.hashesgrep '\$bitlocker\$0\$' bl.hashes > bl.hashhashcat -a 0 -m 22100 bl.hash /usr/share/wordlists/rockyou.txt # AES, so slowOnce 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/loop0pNlsblk # find the BitLocker partition, often p1 or p2mkdir bl blmount # two separate mount pointssudo dislocker /dev/loop0p1 -u<password> -- ./bl # decrypt into ./blsudo mount -o loop ./bl/dislocker-file ./blmount # mount the clear NTFSls ./blmount # browse the filesThe second mount point cannot sit inside the first. ./bl is a FUSE mount that holds only
dislocker-file, so a mkdir under it fails.