登录注入实例
提示:了解Mysql和php可能更容易理解
构造Mysql语句时利用一些方法使某些不应该返回的数据返回或者执行某种不该执行的命令 这个过程就叫注入
那我们来举个例子:
$sql='select * from users where userName='$userName' and password='$password';
代码逻辑(建议阅读)来自: https://blog.csdn.net/qq_39630587/article/details/79768838
假如我们想登录username为1的用户
我们应该怎么构建的sql语句???
如下例子
select * from users where userName=1 and password=正确密码
select * from users where userName=1
当然我们不知道正确密码我们可以试试第二种怎么实现(屏蔽 and password=xxx
mysql怎么实现注释屏蔽那?? 答案就是#号就是注释号 # 后面的内容都被注释 yes!! 我们找到了 现在开始构造语句
select * from users where userName=1 # and password=xxx
这个语句等效于
select * from users where userName=1
那么我们怎么又不是去提交sql语句给后端
我们看看后端代码
<?php
include_once("function/database.php");
// $userName = $_