Wargame/Wargame.kr
[Wargame.kr] strcmp
광팔2
2021. 2. 18. 17:46
반응형
Start를 누르면 wargame.kr:8080/strcmp/ 사이트로 넘어가진다.
strcmp 함수를 우회할 수 있으면 플래그를 얻습니다. 우회해야겠다...
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..";
if 문을 보면 strcmp 함수가 있다. strcmp 함수는 첫 번째와 두 번째 값이 같을 때 0을 출력한다.
즉 $_POST['password'] 와 $password 값이 같으면 된다.
그럼 플래그 값을 얻을 수 있다.
$password = sha1(md5(rand().file_get_contents("/var/lib/dummy_file")).rand());
하지만 $password의 값은 암호화되고 있다.
암호화 값을 맞춘다는 건 쉽지 않다. 문제에서 strcmp 함수의 취약점을 이용하라 했으니 한번 이용해보자.
strcmp 함수의 취약점은 if(strcmp(String,Array()==0) 이런 취약점이 있다.
if (strcmp($_POST['password'], $password[]) == 0)
password를 배열로 만들어주면 취약점이 완성된다.
배열로 만들어주고 입력 칸에 아무거나 넣어주면 플래그를 얻을 수 있다.
플래그 값 : 82f65dc251ed45b5f79702fa8db0dcaa16856309
반응형