proxy checking margarine sucks


SUBMITTED BY: Guest

DATE: Nov. 17, 2013, 4:51 a.m.

FORMAT: Text only

SIZE: 2.2 kB

HITS: 33733

  1. <?php
  2. set_time_limit(0);
  3. /*-----------------------------------------------------------------------*/
  4. echo "\n[+]Enter your proxy list: ";
  5. $proxy_list = fgets(STDIN);
  6. $proxy_list = str_replace("\r\n","",$proxy_list);
  7. $proxy_list = trim($proxy_list);
  8. echo "[+]Enter number of thread: ";
  9. $thread = fgets(STDIN);
  10. $thread = str_replace("\r\n","",$thread);
  11. $thread = trim($thread);
  12. echo "[+]Enter timeout sec: ";
  13. $timeout = fgets(STDIN);
  14. $timeout = str_replace("\r\n","",$timeout);
  15. $timeout = trim($timeout);
  16. echo "[+]Checking proxies\n";
  17. $open_file = file($proxy_list);
  18. echo "-------------------------------------------------------\n";
  19. $open_file = preg_replace("#\r\n#si","",$open_file);
  20. checker($open_file,$thread);
  21. /*-----------------------------------------------------------------------*/
  22. function checker($ips,$thread)
  23. {
  24. global $timeout;
  25. $multi = curl_multi_init();
  26. $ips = array_chunk($ips,$thread);
  27. $total = 0;
  28. $time1 = time();
  29. foreach($ips as $ip)
  30. {
  31. for($i=0;$i<=count($ip)-1;$i++)
  32. {
  33. $curl[$i] = curl_init();
  34. curl_setopt($curl[$i],CURLOPT_RETURNTRANSFER,1);
  35. curl_setopt($curl[$i],CURLOPT_URL,$ip[$i]);
  36. curl_setopt($curl[$i],CURLOPT_TIMEOUT,$timeout);
  37. curl_multi_add_handle($multi,$curl[$i]);
  38. }
  39. do
  40. {
  41. curl_multi_exec($multi,$active);
  42. usleep(11);
  43. }while( $active > 0 );
  44. foreach($curl as $cid => $cend)
  45. {
  46. $info = curl_getinfo($cend);
  47. curl_multi_remove_handle($multi,$cend);
  48. if($info['http_code'] != 0)
  49. {
  50. $total++;
  51. echo "[~]Proxy works -> ".$ip[$cid]."\n";
  52. save_file("works.txt",$ip[$cid]);
  53. }
  54. }
  55. }
  56. $time2 = time();
  57. echo "\n[+]Total working proxies: $total,checking completed\n";
  58. echo "[+]Elapsed time -> ".($time2-$time1)." seconds\n";
  59. echo "-------------------------------------------------------\n";
  60. }
  61. function save_file($file,$content)
  62. {
  63. $open = fopen($file,'ab');
  64. fwrite($open,$content."\r\n");
  65. fclose($open);
  66. }
  67. ?>

comments powered by Disqus