gobuster 报 the server returns a status code that matches 与 目录爆破用法

gobuster 报 the server returns a status code that matches 与 目录爆破用法

Gobuster 是一个用 Go 编写的枚举工具,支持目录/文件、DNS 子域、虚拟主机(vhost)与对象存储桶枚举。它按字典逐条发请求,靠状态码与响应长度筛出真实存在的路径。

仅供已获得书面授权的安全测试使用。

安装与版本

Kali 自带 Gobuster。它没有独立的 version 子命令,直接敲会报错:

bash 复制代码
gobuster version

返回:

复制代码
No help topic for 'version'

这是把 version 当成了 help 主题去查,属于用法问题,不是安装损坏。版本信息在总帮助里:

bash 复制代码
gobuster --help

输出中包含:

复制代码
VERSION:
   3.8

实测环境为 Kali GNU/Linux Rolling 2025.4,Gobuster 3.8。

基本用法

最小的目录爆破命令:

bash 复制代码
gobuster dir -u http://127.0.0.1:8080 -w /usr/share/wordlists/dirb/common.txt

加 -q 只看命中结果:

bash 复制代码
gobuster dir -u http://127.0.0.1:8080 -w /usr/share/wordlists/dirb/common.txt -q

实测回显(目标上放了 /n/ 与 /t1/ 两个目录):

复制代码
/n                    (Status: 301) [Size: 0] [--> /n/]
/t1                   (Status: 301) [Size: 0] [--> /t1/]

-u 是目标 URL,-w 是字典路径,两者都是必填。缺任意一个,Gobuster 只打印帮助而不执行:

bash 复制代码
gobuster dir -w /usr/share/wordlists/dirb/common.txt
复制代码
NAME:
   gobuster dir - Uses directory/file enumeration mode

USAGE:
   gobuster dir [command options] [arguments...]

报错 the server returns a status code that matches

这是 Gobuster 最常见的报错。当服务器对不存在的路径也返回 200(通配响应,常见于前端路由或自定义错误页),Gobuster 的前置校验会直接中止:

复制代码
2026/10/14 16:32:39 the server returns a status code that matches the provided options for non existing urls. http://127.0.0.1:8090/e70a4de0-fcbb-4766-929d-a52b26a620ce => 200 (Length: 17). Please exclude the response length or the status code or set the wildcard option.. To continue please exclude the status code or the length

它发出的是一个随机不存在的路径,如果这个路径都命中 200,说明服务端有兜底。三种解法,按优先级:

先把 200 当成无效码排除:

bash 复制代码
gobuster dir -u http://127.0.0.1:8090 -w /usr/share/wordlists/dirb/common.txt -b 200,404

或者按响应长度排除,适合所有路径长度一致(如 SPA 兜底返回同一页面)的情况:

bash 复制代码
gobuster dir -u http://127.0.0.1:8090 -w /usr/share/wordlists/dirb/common.txt --exclude-length 17

确认是误判、想强行继续时用 --force,但结果不可信:

bash 复制代码
gobuster dir -u http://127.0.0.1:8090 -w /usr/share/wordlists/dirb/common.txt --force

判定原则:先用 curl -i http://127.0.0.1:8090/一个随机字符串 看返回码与长度,与报错里的 200 (Length: 17) 对上,再决定排长度还是排状态码。

报错 wordlist file does not exist

字典路径写错时直接退出:

复制代码
2026/10/14 16:32:37 wordlist file "/root/nope.txt" does not exist: stat /root/nope.txt: no such file or directory

Kali 里现成可用的字典:

bash 复制代码
ls -l /usr/share/wordlists/dirb/common.txt
ls -l /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt

前者 35849 行,适合轻量摸排;后者 725439 行,适合全面覆盖。字典越大请求量越大,按目标承受能力选。

分场景用法

枚举 DNS 子域:

bash 复制代码
gobuster dns -d example.com -w subdomains.txt

枚举虚拟主机,需先用 IP 作 URL:

bash 复制代码
gobuster vhost -u http://192.168.1.10 -w subdomains.txt

追加文件扩展名,一次覆盖多类后缀:

bash 复制代码
gobuster dir -u http://127.0.0.1:8080 -w common.txt -x php,html,txt

只把指定状态码作为命中:

bash 复制代码
gobuster dir -u http://127.0.0.1:8080 -w common.txt -s 200,204,301,302

限速,给每线程加请求间隔:

bash 复制代码
gobuster dir -u http://127.0.0.1:8080 -w common.txt -t 20 -d 200ms

带认证的扫描

目标需要登录时,把会话 Cookie 带上:

bash 复制代码
gobuster dir -u http://127.0.0.1:8080 -w common.txt -c 'SESSIONID=abcdef123456'

Basic 认证用一对参数:

bash 复制代码
gobuster dir -u http://127.0.0.1:8080 -w common.txt -U admin -P 'Passw0rd'

自定义请求头,例如伪造内网来源:

bash 复制代码
gobuster dir -u http://127.0.0.1:8080 -w common.txt -H 'X-Forwarded-For: 127.0.0.1'

未认证与带凭据两次结果差别很大,评估时应分别跑一遍,对比哪些路径只在登录后才出现。

结果去噪

Gobuster 只按状态码与长度过滤,输出里常见三类噪声:软 404、统一跳转页与反向代理兜底页。判定方式是抽几个命中路径手工请求:

bash 复制代码
curl -i http://127.0.0.1:8080/n/

看返回体是否与首页一致、大小是否与 [Size: N] 吻合。对大小一致的批量命中,直接用 --exclude-length 整段排掉。

适用边界

Gobuster 只做存在性枚举,不做内容解析与漏洞验证,输出是一组候选路径。对纯静态站点,收益主要来自备份文件与编辑器残留文件(.bak、.swp、~);对使用前端路由的单页应用,大部分命中都是兜底页,要先解决通配响应再谈命中。字典爆破会显著增加目标日志量,评估前确认监控方已知情。

注意事项

  • 看到 the server returns a status code that matches ... 不要直接加 --force 了事,先确认真实不存在路径的返回码与长度。
  • -b 与 --exclude-length 二选一即可,两个同时给会互相干扰判断。
  • 字典大小直接决定请求量。directory-list-2.3-small.txt 有 72 万行,对单个目标就是 72 万次请求,生产环境务必配合 -d 限速。
  • 默认不跟随重定向,301/302 会原样列出;需要最终落地路径时再加 -r。
  • Gobuster 命中即报告,不做漏洞验证,返回 200 的路径仍可能是软 404 或反向代理的回退页。
相关推荐
小枣信安2 小时前
MCP安全系列之缺乏日志审计
安全·网络安全·ai安全·大模型安全·智能体安全·mcp安全
SGS官方2 小时前
SGS为紫光国芯颁发ISO 26262:2018汽车功能安全ASIL D流程证书
安全·汽车·检测认证机构·sgs
Xudde.2 小时前
PwnLab: init 靶机渗透测试(Vulnhub Writeup)
笔记·学习·安全·web安全
学逆向的2 小时前
C 数据溢出与精度丢失
c语言·开发语言·网络安全
是真的小外套3 小时前
第14章:恶意代码防范技术原理与应用
网络·网络安全
听说6664 小时前
信息安全工程师 - 第二十三章 云计算安全需求分析与安全保护工程
网络·安全·web安全·网络安全·云计算·系统安全
Xudde.4 小时前
HackMe 靶机渗透测试(Vulnhub Writeup)
笔记·学习·安全·web安全
罗斯8394 小时前
Datalog与安全分析
算法·安全·网络安全
橙色云-智橙协同研发4 小时前
电子高科技行业:机械与电子(MCAD & ECAD)如何协同?
大数据·运维·服务器·人工智能·安全