6

thinkphp3.2_find_select_delete注入

 2 years ago
source link: https://xz.aliyun.com/t/2631
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

thinkphp3.2_find_select_delete注入

phpoop / 2018-08-24 19:04:35 / 浏览数 10472 安全技术 漏洞分析 顶(1) 踩(0)

推荐水泡泡师傅的分析感觉比我清楚:https://xz.aliyun.com/t/2629

0x00 简介

已下是阅读须知
本文所用框架是官方Thinkphp3.2.3

好没了,又不是BB机,没有那么多的骚话=-=

0x01 下载安装测试代码

下载地址:http://www.thinkphp.cn/download/610.html

自己配置一下数据库路径:test_thinkphp_3.2.3\Application\Common\Conf\config.php

自己安装,安装完以后:访问一下
http://test_thinkphp_3.2.3.test/index.php/Home/Index/index
没报错就是成功

开启debug 方便本地测试
路径:test_thinkphp_3.2.3\index.php

路径:test_thinkphp_3.2.3\Application\Common\Conf\config.php

0x02 thinkphp3.2 find/select/delete注入演示

3处注入利用方法都是一样的,所以就演示一个 find 注入
Select 与 delete 注入同理

0x03 注意点

因为我们例子使用的是TP的I函数而 I函数在不指定第三个参数的情况下会默认经过
Htmlspecialchars 所以 “ > < 都会给转义成实体编码 这就导致了盲注的麻烦

所以如果你们是要盲注的话,就不能使用 > < “

如果他是指定了第三个参数
例如:
I(‘GET.test’, ‘’, ‘trim’) 这样指定第三个参数,那么你就可以想怎么注入怎么注入

0x04 漏洞成因

我们先跟进去 find 查看

路径:ThinkPHP\Library\Think\Model.class.php
搜索:function find(

路径:ThinkPHP\Library\Think\Model.class.php
搜索:function _parseOptions(

上图中的各种判断,在实际是根本不走的,就算走了也根本无所谓,不影响漏洞使用。所以我们继续跟进

这里重新打开文件: ThinkPHP\Library\Think\Model.class.php
搜索:function find(

打开文件:ThinkPHP\Library\Think\Db\Driver.class.php
搜索:function select(

打开文件:ThinkPHP\Library\Think\Db\Driver.class.php
搜索:function parseSql(

0x05 题外话

通过我们前面的一顿分析我们可以得出漏洞的主要原因是因为
$this->_parseOptions($options);
方法进行了 参数合并而最终又没有二次校验导致的任意注入

而论影响的话。
路径:ThinkPHP\Library\Think\Model.class.php

其中真的可以利用的地方只有6处
delete 方法 第一个参数可外部控制时可注入
select 方法 第一个参数可外部控制时可注入
find 方法 第一个参数可外部控制时可注入

Add 方法 第二个参数可外部控制时可注入
addAll 方法 第二个参数可外部控制时可注入
save 方法 第二个参数可外部控制时可注入

水文-thinkphp3.2_find_select_delete注入分析.zip (1.614 MB) 下载附件
点击收藏 | 2 关注 | 1

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK