rendered paste body<?phpdefine("PROXY_SUFFIX", ".6a.nl"); // domain name suffix to reply fordefine("PROXY_HOME","www.google.com"); /*// Author: Maurits van der Schee// License: GPL$ cat /etc/apache2/sites-available/zesa<VirtualHost *:80>DocumentRoot /home/zesa/public_htmlServerName 6a.nlServerAlias *.6a.nl</VirtualHost>$ cat /home/zesa/public_html/.htaccess RewriteCond %{HTTP_HOST} ^www.6a.nl$RewriteRule ^(.*) http://6a.nl/$1 [R=301,L]RewriteCond %{HTTP_HOST} !^6a.nl$RewriteCond %{REQUEST_URI} !^/browse.phpRewriteCond %{REQUEST_URI} !^/robots.txt$RewriteRule .* /browse.php [L]issues-certificate error (in IE even after install as root CA)-login in to gmailshould be implemented-multipart/form-data (file upload)is implemented-cookies (should be optional?)-dns proxy-https (optional)-x-forwarded-for header (should be optional?)should (probably) not be implemented-crossdomain policy file-banner replacement (adsense) buss model?*/function parse_headers($lines){ $headers = array(); while (count($lines)>0) { $line = trim(array_shift($lines)); if ($line=='') break; $seppos = strpos($line,':'); $name = trim(substr($line,0,$seppos)); $value = trim(substr($line,$seppos+1)); if ($headers[$name]) { if (!is_array($headers[$name])) { $headers[$name] = array($headers[$name]); } array_push($headers[$name],$value); } else $headers[$name]=$value; } return $headers;}function parse_chunked($chunked){ $data = ''; $startpos = 0; while ($startpos<strlen($chunked)) { $new_startpos = strpos($chunked,"\r\n",$startpos)+2; $length = hexdec(rtrim(substr($chunked, $startpos, $new_startpos-$startpos))); $data .= substr($chunked, $new_startpos, $length); $startpos = $new_startpos + $length; } return $data;}function get_request($method, $host, $url, $data){ $headers = array(); array_push($headers, $method.' '.$url.' HTTP/1.1'); array_push($headers, 'Host: '.$host); array_push($headers, 'User-Agent: '.$_SERVER['HTTP_USER_AGENT']); if ($method=='POST') { array_push($headers, 'Content-Type: '.$_SERVER['CONTENT_TYPE']); array_push($headers, 'Content-Length: '.$_SERVER['CONTENT_LENGTH']); } array_push($headers, 'Accept: '.$_SERVER['HTTP_ACCEPT']); array_push($headers, 'Accept-Language: '.$_SERVER['HTTP_ACCEPT_LANGUAGE']); array_push($headers, 'Accept-Charset: '.$_SERVER['HTTP_ACCEPT_CHARSET']); if ($_SERVER['HTTP_COOKIE']) array_push($headers, 'Cookie: '.$_SERVER['HTTP_COOKIE']); array_push($headers, 'Referer: '.$_SERVER['HTTP_REFERER']); //$req_headers = apache_request_headers(); //if (array_key_exists('X-Forwarded-For', $req_headers)) $forwarded_for=$req_headers['X-Forwarded-For'].', '.$_SERVER['REMOTE_ADDR']; if ($_SERVER['HTTP_X-FORWARDED-FOR']) $forwarded_for=$_SERVER['HTTP_X-FORWARDED-FOR'].', '.$_SERVER['REMOTE_ADDR']; else $forwarded_for=$_SERVER['REMOTE_ADDR']; array_push($headers, 'X-Forwarded-For: '.$forwarded_for); array_push($headers, 'Connection: close'); array_push($headers, ''); array_push($headers, $data); return join("\r\n",$headers);}function log_txt($data){ $log = fopen('log.txt', 'a'); fwrite($log, date(DATE_RFC822)." - ".$data."\n"); fclose($log);}function proxy($method,$url){ $url = parse_url($url); $scheme = $url['scheme']; $host = $url['host']; if ($url['port']) $port = $url['port']; else $port = ($scheme=='http'?80:443); $path = $url['path']; $query = $url['query']; if ($query) $query='?'.$query; $data = file_get_contents('php://input'); $data = get_request($method,$host,$path.$query,$data); $ip = gethostbyname($host.'.'); if ($ip==$host.'.') { echo "Could not resolve host '$host'"; exit; } $fp = @fsockopen(($scheme=='https'?'ssl://':'').$ip, $port, $errno, $errstr, 5); if ($fp===false){ echo "$errno $errstr"; exit; } fwrite($fp,$data); /*weird bug*/ $old_errorlevel = error_reporting(1); $data = stream_get_contents($fp); /*weird bug*/ error_reporting($old_errorlevel); fclose($fp); $p = strpos($data,"\r\n\r\n"); $lines = split("\r\n",substr($data,0,$p)); $status = trim(array_shift($lines)); $headers = parse_headers($lines); $data = substr($data,$p+4); $transfer_encoding = $headers['Transfer-Encoding']; if ($transfer_encoding=="chunked") $data = parse_chunked($data); return array('status'=>$status,'headers'=>$headers,'data'=>$data);} function strends($string,$suffix){ return substr($string,-1*strlen($suffix))==$suffix;}function add_warning($matches){ return $matches[1].'<div style="z-index:9999;left:0;top:0;position:fixed;"><a href="#" style="text-decoration:none;font-family: sans-serif;font-weight:bold;font-size:12px;background-color:#770000;color:white;padding:2px;" onclick="this.style.visibility=\'hidden\';">Warning: You are visiting this site through a proxy</a></div>';}function url_rewrite($matches){ if ($_COOKIE['dontcensorme_ssl']) $matches[1]='https'; $url = $matches[1].$matches[2].$matches[3]; if (!strends($url, PROXY_SUFFIX)) $url.=PROXY_SUFFIX; return $url;}function domain_rewrite($matches){ $url = $matches[1].$matches[2].$matches[3]; if (!strends($url, PROXY_SUFFIX)) $url.=PROXY_SUFFIX; return $url;}function rewrite($data){ $data = preg_replace_callback('/(<body[^>]*>)/i','add_warning',$data); return preg_replace_callback('/(https?)(:\/\/)([0-9a-zA-Z\.\-]+)/','url_rewrite',$data);}function rewrite_cookie($data){ return preg_replace_callback('/(domain)(=)([0-9a-zA-Z\.\-]+)/i','domain_rewrite',$data);}$method = trim(strtoupper($_SERVER['REQUEST_METHOD']));$scheme = ($_SERVER['HTTPS']?'https':'http');$host = $_SERVER['HTTP_HOST'];$requri = $_SERVER['REQUEST_URI'];if ($scheme=='http' && $_COOKIE['dontcensorme_ssl']){ header('Location: https://'.$host.$requri);}if ($scheme=='https' && $_COOKIE['dontcensorme_ssl']){ $scheme='http';}$newhost = $host;if (strends($newhost, PROXY_SUFFIX)) $newhost=substr($host,0,-1*strlen(PROXY_SUFFIX));if ('.'.$newhost==PROXY_SUFFIX){ header('Location: http://'.PROXY_HOME.PROXY_SUFFIX); exit;}$response = proxy($method,$scheme.'://'.$newhost.$requri); $redirect_url = trim($response['headers']['Location']);if ($redirect_url) { header('Location: '.rewrite($redirect_url));} $type = $response['headers']['Content-Type'];$type = strtolower(substr($type,0,strpos($type,'/')));if ($type=='text') $data = rewrite($response['data']);else $data = $response['data'];header('Content-Type: '.$response['headers']['Content-Type']);if ($response['headers']['Set-Cookie']){ $setcookie = $response['headers']['Set-Cookie']; if (is_array($setcookie)) { foreach ($setcookie as $cookie) { header('Set-Cookie: '.rewrite_cookie($cookie), false); } } else header('Set-Cookie: '.rewrite_cookie($response['headers']['Set-Cookie']));}echo $data;//echo print_r($_SERVER);//echo print_r($response['headers']);?>