Wargame/wargame.kr
[Wargame.kr] strcmp 풀이 (212p)
bjloed
2020. 7. 28. 23:16
strcmp view-source code
<?php
require("../lib.php"); // for auth_code function
$password = sha1(md5(rand().file_get_contents("/var/lib/dummy_file")).rand());
if (isset($_GET['view-source'])) {
show_source(__FILE__);
exit();
}else if(isset($_POST['password'])){
sleep(1); // do not brute force!
if (strcmp($_POST['password'], $password) == 0) {
echo "Congratulations! Flag is <b>" . auth_code("strcmp") ."</b>";
exit();
} else {
echo "Wrong password..";
}
}
?>
flag를 얻기 위해서는 암호화된 $password의 값을 맞춰야한다.
그런데 if문에서 ===가 아닌 ==로 느슨한 비교를 한다.
POST 값이기 때문에 Burp Suite로 password[] 형태로 넘겨준다면 if문을 우회할 수 있을 듯하다.