dirsearch
是一个用 Python 编写的多线程目录和文件扫描工具,广泛用于网站渗透测试中,以发现隐藏的目录和文件。以下是使用 dirsearch
的基本步骤:
安装 dirsearch
-
克隆仓库:
bash
git clone https://github.com/maurosoria/dirsearch.git cd dirsearch
-
安装依赖:
bash
pip install -r requirements.txt
基本用法
dirsearch
的基本命令格式如下:
bash
python dirsearch.py -u <目标URL> -e <扩展名>
参数说明
-u
/--url
: 指定目标网站的URL。-e
/--extensions
: 指定要搜索的文件扩展名,多个扩展名用逗号分隔(如php,html,js
)。-w
/--wordlist
: 指定自定义的字典文件路径,用于目录和文件名称的爆破。-t
/--threads
: 设置扫描的线程数(默认是 40)。-r
/--recursive
: 启用递归搜索。-x
/--exclude-status
: 排除特定的状态码,使用逗号分隔(如404,403
)。
示例
-
基本扫描:
bash
python dirsearch.py -u https://example.com -e php,html
-
使用自定义字典并增加线程:
bash
python dirsearch.py -u https://example.com -w /path/to/wordlist.txt -t 50
-
启用递归扫描:
bash
python dirsearch.py -u https://example.com -r -e php,html
更多选项
可以通过以下命令查看所有可用的选项和帮助信息:
bash
python dirsearch.py -h
报错:
\gui_scan\dirsearch\dirsearch.py", line 22, in <module> from colorama import init, Fore, Style ModuleNotFoundError: No module named 'colorama'
这个错误提示 ModuleNotFoundError: No module named 'colorama'
表明你的 Python 环境中没有安装 colorama
这个模块。colorama
是 dirsearch
工具使用的一个库,用于支持终端中的颜色输出。
解决方法
你可以通过以下步骤来安装 colorama
:
-
确保你在虚拟环境中(如果有使用的话),然后运行以下命令来安装
colorama
:bash
pip install colorama
-
如果直接在系统环境中使用,也运行同样的命令。
重新运行 dirsearch
完成安装后,重新运行你的 dirsearch
命令:
bash
python dirsearch.py -h
安装所有依赖
为了确保其他所需的依赖库也都已安装,你可以运行以下命令(在 dirsearch
目录下):
bash
pip install -r requirements.txt
这会根据 requirements.txt
文件安装所有列出的依赖,包括 colorama
。
如果会弹出这个报错:
\gui_scan\dirsearch\dirsearch.py", line 35, in <module> from pkg_resources import DistributionNotFound, VersionConflict ModuleNotFoundError: No module named 'pkg_resources'
表示 Python 环境中缺少 setuptools
。pkg_resources
是 setuptools
库的一部分,因此需要安装或更新 setuptools
。
解决方法
-
安装或更新
setuptools
:你可以通过以下命令安装或更新
setuptools
:pip install --upgrade setuptools
-
确保在所需的环境中运行(如果使用虚拟环境):
- 如果你在虚拟环境中,请确保你已经激活了虚拟环境并在此环境内运行上述命令。
重新运行 dirsearch
在安装或升级 setuptools
后,再次尝试运行 dirsearch
:
python dirsearch.py -h
检查其它依赖
如果继续遇到类似的错误,可能指向其他缺失的库。你可以重新运行以下命令来确保安装所有依赖:
pip install -r requirements.txt
环境问题
如果这些步骤没有解决问题,建议检查你的 Python 环境是否设置正确,并考虑创建一个新的虚拟环境以避免环境中的潜在冲突。以下是创建并激活虚拟环境的步骤:
-
创建虚拟环境:
python -m venv myenv
-
激活虚拟环境:
- Windows:
myenv\Scripts\activate
- macOS/Linux:
source myenv/bin/activate
- Windows:
-
在虚拟环境中重新安装依赖:
cd dirsearch pip install -r requirements.txt