dirsearch web目录扫描工具 简介

目录

dirsearch介绍

下载及安装

如何使用

简单用法

递归扫描

线程

前缀/后缀

黑名单

筛选器

原始请求

Wordlist格式

排除扩展

扫描子目录

代理

报告

其他命令

小贴士

选项

选项

强制性

字典设置

一般设置

请求设置

连接设置

配置


dirsearch介绍

        dirsearch是一个基于python3的命令行工具,常用于暴力扫描页面结构,包括网页中的目录和文件。相比其他扫描工具disearch的特点是:

  • 支持HTTP代理
  • 多线程
  • 支持多种形式的网页(asp,php)
  • 生成报告(纯文本,JSON)
  • 启发式检测无效的网页
  • 递归扫描
  • 用户代理随机化
  • 批量处理
  • 扫描器与字典(注:字典必须是文本文件)

下载及安装

        要求:python 3.7或更高版本 

        其中,db文件夹为自带字典文件夹;reports为扫描日志文件夹;dirsearch.py为主程序文件 

使用Git安装

git clone https://github.com/maurosoria/dirsearch.git

使用ZIP文件安装

https://github.com/maurosoria/dirsearch/archive/master.zip

使用Docker安装

        详细信息:GitHub - maurosoria/dirsearch: Web path scanner

Docker build-t“dirsearch:v0.4.1

 使用Kali Linux安装       

sudo apt-get Install dirsearch

使用PYPI安装

PIP3 Install DirSearch

注意:*若要使用SOCKS代理功能,请安装带有**Requirements.txt**的包:

pip3 install -r requirements.txt

一起安装:

git clone https://github.com/maurosoria/dirsearch.git
cd dirsearch
pip3 install -r requirements.txt

如何使用

演示视频:https://asciinema.org/a/380112.svg

地址:https://asciinema.org/a/380112

简单用法

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

递归扫描

-通过使用**-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**

force-recursive(强制递归):强力递归所有找到的路径,而不仅仅是以`/`结尾的路径
deep-recursive(深度递归):递归强力路径的所有深度(`a/b/c`=>add`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.php
        internal

加上后缀后:

         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-content**

python3 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.1
Host: admin.example.com
Cache-Control: max-age=0
Accept: */*

因为dirsearch无法知道URI方案是什么,所以需要使用'--scheme'标志来设置它。默认情况下,该方案是'HTTP',这会导致大量的假阴性。

Wordlist格式

支持的wordlist格式:uppercase, lowercase, capitalization

Lowercase

        admin
        index.html

Uppercase:

        ADMIN
        INDEX.HTML

Capital

        Admin
        Index.html

排除扩展

使用**-x--exclude-extensions**扩展列表将删除wordlist中包含给定扩展的所有路径

python3 dirsearch.py -u https://target -X jsp

基础路径:

        admin.php
        test.jsp

排除扩展后:

        admin.php

-如果要排除所有扩展名,除了在'-e'标志中选择的扩展名之外,请使用**--only-selected**

python3 dirsearch.py -e html -u https://target --only-selected

基础路径:

        index.html
        admin.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

其他命令

        有更多的功能,你需要自己去发现

python3 dirsearch.py -u https://target -t 100 -m POST --data "username=admin"
 
python3 dirsearch.py -u https://target --random-agent --cookie "isAdmin=1" -F
 
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
 
python3 dirsearch.py -u https://target -q --stop-on-error --max-time 360
 
python3 dirsearch.py -u https://target --full-url --max-rate 100
 
python3 dirsearch.py -u https://target --remove-extensions

小贴士

-服务器有请求限制?这很糟糕,但是可以通过使用'--proxy-list'随机化proxy来绕过它
-想找出配置文件或备份吗?尝试`--suffixes ~`和`--prefixes .`
-只想查找文件夹/目录?为什么不结合'--remove-extensions'和'--suffixes/`!
- The mix of `--cidr`, `-F`, `-q` and will reduce most of noises + false negatives when brute-forcing with a CIDR
-扫描一个网址列表,但不想看到一个429 flood?`--Skip-on-Status 429`将帮助您在返回429时跳过目标
-服务器包含会减慢扫描速度的大文件?您可能希望使用`head`HTTP方法而不是`get`
-Brute-forcing CIDR慢?可能您忘了减少请求超时和请求重试。建议:`--timeout 3 --retries 1`

选项

        用法:dirsearch.py [-u|--url] target [-e|--extensions] extensions [options]

选项

  1. --version 显示程序的版本号和退出

  2. -h, --help 显示此帮助消息并退出

强制性

  1. -u URL, --url=URL 目标URL

  2. -l FILE, --url-list=FILE

  3. 目标URL列表文件

  4. --stdin 来自STDIN的目标URL列表

  5. --cidr=CIDR CIDR目标

  6. --raw=FILE 文件从文件加载原始HTTP请求(使用`--Scheme`标志设置方案)

  7. -e EXTENSIONS, --extensions=EXTENSIONS

  8. 用逗号分隔的扩展列表(例如:php、asp)

  9. -X EXTENSIONS, --exclude-extensions=EXTENSIONS

  10. 排除用逗号分隔的扩展名列表(例如:asp、jsp)

  11. -f, --force-extensions

  12. 为每个wordlist条目添加扩展名。默认情况下dirsearch仅将%ext%关键字替换为扩展

字典设置

  1. -w WORDLIST, --wordlists=WORDLIST

  2. 自定义Wordlist(用逗号分隔)

  3. --prefixes=PREFIXES

  4. 为所有wordlist条目添加自定义前缀(分开按逗号)

  5. --suffixes=SUFFIXES

  6. 将自定义后缀添加到所有wordlist条目,忽略目录(用逗号分隔)

  7. --only-selected 移除路径的扩展名与选定的不同通过`-e`的(保留条目没有扩展名)

  8. --remove-extensions

  9. 删除所有路径中的扩展(例如: admin.php -> admin)

  10. -U, --uppercase Uppercase wordlist

  11. -L, --lowercase Lowercase wordlist

  12. -C, --capital Capital wordlist

一般设置

  1. -t THREADS, --threads=THREADS

  2. 线程数

  3. -r, --recursive 蛮力递归

  4. --deep-recursive 对每个目录深度执行递归扫描(例如: api/users -> api/)

  5. --force-recursive 每个找到的路径做递归蛮力,而不是只有路径以斜杠结尾

  6. --recursion-depth=DEPTH

  7. 最大递归深度

  8. --recursion-status=CODES

  9. 执行递归扫描的有效状态代码,支持范围(用逗号分隔)

  10. --subdirs=SUBDIRS 扫描给定URL[s]的子目录(由逗号)

  11. --exclude-subdirs=SUBDIRS

  12. 在递归过程中排除以下子目录扫描(用逗号分隔)

  13. -i CODES, --include-status=CODES

  14. 包括状态代码,以逗号分隔,支持范围(例如:200,300-399)

  15. -x CODES, --exclude-status=CODES

  16. 排除状态代码,用逗号分隔,支持范围(例如:301,500-599)

  17. --exclude-sizes=SIZES

  18. 按大小排除响应,用逗号分隔(例如:123B,4KB)

  19. --exclude-texts=TEXTS

  20. 按文本排除答复,用逗号分隔(例如:'not found'、'error')

  21. --exclude-regexps=REGEXPS

  22. 用逗号分隔的正则表达式排除响应(例如:“not foun[a-z]{1}”,“^error$”)

  23. --exclude-redirects=REGEXPS

  24. 通过重定向正则表达式或文本排除响应,用逗号分隔(例如:'https://okta.com/*')

  25. --exclude-content=PATH

  26. 按此路径的响应内容排除响应

  27. --skip-on-status=CODES

  28. 只要击中其中一个状态代码,就跳过目标,用逗号分隔,支持ranges

  29. --minimal=LENGTH 最小响应长度

  30. --maximal=LENGTH 最大响应长度

  31. --max-time=SECONDS 扫描的最大运行时间

  32. -q, --quiet-mode 安静模式

  33. --full-url 输出中的完整URL(在安静模式)

  34. --no-color 无彩色无彩色输出

请求设置

  1. -m METHOD, --http-method=METHOD

  2. HTTP方法(默认值:GET)

  3. -d DATA, --data=DATA

  4. HTTP请求数据

  5. -H HEADERS, --header=HEADERS

  6. HTTP请求头,支持多个标志(例如:-H 'Referer: example.com')

  7. --header-list=FILE 文件包含HTTP请求头

  8. -F, --follow-redirects

  9. 遵循HTTP重定向

  10. --random-agent 为每个请求选择一个随机用户代理

  11. --auth-type=TYPE 身份验证类型 (basic, digest, bearer, ntlm)

  12. --auth=CREDENTIAL 身份验证凭证 (user:password or bearer token)

  13. --user-agent=USERAGENT

  14. --cookie=COOKIE

连接设置

  1. --timeout=TIMEOUT 超时连接超时

  2. -s DELAY, --delay=DELAY

  3. 请求之间的延迟

  4. --proxy=PROXY 代理URL,支持HTTP和SOCKS代理(例如:localhost:8080,socks5://localhost:8088)

  5. --proxy-list=FILE 文件包含代理服务器

  6. --replay-proxy=PROXY

  7. 使用找到的路径重播的代理

  8. --scheme=SCHEME 默认方案(对于原始请求或如果没有URL中的方案)

  9. --max-rate=RATE 每秒最大请求数

  10. --retries=RETRIES 重试失败请求的重试次数

  11. -b, --request-by-hostname

  12. 默认情况下,dirsearch按IP请求速度。这个将强制dirsearch按主机名请求

  13. --ip=IP 每当发生错误就退出

  14. 报告:

  15. -o FILE, --output=FILE

  16. 输出文件

  17. --format=FORMAT format报表格式(可用:simple、plain、json、xml,md,csv,html)

配置

可以在配置文件中编辑dirsearch标志的默认值:`Default.conf`

# 如果要编辑dirsearch默认配置,可以编辑此文件中的值。'#'后面的一切都是注释并且不会被应用
 
[mandatory]
default-extensions = php,aspx,jsp,html,js
force-extensions = False
# exclude-extensions = old,log
 
[general]
threads = 30
recursive = False
deep-recursive = False
force-recursive = False
recursion-depth = 0
exclude-subdirs = %%ff/
random-user-agents = False
max-time = 0
full-url = False
quiet-mode = False
color = True
recursion-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 = plain
autosave-report = True
# report-output-folder = /home/user
# logs-location = /tmp
## Supported: plain, simple, json, xml, md, csv, html
 
[dictionary]
lowercase = False
uppercase = False
capitalization = False
# prefixes = .,admin
# suffixes = ~,.bak
# wordlist = db/dicc.txt
 
[request]
httpmethod = get
## Lowercase only
follow-redirects = False
# headers-file = headers.txt
# user-agent = MyUserAgent
# cookie = SESSIONID=123
 
[connection]
timeout = 5
delay = 0
scheme = http
maxrate = 0
retries = 2
request-by-hostname = False
exit-on-error = False
# proxy = localhost:8080
# proxy-list = proxies.txt
# replay-proxy = localhost:8000

  • 2
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值