本题重点:(1)php相关函数 ;(2)会灵活运用 group by 和 with rollup;

        if (!$con)         {             die('Could not connect: ' . mysqli_error());         } // 判断数据库是否连接成功

        if(strlen($username)!=strlen(replaceSpecialChar($username))){             die("sql inject error");         }         if(strlen($password)!=strlen(replaceSpecialChar($password))){             die("sql inject error");         } // 把 $username 与 $password 过滤                  $sql="select * from user where username = '$username'";         $result=mysqli_query($con,$sql);             if(mysqli_num_rows($result)>0){                     while($row=mysqli_fetch_assoc($result)){                         if($password==$row['password']){                             echo "登陆成功
";                             echo $flag;                         }

                     }             }     ?>

① group by

不加 group by 时的输出如下:

 

在使用 group by 以后会按照 password 中的值进行排列:

在使用 group by 以后会按照 password 中的值进行排列:

 

② with rollup (group by 后可以跟with rollup,表示在进行分组统计的基础上再次进行汇总统计)

统计group by一个有多少个

username=admin'/**/or/**/1=1/**/group/**/by/**/password/**/with/**/rollup#&password=

因为加入with rollup后 password有一行为NULL,我们只要输入空密码使得(NULL==NULL)即可满足$password==$row['password']的限制成功登陆。

相关文章

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。