Orgy

getCF.php

Aug 28th, 2011
2,034
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  * getCF.php
  5.  * I got tired of looking up the DNS records of these various hosts
  6.  * to find the real IP of a CloudFlare protected Server.
  7.  * www.bigkesh.com
  8.  * orgy[at]bigkesh[dot]com
  9.  * Usage: php getCF.php domain.com
  10.  * Usage2: www.yoursite.com/getCF.php?find=domain.com
  11.  */
  12.  
  13. if (!isset($argv[1]) && !isset($_GET['find']))
  14. {
  15.     die("Argument needs to be a valid hostname.\n");
  16. }
  17.  
  18. $lookupArr = array("mail.", "direct.", "direct-connect.", "cpanel.", "ftp.");
  19.  
  20. foreach ($lookupArr as $lookupKey)
  21. {
  22.    
  23.     if (isset($_GET['find']))
  24.     {
  25.         $newline = "<br />";
  26.         $lookupHost = $lookupKey . $_GET['find'];
  27.     }
  28.     else
  29.     {
  30.         $newline = "\n";
  31.         $lookupHost = $lookupKey . $argv[1];
  32.     }
  33.    
  34.     $foundHost = gethostbyname($lookupHost);
  35.    
  36.     if ($foundHost == $lookupHost)
  37.     {
  38.         echo "{$lookupHost} had no DNS record.{$newline}";
  39.     }
  40.     else
  41.     {
  42.         echo "{$lookupHost} = {$foundHost}{$newline}";
  43.     }
  44. }
  45.  
  46. ?>
Add Comment
Please, Sign In to add comment