스포일러 경고 :이 질문은 Google's XSS Challenge의 문제 중 하나에 대한 답변을 포함합니다! 지금 당장 답을 알고 싶지 않다면 더 이상 읽지 마시기 바랍니다.이 XSS 공격은 어떻게 작동합니까?
은 내가 level 4 of the challenge은, 그러나, 나는 여전히이 작동 이용 방법을 정확하게 모르는 통과 얻을 수 있어요.
<!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>
기본적으로, 그들이 사용하는 장고 프레임 워크 (which uses a bunch of security measure against XSS) : 레벨 4 - 다음은 구글의 XSS 도전에서 코드입니다. 변수 timer
은 사용자로부터 입력을 전달합니다. 이 액티비티의 목적은 Django의 XSS 보안을 우회 할 수있는 페이로드를 보내서 메시지를 경고하는 것입니다. 나는 다음과 같은 페이로드 중 하나를 사용하여 메시지를 경고 할 수 있어요
:
');alert('xss
또는
3') || alert('1
나는 위의 페이로드를 사용하여 레벨을 취소 할 수 있어요하지만 난 여전히 alert() 메서드가 정확히 어디에서 호출되는지 확실하지 않습니까? onload
처리기 또는 startTimer()
메서드 내에 있습니까?
내가 페이로드를 제출 한 후 페이지의 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('');alert('xss');" />
<br>
<div id="message">Your timer will execute in ');alert('xss seconds.</div>
</body>
</html>
오! 정말 혼란 스럽습니다. 나는 문자열''); alert (' xss'가 메소드'startTimer'에 전달되고 메소드 내에서 경고가 호출 중임을 알았습니다. –
+1 때문에 답을 찾을 수있었습니다. –
'+ 경고 ('hi ') +'경고 – Red2678