Created
January 25, 2013 09:18
-
-
Save horsley/4633026 to your computer and use it in GitHub Desktop.
Simple PHP code act as a dig tool to find dns records
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 | |
$result = array(); | |
$result_html = ''; | |
if (isset($_POST['domain']) && !empty($_POST['domain'])) { | |
$domain_regex = '/[a-z\d][a-z\-\d\.]+[a-z\d]/i'; | |
if (preg_match($domain_regex, $_POST['domain'])) { | |
if ($url = parse_url($_POST['domain'])) { //compatible when user post an url instead of a domain | |
if (isset($url['host'])) { | |
$result = dns_get_record($url['host'], DNS_A + DNS_AAAA + DNS_CNAME); | |
} else if (isset($url['path'])) { | |
$result = dns_get_record($url['path'], DNS_A + DNS_AAAA + DNS_CNAME); | |
} | |
} | |
} | |
if (empty($result)) { | |
$result_html = '<hr>Nothing found or Domain Invalid'; | |
} else { | |
foreach($result as $r) { | |
reset($r); | |
$host = current($r); | |
$type = next($r); | |
$value = next($r); | |
$result_html .= sprintf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n", $host, $type, $value); | |
} | |
$result_html = "<hr>\n<table>\n$result_html</table>\n"; | |
} | |
} | |
?><!DOCTYPE HTML> | |
<html xmlns="http://www.w3.org/1999/html"> | |
<head> | |
<meta charset="UTF-8"/> | |
<title>Raw Dns Lookup</title> | |
<style>/* somethin from bootstrap */ | |
button,input {margin: 0;font-size: 100%;vertical-align: middle;} | |
hr {margin: 20px 0;border: 0;border-top: 1px solid #eeeeee;border-bottom: 1px solid #ffffff;} | |
label {margin-bottom: 3px;} | |
.form-inline {vertical-align: middle;} | |
table {width: 100%;text-align: center;margin: auto;} | |
</style> | |
</head> | |
<body> | |
<div style="text-align: center;width: 800px;margin: 1em auto"> | |
<h1>Raw Dns Lookup</h1> | |
<form method="post"> | |
<div class="form-inline"> | |
<label for="domain">Domain: </label> | |
<input id="domain" type="text" name="domain" value="<?=empty($_POST['domain'])?'':$_POST['domain']?>"> | |
<button type="submit">Dig</button> | |
</div> | |
</form> | |
<?=$result_html?$result_html:''?> | |
<hr/> | |
<p>Server Location: | |
<? | |
$geo = json_decode(file_get_contents('http://smart-ip.net/geoip-json')); | |
echo $geo->countryName; | |
?> | |
<br/> | |
<span>Powered by <a href="http://weibo.com/horsley" title="Developer:horsley" target="_blank">Horsley</a></span> | |
</p> | |
</div> | |
</body> | |
</html> |
only returns single record for CNAME. Multiple Record are filter
replace lines 58 and 59 for these
$geo = json_decode(file_get_contents("http://freegeoip.net/json/".$_POST['domain']));
echo $geo->country_name;
this script does not help in found the records of domain
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
replace lines 58 and 59 for these
$geo = json_decode(file_get_contents("http://freegeoip.net/json/".$_POST['domain']));
echo $geo->country_name;