Simple Proxy Extractor


SUBMITTED BY: r0fl

DATE: Sept. 2, 2016, 12:56 p.m.

FORMAT: Text only

SIZE: 1.3 kB

HITS: 436

  1. <?php
  2. //extract proxy+port from url
  3. //extracts proxies from site if in ip:port format
  4. //optionally can use anon http proxy for request
  5. //use: php proxy-extract.php site.com [-p proxy:port]
  6. //extractor by int3
  7. $use_proxy = false;
  8. for ($i=0; $i<$argc; $i++) {
  9. if ($argv[$i] == "-p") {
  10. $i++;
  11. $use_proxy = true;
  12. $proxy = substr($argv[$i], 0, strpos($argv[$i], ":")); //get proxy server
  13. $proxy_port = substr($argv[$i], strpos($argv[$i], ":")+1); //get proxy port
  14. }
  15. else
  16. $url = $argv[1];
  17. }
  18. $curl = curl_init();
  19. curl_setopt($curl, CURLOPT_URL, $url);
  20. curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)");
  21. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  22. if ($use_proxy = true) {
  23. curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, true);
  24. curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
  25. curl_setopt($curl, CURLOPT_PROXY, $proxy);
  26. curl_setopt($curl, CURLOPT_PROXYPORT, $proxy_port);
  27. }
  28. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //return site as string
  29. $page = curl_exec($curl);
  30. curl_close($curl);
  31. preg_match_all("/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\:[0-9]*/", $page, $match);
  32. for ($i=0; $i<count($match[0]); $i++) {
  33. echo $match[0][$i], "\n";
  34. }
  35. ?>

comments powered by Disqus