[网络安全] Dirsearch 工具的安装、使用详细教程(1)

注意,当同时存在python3和python2时,要将两者的exe文件重命名为下图:

image-20230202192656524
python3改为python.exe,python2改为python2.exe即可。

dirsearch下载地址:https://github.com/maurosoria/dirsearch

在这里插入图片描述

将zip包解压后放入python3的Dirsearch目录中

在这里插入图片描述

接着进入C:\Python3\Dirsearch\dirsearch-master目录中,输入cmd:

在这里插入图片描述

在这里插入图片描述

进入命令行后,输入PIP3 install DirSearch

image-20230202202048236

下载失败,但我们看一下警告:

image-20230202203507481

这个警告表示当前使用的 pip 版本为 21.2.4,但是还有更新的版本可用(版本号为 23.0),建议通过命令 C:\Python3\python.exe -m pip install --upgrade pip 来升级 pip。

于是我们输入C:\Python3\python.exe -m pip install --upgrade pip

image-20230202203603213

但还是下载失败,原因是依赖项未升级。

因此我们输入pip install --upgrade -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

该命令会根据 requirements.txt 文件中列出的依赖项,自动安装或升级所需的包,并使用指定的阿里云镜像源来获取依赖项的安装文件。

image-20230202205437734
下载成功:

image-20230202205857415

现在,就可以开始正常使用dirsearch了。

接下来将介绍dirsearch的使用方法。

注意:dirsearch的命令必须在C:\Python3\Dirsearch\dirsearch-master目录下运行


语法及参数

输入python dirsearch.py -h得到dirsearch帮助

回显如下:

C:\Python3\Dirsearch\dirsearch-master>python dirsearch.py -h
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(s), can use multiple flags
 -l PATH, --urls-file=PATH
 URL list file
 --stdin Read URL(s) from STDIN
 --cidr=CIDR Target CIDR
 --raw=PATH Load raw HTTP request from file (use '--scheme' flag
 to set the scheme)
 -s SESSION\_FILE, --session=SESSION\_FILE
 Session file
 --config=PATH Path to configuration file (Default:
 'DIRSEARCH\_CONFIG' environment variable, otherwise
 'config.ini')

 Dictionary Settings:
 -w WORDLISTS, --wordlists=WORDLISTS
 Wordlist files or directories contain wordlists
 (separated by commas)
 -e EXTENSIONS, --extensions=EXTENSIONS
 Extension list separated by commas (e.g. php,asp)
 -f, --force-extensions
 Add extensions to the end of every wordlist entry. By
 default dirsearch only replaces the %EXT% keyword with
 extensions
 -O, --overwrite-extensions
 Overwrite other extensions in the wordlist with your
 extensions (selected via `-e`)
 --exclude-extensions=EXTENSIONS
 Exclude extension list separated by commas (e.g.
 asp,jsp)
 --remove-extensions
 Remove extensions in all paths (e.g. admin.php ->
 admin)
 --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)
 -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 (e.g.
 api/users -> api/)
 --force-recursive Do recursive brute-force for every found path, not
 only directories
 -R DEPTH, --max-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 (e.g. 200,300-399)
 -x CODES, --exclude-status=CODES
 Exclude status codes, separated by commas, support
 ranges (e.g. 301,500-599)
 --exclude-sizes=SIZES
 Exclude responses by sizes, separated by commas (e.g.
 0B,4KB)
 --exclude-text=TEXTS
 Exclude responses by text, can use multiple flags
 --exclude-regex=REGEX
 Exclude responses by regular expression
 --exclude-redirect=STRING
 Exclude responses if this regex (or text) matches
 redirect URL (e.g. '/index.html')
 --exclude-response=PATH
 Exclude responses similar to response of this page,
 path as input (e.g. 404.html)
 --skip-on-status=CODES
 Skip target whenever hit one of these status codes,
 separated by commas, support ranges
 --min-response-size=LENGTH
 Minimum response length
 --max-response-size=LENGTH
 Maximum response length
 --max-time=SECONDS Maximum runtime for the scan
 --exit-on-error Exit whenever an error occurs

 Request Settings:
 -m METHOD, --http-method=METHOD
 HTTP method (default: GET)
 -d DATA, --data=DATA
 HTTP request data
 --data-file=PATH File contains HTTP request data
 -H HEADERS, --header=HEADERS
 HTTP request header, can use multiple flags
 --headers-file=PATH
 File contains HTTP request headers
 -F, --follow-redirects
 Follow HTTP redirects
 --random-agent Choose a random User-Agent for each request
 --auth=CREDENTIAL Authentication credential (e.g. user:password or
 bearer token)
 --auth-type=TYPE Authentication type (basic, digest, bearer, ntlm, jwt)
 --cert-file=PATH File contains client-side certificate
 --key-file=PATH File contains client-side certificate private key
 (unencrypted)
 --user-agent=USER\_AGENT
 --cookie=COOKIE

 Connection Settings:
 --timeout=TIMEOUT Connection timeout
 --delay=DELAY Delay between requests
 -p PROXY, --proxy=PROXY
 Proxy URL (HTTP/SOCKS), can use multiple flags
 --proxies-file=PATH
 File contains proxy servers
 --proxy-auth=CREDENTIAL
 Proxy authentication credential
 --replay-proxy=PROXY
 Proxy to replay with found paths
 --tor Use Tor network as proxy
 --scheme=SCHEME Scheme for raw request or if there is no scheme in the
 URL (Default: auto-detect)
 --max-rate=RATE Max requests per second
 --retries=RETRIES Number of retries for failed requests
 --ip=IP Server IP address

 Advanced Settings:
 --crawl Crawl for new paths in responses

 View Settings:
 --full-url Full URLs in the output (enabled automatically in
 quiet mode)
 --redirects-history
 Show redirects history
 --no-color No colored output
 -q, --quiet-mode Quiet mode

 Output Settings:
 -o PATH/URL, --output=PATH/URL
 Output file or MySQL/PostgreSQL URL (Format:
 scheme://[username:password@]host[:port]/database-
 name)
 --format=FORMAT Report format (Available: simple,plain,json,xml,md,csv
 ,html,sqlite,mysql,postgresql)
 --log=PATH Log file

See 'config.ini' for the example configuration file

翻译如下:

用法:dirsearch.py [-u|--url] 目标 [-e|--extensions] 扩展名 [选项]

选项:
  --version             显示程序的版本号并退出
  -h, --help            显示此帮助消息并退出

必需:
  -u URL, --url=URL     目标URL,可以使用多个选项指定多个目标URL
  -l PATH, --urls-file=PATH
                        URL列表文件
  --stdin               从标准输入读取URL
  --cidr=CIDR           目标CIDR
  --raw=PATH            从文件加载原始HTTP请求(使用'--scheme'标志设置方案)
  -s SESSION\_FILE, --session=SESSION\_FILE
                        会话文件
  --config=PATH         配置文件路径(默认为'DIRSEARCH\_CONFIG'环境变量,否则为'config.ini')

字典设置:
  -w WORDLISTS, --wordlists=WORDLISTS
                        单词列表文件或包含单词列表文件的目录(以逗号分隔)
  -e EXTENSIONS, --extensions=EXTENSIONS
                        扩展名列表,以逗号分隔(例如:php,asp)
  -f, --force-extensions
                        在每个单词列表条目的末尾添加扩展名。默认情况下,dirsearch只替换%EXT%关键字为扩展名。
  -O, --overwrite-extensions
                        使用指定的扩展名覆盖单词列表中的其他扩展名(通过'-e'选择)
  --exclude-extensions=EXTENSIONS
                        排除的扩展名列表,以逗号分隔(例如:asp,jsp)
  --remove-extensions   删除所有路径中的扩展名(例如:admin.php -> admin)
  --prefixes=PREFIXES   将自定义前缀添加到所有单词列表条目中(以逗号分隔)
  --suffixes=SUFFIXES   将自定义后缀添加到所有单词列表条目中,忽略目录(以逗号分隔)
  -U, --uppercase       单词列表转为大写
  -L, --lowercase       单词列表转为小写
  -C, --capital         单词首字母大写

通用设置:
  -t THREADS, --threads=THREADS
                        线程数
  -r, --recursive       递归地进行强制破解
  --deep-recursive      在每个目录深度上执行递归扫描(例如:api/users -> api/)
  --force-recursive     对找到的每个路径执行递归强制破解,而不仅仅是目录
  -R DEPTH, --max-recursion-depth=DEPTH
                        最大递归深度
  --recursion-status=CODES
                        用于执行递归扫描的有效状态码,支持范围(以逗号分隔)
  --subdirs=SUBDIRS     扫描给定URL的子目录(以逗号分隔)
  --exclude-subdirs=SUBDIRS
                        在递归扫描期间排除以下子目录(以逗号分隔)
  -i CODES, --include-status=CODES
                        包括的状态码,以逗号分隔,支持范围(例如:200,300-399)
  -x CODES, --exclude-status=CODES
                        排除的状态码,以逗号分隔,支持范围(例如:301,500-599)
  --exclude-sizes=SIZES
                        根据大小排除响应,以逗号分隔(例如:0B,4KB)
  --exclude-text=TEXTS  根据文本排除响应,可以使用多个标志
  --exclude-regex=REGEX
                        根据正则表达式排除响应
  --exclude-redirect=STRING
                        如果此正则表达式(或文本)与重定向URL匹配,则排除响应(例如:'/index.html')
  --exclude-response=PATH
                        排除类似于此页面响应的响应,路径作为输入(例如:404.html)
  --skip-on-status=CODES
                        每当命中这些状态码之一时跳过目标,以逗号分隔,支持范围
  --min-response-size=LENGTH
                        响应的最小长度
  --max-response-size=LENGTH
                        响应的最大长度
  --max-time=SECONDS    扫描的最大运行时间
  --exit-on-error       发生错误时退出

请求设置:
  -m METHOD, --http-method=METHOD
                        HTTP请求方法(默认为GET)
  -d DATA, --data=DATA  HTTP请求数据
  --data-file=PATH      包含HTTP请求数据的文件
  -H HEADERS, --header=HEADERS
                        HTTP请求标头,可以使用多个标志
  --headers-file=PATH   包含HTTP请求标头的文件
  -F, --follow-redirects
                        跟随HTTP重定向
  --random-agent        每个请求选择一个随机User-Agent
  --auth=CREDENTIAL     认证凭据(例如:user:password或bearer token)
  --auth-type=TYPE      认证类型(basic、digest、bearer、ntlm、jwt)
  --cert-file=PATH      包含客户端证书的文件
  --key-file=PATH       包含客户端证书私钥的文件(未加密)
  --user-agent=USER\_AGENT
  --cookie=COOKIE

连接设置:
  --timeout=TIMEOUT     连接超时时间
  --delay=DELAY         请求之间的延迟
  -p PROXY, --proxy=PROXY
                        代理URL(HTTP/SOCKS),可以使用多个标志
  --proxies-file=PATH   包含代理服务器的文件
  --proxy-auth=CREDENTIAL
                        代理认证凭据
  --replay-proxy=PROXY  用于重放已发现路径的代理
  --tor                 使用Tor网络作为代理
  --scheme=SCHEME       原始请求的协议或URL中没有协议时使用的协议(默认为自动检测)
  --max-rate=RATE       每秒请求数最大值
  --retries=RETRIES     失败请求的重试次数
  --ip=IP               服务器IP地址

高级设置:
  --crawl               在响应中爬取新路径

显示设置:
  --full-url            在输出中显示完整URL(在静默模式下自动启用)
  --redirects-history   显示重定向历史记录
  --no-color            不使用彩色输出
  -q, --quiet-mode      安静模式

输出设置:
  -o PATH/URL, --output=PATH/URL
                        输出文件或MySQL/PostgreSQL数据库URL(格式:
                        scheme://[username:password@]host[:port]/database-
                        name)
  --format=FORMAT       报告格式(可用:simple、plain、json、xml、md、csv、html、
                        sqlite、mysql、postgresql)
  --log=PATH            日志文件

有关示例配置文件,请参见“config.ini”


常见Payload

1.扫描单个URL,并限制线程数和扩展名:

python dirsearch.py -u http://example.com -t 10 -e php,asp --exclude-extensions=html

该命令将对 http://example.com 进行目录扫描,使用最多 10 个线程并仅检查扩展名为 phpasp 的路径,同时排除扩展名为 html 的路径。

2.从URL列表文件中批量扫描:

python dirsearch.py -l urls.txt -t 5 -e php

该命令将从 urls.txt 文件中读取目标URL列表,并使用最多 5 个线程对每个URL进行目录扫描,仅检查扩展名为 php 的路径。

3.使用自定义字典和深度递归扫描:

python dirsearch.py -u http://example.com -w custom-wordlist.txt -r --deep-recursive

该命令将对 http://example.com 进行目录扫描,使用自定义的单词列表文件 custom-wordlist.txt,并启用深度递归扫描,即在每个目录的所有深度上执行递归扫描。

4.在请求中使用自定义HTTP头:

python dirsearch.py -u http://example.com -H "X-Custom-Header: Value" -H "Authorization: Bearer token"

该命令将对 http://example.com 进行目录扫描,并在每个请求中包含自定义的HTTP头,如 X-Custom-HeaderAuthorization

5.指定线程数和延迟时间:

python dirsearch.py -u http://example.com -t 20 --delay 0.5

上述命令将使用20个线程并设置每个请求之间的延迟为0.5秒。

6.使用自定义的请求头和超时时间:

python dirsearch.py -u http://example.com -H "Custom-Header: value" --timeout 10

这个命令将在每个请求中添加一个自定义的请求头 “Custom-Header: value”,并将超时时间设置为10秒。

7.包含和排除特定状态码:

python dirsearch.py -u http://example.com -i 200,302 -x 404,500

 **自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。**

**深知大多数Python工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!**

**因此收集整理了一份《2024年Python开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。**

![img](https://img-blog.csdnimg.cn/img_convert/7c8c42bcbdb19c929b42e5ec4f07f6af.png)

![img](https://img-blog.csdnimg.cn/img_convert/495f9346a1dcaf77ac424c24ed986665.png)

![img](https://img-blog.csdnimg.cn/img_convert/5f0e854bd89f710127ab609062b0f8f3.png)

![img](https://img-blog.csdnimg.cn/img_convert/777cc9d06badccf0bba1d718ea2f4212.png)

![img](https://img-blog.csdnimg.cn/img_convert/6c361282296f86381401c05e862fe4e9.png)

![img](https://img-blog.csdnimg.cn/img_convert/9f49b566129f47b8a67243c1008edf79.png)

**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!**

**由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新**

**如果你觉得这些内容对你有帮助,可以扫码获取!!!(备注:Python)**

转存中...(img-Ccaf8eGd-1713712038123)]

[外链图片转存中...(img-EBOzWrnO-1713712038124)]

[外链图片转存中...(img-6h3wOaXH-1713712038125)]

![img](https://img-blog.csdnimg.cn/img_convert/6c361282296f86381401c05e862fe4e9.png)

![img](https://img-blog.csdnimg.cn/img_convert/9f49b566129f47b8a67243c1008edf79.png)

**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!**

**由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新**

**如果你觉得这些内容对你有帮助,可以扫码获取!!!(备注:Python)**

![](https://img-blog.csdnimg.cn/img_convert/9cf56816fd1399fb2f25671e0ba3f9b6.jpeg)
  • 5
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值