# WordPress AdRotate插件 3.6.6 SQL注入漏洞分析

**URL:** <https://forum.90sec.com/t/topic/3156>\
**Category:** 代码审计\
**Created:** [2012 年1 月 18 日 09:26 UTC](https://forum.90sec.com/t/topic/3156 "2012-01-18T09:26:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

作者： ![pandas](https://forum.90sec.com/user_avatar/forum.90sec.com/pandas/32/11352_2.png) [@pandas](https://forum.90sec.com/u/pandas)\
发布日期： [2012 年1 月 18 日 09:26 UTC](https://forum.90sec.com/t/topic/3156/1 "2012-01-18T09:26:28Z")

</div>

WordPress AdRotate插件 3.6.6 SQL注入漏洞分析  
熙雅(xiya)  
[http://t.qq.com/x\_xiya](http://t.qq.com/x_xiya)  
[http://www.xiya.org](http://www.xiya.org)

系统描述:  
WordPress 是一个免费的开源项目，使用PHP+MySQL开发的博客平台，也可以把 WordPress 当作一个内容管理系统（CMS）来使用。  
官方网址:  
[http://www.wordpress.org/](http://www.wordpress.org/)  
影响版本:  
插件 AdRotate 3.6.6  
漏洞类型:  
SQL注入漏洞

漏洞分析:wp-content\plugins\adrotate\adrotate-out.php文件  
[168-USB PC Camera #2.jpg](https://forum.90sec.com/discuz-migration/attachments/c318d0795e821d2b43f02629271dfbcd14436b068d49afd5be60167b17033789)

首先判断track的值，然后把值通过base64解密出明文赋值给$meta，$meta通过explode()函数分割成一个数组，然后把这个数组进行变量赋值。然后$bannerurl开始代库查询，把我们传递的$ad代入查询。

[2.jpg](https://forum.90sec.com/discuz-migration/attachments/6a5dfb52145ecd25bb63bfdee28ae7e7e6becd2a32a569f848c1fc3ff0638cd6)  
实际测试时，自己写了一个poc测试，发现$ad已经输出我们想要的值，

[3.jpg](https://forum.90sec.com/discuz-migration/attachments/37c10178e870be0aa83c4e6e102988c47197a900ec8ce8bc66dce1f31fb86005)  
实际在phpmyadmin里查询成功.  
[4.jpg](https://forum.90sec.com/discuz-migration/attachments/1c83929c5f425a04220a2dc3b3c7225a37f7c9206ab4f86f8ce29894ca0ef861)

[5.jpg](https://forum.90sec.com/discuz-migration/attachments/14b9ab06a201b442dea3b4608d641c9f7ce30f263aaed5e6472164bc26dea136)  
代码:$bannerurl= $wpdb-\>get\_var($wpdb-\>prepare("SELECT `link` FROM`".$prefix."adrotate` WHERE `id` = '".$ad."' LIMIT1;")); 我构造的查询语句:SELECT`link` FROM `wp_adrotate` WHERE `id` = '1' UNION SELECT USER\_LOGIN fromwp\_users -- ' LIMIT 1; 其实闭合上一个查询，然后联合查询自己的语句，再注释掉后面的东西就可以了。  
[7.jpg](https://forum.90sec.com/discuz-migration/attachments/00f6ef02640bb96be2952e9982b16422f3357521e9e0028140186a8dfb6ad5c4)

利用分析：  
可能是magic\_quotes\_gpc = On 或其他什么原因导致$bannerurl为NULL  
[8.jpg](https://forum.90sec.com/discuz-migration/attachments/6195124e4449e464efe38e794c94fd8cd3e4e2134d2e68603dcccfe061b0556c)  
(注：没有发现国内有人研究与利用，此报告仅仅是代表个人研究与分析观点，可能有误，水平有限。 ^ \_ ^ 读者不明白可以跟我联系!!)

---

<div class="post-metadata">

作者： ![helen](https://forum.90sec.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@helen](https://forum.90sec.com/u/helen)\
发布日期： [2012 年1 月 25 日 00:56 UTC](https://forum.90sec.com/t/topic/3156/2 "2012-01-25T00:56:37Z")

</div>

分析的很好。很明白，3Q
