[Wargame.kr] type confusion 풀이 (282p)
Wargame/wargame.kr

[Wargame.kr] type confusion 풀이 (282p)

type confusion view-source code

Simple Compare Challenge.
hint? you can see the title of this challenge.
:D

<?php
 if (isset($_GET['view-source'])) {
     show_source(__FILE__);
    exit();
 }
 if (isset($_POST['json'])) {
     usleep(500000);
     require("../lib.php"); // include for auth_code function.
    $json = json_decode($_POST['json']);
    $key = gen_key();
    if ($json->key == $key) {
        $ret = ["code" => true, "flag" => auth_code("type confusion")];
    } else {
        $ret = ["code" => false];
    }
    die(json_encode($ret));
 }

 function gen_key(){
     $key = uniqid("welcome to wargame.kr!_", true);
    $key = sha1($key);
     return $key;
 }
?>

쉽게 설명하면, gen_key에서 만들어지는 sha1 랜덤 값과, 입력한 json->key 값이 같아야한다.

==로 느슨한 비교를 하니, if문을 참으로 만들어주면 될 듯하다.

문자열은 항상 참이므로, TRUE에 맞는 값을 Burp Suite를 이용해 넣어주자.