最近一段時間很多使用pbootcms建設(shè)的網(wǎng)站都遭遇到了掛馬的問題,表現(xiàn)形式便是頁面增加了很多?id=123,?/?id=55662567.csv,?id=55674554.shtml 等等形態(tài)。當(dāng)我們查看后臺系統(tǒng)日志中的蜘蛛訪問或者首頁上多了這些鏈接的時候,基本上就是被掛馬了,這個時候我們需要及時作出處理要不然就容易被百度降權(quán)甚至嚴(yán)重的時候會被關(guān)站。
備注:本次掛馬應(yīng)該是程序自動掛馬,很多使用pbootcms的網(wǎng)站都在短時間范圍內(nèi)受到了攻擊。
處理步驟:
1)替換apps以及core文件,如果本地沒有備份保存,那么可以選擇升級到最近版本,目前官方也根據(jù)這個問題進(jìn)行了更新處理.
2)修改robots.txt文件添加針對首頁問題的拒絕訪問規(guī)則
# Robots
Disallow: /admin/*
Disallow: /skin/
Disallow: /template/
Disallow: /static/*
Disallow: /api/*
Disallow: /?*
3) 修改源碼,在apps/home/controller/IndexController.php 文件中添加針對首頁帶參數(shù)問題的處理。代碼大概在200行以后找到//一級目錄這里,在上方添加
if(strstr(URL,"?")){ _404('您訪問的路徑錯誤,請核對后重試!'); } |
如下:在這里的后方加上else流程,進(jìn)入主頁流程的操作,同時加上urlJump方法(或者升級到最新版本以后再進(jìn)行修改)
urlJump方法
//首頁跳轉(zhuǎn)并過濾注入字符 /* * @param $type url模式 * @param $isSecSiteDir 是否為二級目錄 boolean * */ private function urlJump($type, $isSecSiteDir){ $http = is_https() ? 'https://' : 'http://'; $matches1 = ''; switch ($type){ //普通模式 case 1: $preg1 = ''; if($isSecSiteDir === true){ if($_SERVER['REQUEST_URI'] == SITE_DIR . '/index.php'){ $preg1 = '/^/.*?/index.php/'; } elseif($_SERVER['REQUEST_URI'] == '/index.php'){ $preg1 = '/^/index.php/'; } } else { $preg1 = '/^/index.php/'; } preg_match($preg1,$_SERVER['REQUEST_URI'],$matches1); break; //偽靜態(tài) case 2: $preg2 = ''; if($isSecSiteDir === true){ if($_SERVER['REQUEST_URI'] == SITE_DIR . '/'){ $preg2 = '/^/.*/'; } elseif($_SERVER['REQUEST_URI'] == '/'){ $preg2 = '/^/$/'; } } else { $preg2 = '/^/.*/'; } preg_match($preg2,$_SERVER['REQUEST_URI'],$matches1); break; //兼容模式 case 3: $preg3 = ''; if($isSecSiteDir === true){ if(strpos($_SERVER['REQUEST_URI'], SITE_DIR) === 0){ $preg3 = '/(^/.*?/index.php)|(^/.*)/'; } elseif(strpos($_SERVER['REQUEST_URI'], '/') === 0){ $preg3 = '/(^/index.php)|(^/)/'; } } else { $preg3 = '/(^/index.php)|(^/)/'; } preg_match($preg3,$_SERVER['REQUEST_URI'],$matches1); break; } if($matches1[0]){ if($_SERVER['REQUEST_URI'] == $matches1[0]){ $this->getIndexPage(); } else { header("Location: " . $http . $_SERVER['HTTP_HOST'] . $matches1[0], true, 301); } } else { _404('您訪問的頁面不存在,請核對后重試!'); } } |
通過以上三步基本上就可以杜絕本次批量被掛馬的問題,后續(xù)就是要加強服務(wù)器上的安全驗證的問題了.
=======================分割線。