dirsearch - Web 路径发现

当前版本:v0.4.2 (2021.9.12)
一种高级命令行工具,旨在暴力破解网络服务器中的目录和文件,AKA 网络路径扫描器
@maurosoria和@shelld3v正在积极开发dirsearch
安装和使用
要求:python 3.7 或更高版本
选择以下安装选项之一:
- 使用 git 安装:git clone https://github.com/maurosoria/dirsearch.git
- 使用 ZIP 文件安装:在此处下载
- 使用 Docker 安装:(docker build -t “dirsearch:v0.4.1”更多信息)
- 使用 Kali Linux 安装:sudo apt-get install dirsearch
- 使用 PyPi 安装:pip3 install dirsearch
一体:
git clone https://github.com/maurosoria/dirsearch.gitcd dirsearchpip3 install -r requirements.txtpython3 dirsearch.py -u <URL> -e <EXTENSIONS>
报错
Traceback (most recent call last):File "D:\DEV\Python\Python310\Lib\site-packages\dirsearch\thirdparty\oset\pyoset.py", line 8, in <module>from collections import MutableSetImportError: cannot import name 'MutableSet' from 'collections' (D:\DEV\Python\Python310\lib\collections\__init__.py)
解决方式
from collections import MutableSet改为from collections.abc import MutableSet
词汇表(重要)
概括
- Wordlist 是一个文本文件,每一行都是一个路径。
- 关于扩展,与其他工具不同,dirsearch 仅将%EXT%关键字替换为来自-e标志的扩展。
- 对于没有%EXT%(如SecLists)的单词列表,-f | 需要—force-extensions开关来将扩展名附加到 wordlist 中的每个单词,以及/.
- 要使用多个词表,您可以用逗号分隔词表。示例:wordlist1.txt,wordlist2.txt。
例子
正常扩展
传递asp和aspx扩展名将生成以下字典:index.%EXT%
indexindex.aspindex.aspx
强制扩展
使用-f / —force-extensions标志传递“php”和“html”扩展将生成以下字典:admin
adminadmin.phpadmin.htmladmin/
选项
英文
```shell Usage: dirsearch.py [-u|—url] target [-e|—extensions] extensions [options]
Options: —version show program’s version number and exit -h, —help show this help message and exit
Mandatory:
-u URL, —url=URL Target URL
-l FILE, —url-list=FILE
Target URL list file
—stdin Target URL list from STDIN
—cidr=CIDR Target CIDR
—raw=FILE Load raw HTTP request from file (use --scheme flag
to set the scheme)
-e EXTENSIONS, —extensions=EXTENSIONS
Extension list separated by commas (Example: php,asp)
-X EXTENSIONS, —exclude-extensions=EXTENSIONS
Exclude extension list separated by commas (Example:
asp,jsp)
-f, —force-extensions
Add extensions to every wordlist entry. By default
dirsearch only replaces the %EXT% keyword with
extensions
Dictionary Settings:
-w WORDLIST, —wordlists=WORDLIST
Customize wordlists (separated by commas)
—prefixes=PREFIXES
Add custom prefixes to all wordlist entries (separated
by commas)
—suffixes=SUFFIXES
Add custom suffixes to all wordlist entries, ignore
directories (separated by commas)
—only-selected Remove paths have different extensions from selected
ones via -e (keep entries don’t have extensions)
—remove-extensions
Remove extensions in all paths (Example: admin.php ->
admin)
-U, —uppercase Uppercase wordlist
-L, —lowercase Lowercase wordlist
-C, —capital Capital wordlist
General Settings: -t THREADS, —threads=THREADS Number of threads -r, —recursive Brute-force recursively —deep-recursive Perform recursive scan on every directory depth (Example: api/users -> api/) —force-recursive Do recursive brute-force for every found path, not only paths end with slash —recursion-depth=DEPTH Maximum recursion depth —recursion-status=CODES Valid status codes to perform recursive scan, support ranges (separated by commas) —subdirs=SUBDIRS Scan sub-directories of the given URL[s] (separated by commas) —exclude-subdirs=SUBDIRS Exclude the following subdirectories during recursive scan (separated by commas) -i CODES, —include-status=CODES Include status codes, separated by commas, support ranges (Example: 200,300-399) -x CODES, —exclude-status=CODES Exclude status codes, separated by commas, support ranges (Example: 301,500-599) —exclude-sizes=SIZES Exclude responses by sizes, separated by commas (Example: 123B,4KB) —exclude-texts=TEXTS Exclude responses by texts, separated by commas (Example: ‘Not found’, ‘Error’) —exclude-regexps=REGEXPS Exclude responses by regexps, separated by commas (Example: ‘Not foun[a-z]{1}’, ‘^Error$’) —exclude-redirects=REGEXPS Exclude responses by redirect regexps or texts, separated by commas (Example: ‘https://okta.com/*‘) —exclude-content=PATH Exclude responses by response content of this path —skip-on-status=CODES Skip target whenever hit one of these status codes, separated by commas, support ranges —minimal=LENGTH Minimal response length —maximal=LENGTH Maximal response length —max-time=SECONDS Maximal runtime for the scan -q, —quiet-mode Quiet mode —full-url Full URLs in the output (enabled automatically in quiet mode) —no-color No colored output
Request Settings: -m METHOD, —http-method=METHOD HTTP method (default: GET) -d DATA, —data=DATA HTTP request data -H HEADERS, —header=HEADERS HTTP request header, support multiple flags (Example: -H ‘Referer: example.com’) —header-list=FILE File contains HTTP request headers -F, —follow-redirects Follow HTTP redirects —random-agent Choose a random User-Agent for each request —auth-type=TYPE Authentication type (basic, digest, bearer, ntlm) —auth=CREDENTIAL Authentication credential (user:password or bearer token) —user-agent=USERAGENT —cookie=COOKIE
Connection Settings: —timeout=TIMEOUT Connection timeout -s DELAY, —delay=DELAY Delay between requests —proxy=PROXY Proxy URL, support HTTP and SOCKS proxies (Example: localhost:8080, socks5://localhost:8088) —proxy-list=FILE File contains proxy servers —replay-proxy=PROXY Proxy to replay with found paths —scheme=SCHEME Default scheme (for raw request or if there is no scheme in the URL) —max-rate=RATE Max requests per second —retries=RETRIES Number of retries for failed requests -b, —request-by-hostname By default dirsearch requests by IP for speed. This will force dirsearch to request by hostname —ip=IP Server IP address —exit-on-error Exit whenever an error occurs
Reports: -o FILE, —output=FILE Output file —format=FORMAT Report format (Available: simple, plain, json, xml, md, csv, html)
<a name="vhlsx"></a>### 中文```shell用法:dirsearch.py [-u|--url] 目标 [-e|--extensions] 扩展[选项]选项:--version 显示程序的版本号并退出-h, --help 显示此帮助信息并退出强制的:-u URL, --url=URL 目标 URL-l 文件,--url-list=文件目标 URL 列表文件--stdin 来自 STDIN 的目标 URL 列表--cidr=CIDR 目标 CIDR--raw=FILE 从文件加载原始 HTTP 请求(使用 `--scheme` 标志设置方案)-e 扩展,--extensions=扩展用逗号分隔的扩展名列表(例如:php,asp)-X 扩展,--排除扩展=扩展排除以逗号分隔的扩展名列表(例如:asp,jsp)-f, --force-扩展为每个单词表条目添加扩展名。默认dirsearch 仅将 %EXT% 关键字替换为扩展字典设置:-w 单词列表,--单词列表=单词列表自定义词表(以逗号分隔)--prefixes=前缀为所有单词表条目添加自定义前缀(分隔用逗号)--suffixes=后缀为所有单词表条目添加自定义后缀,忽略目录(以逗号分隔)--only-selected 删除路径与选定的扩展名不同通过`-e`(保持条目没有扩展名)--remove-extensions删除所有路径中的扩展名(例如:admin.php ->行政)-U, --uppercase 大写单词表-L, --lowercase 小写单词表-C, --capital 大写单词表通用设置:-t 线程,--threads=线程线程数-r, --recursive 递归暴力破解--deep-recursive 对每个目录深度执行递归扫描(例如:api/users -> api/)--force-recursive 对每个找到的路径进行递归暴力破解,而不是只有路径以斜线结尾--recursion-depth=深度最大递归深度--recursion-status=代码执行递归扫描的有效状态码,支持范围(用逗号分隔)--subdirs=SUBDIRS 扫描给定 URL[s] 的子目录(由逗号)--exclude-subdirs=SUBDIRS递归时排除以下子目录扫描(以逗号分隔)-i CODES,--include-status=CODES包括状态码,用逗号分隔,支持范围(例如:200,300-399)-x CODES,--exclude-status=CODES排除状态码,逗号分隔,支持范围(例如:301,500-599)--exclude-sizes=SIZES按大小排除响应,用逗号分隔(例如:123B,4KB)--exclude-texts=TEXTS按文本排除响应,以逗号分隔(例如:“未找到”、“错误”)--exclude-regexps=REGEXPS通过正则表达式排除响应,用逗号分隔(例如:'Not foun[a-z]{1}'、'^Error$')--exclude-redirects=REGEXPS通过重定向正则表达式或文本排除响应,用逗号分隔(例如:'https://okta.com/*')--exclude-content=PATH按此路径的响应内容排除响应--skip-on-status=CODES每当命中这些状态代码之一时跳过目标,用逗号分隔,支持范围--minimal=LENGTH 最小响应长度--maximal=LENGTH 最大响应长度--max-time=SECONDS 扫描的最大运行时间-q, --quiet-mode 安静模式--full-url 输出中的完整 URL(在静音模式)--no-color 无彩色输出请求设置:-m METHOD,--http-method=METHODHTTP 方法(默认:GET)-d DATA,--data=DATAHTTP 请求数据-H HEADERS,--header=HEADERSHTTP 请求头,支持多个标志(例如:-H '推荐人:example.com')--header-list=FILE 文件包含 HTTP 请求标头-F, --follow-redirects遵循 HTTP 重定向--random-agent 为每个请求选择一个随机的用户代理--auth-type=TYPE 认证类型(basic、digest、bearer、ntlm)--auth=CREDENTIAL 身份验证凭据(用户:密码或承载令牌)--user-agent=USERAGENT--cookie=cookie连接设置:--timeout=TIMEOUT 连接超时-s DELAY, --delay=DELAY请求之间的延迟--proxy=PROXY 代理 URL,支持 HTTP 和 SOCKS 代理(例如:本地主机:8080,袜子5://本地主机:8088)--proxy-list=FILE 文件包含代理服务器--replay-proxy=代理使用找到的路径重播的代理--scheme=SCHEME 默认方案(用于原始请求或如果没有URL 中的方案)--max-rate=RATE 每秒最大请求数--retries=RETRIES 失败请求的重试次数-b, --request-by-hostname默认情况下,通过 IP 进行 dirsearch 请求以提高速度。这将强制 dirsearch 按主机名请求--ip=IP 服务器IP地址--exit-on-error 发生错误时退出报告:-o FILE, --output=FILE输出文件--format=FORMAT 报告格式(可用:simple、plain、json、xml、md, csv, html)
配置
dirsearch 标志的默认值可以在配置文件中编辑,默认情况下是,default.conf但您可以选择另一个带有--config标志的文件
# If you want to edit dirsearch default configurations, you can# edit values in this file. Everything after `#` is a comment# and won't be applied[mandatory]default-extensions = php,aspx,jsp,html,jsforce-extensions = False# exclude-extensions = old,log[general]threads = 30recursive = Falsedeep-recursive = Falseforce-recursive = Falserecursion-depth = 0exclude-subdirs = %%ff/random-user-agents = Falsemax-time = 0full-url = Falsequiet-mode = Falsecolor = Truerecursion-status = 200-399,401,403# include-status = 200-299,401# exclude-status = 400,500-999# exclude-sizes = 0b,123gb# exclude-texts = "Not found"# exclude-regexps = "403 [a-z]{1,25}"# exclude-content = 404.html# skip-on-status = 429,999[reports]report-format = plainautosave-report = True# report-output-folder = /home/user# logs-location = /tmp## Supported: plain, simple, json, xml, md, csv, html[dictionary]lowercase = Falseuppercase = Falsecapitalization = False# prefixes = .,admin# suffixes = ~,.bak# wordlist = db/dicc.txt[request]httpmethod = get## Lowercase onlyfollow-redirects = False# headers-file = headers.txt# user-agent = MyUserAgent# cookie = SESSIONID=123[connection]timeout = 5delay = 0scheme = httpmaxrate = 0retries = 2request-by-hostname = Falseexit-on-error = False# proxy = localhost:8080# proxy-list = proxies.txt# replay-proxy = localhost:8000
如何使用
有关如何使用 dirsearch 的一些示例 - 这些是最常见的参数。如果您需要全部,只需使用-h参数。
简单使用
python3 dirsearch.py -u https://target
python3 dirsearch.py -e php,html,js -u https://target
python3 dirsearch.py -e php,html,js -u https://target -w /path/to/wordlist
暂停进度
dirsearch 允许您使用 CTRL+C 暂停扫描进度,从这里,您可以保存进度(稍后继续)、跳过当前目标或跳过当前子目录。
递归扫描
通过使用-r | —recursive参数,dirsearch 将递归地暴力破解所有目录。
python3 dirsearch.py -e php,html,js -u https://target -r
您可以使用—recursion-depth设置最大递归深度,使用—recursion - status 设置递归状态码
python3 dirsearch.py -e php,html,js -u https://target -r --recursion-depth 3 --recursion-status 200-399
还有 2 个选项:—force-recursive和—deep-recursive
- 强制递归:暴力递归所有找到的路径,而不仅仅是路径以
/结尾 - 深度递归:递归暴力破解路径的所有深度(a/b/c=> 添加
a/,a/b/)
- 强制递归:暴力递归所有找到的路径,而不仅仅是路径以
线程
线程号 ( -t | —threads ) 反映了分离的蛮力进程的数量。所以线程数越大,dirsearch 运行得越快。默认情况下,线程数为 30,但如果您想加快进度,可以增加它。
尽管如此,速度仍然很大程度上取决于服务器的响应时间。作为警告,我们建议您保持线程数不要太大,因为它可能导致 DoS。
python3 dirsearch.py -e php,htm,js,bak,zip,tgz,txt -u https://target -t 20
前缀/后缀
—prefixes:为所有条目添加自定义前缀
python3 dirsearch.py -e php -u https://target --prefixes .,admin,_
基本词表:
tools
使用前缀生成:
.tools admintools _tools
—suffixes:为所有条目添加自定义后缀
python3 dirsearch.py -e php -u https://target --suffixes ~
基本词表:
index.phpinternal
生成后缀:
index.php~internal~
黑名单
在
db/文件夹内,有几个“黑名单文件”。如果这些文件中的路径与文件名中提到的状态相同,则将从扫描结果中过滤掉它们。
示例:如果您添加admin.php到db/403_blacklist.txt,每当您执行admin.php返回 403 的扫描时,都会从结果中过滤掉。过滤器
使用-i | —include-status和-x | —exclude-status选择允许和不允许的响应状态码
对于更高级的过滤器:—exclude-sizes、—exclude-texts、—exclude-regexps、—exclude-redirects和—exclude-contentpython3 dirsearch.py -e php,html,js -u https://target --exclude-sizes 1B,243KB
python3 dirsearch.py -e php,html,js -u https://target --exclude-texts "403 Forbidden"
python3 dirsearch.py -e php,html,js -u https://target --exclude-regexps "^Error$"
python3 dirsearch.py -e php,html,js -u https://target --exclude-redirects "https://(.*).okta.com/*"
python3 dirsearch.py -e php,html,js -u https://target --exclude-content /error.html
原始请求
dirsearch 允许您从文件中导入原始请求。内容看起来像这样:
GET /admin HTTP/1.1Host: admin.example.comCache-Control: max-age=0Accept: */*
由于 dirsearch 无法知道 URI 方案是什么,因此您需要使用—scheme标志来设置它。默认情况下,该方案是http,这会导致很多假阴性。
词表格式
小写
adminindex.html
大写
ADMININDEX.HTML
首字母大写
AdminIndex.html
排除扩展
使用-X | —exclude-extensions带有扩展名列表将删除单词列表中包含给定扩展名的所有路径
python3 dirsearch.py -u https://target -X jsp
基本词表:
admin.phptest.jsp
后:
admin.php
如果要排除所有扩展名,除了您在-e标志中选择的扩展名,请使用—only-selected
python3 dirsearch.py -e html -u https://target --only-selected
基本词表:
index.htmladmin.php
后:
index.html
扫描子目录
从 URL,您可以使用—subdirs扫描子目录列表。
python3 dirsearch.py -e php,html,js -u https://target --subdirs admin/,folder/,/
它的反向版本是—exclude-subdirs,它可以防止 dirsearch 递归扫描给定的子目录。
python3 dirsearch.py -e php,html,js -u https://target --recursive --exclude-subdirs image/,css/
代理
dirsearch 支持 SOCKS 和 HTTP 代理,有两个选项:代理服务器或代理服务器列表。
python3 dirsearch.py -e php,html,js -u https://target --proxy 127.0.0.1:8080
python3 dirsearch.py -e php,html,js -u https://target --proxy socks5://10.10.0.1:8080
python3 dirsearch.py -e php,html,js -u https://target --proxylist proxyservers.txt
报告
支持的报告格式:simple、plain、json、xml、md、csv、 html
python3 dirsearch.py -e php -l URLs.txt --format plain -o report.txt
python3 dirsearch.py -e php -u https://target --format html -o target.json
更多示例命令
cat urls.txt | python3 dirsearch.py -u https://target --stdin
python3 dirsearch.py -u https://target --format json -o target.json
python3 dirsearch.py -u https://target --auth admin:pass --auth-type basic
python3 dirsearch.py -u https://target --header-list rate-limit-bypasses.txt
参考
Shubham Sharma的 Dirsearch 综合指南
- Shubham Sharma的 Dirsearch 综合指南第 2 部分
- GeeksforGeeks 如何使用Dirsearch查找隐藏的 Web 目录
- ESGEEKS 的 GUÍA COMPLETA SOBRE EL USO DE DIRSEARCH
- 如何使用 Dirsearch通过 EHacking检测 Web 目录
- dirsearch how to by VK9 Security
- 通过 Wonder How To使用 Dirsearch 查找隐藏的 Web 目录
- 使用Raj Upadhyay 的dirsearch 暴力破解网络服务器中的目录和文件
- 雅虎上的实时漏洞赏金侦察会议(Amass,crts.sh,dirsearch)w/@TheDawgyg by Nahamsec
- Dirsearch 查找隐藏的 Web 目录by Irfan Shakeel
- 通过 Sahil Ahamad访问 25000 名员工的详细信息
- Shubham Goyal 的目录暴力破解的最佳工具
发现网络服务器上的隐藏文件和目录 - CYBER BYTES 的dirsearch 完整教程
提示
服务器有请求限制?这很糟糕,但随意绕过它,通过随机代理—proxy-list
- 想要找出配置文件或备份?尝试—suffixes ~并—prefixes .
- 只想查找文件夹/目录?为什么不结合—remove-extensions和—suffixes /!
- 使用 CIDR 进行暴力破解时,混合使用—cidr、和 将减少大部分噪音 + 假阴性-F-q
- 扫描 URL 列表,但不想看到 429 泛滥?—skip-on-status 429将帮助您在返回 429 时跳过目标
- 服务器包含会减慢扫描速度的大文件?您可能想使用HEADHTTP 方法而不是GET
- 蛮力 CIDR 很慢?可能您忘记减少请求超时和请求重试。建议:—timeout 3 —retries 1
