跳到主要内容

Dirsearch 目录扫描

Dirsearch 是用 Python 编写的 Web 目录扫描工具。相比 Gobuster,它的特点是内置智能字典处理(自动追加扩展名和后缀)、支持递归扫描、自带高质量默认字典。适合在没有 Go/Rust 编译环境或偏好 Python 工具链的场景下使用。


安装

Kali Linux

Kali 默认已预装:

dirsearch --version

pip

pip install dirsearch

Git Clone

git clone https://github.com/maurosoria/dirsearch.git
cd dirsearch
pip install -r requirements.txt
python3 dirsearch.py -u http://target/

核心参数速查

参数说明示例
-u <url>目标 URL-u http://192.168.1.108/
-l <file>从文件读取多个 URL-l urls.txt
-w <wordlist>自定义字典(默认自带)-w /usr/share/seclists/Discovery/Web-Content/common.txt
-e <exts>扩展名-e php,txt,html
-f强制追加扩展名到每个词条-f
-t <n>线程数(默认 25)-t 50
-r递归扫描-r
-R <depth>递归深度-R 2
-x <codes>排除状态码-x 404,403,500
-i <codes>仅包含状态码-i 200,301
--exclude-sizes <sizes>排除特定大小--exclude-sizes 0B,123B
-H <header>自定义 Header-H "Cookie: session=abc"
-o <file>输出文件-o results.txt
--format <fmt>输出格式--format json
--proxy <proxy>HTTP 代理--proxy http://127.0.0.1:8080
-q安静模式-q
--random-agent随机 User-Agent--random-agent

常用扫描模式

1. 基本扫描(使用内置字典)

dirsearch -u http://192.168.1.108/ -e php,txt,html

2. 使用自定义字典

dirsearch -u http://target/ -w /usr/share/seclists/Discovery/Web-Content/common.txt -e php,txt

3. 递归扫描

dirsearch -u http://target/ -e php -r -R 2

4. 过滤噪音

# 排除 403 和 404
dirsearch -u http://target/ -e php -x 403,404

# 仅显示 200 和 301
dirsearch -u http://target/ -e php -i 200,301

5. 带代理扫描(配合 Burp Suite)

dirsearch -u http://target/ -e php --proxy http://127.0.0.1:8080

6. 多目标批量扫描

dirsearch -l urls.txt -e php,txt -t 30 -o batch_results.txt

扩展名处理机制

Dirsearch 的扩展名处理比 Gobuster 更智能:

字典词条Gobuster -x phpDirsearch -e php
adminadmin, admin.phpadmin, admin.php
config.bakconfig.bak, config.bak.phpconfig.bak(不重复追加)
%EXT%不支持替换为 php

Dirsearch 字典中的 %EXT% 占位符会被 -e 参数的值替换,提供更灵活的控制。


与其他工具的定位

特性DirsearchGobusterFeroxbuster
语言PythonGoRust
速度中等最快
递归
内置字典✅ 自带❌ 必须指定❌ 必须指定
%EXT% 智能处理
代理支持✅ 原生
适用场景Python 环境、联动 Burp速度优先、通用首选递归深度扫描

靶场实战速查

场景命令
零配置快扫dirsearch -u http://target/ -e php,txt,html
自定义字典dirsearch -u http://target/ -w /usr/share/seclists/Discovery/Web-Content/common.txt -e php
递归扫描dirsearch -u http://target/ -e php -r -R 2
过滤误报dirsearch -u http://target/ -e php -x 403,404 --exclude-sizes 0B
配合 Burpdirsearch -u http://target/ -e php --proxy http://127.0.0.1:8080
批量扫描dirsearch -l urls.txt -e php -t 30 -o results.txt

相关知识