http://chinalover.sinaapp.com/index.php

题解:

<html>
<head>
Secure Web Login
</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 = trim($_POST[user]);
  $pass = md5(trim($_POST[pass]));
  $sql="select user from ctf where (user='".$user."') and (pw='".$pass."')";
    echo '</br>'.$sql;
  $query = mysql_fetch_array(mysql_query($sql));
  if($query[user]=="admin") {
      echo "<p>Logged in! flag:******************** </p>";
  }
  if($query[user] != "admin") {
    echo("<p>You are not admin!</p>");
  }
}
echo $query[user];
?>
<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>

题目有两个输入框,一个user一个密码,要求user为admin,所以要想办法避免密码的验证,看源码

$sql="select user from ctf where (user='".$user."') and (pw='".$pass."')"

可以在输入的user做手脚,把后面的注释掉,同时别忘了闭合这一语句,输入 admin‘)#即可,因为#后面都被注释了,原来的后括号也没了,所以要补上括号。

select user from cft where (user='admin ‘)#') and (pw='pass')