dirsearch工具的使用
dirsearch
是一款用于目录和文件扫描的命令行工具,常用于Web应用的路径枚举。以下是其常用参数及使用方法的详细说明:
基本语法
python3 dirsearch.py -u <URL> [选项]
核心参数
参数 | 缩写 | 说明 |
---|---|---|
-u <URL> | 指定目标URL(如 http://example.com )。 | |
-l <FILE> | 从文件加载多个目标URL(每行一个)。 | |
-e <EXT> | 指定文件扩展名扫描(如 php,html,js )。 | |
-w <WORDLIST> | 使用自定义字典文件(默认使用内置字典)。 | |
--wordlists-path | 指定字典文件目录路径。 | |
-r | 递归扫描子目录。 | |
--recursion-depth | 设置递归深度(默认1)。 | |
--force-extensions | 强制扫描时添加扩展名到所有条目(即使目录)。 | |
-t <THREADS> | 设置并发线程数(默认25)。 | |
--timeout=<SEC> | 请求超时时间(默认15秒)。 | |
--delay=<MS> | 请求间延迟(毫秒)。 | |
--proxy=<PROXY> | 使用代理(如 http://127.0.0.1:8080 )。 | |
--cookie=<COOKIE> | 设置请求Cookie(如 session=123 )。 | |
--user-agent=<UA> | 自定义User-Agent。 | |
--headers=<HEADERS> | 添加请求头(如 "Header1:Value" )。 | |
-f | 强制显示404状态码的结果。 | |
--random-agent | 随机使用User-Agent。 | |
--full-url | 输出结果显示完整URL。 | |
-q | 安静模式(仅显示结果)。 | |
--json-report=<FILE> | 生成JSON格式报告。 | |
--simple-report=<FILE> | 生成简单格式报告。 |
常用场景示例
基础扫描
python3 dirsearch.py -u http://example.com
指定扩展名和字典
python3 dirsearch.py -u http://example.com -e php,html -w /path/to/wordlist.txt
递归扫描(深度2)
python3 dirsearch.py -u http://example.com -r --recursion-depth 2
使用代理和自定义Header
python3 dirsearch.py -u http://example.com --proxy http://127.0.0.1:8080 --headers "X-Forwarded-For:127.0.0.1"
生成报告
python3 dirsearch.py -u http://example.com --json-report report.json
注意事项
权限问题:确保对目标有合法授权。
速率限制:避免高频请求导致IP被封,可调整
--delay
或-t
。字典选择:默认字典较小,推荐使用更全面的字典(如
SecLists
)。递归风险:递归扫描可能产生大量请求,谨慎使用。
通过合理组合参数,dirsearch
可以高效地发现Web应用的隐藏路径和文件。建议先小规模测试再扩大扫描范围。