Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 11th, 2012  |  syntax: None  |  size: 1.56 KB  |  hits: 45  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. <?php
  3.  
  4. # CloudFlare IP Resolver
  5.  
  6. # Coded By Phizo
  7. # http://hackforums.net/member.php?action=profile&uid=42381
  8.  
  9. function is_ipv4($ip)
  10. {
  11.     return filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? $ip : '(Null)';
  12. }
  13.  
  14. $me = $argv[0];
  15. $url = @$argv[1];
  16.  
  17. if(!isset($url))
  18.     die("\n[+] Usage: php {$me} <url>\n[+] Example: php {$me} http://www.imgur.com\n");
  19.  
  20. if(!preg_match('/^(https?):\/\/(w{3}|w3)\./i', $url))
  21.     die("\nURL is invalid.\nURL must be formatted as: http(s)://www." . preg_replace('/^(https?):\/\//', '', $url) . "\n(for compatibility reasons)\n");
  22.  
  23. $headers = get_headers($url, 1);
  24. $server = $headers['Server'];
  25.  
  26. $subs = array('cpanel.', 'ftp.', 'mail.', 'webmail.', 'direct.', 'direct-connect.', 'record.', 'ssl.', 'dns.', 'help.', 'blog.', 'forum.');
  27. $count = count($subs);
  28.  
  29. if(preg_match('/^(https?):\/\/(w{3}|w3)\./i', $url, $matches))
  30. {
  31.     if($matches[2] != 'www')
  32.     {
  33.   $url = preg_replace('/^(https?):\/\//', '', $url);
  34.     }
  35.     else
  36.     {
  37.   $url = explode($matches[0], $url);
  38.   $url = $url[1];
  39.     }
  40. }
  41.  
  42. if(is_array($server))
  43.     $server = $server[0];
  44.  
  45. if(preg_match('/cloudflare/i', $server))
  46.     echo "\n[+] CloudFlare detected: {$server}\n";
  47. else
  48.     echo "\n[+] CloudFlare wasn't detected, proceeding anyway.\n";
  49.  
  50. echo '[+] IP: ' . is_ipv4(gethostbyname($url)) . "\n\n";
  51. echo "[+] Searching for more IP addresses.\n\n";
  52.  
  53. for($x = 0; $x < $count; $x++)
  54. {
  55.     $site = $subs[$x] . $url;
  56.     $ip = is_ipv4(gethostbyname($site));
  57.  
  58.     echo "Trying {$site}: {$ip}\n";
  59. }
  60.  
  61. echo "\n[+] Finished.\n";
  62.  
  63. ?>