Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if($_GET['showData']){
- echo "Posted: <pre>";
- print_r($_GET);
- echo "</pre>\n";
- }
- $host = trim($_GET['host']);
- require_once 'Net/DNS2.php';
- switch($_GET['ns']){
- case "google":
- $ns = array('8.8.8.8');
- break;
- default:
- if(isset($_GET['other'])){
- $ns = array($_GET['other']);
- } else {
- $ns = array($_GET['ns']);
- }
- break;
- }
- if(isset($_GET['supNoData'])){
- $suppressNoData = true;
- } else {
- $suppressNoData = false;
- }
- $r = new Net_DNS2_Resolver(array(
- 'nameservers' => $ns
- ));
- if(empty($_GET['r'])){
- // Set Default Record Types to lookup
- $_GET['r'] = array('A', 'MX', 'SRV', 'TXT', 'CNAME', 'NS');
- }
- if(empty($_GET['s'])){
- // Set Default Dub-Domains to lookup
- $_GET['s']['a'] = array('root', 'ftp', 'list', 'mail', 'store', 'www');
- $_GET['s']['m'] = array('list');
- $_GET['s']['c'] = array('autodiscover');
- $_GET['s']['s'] = array('_sip._tls', '_sipfederationtls._tcp');
- }
- if($_GET['showData']){
- echo "After Default adds: <pre>";
- print_r($_GET);
- echo "</pre>\n";
- }
- echo "<table>\n";
- echo "\t<tr><th>domain</th><th>type</th><th>data</th><th>ttl</th></tr>\n";
- $record_results = array();
- foreach($_GET['r'] as $record){
- // A Records
- if($record == "A"){
- if($_GET['s']['a'][0] == "root"){
- if($_GET['showData']){
- echo "<tr><td colspan='4'>Performing A Record lookup on $host</td></tr>\r\n";
- }
- try {
- $result = $r->query($host, 'A');
- } catch(Net_DNS2_Exception $e) {
- //echo "::query() failed: ", $e->getMessage(), "\n";
- if(!$suppressNoData){
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", $host, "A", "No Data", 0);
- }
- continue;
- }
- //
- // loop through the answer, printing out the A records returned.
- //
- foreach($result->answer as $arr) {
- $data = $arr->address;
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", $arr->name, $arr->type, $data, $arr->ttl);
- $record_results[] = array(
- 'domain' => $arr->name,
- 'type' => $arr->type,
- 'data' => $arr->address,
- 'ttl' => $arr->ttl
- );
- }
- unset($_GET['s']['a'][0]);
- }
- if(isset($_GET['s']['a'])){
- foreach($_GET['s']['a'] as $sub){
- if($_GET['showData']){
- echo "<tr><td colspan='4'>Performing A Record lookup on $sub.$host</td></tr>\r\n";
- }
- try {
- $lookup = "$sub.$host";
- $result = $r->query($lookup, 'A');
- } catch(Net_DNS2_Exception $e) {
- //echo "::query() failed: ", $e->getMessage(), "\n";
- if(!$suppressNoData){
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", "$sub.$host", "A", "No Data", 0);
- }
- continue;
- }
- //
- // loop through the answer, printing out the A records returned.
- //
- foreach($result->answer as $a2rr) {
- $data = $a2rr->address;
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", $a2rr->name, $a2rr->type, $data, $a2rr->ttl);
- $record_results[] = array(
- 'domain' => $a2rr->name,
- 'type' => $a2rr->type,
- 'data' => $a2rr->address,
- 'ttl' => $a2rr->ttl
- );
- }
- }
- }
- }
- // MX Records
- if($record == "MX"){
- if($showData){
- echo "<tr><td colspan='4'>Performing MX Record lookup on $host</td></tr>\r\n";
- }
- try {
- $result = $r->query($host, 'MX');
- } catch(Net_DNS2_Exception $e) {
- //echo "::query() failed: ", $e->getMessage(), "\n";
- if(!$suppressNoData){
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", $host, "MX", "0 No Data", 0);
- }
- continue;
- }
- //
- // loop through the answer, printing out the MX servers returned.
- //
- foreach($result->answer as $mxrr){
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", $mxrr->name, $mxrr->type, $mxrr->preference . " " . $mxrr->excha$
- $record_results[] = array(
- 'domain' => $mxrr->name,
- 'type' => $mxrr->type,
- 'data' => $mxrr->preference . " " . $mxrr->exchange,
- 'ttl' => $mxrr->ttl
- );
- }
- foreach($result->answer as $mxrr){
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", $mxrr->name, $mxrr->type, $mxrr->preference . " " . $mxrr->excha$
- $record_results[] = array(
- 'domain' => $mxrr->name,
- 'type' => $mxrr->type,
- 'data' => $mxrr->preference . " " . $mxrr->exchange,
- 'ttl' => $mxrr->ttl
- );
- }
- if(isset($_GET['s']['m'])){
- foreach($_GET['s']['m'] as $sub){
- try {
- $result = $r->query("$sub.$host", 'MX');
- } catch(Net_DNS2_Exception $e) {
- //echo "::query() failed: ", $e->getMessage(), "\n";
- if(!$suppressNoData){
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", "0 $sub.$host", "MX", "No Data", 0);
- }
- continue;
- }
- foreach($result->answer as $mxrr){
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", $mxrr->name, $mxrr->type, $mxrr->preference . " $
- $record_results[] = array(
- 'domain' => $mxrr->name,
- 'type' => $mxrr->type,
- 'data' => $mxrr->preference . " " . $mxrr->exchange,
- 'ttl' => $mxrr->ttl
- );
- }
- }
- }
- }
- // Text Record
- if($record == "TXT"){
- if($showData){
- echo "<tr><td colspan='4'>Performing TXT Record lookup on $host</td></tr>\r\n";
- }
- try {
- $result = $r->query($host, 'TXT');
- } catch(Net_DNS2_Exception $e) {
- //echo "::query() failed: ", $e->getMessage(), "\n";
- if(!$suppressNoData){
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", $host, "TXT", "No Data", 0);
- }
- continue;
- }
- //
- // loop through the answer, printing out the TXT servers returned.
- //
- foreach($result->answer as $txtrr){
- if($txtrr->text[0] == "" || $txtrr->text[0] == " "){ continue; }
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", $txtrr->name, $txtrr->type, $txtrr->text[0], $txtrr->ttl);
- $record_results[] = array(
- 'domain' => $txtrr->name,
- 'type' => $txtrr->type,
- 'data' => $txtrr->text[0],
- 'ttl' => $txtrr->ttl
- );
- }
- }
- // SRV Records
- if($record == "SRV"){
- if(isset($_GET['s']['s'])){
- foreach($_GET['s']['s'] as $sub){
- if($showData){
- echo "<tr><td colspan='4'>Performing SRV Record lookup on $sub.$host</td></tr>\r\n";
- }
- try {
- $result = $r->query("$sub.$host", 'SRV');
- } catch(Net_DNS2_Exception $e) {
- //echo "::query() failed: ", $e->getMessage(), "\n";
- if(!$suppressNoData){
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", "$sub.$host", "SRV", "0 0 0 No Data", 0);
- }
- continue;
- }
- //
- // loop through the answer, printing out the SRV servers returned.
- //
- foreach($result->answer as $srvrr) {
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", $srvrr->name, $srvrr->type, $srvrr->priority . "$
- $record_results[] = array(
- 'domain' => $srvrr->name,
- 'type' => $srvrr->type,
- 'data' => $srvrr->priority . " " . $srvrr->weight . " " . $srvrr->port . " " . $srvrr->target,
- 'ttl' => $srvrr->ttl
- );
- }
- }
- }
- }
- // CNAME Records
- if($record == "CNAME"){
- if(isset($_GET['s']['c'])){
- foreach($_GET['s']['c'] as $sub){
- if($showData){
- echo "<tr><td colspan='4'>Performing CNAME Record lookup on $sub.$host</td></tr>\r\n";
- }
- try {
- $result = $r->query("$sub.$host", "CNAME");
- } catch(Net_DNS2_Exception $e) {
- //echo "::query() failed: ", $e->getMessage(), "\n";
- if(!$suppressNoData){
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", "$sub.$host", "CNAME", "No Data", 0);
- }
- continue;
- }
- foreach($result->answer as $crr) {
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", $crr->name, $crr->type, $crr->cname, $crr->ttl);
- $record_results[] = array(
- 'domain' => $crr->name,
- 'type' => $crr->type,
- 'data' => $crr->cname,
- 'ttl' => $crr->ttl
- );
- }
- }
- }
- }
- // Name Server Records
- if($record == "NS"){
- if($showData){
- echo "<tr><td colspan='4'>Performing NS Record lookup on $host</td></tr>\r\n";
- }
- try {
- $result = $r->query("$host", "NS");
- } catch(Net_DNS2_Exception $e) {
- //echo "::query() failed: ", $e->getMessage(), "\n";
- if(!$suppressNoData){
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", $host, "NS", "No Data", 0);
- }
- continue;
- }
- foreach($result->answer as $nsrr) {
- printf("\t<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>\n", $nsrr->name, $nsrr->type, $nsrr->nsdname, $nsrr->ttl);
- $record_results[] = array(
- 'domain' => $nsrr->name,
- 'type' => $nsrr->type,
- 'data' => $nsrr->nsdname,
- 'ttl' => $nsrr->ttl
- );
- }
- }
- }
- echo "</table>\n";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement