Advertisement
Guest User

Untitled

a guest
Mar 15th, 2015
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.63 KB | None | 0 0
  1. <?php
  2.  
  3.     header("Pragma-directive: no-cache");
  4.     header("Cache-directive: no-cache");
  5.     header("Cache-control: no-cache");
  6.     header("Pragma: no-cache");
  7.     header("Expires: 0");
  8.    
  9.     $userid = '832960'; // User id from cookie
  10.     $password = ''; // Password from cookie
  11.  
  12.     function encodeURIComponent($str) {
  13.         $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')');
  14.         return strtr(rawurlencode($str), $revert);
  15.     }
  16.    
  17.     function CURL($url, $settings = null, $posts = null, $cookies = null, $cb = null) // Renew function to a class (for default cookies/ and others)
  18.     {
  19.         $curl = curl_init($url);
  20.         curl_setopt($curl, CURLOPT_TIMEOUT, 20);
  21.        
  22.         if (!empty($settings) && is_array($settings))
  23.         {
  24.             curl_setopt_array($curl, $settings);
  25.         }
  26.        
  27.         if (!empty($posts) && is_array($posts))
  28.         {
  29.             $postsdata = http_build_query($posts);
  30.            
  31.             curl_setopt($curl, CURLOPT_POST, true);
  32.             curl_setopt($curl, CURLOPT_POSTFIELDS, $postsdata);
  33.         }
  34.        
  35.         if (!empty($cookies) && is_array($cookies))
  36.         {
  37.             $cookiesdata = http_build_query($cookies, null, ';');
  38.            
  39.             curl_setopt($curl, CURLOPT_COOKIE, $cookiesdata);
  40.         }
  41.        
  42.         $data = curl_exec($curl);
  43.        
  44.         if (is_callable($cb))
  45.         {
  46.             $cb($curl, $data);
  47.         }
  48.        
  49.         curl_close($curl);
  50.        
  51.         return $data;
  52.     }
  53.    
  54.     if (!empty($_SERVER['HTTP_REFERER']))
  55.     {
  56.         $cookie_file = './rz_cookies.cjar';
  57.         $referer_cookies = array();
  58.         $referer_page = CURL(
  59.             $_SERVER['HTTP_REFERER'], // referer
  60.             array(
  61.                 CURLOPT_FOLLOWLOCATION => true,
  62.                 CURLOPT_RETURNTRANSFER => true,
  63.                 CURLOPT_HEADER => true,
  64.                
  65.                 CURLOPT_COOKIEJAR => $cookie_file,
  66.                 CURLOPT_COOKIEFILE => $cookie_file,
  67.                
  68.                 CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
  69.             ),
  70.             null,
  71.             array(
  72.                 'rz_userid' => $userid,
  73.                 'rz_password' => $password
  74.             ),
  75.             function($curl, $content) use ($referer_cookies) {
  76.                 $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
  77.                 $headers = substr($content, 0, $header_size);
  78.                 if (preg_match_all('/Set-Cookie:(?<cookie>\s{0,}.*)$/im', $content, $cookies))
  79.                 {
  80.                     foreach ($cookies['cookie'] as $cookie)
  81.                     {
  82.                         preg_match('/(?P<name>[^=]*)=(?P<value>[^;]*)(.*?expires=(?P<expires>[^;]*)|).*?path=(?P<path>[^;]*).*?domain=(?P<domain>[^\s;]*).*?$/im', $cookie, $match);
  83.                         $referer_cookies[$match['name']] = $match['value'];
  84.                     }
  85.                 }
  86.             }
  87.         );
  88.        
  89.         if (preg_match('/content.incapsula.com\/jsTest.html/', $referer_page))
  90.         {
  91.             header('X-Debug-Validate: 0');
  92.             // request validation simulation start \\
  93.            
  94.             // PART #1 \\
  95.            
  96.             $incap_test_result = 'navigator%3Dobject,navigator.vendor%3DGoogle%20Inc.,opera%3DReferenceError%3A%20opera%20is%20not%20defined,ActiveXObject%3DReferenceError%3A%20ActiveXObject%20is%20not%20defined,navigator.appName%3DNetscape,plugin%3Ddll,webkitURL%3Dfunction,navigator.plugins.length%3D%3D0%3Dfalse,_phantom%3DReferenceError%3A%20_phantom%20is%20not%20defined'; // Google Chrome Versie 40.0.2214.111 m localhost result
  97.            
  98.             $incap_session_cookies = array_filter($referer_cookies, function($v, $key) {
  99.            
  100.                 return preg_match('/^incap_ses_/', $key);
  101.             });
  102.            
  103.             if (empty($incap_session_cookies))
  104.             {
  105.                 header('X-Debug-Validate: 1');
  106.                
  107.                 exit;
  108.             }
  109.            
  110.             $incap_session_cookies = array_values($incap_session_cookies);
  111.             $digests = array_fill(0, count($incap_session_cookies), 'undefined');
  112.             for ($i = 0; $i < $incap_session_cookies; $i++)
  113.             {
  114.                 $result = 0;
  115.                 $data = $incap_test_result + $incap_session_cookies[$i];
  116.                 for ($j = 0; $j < strlen($data); $j++)
  117.                 {
  118.                     $result += ord($data[$j]);
  119.                 }
  120.                
  121.                 $digests[i] = $result;
  122.             }
  123.            
  124.             $incap_test_result = $incap_test_result . ',digests=' . implode(',', $digests);
  125.            
  126.             if (!preg_match('/document\.createElement\("img"\)\.src\="(.*)+"\+Math\.random\(\)/', $referer_page, $match))
  127.             {
  128.                 header('X-Debug-Validate: 2');
  129.                
  130.                 exit;
  131.             }
  132.            
  133.             $resource = $match[1];
  134.            
  135.             header('X-Debug-Resource: ' . $resource);
  136.            
  137.             CURL(
  138.                 'http://forum.ragezone.com' . $resource . time(),
  139.                 array(
  140.                     CURLOPT_FOLLOWLOCATION => true,
  141.                     CURLOPT_RETURNTRANSFER => true,
  142.                    
  143.                     CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT']
  144.                 ),
  145.                 null,
  146.                 array(
  147.                     '___utmvc' => $incap_test_result
  148.                 )
  149.             );
  150.             // request http://forum.ragezone.com/_Incapsula.... with encoded cookie +  incap_ses cookie
  151.            
  152.             // PART #2 \\
  153.            
  154.             if (!preg_match('/var b="(.*)+";/', $referer_page, $match))
  155.             {
  156.                 header('X-Debug-Validate: 3');
  157.                
  158.                 exit;
  159.             }
  160.            
  161.             $hexdata = $match[1];
  162.            
  163.             $js_code = '';
  164.             for ($i = 0; $i < strlen($hexdata); $i += 2)
  165.             {
  166.                 $hex = substr($hexdata, $i, $i + 2);
  167.                 $js_code .= chr(hex2dec($hex));
  168.             }
  169.            
  170.             $timing = ['s:5','c:10','r:15'];
  171.             $status = 'complete';
  172.            
  173.             // onunload url
  174.             if (!preg_match('/document\.createElement\("img"\)\.src="(.*)+"\+encodeURIComponent\(/', $js_code, $match))
  175.             {
  176.                 header('X-Debug-Validate: 4');
  177.                
  178.                 exit;
  179.             }
  180.            
  181.             $onunload_url = $match[1] . encodeURIComponent($status . '(' . implode(',', $timing) . ')');
  182.            
  183.             if (!preg_match('/xhr\.open\("GET","(.*)+",false\);/', $js_code, $match))
  184.             {
  185.                 header('X-Debug-Validate: 5');
  186.                
  187.                 exit;
  188.             }
  189.            
  190.             $xhr_url = $match[1];
  191.            
  192.             // PART #3 \\
  193.            
  194.             CURL(
  195.                 'http://content.incapsula.com/jsTest.html',
  196.                 array(
  197.                     CURLOPT_RETURNTRANSFER => true,
  198.                    
  199.                     CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT']
  200.                 )
  201.             );
  202.            
  203.             // PART #4 \\
  204.            
  205.             CURL(
  206.                 $xhr_url,
  207.                 array(
  208.                     CURLOPT_RETURNTRANSFER => true,
  209.                    
  210.                     CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT']
  211.                 )
  212.             );
  213.            
  214.             sleep(15);
  215.            
  216.             CURL(
  217.                 $onunload_url,
  218.                 array(
  219.                     CURLOPT_RETURNTRANSFER => true,
  220.                    
  221.                     CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT']
  222.                 )
  223.             );
  224.            
  225.             //header('Location: https://www.jospiek.nl/image.php');
  226.             //exit;
  227.            
  228.             $referer_page = CURL(
  229.                 $_SERVER['HTTP_REFERER'], // referer
  230.                 array(
  231.                     CURLOPT_FOLLOWLOCATION => true,
  232.                     CURLOPT_RETURNTRANSFER => true,
  233.                    
  234.                     CURLOPT_COOKIEJAR => $cookie_file,
  235.                     CURLOPT_COOKIEFILE => $cookie_file,
  236.                    
  237.                     CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT']
  238.                 ),
  239.                 null,
  240.                 array(
  241.                     'rz_userid' => $userid,
  242.                     'rz_password' => $password
  243.                 )
  244.             );
  245.            
  246.             // request referer page again!
  247.         }
  248.         else
  249.         {
  250.             header('X-Debug-Validate: -1');
  251.         }
  252.     }
  253.     else
  254.     {
  255.         $referer_page = 'x]';
  256.     }
  257.    
  258.     header('X-Debug: 0');
  259.  
  260.     header('Content-Type: image/png');
  261.    
  262.     if (preg_match('/\/\/forum.ragezone.com\/f/', $_SERVER['HTTP_REFERER']) && preg_match('/<ol class="commalist">/', $referer_page))
  263.     {
  264.         header('X-Debug: 1');
  265.    
  266.         $usernames = array();
  267.         if (preg_match_all('/<li><a class="username" href="http:\/\/forum\.ragezone\.com\/members\/[0-9]+\.html">(.*?)<\/a>(, |\+, |)<\/li>/', $referer_page, $matches))
  268.         {
  269.             foreach ($matches[1] as $username)
  270.             {
  271.                 $username = str_replace('&nbsp;', '', strip_tags($username));
  272.            
  273.                 array_push($usernames, $username);
  274.             }
  275.         }
  276.        
  277.         $im = imagecreatetruecolor(400,100);  
  278.         $almostblack = imagecolorallocate($im,254,254,254);  
  279.         imagefill($im,0,0,$almostblack);  
  280.         $black = imagecolorallocate($im,0,0,0);  
  281.         $white = imagecolorallocate($im,255,255,255);  
  282.         $xd = imagecolorallocate($im,50,51,4);  
  283.         imagecolortransparent($im,$almostblack);
  284.        
  285.         imagettftext($im, 10, 0, 10, 20, $black, './arial.ttf', "People on this thread: \r\n" . chunk_split(implode(', ', $usernames), 60));
  286.        
  287.         imagepng($im);
  288.         imagedestroy($im);
  289.     }
  290.     else
  291.     {
  292.         echo file_get_contents('http://www.shedworx.com/files/images/error.png');
  293.     }
  294.    
  295.     // Generate the PHPGD image!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement