dirsearch
2026/5/29工具工具Web安全目录扫描dirsearch大约 4 分钟
dirsearch
链接
是什么
dirsearch 是一个 Web 路径扫描工具,用来发现站点上的目录、文件、备份文件、接口路径和常见敏感资源。
它适合 CTF Web 题的信息收集阶段,尤其是题目页面很少、功能入口不明显、需要发现隐藏路径时。
常见发现目标:
/admin/backup.zip/robots.txt/.git/config/api//upload/
安装与配置
推荐从官方仓库安装:
git clone https://github.com/maurosoria/dirsearch.git --depth 1
cd dirsearch
python3 -m pip install -r requirements.txt
python3 dirsearch.py -u http://target.com -e php,txt,zip也可以安装成命令:
python3 -m pip install .
dirsearch -u http://target.com -e php,txt,zipWindows 下建议在 WSL、Kali、Ubuntu 虚拟机或 Python 虚拟环境里使用。
基本用法
扫描一个站点
python3 dirsearch.py -u http://target.com -e php,html,txt指定字典
python3 dirsearch.py -u http://target.com -w wordlists/common.txt指定状态码
python3 dirsearch.py -u http://target.com -e php,txt -i 200,301,302,403排除状态码
python3 dirsearch.py -u http://target.com -e php,txt -x 404,500调整线程
python3 dirsearch.py -u http://target.com -e php,txt -t 30加 Cookie
python3 dirsearch.py -u http://target.com -e php,txt --cookie "PHPSESSID=abc123"走 Burp 代理
python3 dirsearch.py -u http://target.com -e php,txt --proxy http://127.0.0.1:8080更多选项
递归扫描
python3 dirsearch.py -u http://target.com -e php,txt -r递归扫描发现的目录,深度可通过 --recursion-depth 控制。
指定 HTTP 方法
python3 dirsearch.py -u http://target.com -e php,txt --method POST自定义 Header
python3 dirsearch.py -u http://target.com -e php,txt -H "X-Forwarded-For: 127.0.0.1"排除大小
python3 dirsearch.py -u http://target.com -e php,txt --exclude-sizes 0B排除特定大小的响应,减少噪音。
输出格式
python3 dirsearch.py -u http://target.com -e php,txt -o result.json --format json
python3 dirsearch.py -u http://target.com -e php,txt -o result.csv --format csv延迟请求
python3 dirsearch.py -u http://target.com -e php,txt --delay 0.5避免触发 WAF 或限流。
随机 User-Agent
python3 dirsearch.py -u http://target.com -e php,txt --random-agentCTF常用技巧
先扫基础扩展名
python3 dirsearch.py -u http://target.com -e php,html,txt,zip,bak,tar,gzWeb 题常见扩展包括:
php,html,js,txt,zip,bak,old,swp,conf,json重点看异常状态码
200 不一定最重要,301、302、403 也很有价值。
403: 可能存在真实目录,只是禁止访问
301/302: 可能是目录跳转或登录跳转
500: 可能触发了后端异常发现备份文件
python3 dirsearch.py -u http://target.com -e zip,tar,gz,rar,7z,bak,old,swp常见备份文件名:
www.zip
backup.zip
source.zip
src.zip
index.php.bak
config.php.bak
.index.php.swp登录后扫描
如果未登录状态扫不到内容,先登录,复制 Cookie 后再扫:
python3 dirsearch.py -u http://target.com -e php,txt --cookie "session=..."扫描 API 端点
python3 dirsearch.py -u http://target.com/api/ -e php,json,txt -w api-wordlist.txt配合自动化脚本
#!/bin/bash
# 扫描多个目标
for target in $(cat targets.txt); do
python3 dirsearch.py -u $target -e php,txt,zip -o "results/${target}.json" --format json
done常用字典推荐
dirsearch 默认字典:
- db/dicc.txt — 通用字典
- common.txt — 常见路径
自定义字典:
- 根据题目技术栈定制
- 包含常见备份文件名
- 包含常见 API 路径常见问题
扫描结果全是 200
可能站点把所有不存在路径都返回同一个页面。先访问一个随机路径观察响应长度,再用过滤参数排除。
扫描太慢
可以减少扩展名、换更小的字典、适当增加线程。不要盲目把线程拉太高,容易误判或把靶机打挂。
扫到 403 怎么办
不要直接放弃。尝试大小写、尾部斜杠、加 Header、访问目录下常见文件,或者回到知识库里的路径穿越、访问控制与越权页面判断。
字典不够用
1. 使用 SecLists 字典库
2. 根据题目技术栈定制
3. 从已发现路径推导新路径
4. 使用 CeWL 从页面生成字典被 WAF 拦截
1. 降低线程数
2. 添加延迟
3. 使用随机 User-Agent
4. 使用代理轮换
5. 尝试不同 HTTP 方法关联
- HTTP请求与响应
- 路径穿越
- 任意文件读取与下载
- 访问控制与越权
- Burp Suite
- curl
- ffuf