草庐IT

dirsearch安装和使用

小小小维 2023-04-22 原文

目录

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]

选项

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

强制性

    -u URL, --url=URL   目标URL
    -l FILE, --url-list=FILE
                        目标URL列表文件
    --stdin             来自STDIN的目标URL列表
    --cidr=CIDR         CIDR目标
    --raw=FILE          文件从文件加载原始HTTP请求(使用`--Scheme`标志设置方案)
    -e EXTENSIONS, --extensions=EXTENSIONS
                        用逗号分隔的扩展列表(例如:php、asp)
    -X EXTENSIONS, --exclude-extensions=EXTENSIONS
                        排除用逗号分隔的扩展名列表(例如:asp、jsp)
    -f, --force-extensions
                        为每个wordlist条目添加扩展名。默认情况下dirsearch仅将%ext%关键字替换为扩展

字典设置

    -w WORDLIST, --wordlists=WORDLIST
                        自定义Wordlist(用逗号分隔)
    --prefixes=PREFIXES
                        为所有wordlist条目添加自定义前缀(分开按逗号)
    --suffixes=SUFFIXES
                        将自定义后缀添加到所有wordlist条目,忽略目录(用逗号分隔)
    --only-selected     移除路径的扩展名与选定的不同通过`-e`的(保留条目没有扩展名)
    --remove-extensions
                        删除所有路径中的扩展(例如: admin.php -> admin)
    -U, --uppercase     Uppercase wordlist
    -L, --lowercase     Lowercase wordlist
    -C, --capital       Capital wordlist

一般设置

    -t THREADS, --threads=THREADS
                        线程数
    -r, --recursive     蛮力递归
    --deep-recursive    对每个目录深度执行递归扫描(例如: api/users -> api/)
    --force-recursive   每个找到的路径做递归蛮力,而不是只有路径以斜杠结尾
    --recursion-depth=DEPTH
                        最大递归深度
    --recursion-status=CODES
                        执行递归扫描的有效状态代码,支持范围(用逗号分隔)
    --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
                       按文本排除答复,用逗号分隔(例如:'not found'、'error')
    --exclude-regexps=REGEXPS
                        用逗号分隔的正则表达式排除响应(例如:“not foun[a-z]{1}”,“^error$”)
    --exclude-redirects=REGEXPS
                        通过重定向正则表达式或文本排除响应,用逗号分隔(例如:'https://okta.com/*')
    --exclude-content=PATH
                        按此路径的响应内容排除响应
    --skip-on-status=CODES
                        只要击中其中一个状态代码,就跳过目标,用逗号分隔,支持ranges
    --minimal=LENGTH    最小响应长度
    --maximal=LENGTH    最大响应长度
    --max-time=SECONDS  扫描的最大运行时间
    -q, --quiet-mode    安静模式
    --full-url          输出中的完整URL(在安静模式)
    --no-color          无彩色无彩色输出

请求设置

    -m METHOD, --http-method=METHOD
                        HTTP方法(默认值:GET)
    -d DATA, --data=DATA
                        HTTP请求数据
    -H HEADERS, --header=HEADERS
                        HTTP请求头,支持多个标志(例如:-H 'Referer: example.com')
    --header-list=FILE  文件包含HTTP请求头
    -F, --follow-redirects
                        遵循HTTP重定向
    --random-agent      为每个请求选择一个随机用户代理
    --auth-type=TYPE    身份验证类型 (basic, digest, bearer, ntlm)
    --auth=CREDENTIAL   身份验证凭证 (user:password or bearer token)
    --user-agent=USERAGENT
    --cookie=COOKIE

连接设置

    --timeout=TIMEOUT   超时连接超时
    -s DELAY, --delay=DELAY
                        请求之间的延迟
    --proxy=PROXY       代理URL,支持HTTP和SOCKS代理(例如:localhost:8080,socks5://localhost:8088)
    --proxy-list=FILE   文件包含代理服务器
    --replay-proxy=PROXY
                        使用找到的路径重播的代理
    --scheme=SCHEME     默认方案(对于原始请求或如果没有URL中的方案)
    --max-rate=RATE     每秒最大请求数
    --retries=RETRIES   重试失败请求的重试次数
    -b, --request-by-hostname
                        默认情况下,dirsearch按IP请求速度。这个将强制dirsearch按主机名请求
    --ip=IP             每当发生错误就退出

  报告:
    -o FILE, --output=FILE
                        输出文件
    --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

文章内容出处:dirsearch安装包中的README.md文件,是英文版的,我用翻译工具翻译整理的,有任何问题和错误的地方欢迎指正,谢谢。

有关dirsearch安装和使用的更多相关文章

  1. ruby - 如何使用 Nokogiri 的 xpath 和 at_xpath 方法 - 2

    我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div

  2. ruby - 使用 RubyZip 生成 ZIP 文件时设置压缩级别 - 2

    我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看ruby​​zip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d

  3. ruby - 为什么我可以在 Ruby 中使用 Object#send 访问私有(private)/ protected 方法? - 2

    类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc

  4. ruby-on-rails - 使用 Ruby on Rails 进行自动化测试 - 最佳实践 - 2

    很好奇,就使用ruby​​onrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提

  5. ruby - 在 Ruby 中使用匿名模块 - 2

    假设我做了一个模块如下:m=Module.newdoclassCendend三个问题:除了对m的引用之外,还有什么方法可以访问C和m中的其他内容?我可以在创建匿名模块后为其命名吗(就像我输入“module...”一样)?如何在使用完匿名模块后将其删除,使其定义的常量不再存在? 最佳答案 三个答案:是的,使用ObjectSpace.此代码使c引用你的类(class)C不引用m:c=nilObjectSpace.each_object{|obj|c=objif(Class===objandobj.name=~/::C$/)}当然这取决于

  6. ruby - 使用 ruby​​ 和 savon 的 SOAP 服务 - 2

    我正在尝试使用ruby​​和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我

  7. python - 如何使用 Ruby 或 Python 创建一系列高音调和低音调的蜂鸣声? - 2

    关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。

  8. ruby-on-rails - 'compass watch' 是如何工作的/它是如何与 rails 一起使用的 - 2

    我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t

  9. ruby - 使用 ruby​​ 将 HTML 转换为纯文本并维护结构/格式 - 2

    我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h

  10. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

随机推荐