john-crack

$npx mdskill add wgpsec/AboutSecurity/john-crack

Crack offline hashes using John the Ripper's advanced attack methods.

  • Recover passwords from MD5, SHA, NTLM, and encrypted file formats.
  • Integrates with 2john tools to extract hashes from ZIP, PDF, and SSH keys.
  • Automatically detects hash types and applies rule-based or brute-force strategies.
  • Outputs decrypted plaintext passwords directly to the terminal or log file.

SKILL.md

.github/skills/john-crackView on GitHub ↗
---
name: john-crack
description: "使用 John the Ripper 进行离线密码破解。当需要破解哈希(MD5/SHA/NTLM/Kerberos/ZIP/RAR/PDF/SSH Key 等)时使用。John 支持自动检测哈希类型、字典攻击、规则变形、增量爆破,内置 *2john 工具链从各种格式提取哈希。任何涉及离线密码破解、哈希还原、密码审计的场景都应使用此技能"
metadata:
  tags: "john,crack,password,密码破解,哈希,hash,MD5,NTLM,Kerberos,字典攻击,规则,暴力破解"
  category: "tool"
---

# John the Ripper 离线密码破解方法论

John the Ripper 是最经典的离线密码破解工具。核心优势:**自动哈希识别** + **丰富规则引擎** + ***2john 提取工具链**。支持 200+ 哈希类型。

项目地址:https://github.com/openwall/john

## Phase 1: 基本破解

```bash
# 自动检测哈希类型并破解
john hashes.txt

# 指定哈希格式
john --format=Raw-MD5 hashes.txt
john --format=NT hashes.txt
john --format=Raw-SHA256 hashes.txt

# 字典攻击
john --wordlist=rockyou.txt hashes.txt

# 查看已破解的密码
john --show hashes.txt
```

## Phase 2: 规则变形攻击

```bash
# 字典 + 默认规则
john --wordlist=rockyou.txt --rules hashes.txt

# 字典 + best64 规则(最常用)
john --wordlist=rockyou.txt --rules=best64 hashes.txt

# 字典 + Jumbo 规则(更全面)
john --wordlist=rockyou.txt --rules=Jumbo hashes.txt

# 字典 + KoreLogic 规则(最复杂,最慢)
john --wordlist=rockyou.txt --rules=KoreLogic hashes.txt

# 列出可用规则
john --list=rules
```

## Phase 3: 哈希提取(*2john 工具链)

```bash
# ZIP 文件
zip2john secret.zip > zip_hash.txt
john zip_hash.txt

# RAR 文件
rar2john secret.rar > rar_hash.txt

# PDF 文件
pdf2john.pl secret.pdf > pdf_hash.txt

# SSH 私钥
ssh2john id_rsa > ssh_hash.txt

# KeePass 数据库
keepass2john database.kdbx > keepass_hash.txt

# Office 文档
office2john document.docx > office_hash.txt

# Kerberos TGS (Kerberoasting)
john --format=krb5tgs --wordlist=rockyou.txt tgs_hashes.txt

# Kerberos AS-REP (AS-REP Roasting)
john --format=krb5asrep --wordlist=rockyou.txt asrep_hashes.txt

# NTLM Hash
john --format=NT --wordlist=rockyou.txt ntlm_hashes.txt
```

## Phase 4: 增量和掩码攻击

```bash
# 增量模式(纯暴力,自动递增长度)
john --incremental hashes.txt

# 指定字符集
john --incremental=Digits hashes.txt     # 纯数字
john --incremental=Alnum hashes.txt      # 字母数字
john --incremental=ASCII hashes.txt      # 全 ASCII

# 掩码攻击(Hashcat 风格)
john --mask='?d?d?d?d?d?d' hashes.txt          # 6 位数字
john --mask='?u?l?l?l?d?d?d?s' hashes.txt      # 大写+小写x3+数字x3+特殊
```

## Phase 5: 实用技巧

```bash
# 恢复中断的破解
john --restore

# 查看当前进度
john --status

# 多核并行
john --fork=4 --wordlist=rockyou.txt hashes.txt

# 指定会话名称
john --session=my_crack --wordlist=rockyou.txt hashes.txt

# 只破解特定用户
john --users=admin hashes.txt
```

## 渗透测试常用场景

| 场景 | 命令 |
|------|------|
| NTLM 破解 | `john --format=NT --wordlist=rockyou.txt ntlm.txt` |
| Kerberoasting | `john --format=krb5tgs --wordlist=rockyou.txt tgs.txt` |
| SSH 密钥破解 | `ssh2john id_rsa > h.txt && john --wordlist=rockyou.txt h.txt` |
| ZIP 密码破解 | `zip2john file.zip > h.txt && john h.txt` |
| Linux shadow | `john --wordlist=rockyou.txt /tmp/shadow` |
| 字典+规则 | `john --wordlist=rockyou.txt --rules=best64 hashes.txt` |

More from wgpsec/AboutSecurity

SkillDescription
401-403-bypass401/403 访问拒绝绕过方法论。当遇到管理后台、API 端点返回 401/403 Forbidden 时使用。覆盖路径操纵、HTTP 方法篡改、Header 注入、协议降级、组合攻击
ad-acl-abuseActive Directory ACL 滥用攻击方法论。当 BloodHound 发现 GenericAll/WriteDACL/WriteOwner/GenericWrite/ForceChangePassword 等危险 ACE 时使用。覆盖 ACE 枚举、权限滥用链、Shadow Credentials、RBCD 攻击
ad-delegation-attackKerberos 委派攻击(非约束/约束/RBCD)。当 BloodHound 发现委派配置、或已获取有 SPN 的服务账号/机器账号控制权时使用。通过 S4U 协议滥用可实现跨服务模拟任意用户,常用于域内权限提升和横向移动。
ad-domain-attackActive Directory 域环境攻击全链路。当目标主机在域环境中(systeminfo 显示 Domain 非 WORKGROUP)、发现 88/389/636 端口、或获取到域用户凭据时使用。覆盖域信息收集、用户枚举、Kerberoasting、AS-REP Roasting、委派攻击、ACL 滥用、DCSync、Golden/Silver Ticket
ad-persistenceAD 域环境持久化技术。当已获取域管/本地管理员权限、需要建立持久访问以确保重启或密码更改后仍能回到目标环境时使用。覆盖主机级持久化(计划任务/注册表Run/COM劫持/WMI事件订阅/Windows服务/启动文件夹)、域级持久化(Golden Ticket/Silver Ticket/Skeleton Key/DSRM/AdminSDHolder)、DCShadow/GoldenGMSA高级技术、清理命令与检测规避
ad-trust-attack域信任关系攻击。当目标存在多域/多林环境时使用。包含父子域提权(Golden Ticket + ExtraSid)、跨林攻击(SID History/MSSQL Trust Links)、单向信任利用。已获取子域 Domain Admin 或发现信任关系时优先加载。
adcs-certipy-attackActive Directory Certificate Services (ADCS) 证书攻击。当发现域内有 CA 服务器、ADCS Web Enrollment、证书模板配置错误时使用。覆盖 ESC1-ESC11 所有证书滥用路径、Certipy 工具链、证书伪造、NTLM 中继到 ADCS。发现 ADCS/CA/证书/certsrv 相关内容时一定要使用此技能
adinfo-enum使用 Adinfo 进行 Active Directory 信息收集。当获得域用户凭据后需要快速收集域环境信息时使用。Adinfo 是一个快速 AD 信息收集工具,一条命令输出域控列表、域管用户、信任关系、GPO、SPN、委派配置等关键信息——比手动 LDAP 查询快得多。发现域环境后第一步信息收集使用此技能
agent-security|
ai-data-security|