Post

Hashcat Cheatsheet

Tổng hợp hash types, attack modes, rules và workflow crack password thực tế với Hashcat.

Hashcat Cheatsheet

Tổng Quan

Hashcat không giải mã hash — nó thử hàng triệu/tỷ mật khẩu, hash chúng lại, rồi so sánh với hash mục tiêu. Khi khớp → tìm được mật khẩu gốc.


Cú Pháp Cơ Bản

1
hashcat -m <hash_type> -a <attack_mode> <hash_file> <wordlist/mask>
Tham sốÝ nghĩa
-mLoại hash (hash type ID)
-aChế độ tấn công (attack mode)
-oFile lưu kết quả
--showHiển thị hash đã crack
--usernameFile hash có chứa username
-rÁp dụng rule file
--forceBỏ qua cảnh báo (dùng trên VM)
-w 3Workload profile (1-4)
--statusHiển thị trạng thái trong lúc chạy

Các Loại Hash Phổ Biến (-m)

Hash Tổng Quát (Generic)

IDHash TypePrefix / Độ dàiGhi chú
0MD532 hexRất phổ biến, nhanh crack
100SHA-140 hexGit, cũ
1400SHA-25664 hex 
1700SHA-512128 hex 
17300Keccak-25664 hexTiền thân SHA3

Linux / Unix

IDHash TypePrefixGhi chú
500md5crypt$1$/etc/shadow
1800sha512crypt$6$/etc/shadow hiện đại
7400sha256crypt$5$/etc/shadow
400phpass$P$ / $H$WordPress, phpBB

Windows / Active Directory

IDHash TypeGhi chú
1000NTLMSAM, secretsdump, Mimikatz
3000LMWindows cũ (< Vista)
5500NetNTLMv1Responder (cũ)
5600NetNTLMv2Responder capture (phổ biến)
13100Kerberoast TGS-REPAD — GetUserSPNs.py
18200AS-REP RoastAD — no preauth
2100DCC2 (MSCACHEv2)Domain cached credentials

Web Application

IDHash TypePrefixGhi chú
3200bcrypt$2a$ / $2b$Chậm, web app hiện đại
400phpass$P$WordPress
300MySQL4.1+* đầu dòng 

Network / Services

IDHash TypeGhi chú
7300IPMI2 RAKPIPMI — iDRAC, iLO
22000WPA-PBKDF2-PMKIDWiFi WPA2 (hcxdumptool)
5600NetNTLMv2Responder

Xác định loại hash nhanh:

1
2
3
hashid '$1$xyz$...'
hash-identifier
# Online: https://hashes.com/en/tools/hash_identifier

Các Chế Độ Tấn Công (-a)

Mode 0 — Dictionary Attack

1
hashcat -m 0 -a 0 hash.txt /usr/share/wordlists/rockyou.txt

Mode 1 — Combination Attack

1
2
# "pass" + "word" → "password"
hashcat -m 0 -a 1 hash.txt wordlist1.txt wordlist2.txt

Mode 3 — Brute-force / Mask Attack

1
2
3
4
5
6
7
8
# 8 ký tự chữ thường
hashcat -m 0 -a 3 hash.txt ?l?l?l?l?l?l?l?l

# 4 chữ hoa + 4 số
hashcat -m 0 -a 3 hash.txt ?u?u?u?u?d?d?d?d

# Increment 6-8 ký tự
hashcat -m 0 -a 3 --increment --increment-min=6 hash.txt ?a?a?a?a?a?a?a?a

Ký hiệu Mask:

Ký hiệuBộ ký tự
?la-z (chữ thường)
?uA-Z (chữ hoa)
?d0-9 (số)
?sKý tự đặc biệt !@#$...
?aTất cả (?l?u?d?s)
?hHex thường 0-9a-f
?HHex hoa 0-9A-F

Mode 6 — Hybrid Wordlist + Mask

1
2
# "password" + "123" → "password123"
hashcat -m 0 -a 6 hash.txt rockyou.txt ?d?d?d

Mode 7 — Hybrid Mask + Wordlist

1
2
# "2024" + "password" → "2024password"
hashcat -m 0 -a 7 hash.txt ?d?d?d?d rockyou.txt

Rules

1
2
3
4
5
# Rule có sẵn
hashcat -m 0 -a 0 hash.txt rockyou.txt -r /usr/share/hashcat/rules/best64.rule

# Nhiều rule
hashcat -m 0 -a 0 hash.txt rockyou.txt -r rules/best64.rule -r rules/d3ad0ne.rule

Rule files phổ biến:

Rule FileMô tả
best64.rule64 rule hiệu quả nhất
rockyou-30000.ruleRule từ phân tích rockyou
d3ad0ne.ruleBiến thể phức tạp
OneRuleToRuleThemAll.ruleRule tổng hợp lớn

Tự tạo rule:

1
2
3
4
5
6
7
8
9
10
# rule.txt
l           # lowercase toàn bộ
u           # uppercase toàn bộ
c           # Capitalize chữ đầu
r           # Reverse: "password" → "drowssap"
$1          # Thêm "1" vào cuối
^2024       # Thêm "2024" vào đầu
sa@         # Thay 'a' → '@'

hashcat -m 0 -a 0 hash.txt rockyou.txt -r rule.txt

Ví Dụ Thực Tế

Crack NTLM (Windows)

1
2
hashcat -m 1000 -a 0 ntlm_hashes.txt rockyou.txt
hashcat -m 1000 -a 0 --username ntlm_hashes.txt rockyou.txt

Crack /etc/shadow (Linux)

1
2
unshadow /etc/passwd /etc/shadow > combined.txt
hashcat -m 1800 -a 0 combined.txt rockyou.txt

Crack NetNTLMv2 (từ Responder)

1
hashcat -m 5600 -a 0 netntlmv2.txt rockyou.txt

Crack Kerberoast TGS

1
hashcat -m 13100 -a 0 kerberoast.txt rockyou.txt -r rules/best64.rule

Crack WPA2 WiFi

1
hashcat -m 22000 -a 0 wifi.hc22000 rockyou.txt

Crack bcrypt

1
hashcat -m 3200 -a 0 bcrypt.txt rockyou.txt -w 3

Tối Ưu Hiệu Suất

1
2
3
4
5
# Workload cao nhất
hashcat -m 0 -a 0 hash.txt rockyou.txt -w 4

# Force CPU (VM không có GPU)
hashcat -m 0 -a 0 hash.txt rockyou.txt --force

Trên VM (VirtualBox/VMware), GPU thường không khả dụng. Phải dùng --force để ép dùng CPU — tốc độ sẽ chậm hơn nhiều.


Quản Lý Session & Restore

1
2
3
4
5
# Đặt tên session
hashcat -m 0 -a 0 hash.txt rockyou.txt --session mysession

# Resume
hashcat --restore --session mysession

Xem Kết Quả

1
2
3
4
5
hashcat -m 0 hash.txt --show
hashcat -m 1000 --username ntlm.txt --show

# Potfile mặc định
~/.local/share/hashcat/hashcat.potfile

Wordlists Phổ Biến

WordlistĐường dẫnGhi chú
rockyou.txt/usr/share/wordlists/rockyou.txt14M mật khẩu
SecLists/usr/share/seclists/Passwords/Bộ sưu tập lớn
1
gunzip /usr/share/wordlists/rockyou.txt.gz

Nhận Diện Hash

1
2
3
hashid '$2a$12$xyz...'
hash-identifier
hashcat --example-hashes | grep -A2 "NTLM"

Nhận diện nhanh qua prefix:

  • $1$ → MD5crypt (500)
  • $2a$ / $2b$ → bcrypt (3200)
  • $5$ → SHA256crypt (7400)
  • $6$ → SHA512crypt (1800)
  • * đầu dòng → MySQL (300)
  • 32 hex không prefix → MD5 (0)
  • 40 hex không prefix → SHA1 (100)

Lỗi Thường Gặp

LỗiNguyên nhânGiải pháp
No devices foundKhông nhận GPUThêm --force dùng CPU
Token length exceptionHash format saiKiểm tra lại định dạng hash
Separator unmatchedHash bị lỗi dòngDùng --username nếu có prefix
ExhaustedHết wordlist, không tìm raĐổi wordlist hoặc thêm rule
CrackedTìm được!Xem kết quả bằng --show
This post is licensed under CC BY 4.0 by the author.