合肥市高新區(qū)長江西路與科學(xué)大道交口5F創(chuàng)業(yè)園A座309
136 5560 1775

網(wǎng)站首頁被篡改 Thinkphp5.0.0~5.0.23遠(yuǎn)程代碼執(zhí)行漏洞修復(fù)

發(fā)表日期:2019-08-12 瀏覽次數(shù):65535次

最近發(fā)現(xiàn)多個Thinkphp5開發(fā)的網(wǎng)站被掛馬,導(dǎo)致首頁被篡改,其他頁面無法正常訪問的情況。

木馬中均包含以下代碼:define('Viv, bebegim.','Denzel-你的英雄');

經(jīng)過檢查,這些攻擊是利用了Thinkphp5.0.0~5.0.23版本遠(yuǎn)程進(jìn)行代碼調(diào)用的漏洞進(jìn)行的getshell。
Thinkphp5官方已經(jīng)發(fā)布了安全更新版本:ThinkPHP5.0.24版本發(fā)布——安全更新
你可以將版本更新到5.0.24版本及以上。

如果不方便更新到最新版本,那么可以按照最新版本的Request類的method方法進(jìn)行手動修復(fù),具體如下:

1.打開/thinkphp/library/think/Request.php文件,找到method方法(約500行),修改下面代碼:
$this->method = strtoupper($_POST[Config::get('var_method')]);
$this->{$this->method}($_POST);

改為:

$method = strtoupper($_POST[Config::get('var_method')]);

if (in_array($method, ['GET', 'POST', 'DELETE', 'PUT', 'PATCH'])) {
$this->method = $method;
$this->{$this->method}($_POST);
} else {
$this->method = 'POST';
}
unset($_POST[Config::get('var_method')]);

2.再在 /thinkphp/library/think/App.php這里加上如下代碼,搜索“獲取控制器名”可以找到
$controller = strip_tags($result[1] ?: $config['default_controller']);
$controller = $convert ? strtolower($controller) : $controller;
改成
$controller = strip_tags($result[1] ?: $config['default_controller']);
if (!preg_match('/^[A-Za-z](\w|\.)*$/', $controller)) {
throw new HttpException(404, 'controller not exists:' . $controller);
}
$controller = $convert ? strtolower($controller) : $controller;

將文章分享到:

版權(quán)所有:啟邁科技-合肥網(wǎng)站建設(shè) 皖I(lǐng)CP備19009304號-1 皖公網(wǎng)安備 34010402702162號

網(wǎng)站建設(shè),網(wǎng)站設(shè)計(jì)公司啟邁科技,為眾多企業(yè)提供網(wǎng)站建設(shè),網(wǎng)站制作,響應(yīng)式網(wǎng)站設(shè)計(jì),手機(jī)網(wǎng)站建設(shè),微網(wǎng)站,模板建站,企業(yè)郵箱等一站式互聯(lián)網(wǎng)解決方案和建站服務(wù)10年。