prompt(1) to win XSS在线练习题,每一道都非常有趣,题目都有典型性。官方wiki题解在这里
0x00
|
|
简单双引号闭合,为了使答案最短,可以用svg
标签:"><svg/onload=prompt(1)>
0x01
|
|
规则会将</xx>
过滤,可以通过不使用>
来绕过规则,跟上题一样,可以使用svg
标签,这里需要注意的知识点是:为了让onload
立即渲染执行,可以通过在后面加上分隔符(空格
或回车
)来执行,所以最终答案为:<svg/onload=prompt(1)
注意末尾要加`或者
\n`
0x02
|
|
规则过滤了 =
(
由于我们使用HTML实体
在<svg>
的<script>
中,或者其他CDATA元素
中是会被解析成文本的,所以可以使用HTML实体
,绕过(
检测,所以最终结果如下:<svg><script>prompt(1)</script>
0x03
|
|
可以看见输出被注释<!-- -->
包裹,需要闭合注释进行执行,而代码又会过滤->
,所以需要知道一些特殊的点:
“… the comment must be ended by the three character sequence U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN (–>).”
在HTML说明中规定注释的结尾必须以-->
为结尾,而在HTML5
中有些不一样,除了-->
之外,--!>
也可以闭合!
答案:--!><svg/onload=prompt(1)
0x04
|
|
这道题题目限制在prompt.ml/
域名下去加载资源,所以是想办法绕过检测机制去加载我们恶意网站的内容,这里需要知道一个知识:
|
|
即在url中还有一个访问凭证
字段,我们的想法是通过@
符号,使浏览器让prompt.ml
等内容被识别为凭证信息,从而访问我们的恶意网站,由于使用了decodeURIComponent
函数,可以通过使用URLencode
进行转义,被decode之后的内容还满足正则表达式,但input
本身的%2f
会被识别为凭证信息,所以答案应该是:
|
|
0x05
|
|
题目过滤了>
和所有事件,有一点需要明确,其正则表达式没有使用多行匹配模式,这一点可以被很多时候利用,还有一点是由于我们所处的位置在type=text
之前,所以可以使用type=img
将其类型改为image,可以想想type=hidden
,然后通过换行绕过正则表达式,答案为:
|
|
0x06
|
|
常见方式,使用自己定义的同名属性来代替默认字段内容,这样首先会加载我们新创建的字段内容,答案如下:
|
|
0x07
|
|
由题目得通过#
进行分割输出且限制长度为12个字符,比较常见方法通过/**/
注释来进行构造,答案如下:
0x08
|
|
需要知道一个知识点:
|
|
所以答案为:
|
|
0x09
|
|
这道题比较有意思,过滤了标签的开始,并将内容全部大写了,这里需要知道,unicode码包含了许多国家的语言文字,有一些语言的字母调用Upper函数
进行大写,由于没有对应的大写文字,会自动的转换为英文字母,而在url中,协议和域名是不区分大小写的这时,我们就可以进行利用了。
首先,我们可以在控制台写一个循环来查找Upper之后是S
的字符。
|
|
然后用这个字符ſ
进行绕过。结果如下:
|
|
0x0A
|
|
这种过滤多次一般会存在后者刚好帮前者达成了目的,比较简单:
|
|
0x0B
|
|
有一个知识点,在脚本环境中,"string"(alert(1))
不会报错,且会正确执行,而为了使语法正确,使用in
关键字,结果如下:
|
|
0x0C
|
|
对于encodeURIComponent
,其不会编码 .()
可以通过 toString()
构造payload
toString(radix)
中radix
为 2-36 可以选36使其作为一个进制,将字符包含起来
使用parseInt(str, radix)
将字符转为数字之后使用(number).toString(radix)
然后用eval进行调用 注意number有括号,(number).toString(radix)
可简写为 (numbrer..toString(radix)
,字符之间用concat()
连接
|
|
0x0D
|
|
1 >In fact, config.source is equal to config.__proto__.source, this because __proto__ is an accessor property (getter/setter function)
这也是常见的构造相同名称的属性进行绕过替换。知道这一点,我们可以将结果构造成如下形式:
|
|
他会理解为:
|
|
之后,我们的payload
已经进入source
字段中,但是如果我们无法注入"
,依旧无法跳出<img src="_posts/prompt-1-writeup.md">
,这里需要一个奇技淫巧,String.replace
,他有一些特殊的替换规则:
Pattern | Inserts |
---|---|
$$ |
Inserts a “$”. |
$& |
Inserts the matched substring. |
$` | Inserts the portion of the string that precedes the matched substring. |
$' |
Inserts the portion of the string that follows the matched substring. |
$n |
Where n is a positive integer less than 100, inserts the nth parenthesized submatch string, provided the first argument was a RegExp object. Note that this is 1-indexed. |
所以,答案为:
|
|
0x0E
|
|
这题chrome上好像不行,firefox上使用iframe,src使用base64
编码可以达成绕过。
|
|
0x0F
|
|
同之前的题,利用注释闭合,不同的是,这里使用<!---->
,答案如下:
|
|