Php webgrabber

11/18/2014 01:11 UND3RW0RLD#1
Hey here is a little toy. If you want to piss off bp you can mirror their loginpage. This saves you much time, because you get their updates instantly

PHP Code:
function getWebContents($url)
{
  
$parse parse_url($url);
  if(!
$parse || !isset($parse['host'])) 
  {
    return 
false;
  }

  
$host $parse['host'];
  
$port = isset($parse['port']) ? $parse['port'] : ($parse['scheme'] == 'http' 80 443);
  
$pfad = isset($parse['path']) ? $parse['path'] : '/';
  
  if (isset(
$parse['query']))
  {
    
$query = array();
    
$parse['query'] = explode("&",urldecode($parse['query']));
    foreach (
$parse['query'] as $entry)
    {
      
$entry explode("=",$entry);
      
$query[] = $entry[0]."=".urlencode($entry[1]);
    }
    
$parse['query'] = implode("&",$query);
  }
    
  
$ConnectionHandle = @fsockopen(($port != 443 $host 'ssl://' $host), $port$errno$errstr2);
  
  if(!
$ConnectionHandle) {
    return 
false;
  }
  
  
$request   = array();  
  
$request[] = "GET ".$pfad.(isset($parse['query'])?"?".$parse['query']:"")." HTTP/1.1";
  
$request[] = "Host: ".$host;
  
$request[] = "User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)";
  
$request[] = "Accept: text/html,text/plain";
  
$request[] = "Accept-Language: en-us,en;q=0.5";
  
$request[] = "Accept-Encoding: deflate";
  
$request[] = "Accept-Charset: ISO-8859-1";
  
$request[] = "Connection: close";
  
  
$request implode("\r\n",$request)."\r\n\r\n";
  
  
fputs ($ConnectionHandle$request);

  
$retr "";
  while (!
feof($ConnectionHandle)) 
  {
    
$retr .= fgets($ConnectionHandle128);
  }  
  
  
fclose($ConnectionHandle);

  
$pos strpos($retr"\r\n\r\n");
  
$header substr($retr0$pos); 
  
$header explode("\r\n"$header);
    
  
$status explode(" ",$header[0]);
    
  
$http $status[0];
  unset(
$status[0]);
  unset(
$header[0]);
    
  
$h = array();
  
$h[$http] = implode(" ",$status);  
    
  foreach(
$header as $i)
  {
    
$i explode(":",$i);
    
$h[trim($i[0])] = trim($i[1]);
  } 
  
  
$content substr($retr$pos 4);
  
  
$content str_replace(array("ö""ä""ü""ß""Ö",  "Ä""Ü""é""Â"),
           array(
"ö""ä""ü",  "ß""Ö""Ä""Ü","é"), 
           
$content);
  
  return array(
"header" => $h"content" => $content);

this generates an output like: (example google)
Code:
array(2) {
  ["header"]=>
  array(8) {
    ["HTTP/1.0"]=>
    string(6) "200 OK"
    ["Date"]=>
    string(19) "Mo, 17 Nov 2014 19"
    ["Expires"]=>
    string(2) "-1"
    ["Cache-Control"]=>
    string(18) "private, max-age=0"
    ["Content-Type"]=>
    string(24) "text/html; charset=UTF-8"
    ["Set-Cookie"]=>
    string(164) "NID=51=R3n-Ek-42HTVUVUk7a4xm3VQA1p-TAt5ZRPCabzgiAAEJt1xcpay84rooJHsy8yGK1n5dg-ULoCsLKYqFHJjddtQRkC63aPXV-zS1AFgYmLGkgLDVaekiox0QsLF9Zhz; expires=Sat, 07-Apr-2015 19"
    ["Server"]=>
    string(3) "gws"
    ["X-XSS-Protection"]=>
    string(13) "1; mode=block"
  }
  ["content"]=>
  string(29765) "<!doctype html><html>... (ripped)"
}
if you call it like:
PHP Code:
$data getWebContents("http://www.google.de"); 
PHP Code:
echo $data["content"]; 
to handle forms you can use str_replace. This ofc forces you to make own processingpages like "takesignup".

or if you want to mirror pages like "choosefaction" too you have to extend the array $request with
PHP Code:
// vBulletin-board-default setting
$request[] = "Cookie: bblastvisit=0; bblastactivity=0"
the possibities to use this script are endless not only for dark orbit. :)
11/18/2014 20:56 Luffa#2
i should not comment on anything at epvp.
But awesome job :D

Best Regards