Created
March 9, 2018 02:33
-
-
Save mnathani/fa511783bf72c503bc7af80631da5eba to your computer and use it in GitHub Desktop.
dns-investigate.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$time = microtime(); | |
$time = explode(' ', $time); | |
$time = $time[1] + $time[0]; | |
$start = $time; | |
if(isset( $_GET["Domain"])){ | |
$domain=$_GET["Domain"]; | |
} | |
else{ | |
$domain="example.com"; | |
} | |
?> | |
<h2> Enter a domain you would like to investigate:</h2> | |
<form name="input" action="https://dns.exacthosting.tools" method="get"> | |
Domain: <input type="text" size="42" name="Domain"> | |
<input type="submit" value="Submit"> | |
</form> | |
<br /> | |
<hr> | |
<?php | |
$title="Domain Investigation of ".$domain; | |
$clientip=$_SERVER['REMOTE_ADDR']; | |
?> | |
<?php | |
//8.8.8.8.in-addr.arpa. 85401 IN PTR google-public-dns-a.google.com. | |
//3.1.0.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.0.7.0.0.4.0.b.8.f.7.0.6.2.ip6.arpa. 85432 IN PTR lax04s08-in-x13.1e100.net. | |
if(strcmp(substr($domain,0,8),"https://")==0) | |
{ | |
if(strcmp(substr($domain,0,12),"https://www.")==0) | |
{ | |
$odomain=substr($domain,12,(strlen($domain)-12)); | |
//echo "Line 40"; | |
//echo $odomain; | |
} | |
else | |
{ | |
$odomain=substr($domain,8,(strlen($domain)-8)); | |
//echo "Line 45"; | |
//echo $odomain; | |
} | |
} | |
//echo "Strlen ".strlen($domain); | |
if(strcmp(substr($domain,0,7),"http://")==0) | |
{ | |
if(strcmp(substr($domain,0,11),"http://www.")==0) | |
{ | |
$odomain=substr($domain,11,(strlen($domain)-11)); | |
// echo "Line 42"; | |
} | |
else | |
{ | |
$odomain=substr($domain,7,(strlen($domain)-7)); | |
// echo "Line 47"; | |
} | |
//echo "Strlen ".strlen($domain); | |
} | |
else | |
{ | |
//echo "ELSE". substr($domain,0,7); | |
$odomain=$domain; | |
} | |
if(strcmp(substr($odomain,0,4),"www.")==0) | |
{ | |
// echo "line 60"; | |
$odomain=substr($odomain,4,(strlen($odomain)-4)); | |
} | |
//else | |
//{ | |
// echo "line 65"; | |
//} | |
$slash=strpos($odomain,"/"); | |
if($slash>=-1) | |
{ | |
$odomain=substr($odomain,0,$slash); | |
} | |
//echo $odomain; | |
//$QueryType=$_GET["QueryType"]; | |
//echo $domain; | |
//echo "\n"; | |
?> | |
<h1 id="heading">Investigating <a href="http://<?php echo $odomain ?>" target="_blank"><?php echo $odomain ?></a></h1> | |
<h2> Name Servers for: <?php echo $odomain ?></h2> | |
<div id="wood"> | |
<pre> | |
<?php | |
//echo "<br/>d_tld: ".$d_tld."<br/>"; | |
//$pattern=" NS "; | |
//echo $odomain; | |
//echo "Before"; | |
exec("dig ns ".$odomain. " +noall +answer", $domainns); | |
asort($domainns); | |
exec("timeout 1 /usr/bin/dig ".escapeshellarg($odomain)." +noall +authority @a.root-servers.net", $digroot); | |
$digroote = explode("\t", end($digroot)); | |
exec("timeout 1 /usr/bin/dig ".escapeshellarg($odomain)." +noall +authority @".end($digroote), $digtld); | |
//print_r ($domainns); | |
foreach($domainns as $fdomainns) | |
{ | |
if((strpos($fdomainns, 'global options') == false) && (strpos($fdomainns, 'DiG')== false)) | |
{ | |
echo $fdomainns."<br/>"; | |
} | |
} | |
//foreach ($output as $root) | |
//{ | |
echo "</pre><hr></div>"; | |
?> | |
<h2> Name Servers for: <?php echo $odomain ?> as per <?php echo end($digroote) ?></h2> | |
<div id="wood"> | |
<pre> | |
<?php | |
foreach($digtld as $digfdomainns) | |
{ | |
if((strpos($digfdomainns, 'global options') == false) && (strpos($digfdomainns, 'DiG')== false)) | |
{ | |
echo $digfdomainns."<br/>"; | |
} | |
} | |
//foreach ($output as $root) | |
//{ | |
echo "</pre><hr></div>"; | |
$servername = "localhost"; | |
$username = "dnsexact_db7"; | |
$password = "PASSWORD"; | |
$dbname = "dnsexact_db7"; | |
if (!$link = mysql_connect($servername, $username, $password)) { | |
echo 'Could not connect to mysql'; | |
exit; | |
} | |
if (!mysql_select_db($dbname, $link)) { | |
echo 'Could not select database'; | |
exit; | |
} | |
//$odomain="exacthosting.com"; | |
//$sql = 'SELECT foo FROM bar WHERE id = 42'; | |
$sql = 'SELECT `comment` FROM `domains` WHERE `domain` ="'.$odomain.'"'; | |
$result = mysql_query($sql, $link); | |
if (!$result) { | |
echo "DB Error, could not query the database\n"; | |
echo 'MySQL Error: ' . mysql_error(); | |
exit; | |
} | |
while ($row = mysql_fetch_assoc($result)) { | |
echo "<div><h2>Customer Group: <font color='#CC0022'>".$row['comment']."</font></h2>"; | |
} | |
echo "</div>"; | |
mysql_free_result($result); | |
?> | |
<h2> SSL tests for: <?php echo $odomain; ?></h2> | |
<div id="wood"><h3> | |
<ul> | |
<li> | |
<a href="https://www.ssllabs.com/ssltest/analyze.html?d=<?php echo $odomain;?>&latest" target="_blank">SSL Labs</a> | |
</li> | |
<li> | |
<a href="https://www.sslshopper.com/ssl-checker.html?hostname=<?php echo $odomain;?>" target="_blank">SSL Shopper</a> | |
</li> | |
</ul> | |
</h3> | |
<hr><div id="wood"> | |
<?php | |
exec("echo | openssl s_client -showcerts -servername ".$odomain." -connect ".$odomain.":443 2>/dev/null | openssl x509 -inform pem -noout -text | grep -E 'DNS|Not After'", $ssl); | |
foreach($ssl as $sslline) | |
{ | |
echo $sslline."<br/>\n"; | |
} | |
?> | |
</div> | |
<?php | |
exec("timeout 1 /usr/bin/dig a ".escapeshellarg($odomain)." +noall +answer", $a); | |
exec("timeout 1 /usr/bin/dig a ".escapeshellarg($odomain)." +short", $ashort); | |
exec("timeout 1 /usr/bin/dig txt _dmarc.".escapeshellarg($odomain)." +short", $dmarc); | |
exec("timeout 1 /usr/bin/dig www.".escapeshellarg($odomain)." +noall +answer", $www); | |
//echo "ashort="; | |
//echo $ashort[0]; | |
exec("timeout 1 /usr/bin/dig -x ".escapeshellarg($ashort[0])." +noall +answer", $aptr); | |
if(strpos(end($a),"A")!=False) | |
{ | |
echo "<h2>A records for ".$odomain .'</h2><div id="wood"><pre>'; | |
//print_r($a); | |
foreach($a as $fa) | |
{ | |
if((strpos($fa, 'global options') == false) && (strpos($fa, 'DiG')== false)) | |
{ | |
echo $fa."<br/>"; | |
} | |
} | |
//echo "<h2>PTR records for ".$odomain .'</h2><div id="wood"><pre>'; | |
// //print_r($a); | |
//foreach($a as $fa) | |
//{ | |
// echo $fa."<br/>"; | |
//} | |
echo "</pre></div>"; | |
} | |
echo "<h2>Reverse Lookup for A records for ".$odomain .'</h2><div id="wood"><pre>'; | |
//print_r($aptr); | |
//echo $aptr; | |
foreach($aptr as $faptr) | |
{ | |
if((strpos($faptr, 'global options') == false) && (strpos($faptr, 'DiG')== false)) | |
{ | |
echo $faptr."<br/>"; | |
} | |
} | |
echo "</pre></div>"; | |
exec("whois -h whois.bgpmon.net ". $ashort[0] ,$ashortwhois); | |
echo "<h2>IP block / ASN records for ".$ashort[0]."</h2><div id='wood'><pre>"; | |
//print_r($ds); | |
foreach($ashortwhois as $asw) | |
{ | |
echo $asw."<br/>"; | |
} | |
echo "</div>"; | |
if(!empty($dmarc)) | |
{ | |
echo "<h2>DMARC records for ".$odomain .'</h2><div id="wood"><pre>'; | |
//print_r($dmarc); | |
foreach($dmarc as $fdmarc) | |
{ | |
echo $fdmarc."<br/>"; | |
} | |
echo "</pre></div>"; | |
} | |
else{ | |
echo "<br><br><h2>No DMARC records published for Domain: ".$odomain .'</h2><br><br>'; | |
} | |
if(!empty($www)) | |
{ | |
echo "<h2>WWW records for ".$odomain .'</h2><div id="wood"><pre>'; | |
//print_r($www); | |
foreach($www as $fwww) | |
{ | |
if((strpos($fwww, 'global options') == false) && (strpos($fwww, 'DiG')== false)) | |
{ | |
echo $fwww."<br/>"; | |
} | |
} | |
echo "</pre></div>"; | |
} | |
exec("timeout 1 /usr/bin/dig a ".escapeshellarg($odomain)." +short", $binga); | |
echo "<h2>Find out what other sites are hosted on the same IP address:<br><br><div align='center'><a href='http://www.bing.com/search?q=ip:".$binga[0]."' target='_blank'>Bing IP Results for ".$binga[0].'</a></div></h2><div id="wood">'; | |
exec("timeout 1 /usr/bin/dig aaaa ".escapeshellarg($odomain)." +noall +answer", $aaaa); | |
if(strpos(end($aaaa),"AAAA")!=false) | |
{ | |
echo " <h2>AAAA records for ".$odomain ."</h2><pre>"; | |
//print_r($aaaa); | |
foreach($aaaa as $faaaa) | |
{ | |
if((strpos($faaaa, 'global options') == false) && (strpos($faaaa, 'DiG')== false)) | |
echo $faaaa."<br/>"; | |
} | |
echo "</pre>"; | |
} | |
exec("timeout 1 /usr/bin/dig mx ".escapeshellarg($odomain)." +noall +answer", $mx); | |
exec("timeout 1 /usr/bin/dig mx ".escapeshellarg($odomain)." +short", $smx); | |
if(strpos(end($mx),"MX")!=False) | |
{ | |
echo "</div><h2>MX records for ".$odomain.'</h2><div id="wood"><pre>'; | |
//print_r($mx); | |
foreach($mx as $fmx) | |
{ | |
if((strpos($fmx, 'global options') == false) && (strpos($fmx, 'DiG')== false)) | |
{ | |
echo $fmx."<br/>"; | |
} | |
} | |
echo "</pre>"; | |
//echo "SMX:<br />"; | |
//print_r($smx); | |
//echo "-SMX:<br />"; | |
//exec("timeout 1 /usr/bin/dig ".escapeshellarg($smx[0])." +short", $mxip); | |
echo "</div><h2>A records for each MX record for domain: ".$odomain.'</h2><div id="wood"><pre>'; | |
foreach($smx as $smxline) | |
{ | |
$smxline=substr($smxline,strrpos($smxline," ")+1); | |
//echo "smxline:<br />"; | |
//echo $smxline; | |
//echo "<br />-smxline:<br />"; | |
exec("timeout 1 /usr/bin/dig ".escapeshellarg($smxline)." +short", $mxip); | |
//echo "mxip:<br />"; | |
//print_r($mxip); | |
//echo "-mxip:<br />"; | |
exec("timeout 1 /usr/bin/dig ".escapeshellarg($smxline)." +noall +answer", $asmxline); | |
//echo "ASMXLINE:<br />"; | |
//print_r($asmxline); | |
//echo "-ASMXLINE:<br />"; | |
foreach($asmxline as $mxline) | |
{ | |
if (strpos($mxline,'IN A') !== false) { | |
echo $mxline. "<br />"; | |
} | |
} | |
unset($asmxline); | |
} | |
echo "</pre></div><br /><br /><div id='wood'><table border ='1'><tr><td>MX IP:</td><td>Reverse Lookup</td></tr><div id='wood'><pre>"; | |
foreach($mxip as $mxipline) | |
{ | |
//echo "MXIPLINE: ".$mxipline; | |
exec("timeout 1 /usr/bin/dig -x ".escapeshellarg($mxipline)." +short", $inmxip); | |
echo "<tr><td>".$mxipline."</td><td>".$inmxip[0]."</td></tr>"; | |
unset($inmxip); | |
} | |
echo "</table></pre>"; | |
$aaaar="</div><h2>AAAA records for each MX record for domain: ".$odomain."</h2><div id='wood'><pre>\n"; | |
//echo "<h2>AAAA records for each MX record for domain: ".$odomain."</h2>"; | |
foreach($smx as $smxline) | |
{ | |
$smxline=substr($smxline,strrpos($smxline," ")+1); | |
exec("timeout 1 /usr/bin/dig ".escapeshellarg($smxline)." aaaa +noall +answer", $asmxline); | |
exec("timeout 1 /usr/bin/dig ".escapeshellarg($smxline)." aaaa +short", $mxipv6); | |
//print_r($asmxline); | |
$ais=false; | |
foreach($asmxline as $mxline) | |
{ | |
if (strpos($mxline,'IN AAAA') !== false) { | |
//echo $mxline. "<br />"; | |
$ais=true; | |
$aaaar.= $mxline. "<br />"; | |
} | |
unset($asmxline); | |
} | |
} | |
} | |
//echo "Count: ". count($aaaar); | |
//echo $aaaar; | |
if($ais) | |
{ | |
echo $aaaar; | |
} | |
echo "</pre></div>"; | |
//echo "<br /><br /><table border ='1'><tr><td>MX IPv6:</td><td>Reverse Lookup</td></tr>"; | |
$amxipv6="<br /><br /><div id='wood'><table border ='1'><tr><td>MX IPv6:</td><td>Reverse Lookup</td></tr>"; | |
foreach($mxipv6 as $mxipv6line) | |
{ | |
//echo "MXIPLINE: ".$mxipline; | |
exec("timeout 1 /usr/bin/dig -x ".escapeshellarg($mxipv6line)." +short", $inmxipv6); | |
//echo "<tr><td>".$mxipv6line."</td><td>".$inmxipv6[0]."</td></tr>"; | |
$amxipv6.="<tr><td>".$mxipv6line."</td><td>".$inmxipv6[0]."</td></tr>"; | |
unset($inmxipv6); | |
} | |
$amxipv6.="</table></div>\n"; | |
if($ais) | |
{ | |
echo $amxipv6; | |
} | |
exec("timeout 1 /usr/bin/dig txt ".escapeshellarg($odomain)." +noall +answer +multi", $spf); | |
if(strpos(end($spf),"TXT")!=false) | |
{ | |
echo "<hr><h2>SPF / TXT records for ". $odomain ."</h2><div id='wood'>"; | |
echo '<table width="80%"><tr><td>'; | |
//print_r($spf); | |
foreach($spf as $spfline) | |
{ | |
if((strpos($spfline, 'global options') == false) && (strpos($spfline, 'DiG')== false)) | |
{ | |
echo $spfline. "<br/><br/>"; | |
} | |
} | |
echo "</td></tr></table></div>"; | |
} | |
?> | |
<hr><h2>SOA record for <?php echo $odomain ?></h2><div id='wood'> | |
<?php | |
exec("timeout 1 /usr/bin/dig soa ".escapeshellarg($odomain)." +noall +answer +multi", $soa); | |
echo "<table width=800><tr><td>"; | |
//print_r($spf); | |
foreach($soa as $soaline) | |
{ | |
if((strpos($soaline, 'global options') == false) && (strpos($soaline, 'DiG')== false)) | |
{ | |
echo $soaline. "<br/><br/>"; | |
} | |
} | |
exec("timeout 1 /usr/bin/dig ds ".escapeshellarg($odomain)." +noall +answer", $ds); | |
echo "</div>"; | |
echo "</td></tr></table></div>"; | |
if(strpos(end($ds),"DS")!=False) | |
{ | |
echo "<h2>DS records for ".$odomain."</h2><div id='wood'>"; | |
//print_r($ds); | |
foreach($ds as $fds) | |
{ | |
if((strpos($fds, 'global options') == false) && (strpos($fds, 'DiG')== false)) | |
{ | |
echo $fds."<br/>"; | |
} | |
} | |
echo "</div>"; | |
} | |
exec("timeout 1 /usr/bin/dig +short ".escapeshellarg($odomain), $domainip); | |
if(end($domainip)) | |
{ | |
//exec("whois ". end($domainip),$whoisip); | |
//exec("whois ". end($domainip),$whoisip); | |
// exec("whois -h whois.bgpmon.net ". end($domainip),$whoisbgp); | |
//exec("whois -h v4.whois.cymru.com " . end($domainip),$whoiscbgp); | |
} | |
?> | |
<hr> | |
<?php | |
//include("ad.html"); | |
?> | |
<div class="fixed"> | |
<?php | |
if(substr($odomain,-3)=="com") | |
{ | |
// $comwhois="whois 'domain ".$odomain."'"; | |
$comwhois="whois ".$odomain; | |
} | |
else | |
{ | |
$comwhois = "whois ". $odomain; | |
} | |
//echo "<h2>Whois report for ".$odomain."</h2>"; | |
//exec("whois ".escapeshellarg($odomain), $whois); | |
//exec($comwhois, $whois); | |
//} | |
exec("whois -h whois.tucows.com ". $odomain ,$tucowswhois); | |
echo "<h2>Tucows Whois lookup for ".$odomain."</h2><div id='wood'><pre>"; | |
//print_r($ds); | |
foreach($tucowswhois as $tasw) | |
{ | |
echo $tasw."<br/>"; | |
} | |
echo "</div><br/><br/><br/>"; | |
exec("whois ". $odomain ,$dwhois); | |
echo "<h2>Whois lookup for ".$odomain."</h2><div id='wood'><pre>"; | |
//print_r($ds); | |
foreach($dwhois as $dasw) | |
{ | |
echo $dasw."<br/>"; | |
} | |
echo "</div>"; | |
?> | |
<?php | |
echo "<div id='blue'>"; | |
//exec("whois ".escapeshellarg($domain), $output); | |
//print_r($output); | |
//foreach ($whois as $line) | |
//{ | |
// echo $line. "<br/>"; | |
//} | |
?> | |
</div> | |
</div> | |
<div class="fixed"> | |
<pre> | |
<?php | |
// print_r($digroot); | |
// $digroote = explode("\t", end($digroot)); | |
//print_r($digroote); | |
//exec("timeout 1 /usr/bin/dig ".escapeshellarg($odomain)." +noall +authority @".end($digroote), $digtld); | |
// print_r($digtld); | |
?> | |
</pre> | |
<?php | |
//print_r($pieces); | |
$time = microtime(); | |
$time = explode(' ', $time); | |
$time = $time[1] + $time[0]; | |
$finish = $time; | |
$total_time = round(($finish - $start), 4); | |
$total_min=$total_time/60; | |
$total_min=number_format((float)$total_min, 2, '.', ''); | |
echo 'Page generated in '.$total_time.' seconds.'; | |
echo ', '.$total_min.' minutes.'; | |
?> | |
</div> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment