๐ old-06 ์๊ฒ์ ๋ฌธ์ ํ์ด
1. ๋ฌธ์ ํ๋ฉด์ผ๋ก ๋ค์ด๊ฐ view-source ํด๋ฆญ
2. ์ฝ๋ ๋ถ์๊ณผ ํจ๊ป ๋ฌธ์ ํ์ด ์กฐ๊ฑด ํ์
<?php
// ํ์ํ ์ค์ ํ์ผ ํฌํจ
include "../../config.php";
// URL ๋งค๊ฐ๋ณ์๋ก view_source๊ฐ ์ ๋ฌ๋๋ฉด view_source ํจ์ ํธ์ถ
if ($_GET['view_source']) view_source();
// ์ฟ ํค 'user'๊ฐ ์์ ๊ฒฝ์ฐ (๋ก๊ทธ์ธ๋์ง ์์ ๊ฒฝ์ฐ)
if (!$_COOKIE['user']) {
// ์ด๊ธฐ ID์ ๋น๋ฐ๋ฒํธ ์ค์
$val_id = "guest";
$val_pw = "123qwe";
// ID์ ๋น๋ฐ๋ฒํธ๋ฅผ 20ํ์ฉ base64 ์ธ์ฝ๋ฉ
for ($i = 0; $i < 20; $i++) {
$val_id = base64_encode($val_id);
$val_pw = base64_encode($val_pw);
}
// ํน์ ๋ฌธ์๋ฅผ ๋ค๋ฅธ ๋ฌธ์๋ก ๊ต์ฒด
$val_id = str_replace("1", "!", $val_id);
$val_id = str_replace("2", "@", $val_id);
$val_id = str_replace("3", "$", $val_id);
$val_id = str_replace("4", "^", $val_id);
$val_id = str_replace("5", "&", $val_id);
$val_id = str_replace("6", "*", $val_id);
$val_id = str_replace("7", "(", $val_id);
$val_id = str_replace("8", ")", $val_id);
$val_pw = str_replace("1", "!", $val_pw);
$val_pw = str_replace("2", "@", $val_pw);
$val_pw = str_replace("3", "$", $val_pw);
$val_pw = str_replace("4", "^", $val_pw);
$val_pw = str_replace("5", "&", $val_pw);
$val_pw = str_replace("6", "*", $val_pw);
$val_pw = str_replace("7", "(", $val_pw);
$val_pw = str_replace("8", ")", $val_pw);
// ์ฟ ํค 'user'์ 'password' ์ค์ . ์ ํจ๊ธฐ๊ฐ์ 86400์ด(ํ๋ฃจ)๋ก ์ค์
Setcookie("user", $val_id, time() + 86400, "/challenge/web-06/");
Setcookie("password", $val_pw, time() + 86400, "/challenge/web-06/");
// ํ์ด์ง ์๋ก๊ณ ์นจ
echo("<meta http-equiv=refresh content=0>");
exit;
}
?>
<html>
<head>
<title>Challenge 6</title>
<style type="text/css">
body { background:black; color:white; font-size:10pt; }
</style>
</head>
<body>
<?php
// ์ฟ ํค 'user'์ 'password' ๊ฐ์ ๊ฐ์ ธ์์ ๋์ฝ๋ฉ
$decode_id = $_COOKIE['user'];
$decode_pw = $_COOKIE['password'];
// ํน์ ๋ฌธ์๋ฅผ ์๋ ๋ฌธ์๋ก ๊ต์ฒด
$decode_id = str_replace("!", "1", $decode_id);
$decode_id = str_replace("@", "2", $decode_id);
$decode_id = str_replace("$", "3", $decode_id);
$decode_id = str_replace("^", "4", $decode_id);
$decode_id = str_replace("&", "5", $decode_id);
$decode_id = str_replace("*", "6", $decode_id);
$decode_id = str_replace("(", "7", $decode_id);
$decode_id = str_replace(")", "8", $decode_id);
$decode_pw = str_replace("!", "1", $decode_pw);
$decode_pw = str_replace("@", "2", $decode_pw);
$decode_pw = str_replace("$", "3", $decode_pw);
$decode_pw = str_replace("^", "4", $decode_pw);
$decode_pw = str_replace("&", "5", $decode_pw);
$decode_pw = str_replace("*", "6", $decode_pw);
$decode_pw = str_replace("(", "7", $decode_pw);
$decode_pw = str_replace(")", "8", $decode_pw);
// ID์ ๋น๋ฐ๋ฒํธ๋ฅผ 20ํ์ฉ base64 ๋์ฝ๋ฉ
for ($i = 0; $i < 20; $i++) {
$decode_id = base64_decode($decode_id);
$decode_pw = base64_decode($decode_pw);
}
// ๋์ฝ๋ฉ๋ ID์ ๋น๋ฐ๋ฒํธ๋ฅผ ์ถ๋ ฅ
echo("<hr><a href=./?view_source=1 style=color:yellow;>view-source</a><br><br>");
echo("ID : $decode_id<br>PW : $decode_pw<hr>");
// ID์ ๋น๋ฐ๋ฒํธ๊ฐ admin๊ณผ nimda์ผ ๊ฒฝ์ฐ solve ํจ์๋ฅผ ํธ์ถํ์ฌ ๋ฌธ์ ํด๊ฒฐ
if ($decode_id == "admin" && $decode_pw == "nimda") {
solve(6);
}
?>
</body>
</html>
++ ID์ ๋น๋ฐ๋ฒํธ๋ฅผ ๊ธฐ์กด ์ฝ๋์ ๋ฐ๋๋ก Encode & Decode ํ์ฌ ์๋์ ๊ฐ์ ๊ตฌํด์ผ ํจ
3. ๋ฌธ์ ํด๊ฒฐ์ ์ํ Python ์คํฌ๋ฆฝํธ ์์ฑ
import base64
# ๋ฌธ์ ์นํ์ ์ญ์ผ๋ก ์ํํ๋ ํจ์ ์ ์
def reverse_replace(s):
s = s.replace("1", "!")
s = s.replace("2", "@")
s = s.replace("3", "$")
s = s.replace("4", "^")
s = s.replace("5", "&")
s = s.replace("6", "*")
s = s.replace("7", "(")
s = s.replace("8", ")")
return s
# ๊ด๋ฆฌ์ ์์ด๋์ ๋น๋ฐ๋ฒํธ๋ฅผ UTF-8 ์ธ์ฝ๋ฉํ์ฌ ๋ฐ์ดํธ๋ก ๋ณํ
id = 'admin'.encode()
pw = 'nimda'.encode()
# ๊ฐ๊ฐ 20๋ฒ์ base64 ์ธ์ฝ๋ฉ ์ ์ฉ
for j in range(20):
pw = base64.b64encode(pw)
id = base64.b64encode(id)
# ๋ฌธ์ ์นํ์ ์ญ์ผ๋ก ์ํํ์ฌ ์๋์ ๊ฐ ๋์ถ
id = reverse_replace(id.decode())
pw = reverse_replace(pw.decode())
# ๊ฒฐ๊ณผ ์ถ๋ ฅ
print("Decoded ID:", id)
print("\n\n")
print("Decoded Password:", pw)
4. ์์ฑํ Python ์คํฌ๋ฆฝํธ๋ฅผ Google Colab์์ ์คํ
# Decoded ID
: Vm0wd@QyUXlVWGxWV0d^V!YwZDRWMVl$WkRSV0!WbDNXa!JTVjAxV@JETlhhMUpUVmpBeFYySkVUbGhoTVVwVVZtcEJlRll&U@tWVWJHaG9UVlZ$VlZadGNFSmxSbGw!VTJ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cookies ๋ก ์ด๋ --> https://webhacking.kr ํด๋ฆญ
7. user ์ password์ ์ฟ ํค๊ฐ์ ์ผ์ ์ ์ป์ ๊ฐ์ผ๋ก ๋ณ๊ฒฝ
8. ๊ฐ ๋ณ๊ฒฝ ํ ํ์ด์ง ์๋ก๊ณ ์นจ --> ๋ฌธ์ ํด๊ฒฐ ์ฑ๊ณต
'โ๏ธ Web Hacking > Webhacking.kr' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Webhacking.kr] old-39 ์๊ฒ์ ๋ฌธ์ ํ์ด (0) | 2023.08.30 |
---|---|
[Webhacking.kr] old-01 ์๊ฒ์ ๋ฌธ์ ํ์ด (0) | 2023.08.28 |
[Webhacking.kr] old-11 ์๊ฒ์ ๋ฌธ์ ํ์ด (0) | 2023.08.26 |
[Webhacking.kr] old-23 ์๊ฒ์ ๋ฌธ์ ํ์ด (0) | 2023.08.25 |
[Webhacking.kr] old-20 ์๊ฒ์ ๋ฌธ์ ํ์ด (0) | 2023.08.24 |