Created
January 13, 2018 03:06
-
-
Save mnathani/b085ff53118b5c10249b6ea9c784c09c to your computer and use it in GitHub Desktop.
Eyes please php cli first attempt
This file contains hidden or 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 | |
//stream_set_blocking(STDIN, 0); | |
//$f = fgets(STDIN); | |
//var_dump($f); | |
echo "Domain,A Record,PTR Record of A,WWW Record,Nameservers,MX Records,A Record of MX,PTR Record of A of MX\n"; | |
while (($ind = fgets(STDIN)) !== false) { | |
$ind=trim($ind); | |
exec("/usr/bin/dig a ".$ind." +short", $inda); | |
sort($inda); | |
//echo "<pre>"; | |
//var_dump($inda); | |
//echo "</pre>"; | |
if(count($inda)==0) | |
{ | |
$indptr[0]=""; | |
} | |
else | |
{ | |
exec("/usr/bin/dig -x ".$inda[0]." +short", $indptr); | |
} | |
exec("/usr/bin/dig mx ".$ind." +short", $indmx); | |
sort($indmx); | |
// $indamatches=explode("\n",$inda); | |
//print_r($inda); | |
exec("/usr/bin/dig www.".$ind." +short", $indwww); | |
exec("/usr/bin/dig ns ".$ind." +short", $indns); | |
sort($indns); | |
//print_r($indns); | |
foreach ($inda as $indaelement) | |
{ | |
$indapresent= "".$indapresent.$indaelement.";"; | |
$inahtml="".$inahtml.$indaelement."<br/>"; | |
} | |
foreach ($indmx as $indmxelement) | |
{ | |
$indmxpresent= "".$indmxpresent.$indmxelement.";"; | |
$inmxhtml="".$inmxhtml.$indmxelement."<br/>"; | |
} | |
foreach ($indns as $indnselement) | |
{ | |
$indnspresent= "".$indnspresent.$indnselement.";"; | |
$innshtml="".$innshtml.$indnselement."<br/>"; | |
} | |
// <td>Domain</td><td>A Record</td><td>PTR Record</td><td>NameServers</td><td>MX Records</td> | |
// echo "<tr><td>".$ind."</td><td>".$inahtml."</td><td>".$indptr[0]."</td><td>".$innshtml."</td><td>".$inmxhtml."</td></tr>"; | |
//$csv=$csv.$ind .", ".$indapresent.", ".$indptr[0].", ".$indnspresent.", ".$indmxpresent."\n"; | |
echo $ind .", ".$indapresent.", ".$indptr[0].",".$indwww[0].", ".$indnspresent.", ".$indmxpresent."\n"; | |
unset($inda); | |
unset($indaelement); | |
unset($indapresent); | |
unset($indns); | |
unset($indnselement); | |
unset($indnspresent); | |
unset($innshtml); | |
unset($inahtml); | |
unset($indptr); | |
unset($indmx); | |
unset($indmxelement); | |
unset($indmxpresent); | |
unset($inmxhtml); | |
} | |
//echo "<pre>".$csv."</pre>"; | |
//echo $csv; | |
// process the line read. | |
//echo $line; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment