Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // debug
- error_reporting(0);
- // you know
- $maximum_proxies_to_test = 50;
- // password for page
- $password = '';
- // let's roll
- function return_env_variables()
- {
- echo '<pre>'."\n";
- foreach ($_SERVER as $header => $value )
- {
- if ((strpos($header , 'REMOTE')!== false || strpos($header , 'HTTP')!== false || strpos($header , 'REQUEST')!== false) && ( strpos($header , 'HTTP_HOST') !== 0))
- {
- echo $header.' = '.$value."\n";
- }
- }
- echo '</pre>';
- }
- // function to go away and get the page (calls through the proxy back to itself)
- function get_judge_page($proxy)
- {
- // Depending on the server environment, this timeout setting may not be available.
- $timeout = 15;
- $proxy_cont = '';
- list($proxy_host, $proxy_port) = explode(":", $proxy);
- $proxy_fp = fsockopen($proxy_host, $proxy_port, $errornumber, $errorstring, $timeout);
- if ($proxy_fp)
- {
- stream_set_timeout($proxy_fp, $timeout);
- fputs($proxy_fp, "GET " . $_SERVER['SCRIPT_NAME'] . "?test HTTP/1.0\r\nHost: " . $_SERVER['SERVER_NAME'] . "\r\n\r\n");
- while(!feof($proxy_fp))
- {
- $proxy_cont .= fread($proxy_fp,4096);
- }
- fclose($proxy_fp);
- $proxy_cont = substr($proxy_cont, strpos($proxy_cont,"\r\n\r\n")+4);
- }
- return $proxy_cont;
- }
- // check for the control string to see if it's a valid fetch of the judge
- function check_valid_judge_response($page)
- {
- if(strlen($page) < 5)
- return false;
- return strpos($page, 'REMOTE_ADDR') !== false;
- }
- // check for the IP addresses :3
- function check_anonymity($page)
- {
- if(strpos($page, $_SERVER['LOCAL_ADDR']) !== false)
- return false;
- return true;
- }
- // takes and tests a proxy
- // 0 - bad proxy
- // 1 - good (non anonymous) proxy
- // 2 - good (anonymous) proxy
- function test_proxy($proxy)
- {
- $page = get_judge_page($proxy);
- if(!check_valid_judge_response($page))
- return 0;
- if(!check_anonymity($page))
- return 1;
- return 2;
- }
- // if this is a judge request, just return the environmental variables
- if(getenv('QUERY_STRING') == "test")
- {
- return_env_variables();
- }
- // else check whether we have been passed a list of proxies to test or not
- // should really use $_POST but it's been left as $HTTP_POST_VARS for older versions of PHP
- elseif( (isset($HTTP_POST_VARS['action']) && $HTTP_POST_VARS['action'] === 'fred') &&
- (isset($HTTP_POST_VARS['proxies']) && $HTTP_POST_VARS['proxies'] != '') &&
- ( (strlen($password) == 0) || (isset($HTTP_POST_VARS['password']) && $HTTP_POST_VARS['password'] === $password) ))
- {
- $proxies = explode("\n", str_replace("\r", "", $HTTP_POST_VARS['proxies']), $maximum_proxies_to_test + 1);
- // set the overall time limit for the page execution to 10 mins
- set_time_limit(600);
- // set up some arrays to hold the results
- $anon_proxies = array();
- $nonanon_proxies = array();
- $bad_proxies = array();
- // loop through and test the proxies
- for($thisproxy = 0; $thisproxy < ($maximum_proxies_to_test > count($proxies) ? count($proxies) : $maximum_proxies_to_test); $thisproxy += 1)
- {
- $draculalol = htmlspecialchars($proxies[$thisproxy]);
- echo '' . $draculalol . '';
- flush();
- switch(test_proxy($proxies[$thisproxy]))
- {
- case 2:
- echo ' - <font color="green">Анонимная</font><br>' . "\n";
- $anon_proxies[count($anon_proxies)] = $proxies[$thisproxy];
- break;
- case 1:
- echo ' - <font color="yellow">Не анонимная</font><br>' . "\n";
- $nonanon_proxies[count($nonanon_proxies)] = $proxies[$thisproxy];
- break;
- case 0:
- echo ' - <font color="red">Не рабочая</font><br>' . "\n";
- $bad_proxies[count($bad_proxies)] = $proxies[$thisproxy];
- break;
- }
- }
- echo '<pre>';
- echo '<br><b><font color="green" size="2">Анонимные прокси:</font></b>' . "\n";
- for($thisproxy = 0; $thisproxy < count($anon_proxies); $thisproxy += 1)
- echo $anon_proxies[$thisproxy] . "\n";
- echo '<br><b><font color="yellow" size="2">Не анонимные прокси:</font></b>' . "\n";
- for($thisproxy = 0; $thisproxy < count($nonanon_proxies); $thisproxy += 1)
- echo $nonanon_proxies[$thisproxy] . "\n";
- echo '<br><b><font color="red" size="2">Не рабочие прокси:</font></b>' . "\n";
- for($thisproxy = 0; $thisproxy < count($bad_proxies); $thisproxy += 1)
- $xek = htmlspecialchars($bad_proxies[$thisproxy]);
- echo $xek . "\n";
- echo '</pre>';
- }
- // just a blank call of the page - show the form for the user to fill in
- else
- {
- echo '<form method="POST" action="' . $_SERVER['SCRIPT_NAME'] . '">' . "\n";
- echo '<input type="hidden" name="action" value="fred">' . "\n";
- echo '<textarea name="proxies" cols=50 rows=10></textarea><br>' . "\n";
- if(strlen($password) > 0)
- echo 'Password: <input type="password" name="password" size="15"><br>' . "\n";
- echo '<input type="submit" value="Старт">' . "\n";
- echo '</form>' . "\n";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement