【发布时间】:2014-06-10 20:12:12
【问题描述】:
剧透警告:此问题包含对来自Google's XSS Challenge! 的问题之一的回答。如果您现在不想知道答案,请停止继续阅读。
我能够通过level 4 of the challenge,但是,我仍然不知道该漏洞利用的具体情况如何。以下是来自 Google 的 XSS 挑战 - Level 4 的代码:
<!doctype html>
<html>
<head>
<!-- Internal game scripts/styles, mostly boring stuff -->
<script src="/static/game-frame.js"></script>
<link rel="stylesheet" href="/static/game-frame-styles.css" />
<script>
function startTimer(seconds) {
seconds = parseInt(seconds) || 3;
setTimeout(function() {
window.confirm("Time is up!");
window.history.back();
}, seconds * 1000);
}
</script>
</head>
<body id="level4">
<img src="/static/logos/level4.png" />
<br>
<img src="/static/loading.gif" onload="startTimer('{{ timer }}');" />
<br>
<div id="message">Your timer will execute in {{ timer }} seconds.</div>
</body>
</html>
基本上,他们使用的是 Django 框架 (which uses a bunch of security measure against XSS)。变量timer 携带来自用户的输入。此活动的目标是通过发送可以绕过 Django 的 XSS 安全性的有效负载来警告消息。
我可以使用以下负载之一来提醒消息:
');alert('xss
或
3') || alert('1
我可以使用上述有效负载清除关卡,但我仍然不确定究竟在哪里调用了 alert() 方法?在onload 处理程序中还是在startTimer() 方法中?
我很困惑,因为如果我在提交有效负载后检查页面的源 HTML,Django 正在对有效负载进行编码:
<html>
<head>
<!-- Internal game scripts/styles, mostly boring stuff -->
<script src="/static/game-frame.js"></script>
<link rel="stylesheet" href="/static/game-frame-styles.css" />
<script>
function startTimer(seconds) {
seconds = parseInt(seconds) || 3;
setTimeout(function() {
window.confirm("Time is up!");
window.history.back();
}, seconds * 1000);
}
</script>
</head>
<body id="level4">
<img src="/static/logos/level4.png" />
<br>
<img src="/static/loading.gif" onload="startTimer('');alert('xss');" />
<br>
<div id="message">Your timer will execute in ');alert('xss seconds.</div>
</body>
</html>
【问题讨论】:
标签: javascript django xss