Advertisement
YunusIncredibl

DNS Record Lookup

May 6th, 2014
1,191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. <title>DNS Record Lookup by Yunus Incredibl</title>
  2. <form method="POST">
  3. Hostname : <input type="text" name="hostname" size="50" placeholder="www.site.com" style='border: solid 1px red'>
  4. <br><br>Record : <select style='border: solid 1px red' name='record'>
  5. <?php
  6.  
  7. /*
  8.  
  9. DNS Record Lookup
  10.  
  11. by YunusIncredibl
  12.  
  13. 2014
  14.  
  15. */
  16.  
  17. set_time_limit (0);
  18.  
  19. $records = array ("A", "CNAME", "MX", "NS", "PTR", "SOA", "TXT", "AAAA", "ALL");
  20.  
  21. foreach ($records as $record)
  22.     echo "<option>".$record."</option>";
  23.  
  24. echo '</select><br><br><input type="submit" value="Lookup" name="go"><br></form>';
  25.  
  26. if (@$_POST['go'])
  27. {
  28.     $host = $_POST['hostname'];
  29.     if (@preg_match ("/:\/\//", $host))
  30.         $host = parse_url ($host, PHP_URL_HOST);
  31.     $rec = $_POST['record'];
  32.     switch ($rec)
  33.     {
  34.     case "A":
  35.         fetch_dns_record ($host, DNS_A);
  36.         break;
  37.     case "CNAME":
  38.         fetch_dns_record ($host, DNS_CNAME);
  39.         break;
  40.     case "MX":
  41.         fetch_dns_record ($host, DNS_MX);
  42.         break;
  43.     case "NS":
  44.         fetch_dns_record ($host, DNS_NS);
  45.         break;
  46.     case "PTR":
  47.         fetch_dns_record ($host, DNS_PTR);
  48.         break;
  49.     case "SOA":
  50.         fetch_dns_record ($host, DNS_SOA);
  51.         break;
  52.     case "TXT":
  53.         fetch_dns_record ($host, DNS_TXT);
  54.         break;
  55.     case "AAAA":
  56.         fetch_dns_record ($host, DNS_AAAA);
  57.         break;
  58.     case "ALL":
  59.         fetch_dns_record ($host, DNS_ALL);
  60.         break;
  61.     default:
  62.         break;
  63.     }
  64. }
  65.  
  66. function fetch_dns_record ($host, $type)
  67. {
  68.     if (!$record = @dns_get_record ($host, $type))
  69.         die ("DNS Query failed !");
  70.     foreach ($record as $y)
  71.     {
  72.         echo "<br><br>";
  73.         foreach ($y as $x => $k)
  74.             echo $x." : "."$k<br>";
  75.     }
  76. }
  77. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement