mcpField
R
recon-dir-scan

recon-dir-scan

github.com/crazymarky安全34976 次安装21 周前更新
代码仓库

关于 recon-dir-scan

recon-dir-scan 是用于目录与文件枚举的安全测试 Skill,面向需要发现 Web 应用路径、隐藏文件和 API 端点的测试人员。它提供 ffuf、gobuster 等工具的操作场景,并包含结果解析、字典整理及结果存储说明。

主要功能

  1. 01使用 ffuf 和 gobuster 枚举路径
  2. 02递归扫描并按状态码筛选
  3. 03探测文件扩展名、隐藏文件与虚拟主机
  4. 04枚举 API 端点和请求参数
  5. 05解析、保存及持久化扫描结果

适用场景

  1. 01在授权评估中查找隐藏目录和备份文件
  2. 02递归检查 Web 应用路径
  3. 03发现 API 端点或未公开参数
  4. 04保存目录扫描发现以供后续报告

安装

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

$npx skills add https://github.com/crazymarky/pentest-skills --skill recon-dir-scan

安装后在 Claude Code 中输入/recon-dir-scan确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

assets/
api-endpoints.txt
common-dirs.txt
common-files.txt
hidden-files.txt
references/
ffuf_guide.md
gobuster_guide.md
wordlist_guide.md
scripts/
dir_scan_storage.py
ffuf_results_parser.py
merge_wordlists.py
status_code_analyzer.py

详细介绍

目录和文件枚举

授权警告

重要: 未经适当授权扫描目录可能会被检测为入侵尝试。请始终确保你已获得:

  • 目标应用所有者的书面许可
  • 明确的授权测试范围
  • 遵守当地法规

前提条件

系统上必须安装以下工具:

  • ffuf - go install github.com/ffuf/ffuf@latest
  • gobuster - go install github.com/OJ/gobuster/v3/cmd/gobusterdir@main

可选工具:

  • feroxbuster - cargo install feroxbuster
  • dirsearch - pip install dirsearch
  • dirb - 通过包管理器安装

快速开始

最常用的目录枚举命令:

快速目录扫描(ffuf)
ffuf -w wordlist.txt -u https://target.com/FUZZ
按状态码递归扫描
ffuf -w wordlist.txt -u https://target.com/FUZZ -mc 200,301,302 -recursion
Gobuster 快速扫描
gobuster dir -u https://target.com -w wordlist.txt -t 50

常见场景

场景 1:基本目录模糊测试

需要发现目录和文件时:

ffuf -w wordlist.txt -u https://target.com/FUZZ

参数:

  • -w wordlist.txt - 字典路径
  • -u - 含有 FUZZ 关键字的目标 URL
  • -t - 线程数(默认值:40)

示例:

ffuf -w /usr/share/seclists/Discovery/Web-Content/common.txt -u https://target.com/FUZZ

场景 2:按状态码筛选

只需要特定 HTTP 状态码时:

ffuf -w wordlist.txt -u https://target.com/FUZZ -mc 200,301,302,403

状态码筛选条件:

代码含义
200OK(有效页面)
301,302重定向
403禁止访问(目录存在,但无法访问)
401需要身份验证

否定筛选条件(排除状态码):

ffuf -w wordlist.txt -u https://target.com/FUZZ -mc 200,204,301,302,307,401,403 -mc 404

场景 3:递归扫描

需要递归扫描发现的目录时:

ffuf -w wordlist.txt -u https://target.com/FUZZ -recursion -recursion-depth 2

参数:

  • -recursion - 启用递归扫描
  • -recursion-depth - 最大深度(默认值:0)

示例:

ffuf -w wordlist.txt -u https://target.com/FUZZ -recursion -recursion-depth 3

场景 4:文件扩展名模糊测试

搜索特定文件类型时:

ffuf -w wordlist.txt -u https://target.com/FUZZ -X .txt

多个扩展名:

ffuf -w wordlist.txt -u https://target.com/FUZZ -X .txt,.php,.bak,.old

从字典中获取扩展名:

# Format: extension:wordlist
ffuf -w extensions.txt:EXT -w words.txt:FUZZ -u https://target.com/FUZZ.EXT

场景 5:发现隐藏文件

查找备份文件、配置文件或隐藏文件时:

# Hidden dotfiles
ffuf -w hidden_files.txt -u https://target.com/FUZZ

# Backup files
ffuf -w wordlist.txt -u https://target.com/FUZZ -X .bak,.backup,.old,.tmp,.swp

# Config files
ffuf -w config_files.txt -u https://target.com/FUZZ

需要检查的常见隐藏文件:

.git
.env
.env.local
.env.backup
config.php.bak
wp-config.php.bak
.gitignore
.htaccess

场景 6:虚拟主机发现

测试虚拟主机路由时:

ffuf -w vhosts.txt -u https://target.com -H "Host: FUZZ.target.com"

参数:

  • -H - 添加自定义标头
  • 标头值中的 FUZZ - 替换为字典条目

示例:

ffuf -w subdomains.txt -u http://192.168.1.100 -H "Host: FUZZ.example.com"

场景 7:API 端点发现

枚举 API 端点时:

ffuf -w api_endpoints.txt -u https://target.com/api/FUZZ

常见 API 模式:

/api/v1/FUZZ
/api/v2/FUZZ
/graphql
/api/graphql
/rest/FUZZ

使用 HTTP 方法:

ffuf -w endpoints.txt -u https://target.com/api/FUZZ -X GET,POST,PUT,DELETE

场景 8:参数模糊测试

发现隐藏参数时:

ffuf -w params.txt -u https://target.com/page?FUZZ=test

值模糊测试:

ffuf -w values.txt -u https://target.com/page?param=FUZZ

场景 9:Gobuster 扫描

使用 gobuster 替代 ffuf:

# Basic scan
gobuster dir -u https://target.com -w wordlist.txt -t 50

# With status filtering
gobuster dir -u https://target.com -w wordlist.txt -t 50 -k --status-codes 200,301,302,403

# Recursive
gobuster dir -u https://target.com -w wordlist.txt -t 50 -r

# With extensions
gobuster dir -u https://target.com -w wordlist.txt -t 50 -x php,txt,html

场景 10:Feroxbuster 扫描

基于 Rust 的新式目录扫描器:

# Basic scan
feroxbuster -u https://target.com -w wordlist.txt

# With recursion and status codes
feroxbuster -u https://target.com -w wordlist.txt -C 404 --depth 3

# Scan multiple URLs
feroxbuster -u https://target.com -u https://target2.com -w wordlist.txt

工具选择指南

场景推荐工具命令
快速扫描ffufffuf -w wordlist.txt -u https://target.com/FUZZ
递归扫描ffufffuf -w wordlist.txt -u https://target.com/FUZZ -recursion
大型字典gobustergobuster dir -u https://target.com -w wordlist.txt -t 100
多目标feroxbusterferoxbuster -u https://target.com -w wordlist.txt
隐藏文件ffufffuf -w files.txt -u https://target.com/FUZZ
API 发现ffufffuf -w api.txt -u https://target.com/api/FUZZ

工具对比:

工具语言速度特性最适用场景
ffufGo极快高度灵活,支持筛选大多数场景
gobusterGo快简单、可靠快速扫描
feroxbusterRust快多目标、递归大型评估
dirsearchPython中等内置字典初学者

常用字典

字典大小描述位置
common.txt~4,600常见目录/文件SecLists
raft-medium-directories~30,000中等覆盖范围SecLists
raft-large-directories~60,000大范围覆盖SecLists
directory-list-2.3-medium~220,000全面DirBuster
apache.txt~5,000Apache 默认项SecLists
api-endpoints.txt~500API 探测自定义

SecLists 路径:

/usr/share/seclists/Discovery/Web-Content/
/usr/share/seclists/Discovery/Web-Content/api/
/usr/share/seclists/Discovery/Web-Content/raft/

高级技巧

速率限制

通过降低请求速度来避免被检测到:

ffuf -w wordlist.txt -u https://target.com/FUZZ -rate 100
User-Agent 轮换
ffuf -w wordlist.txt -u https://target.com/FUZZ \
  -H "User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1)"
身份验证
# Basic auth
ffuf -w wordlist.txt -u https://user:[email protected]/FUZZ

# Header-based auth
ffuf -w wordlist.txt -u https://target.com/FUZZ \
  -H "Authorization: Bearer TOKEN"
基于 Cookie/会话
ffuf -w wordlist.txt -u https://target.com/FUZZ \
  -H "Cookie: session=YOUR_SESSION_TOKEN"
输出匹配

按响应内容筛选:

ffuf -w wordlist.txt -u https://target.com/FUZZ \
  -mr "admin"  # Match response containing "admin"

ffuf -w wordlist.txt -u https://target.com/FUZZ \
  -ms 1520    # Match specific response size

输出格式

保存结果
# ffuf JSON output
ffuf -w wordlist.txt -u https://target.com/FUZZ -o results.json

# ffuf plain output
ffuf -w wordlist.txt -u https://target.com/FUZZ -o results.txt

# Gobuster output
gobuster dir -u https://target.com -w wordlist.txt -o results.txt
恢复扫描
# ffuf resume
ffuf -w wordlist.txt -u https://target.com/FUZZ -resume-ffuf

提示和最佳实践

  1. 从小规模开始 - 先使用较小的字典,以便快速取得成果
  2. 积极筛选 - 使用 -mc 减少噪声
  3. 检查响应大小 - 大小相同的页面通常是假阳性
  4. 手动验证 - 始终手动检查有意思的结果
  5. 速率限制 - 通过适当的延迟避免被屏蔽
  6. 组合字典 - 使用多个字典以扩大覆盖范围
  7. 检查参数 - 别忘了对查询参数进行模糊测试
  8. 留意 403 - 禁止访问的响应可揭示有效路径

资源

脚本
  • scripts/ffuf_results_parser.py - 解析并筛选 ffuf JSON 结果
  • scripts/merge_wordlists.py - 合并多个字典并删除重复项
  • scripts/status_code_analyzer.py - 分析响应模式
参考资料
  • references/ffuf_guide.md - 全面的 ffuf 参考指南
  • references/gobuster_guide.md - Gobuster 使用文档
  • references/wordlist_guide.md - 字典选择与创建指南

场景:持久化保存目录扫描结果

需要将目录扫描结果持久化到数据库时:

# Manual entry after discovering directories
python .claude/skills/recon-dir-scan/scripts/dir_scan_storage.py \
  --host-ip 192.168.1.100 \
  --url "https://example.com" \
  --path "/admin" \
  --status 200 \
  --size 1234 \
  --subsystem "Web Application"

参数:

  • --host-ip - 目标主机 IP(必填)
  • --url - 基础 URL(必填)
  • --path - 发现的路径(必填)
  • --status - HTTP 状态码(可选)
  • --size - 响应大小(可选)
  • --tool - 使用的工具(默认:ffuf)
  • --subsystem - 子系统名称(可选)

数据库位置: ./data/results.db

相关技能: results-storage - 查询数据、生成报告


资源文件
  • assets/common-dirs.txt - 常见目录名称
  • assets/common-files.txt - 常见文件名称
  • assets/hidden-files.txt - 隐藏文件和备份文件
  • assets/api-endpoints.txt - 常见 API 端点

评论

支持 Markdown