if you can bypass the strcmp function, you get the flag.
strcmp는 문자열을 비교하는 함수인데 bypass를 어떻게 해야할것인가.
<?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..";
}
}
?>
<br />
<br />
<form method="POST">
password : <input type="text" name="password" /> <input type="submit" value="chk">
</form>
<br />
<a href="?view-source">view-source</a>
일반적으론 패스할수 없다고 생각되지만 php strcmp 에 배열 취약점이 있다
DOM을 조작해도 좋고, 패킷을 그냥 생성해도 보내도 상관없다. password=가 아닌 password[]= 형태로 만들어 보내주자. 값은 상관없다.
가면갈수록 === 를 안쓰면 큰일나겠다는 생각이 든다.