ν°μ€ν 리 λ·°
μ€λͺ (λ²μ)
μΉ μμ© νλ‘κ·Έλ¨μ μ’ μ’ μ¬μ©μ λ°μ΄ν°λ₯Ό μλ² μΈ‘μ 보κ΄νκ³ μ μ λ ν΄λΌμ΄μΈνΈ μΈ‘ λ°μ΄ν°λ² μ΄μ€μ 보κ΄νκ³ λμ€μ μ¬μ©μμκ² νμν©λλ€. μ΄λ¬ν μ¬μ©μ μ μ΄ λ°μ΄ν°μ μΆμ²μ κ΄κ³μμ΄ μ μ€νκ² μ²λ¦¬ν΄μΌ ν©λλ€.
μ΄ μμ€μ 볡μ‘ν μ±μμ XSS λ²κ·Έκ° μΌλ§λ μ½κ² λμ λ μ μλμ§ λ³΄μ¬μ€λλ€.
μ무 λͺ©ν : alert() μμ© νλ‘κ·Έλ¨ μ»¨ν μ€νΈμμ νμ μ€ν¬λ¦½νΈλ₯Ό μ½μ ν©λλ€.
μ°Έκ³ : μμ© νλ‘κ·Έλ¨μ κ²μλ¬Όμ μ μ₯νλ―λ‘ κ²½κ³ λ₯Ό μ€ννκΈ° μν΄ μ½λλ₯Ό μ΄μ§ μ λ ₯νλ©΄ λ€μ λ‘λν λλ§λ€μ΄ μμ€μ΄ ν΄κ²°λ©λλ€.
Level 2 μμλ " <script> " νκ·Έλ₯Ό λ§κ³ μμ΅λλ€.
λν μ¬μ§μ 보μ΄λ κ²μ²λΌ HTML νΌμ μ μμ μΈ μ€ν¬λ¦½νΈ ꡬ문μ μ½μ νμ¬ ν΄λΉ νμ΄μ§μ μ κ·Όνλ λͺ¨λ μ¬μ©μ λ€μ νκΉμΌλ‘ νκ³ " Persistence " μ§μμ±μ κ°μ§ 곡격μ νλΌλ μΆμ μμ μλκ° λ³΄μ λλ€.
--index.html--
<!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" />
<!-- This is our database of messages -->
<script src="/static/post-store.js"></script>
<script>
var defaultMessage = "Welcome!<br><br>This is your <i>personal</i>"
+ " stream. You can post anything you want here, especially "
+ "<span style='color: #f00ba7'>madness</span>.";
var DB = new PostDB(defaultMessage);
function displayPosts() {
var containerEl = document.getElementById("post-container");
containerEl.innerHTML = "";
var posts = DB.getPosts();
for (var i=0; i<posts.length; i++) {
var html = '<table class="message"> <tr> <td valign=top> '
+ '<img src="/static/level2_icon.png"> </td> <td valign=top '
+ ' class="message-container"> <div class="shim"></div>';
html += '<b>You</b>';
html += '<span class="date">' + new Date(posts[i].date) + '</span>';
html += "<blockquote>" + posts[i].message + "</blockquote";
html += "</td></tr></table>"
containerEl.innerHTML += html;
}
}
window.onload = function() {
document.getElementById('clear-form').onsubmit = function() {
DB.clear(function() { displayPosts() });
return false;
}
document.getElementById('post-form').onsubmit = function() {
var message = document.getElementById('post-content').value;
DB.save(message, function() { displayPosts() } );
document.getElementById('post-content').value = "";
return false;
}
displayPosts();
}
</script>
</head>
<body id="level2">
<div id="header">
<img src="/static/logos/level2.png" />
<div>Chatter from across the Web.</div>
<form action="?" id="clear-form">
<input class="clear" type="submit" value="Clear all posts">
</form>
</div>
<div id="post-container"></div>
<table class="message">
<tr>
<td valign="top">
<img src="/static/level2_icon.png">
</td>
<td class="message-container">
<div class="shim"></div>
<form action="?" id="post-form">
<textarea id="post-content" name="content" rows="2"
cols="50"></textarea>
<input class="share" type="submit" value="Share status!">
<input type="hidden" name="action" value="sign">
</form>
</td>
</tr>
</table>
</body>
</html>
ν΄λΉ λ 벨μμλ <scirpt> νκ·Έλ₯Ό νν°λ§ κ±Έμ΄ μ μμ μΈ μ€ν¬λ¦½νΈκ° μ€νλμ§ λͺ»νλλ‘ λ§κ³ μλ€. μ΄λ΄ λλ λ€λ₯Έ νκ·Έλ₯Ό μ¬μ©νμ¬ μ€ν¬λ¦½νΈκ° μ€νλλλ‘ μ λ°ν μ μλ€.
<img src> νκ·Έμ μ΄λ²€νΈ νΈλ€λ¬λ₯Ό μ‘°ν©νμ¬ μ€νμν¬ μ μλ€.
html μ½λλ₯Ό 보면 <img src= λ₯Ό ν΅ν΄ /static/level 2μ΄λΌλ κ²½λ‘λ₯Ό ν΅ν΄ μ΄λ―Έμ§λ₯Ό λΆλ¬μ€κ³ μλ€. λ§μ½ κ²½λ‘λ₯Ό μλ κ²½λ‘λ‘ μ§μ ν΄μ£Όλ©΄ μλ¬κ° λ°μνλλ° μ΄λ μλ°μ€ν¬λ¦½νΈ μ΄λ²€νΈ νΈλ€λ¬μΈ onerrorλ₯Ό μ°κ³νμ¬ μλ¬κ° λ°μ μ onerror ν¨μκ° λ°μλλλ‘ ν μ μλ€.
λ§μ§λ§μΌλ‘ μ¬μ©μ νλ©΄μ κ²½κ³ λ¬Έκ΅¬λ₯Ό λμ°κΈ° μν΄ alert, confirm, prompt λ± μ¬μ©νλ©΄ λλ€.
ννΈ
1. "νμ"κ²μλ¬Όμλ ν νλ¦Ώμ΄ μν λ©μμ§μ λ΄μ©μ μ΄μ€μΌμ΄ν νμ§ μμμ λνλ΄λ HTMLμ΄ ν¬ν¨λμ΄ μμ΅λλ€.
2. μ΄ μμ€μμ <script> νκ·Έλ₯Ό μ λ ₯νλ©΄ μλνμ§ μμ΅λλ€. λμ JavaScript μμ±μ΄ μλ μμλ₯Ό μ¬μ©ν΄λ³΄μμμ€.
3. μ΄ λ 벨μ λ¬Έμ i , m , g λ° μμ±μ μν΄ νμλ©λλ€ onerror
Exlpoit Code
<img src=onerror=prompt("xss")>
<img src=x onerror=prompt("xss")>
'CHALLENGE' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
XSS-Game Level 6 (0) | 2020.12.01 |
---|---|
XSS-Game Level 5 (0) | 2020.11.30 |
XSS-Game Level 4 (0) | 2020.11.29 |
XSS-Game Level 3 (0) | 2020.11.28 |
XSS-Game Level 1 (2) | 2020.11.26 |