i-Hmx

Multithread proxy checker

Aug 31st, 2012
1,902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.88 KB | None | 0 0
  1. <?php
  2. set_time_limit(0);
  3. /***********************************************
  4. * Multithreaded Proxy Checker
  5. * Coded by Miyachung
  6. * Janissaries.Org
  7. ------------------------------------------------
  8. * Demonstration -> http://www.youtube.com/watch?v=4icPZHv3W9g
  9. * Type list like IP:PORT in a file
  10. ***********************************************/
  11.  
  12. /*-----------------------------------------------------------------------*/
  13.     echo "\n[+]Enter your proxy list: ";
  14.     $proxy_list = fgets(STDIN);
  15.     $proxy_list = str_replace("\r\n","",$proxy_list);
  16.     $proxy_list = trim($proxy_list);
  17.  
  18.     echo "[+]Enter number of thread: ";
  19.     $thread = fgets(STDIN);
  20.     $thread = str_replace("\r\n","",$thread);
  21.     $thread = trim($thread);
  22.     echo "[+]Enter timeout sec: ";
  23.     $timeout = fgets(STDIN);
  24.     $timeout = str_replace("\r\n","",$timeout);
  25.     $timeout = trim($timeout);
  26.     echo "[+]Checking proxies\n";
  27.     echo "-------------------------------------------------------\n";
  28.     $open_file    =    file($proxy_list);
  29.     $open_file  =    preg_replace("#\r\n#si","",$open_file);
  30.  
  31.        
  32.     checker($open_file,$thread);
  33. /*-----------------------------------------------------------------------*/
  34. function checker($ips,$thread)
  35. {
  36.     global $timeout;
  37.    
  38.     $multi    = curl_multi_init();
  39.     $ips    = array_chunk($ips,$thread);
  40.     $total    = 0;
  41.     $time1  = time();
  42.         foreach($ips as $ip)
  43.         {
  44.             for($i=0;$i<=count($ip)-1;$i++)
  45.             {
  46.             $curl[$i] = curl_init();
  47.             curl_setopt($curl[$i],CURLOPT_RETURNTRANSFER,1);
  48.             curl_setopt($curl[$i],CURLOPT_URL,"http://www.google.com.tr");
  49.             curl_setopt($curl[$i],CURLOPT_PROXY,$ip[$i]);
  50.             curl_setopt($curl[$i],CURLOPT_TIMEOUT,$timeout);
  51.             curl_multi_add_handle($multi,$curl[$i]);
  52.             }
  53.            
  54.             do
  55.             {
  56.             curl_multi_exec($multi,$active);
  57.             usleep(11);
  58.             }while( $active > 0 );
  59.            
  60.             foreach($curl as $cid => $cend)
  61.             {
  62.                 $con[$cid] = curl_multi_getcontent($cend);
  63.                 curl_multi_remove_handle($multi,$cend);
  64.                 if(preg_match('#calendar\?tab=wc#si',$con[$cid]))
  65.                 {
  66.                     $total++;
  67.                     echo "[~]Proxy works -> ".$ip[$cid]."\n";
  68.                     save_file("works.txt",$ip[$cid]);
  69.                 }
  70.             }
  71.         }
  72.     $time2 = time();
  73.     echo "\n[+]Total working proxies: $total,checking completed\n";
  74.     echo "[+]Elapsed time -> ".($time2-$time1)." seconds\n";
  75.     echo "[+]Coded by miyachung || Janissaries.Org\n";
  76.     echo "-------------------------------------------------------\n";
  77. }
  78.    
  79. function save_file($file,$content)
  80. {
  81.     $open = fopen($file,'ab');
  82.     fwrite($open,$content."\r\n");
  83.     fclose($open);
  84. }
  85.  
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment