[第五空间 2021]yet_another_mysql_injection

POC

题型属于Qunie构造形注入(payload===password)

构造挺麻烦的,所以我写了一个脚本

解这道题的过程

首先查看网页源码,得知

得到网站源码如下

<?php

include_once("lib.php");

function alertMes($mes,$url){

    die("<script>alert('{$mes}');location.href='{$url}';</script>");

}



function checkSql($s) {

    if(preg_match("/regexp|between|in|flag|=|>|<|and|\||right|left|reverse|update|extractvalue|floor|substr|&|;|\\\$|0x|sleep|\ /i",$s)){

        alertMes('hacker', 'index.php');

    }

}



if (isset($_POST['username']) && $_POST['username'] != '' && isset($_POST['password']) && $_POST['password'] != '') {

    $username=$_POST['username'];

    $password=$_POST['password'];

    if ($username !== 'admin') {

        alertMes('only admin can login', 'index.php');

    }

    checkSql($password);

    $sql="SELECT password FROM users WHERE username='admin' and password='$password';";

    $user_result=mysqli_query($con,$sql);

    $row = mysqli_fetch_array($user_result);

    if (!$row) {

        alertMes("something wrong",'index.php');

    }

    if ($row['password'] === $password) {

        die($FLAG);

    } else {

    alertMes("wrong password",'index.php');

  }

}



if(isset($_GET['source'])){

  show_source(__FILE__);

  die;

}

?>

<!-- /?source -->

<html>

    <body>

        <form action="/index.php" method="post">

            <input type="text" name="username" placeholder="账号"><br/>

            <input type="password" name="password" placeholder="密码"><br/>

            <input type="submit" / value="登录">

        </form>

    </body>

</html>

仔细审阅后,发现有回现,报错,盲注基本上都不行,实际上可以用like进行盲注,但我不会

这题就是让来构造Qunie的

 

EXP

直接上我写好的脚本跑一下就行了

=Qunie构造脚本(payload==password).py