gobuster 报 the server returns a status code that matches 与 目录爆破用法
Gobuster 是一个用 Go 编写的枚举工具,支持目录/文件、DNS 子域、虚拟主机(vhost)与对象存储桶枚举。它按字典逐条发请求,靠状态码与响应长度筛出真实存在的路径。
仅供已获得书面授权的安全测试使用。
安装与版本
Kali 自带 Gobuster。它没有独立的 version 子命令,直接敲会报错:
gobuster version返回:
No help topic for 'version'这是把version当成了 help 主题去查,属于用法问题,不是安装损坏。版本信息在总帮助里:
gobuster --help输出中包含:
VERSION: 3.8实测环境为 Kali GNU/Linux Rolling 2025.4,Gobuster 3.8。
基本用法
最小的目录爆破命令:
gobuster dir -u http://127.0.0.1:8080 -w /usr/share/wordlists/dirb/common.txt加-q只看命中结果:
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 只打印帮助而不执行:
gobuster dir -w /usr/share/wordlists/dirb/common.txtNAME: 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 当成无效码排除:
gobuster dir -u http://127.0.0.1:8090 -w /usr/share/wordlists/dirb/common.txt -b 200,404或者按响应长度排除,适合所有路径长度一致(如 SPA 兜底返回同一页面)的情况:
gobuster dir -u http://127.0.0.1:8090 -w /usr/share/wordlists/dirb/common.txt --exclude-length 17确认是误判、想强行继续时用--force,但结果不可信:
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 directoryKali 里现成可用的字典:
ls -l /usr/share/wordlists/dirb/common.txt ls -l /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt前者 35849 行,适合轻量摸排;后者 725439 行,适合全面覆盖。字典越大请求量越大,按目标承受能力选。
分场景用法
枚举 DNS 子域:
gobuster dns -d example.com -w subdomains.txt枚举虚拟主机,需先用 IP 作 URL:
gobuster vhost -u http://192.168.1.10 -w subdomains.txt追加文件扩展名,一次覆盖多类后缀:
gobuster dir -u http://127.0.0.1:8080 -w common.txt -x php,html,txt只把指定状态码作为命中:
gobuster dir -u http://127.0.0.1:8080 -w common.txt -s 200,204,301,302限速,给每线程加请求间隔:
gobuster dir -u http://127.0.0.1:8080 -w common.txt -t 20 -d 200ms带认证的扫描
目标需要登录时,把会话 Cookie 带上:
gobuster dir -u http://127.0.0.1:8080 -w common.txt -c 'SESSIONID=abcdef123456'Basic 认证用一对参数:
gobuster dir -u http://127.0.0.1:8080 -w common.txt -U admin -P 'Passw0rd'自定义请求头,例如伪造内网来源:
gobuster dir -u http://127.0.0.1:8080 -w common.txt -H 'X-Forwarded-For: 127.0.0.1'未认证与带凭据两次结果差别很大,评估时应分别跑一遍,对比哪些路径只在登录后才出现。
结果去噪
Gobuster 只按状态码与长度过滤,输出里常见三类噪声:软 404、统一跳转页与反向代理兜底页。判定方式是抽几个命中路径手工请求:
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 或反向代理的回退页。