Advertisement
i-Hmx

Multithread proxy checker

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