Password Cracking

Sections Password Cracking

Offline hash cracking. Online brute force is in 02 Service Enum under each service.

WL=/usr/share/wordlists/rockyou.txt
RULES=/usr/share/hashcat/rules/best64.rule

i. Identify the hash first

hashid 'hash-here'
hash-identifier
nth hash-here                              ## name-that-hash, most accurate

Common modes you will hit on every box:

Hashhashcat -mNotes
MD50almost never alone, often wrapped
SHA1100same
NTLM1000local Windows accounts, from SAM
NetNTLMv25600from responder / smb relay
Kerberos TGS (kerberoast)13100$krb5tgs$23$*
Kerberos AS-REP18200$krb5asrep$23$
MD5crypt500$1$ Linux shadow
sha256crypt7400$5$
sha512crypt1800$6$ Linux shadow, SLOW
bcrypt3200$2a$, $2b$, SLOW
MSSQL 2012+17310x0200...
WPA-PBKDF222000new format, replaces 2500
LUKS14600also 29541 for LUKS2
7-Zip11600$7z$
KeePass13400use keepass2john first

ii. Hashcat basics

Dictionary attack:

hashcat -m 1000 hash.txt "$WL"

Dictionary + rules, the workhorse:

hashcat -m 1000 hash.txt "$WL" -r "$RULES"
hashcat -m 1000 hash.txt "$WL" -r /usr/share/hashcat/rules/OneRuleToRuleThemAll.rule

Mask attack, you know the structure:

## 8 chars, 1 upper + 6 lower + 1 digit
hashcat -m 1000 hash.txt -a 3 '?u?l?l?l?l?l?l?d'
## Custom charset, ?1 = digits + special
hashcat -m 1000 hash.txt -a 3 -1 '?d!@#$' 'Pass?1?1?1?1'

Combinator, two dicts joined:

hashcat -m 1000 hash.txt -a 1 names.txt years.txt

Hybrid, dict + mask:

hashcat -m 1000 hash.txt -a 6 "$WL" '?d?d?d?d'    ## word + 4 digits
hashcat -m 1000 hash.txt -a 7 '?d?d?d?d' "$WL"    ## 4 digits + word

Show cracked:

hashcat -m 1000 hash.txt --show

Useful flags:

-w 3                                ## workload high
-O                                  ## optimized kernel, password len <= 27
--username                          ## file is user:hash format
--status --status-timer 10          ## live progress
-d 1,2                              ## use specific GPU devices
--session=name --restore            ## resumable sessions

iii. John when hashcat won’t load

Fast for small/quick stuff or when GPU is unavailable. Auto-detects format:

john --wordlist="$WL" hash.txt
john --wordlist="$WL" --rules=Jumbo hash.txt
john --format=NT --wordlist="$WL" hash.txt
john --show hash.txt

John helpers convert weird formats to crackable hash strings:

zip2john file.zip > z.hash
ssh2john id_rsa > k.hash
keepass2john db.kdbx > kp.hash
office2john.py file.docx > o.hash
pdf2john.pl file.pdf > p.hash

iv. Wordlists

Defaults worth knowing:

  • /usr/share/wordlists/rockyou.txt-start here
  • /usr/share/wordlists/seclists/Passwords/-categorized lists
  • /usr/share/wordlists/seclists/Usernames/-for spraying

Better ones to download:

Build a custom list from the target:

cewl -d 3 -m 6 -w cewl.txt https://target.htb
## Then permute with hashcat rules:
hashcat --stdout cewl.txt -r "$RULES" | sort -u > custom.txt

v. Kerberos hash cracking

Kerberoasting output from GetUserSPNs.py or nxc:

hashcat -m 13100 spn.hash "$WL" -r "$RULES"

AS-REP roasting output:

hashcat -m 18200 asrep.hash "$WL" -r "$RULES"
66 and bcrypt are slow

sha512crypt and bcrypt cost millions of cycles per attempt. Even on a 4090 you get a few thousand hashes/sec. Use targeted wordlists, masks, and -O. For full brute, rent GPUs (see below).

vi. Cracking SSH known_hosts

Reveals internal IPs the user has connected to:

curl -SsfL https://github.com/chris408/known_hosts-hashcat/raw/refs/heads/master/kh-converter.py -O
curl -SsfL https://github.com/chris408/known_hosts-hashcat/raw/refs/heads/master/ipv4_hcmask.txt -O
python3 kh-converter.py ~/.ssh/known_hosts > kh.hash
hashcat -m 160 --hex-salt kh.hash -a 3 ipv4_hcmask.txt

vii. Cloud cracking when local GPU is weak

  • vast.ai -rent RTX 4090s by the hour
  • runpod.io -same idea, hashcat docker image
  • Use dizcza/docker-hashcat:cuda to skip setup

viii. Online lookup before brute force

Always try these first, they are free:

ix. Generate strong test hashes (for box-making)

## NTLM
python3 -c 'import hashlib; print(hashlib.new("md4","Passw0rd!".encode("utf-16le")).hexdigest())'
## sha512crypt
mkpasswd -m sha-512 Passw0rd!
## bcrypt
htpasswd -bnBC 10 "" Passw0rd! | tr -d ':\n'