dirsearch是一款基于Python开发的轻量级Web目录扫描工具,主要用于安全测试人员对目标网站进行目录和文件枚举。与同类工具相比,其优势在于:
在Windows环境下部署时,需要特别注意Python环境兼容性和系统权限问题。实测在Win10 21H2版本中,Python 3.8.x系列兼容性最佳。
推荐使用Python 3.8.10版本:
bash复制python --version
pip --version
核心依赖包括:
安装命令:
bash复制pip install requests urllib3 colorama --upgrade
注意:若遇SSL证书错误,需执行:
bash复制pip install --upgrade certifi
官方GitHub仓库克隆:
bash复制git clone https://github.com/maurosoria/dirsearch.git
cd dirsearch
或直接下载ZIP包:
编辑default.conf关键参数:
ini复制[general]
threads = 20 # 根据CPU核心数调整
timeout = 15 # 超时秒数
max-recursion = 3 # 递归深度
[dictionary]
extensions = php,asp,aspx,jsp,html,json # 目标环境扩展名
针对http://example.com的扫描:
bash复制python dirsearch.py -u http://example.com -e php,html -t 15
参数说明:
-e 指定文件扩展名-t 设置线程数bash复制python dirsearch.py -u http://example.com --exclude-status 403,404
bash复制python dirsearch.py -u http://example.com -w D:\custom_wordlist.txt
bash复制python dirsearch.py -u http://example.com -o report.json --format=json
现象:大量Timeout警告
解决方案:
现象:UnicodeEncodeError
解决方法:
python复制import sys
import io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
通过环境变量设置:
bash复制set http_proxy=http://127.0.0.1:8080
set https_proxy=http://127.0.0.1:8080
bash复制sort wordlist.txt | uniq > cleaned_wordlist.txt
bash复制python dirsearch.py -u http://example.com --scan-subdirs=admin,backup
实测在i5-10210U处理器上,完整扫描约需12-15分钟(默认字典)。建议首次扫描使用-e php,html参数缩小范围,确认可行后再进行全量扫描。