old-46 -- SQLi (String Formats)

URL: https://webhacking.kr/challenge/web-23/?view_source=1arrow-up-right

old-46.png
<?php if ($_GET["lv"]) {
    $db = dbconnect();
    $_GET["lv"] = addslashes($_GET["lv"]);
    $_GET["lv"] = str_replace(" ", "", $_GET["lv"]);
    $_GET["lv"] = str_replace("/", "", $_GET["lv"]);
    $_GET["lv"] = str_replace("*", "", $_GET["lv"]);
    $_GET["lv"] = str_replace("%", "", $_GET["lv"]);
    if (preg_match("/select|0x|limit|cash/i", $_GET["lv"])) {
        exit();
    }
    $result = mysqli_fetch_array(
        mysqli_query($db, "select id,cash from chall46 where lv=$_GET[lv]")
    );
    if ($result) {
        echo "{$result["id"]} information<br><br>money : {$result["cash"]}";
        if ($result["id"] == "admin") {
            solve(46);
        }
    }
} ?> 
old-46-1.png

Code used to generate payload:

Last updated