This repository has been archived by the owner on Apr 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
rdc.php
60 lines (60 loc) · 2.19 KB
/
rdc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/php -q
<?php
echo "https://github.com/adamziaja/dns-check\n";
echo "(C) 2013 Adam Ziaja <[email protected]> http://adamziaja.com\n";
require_once('Net/DNS2.php'); // http://code.google.com/p/netdns2/
$domain = $argv[1];
foreach (gethostbynamel($domain) as $ip) {
$arpa = implode('.', array_reverse(explode('.', $ip))) . '.in-addr.arpa';
do {
$dns_arpa = dns_get_record($arpa, DNS_NS);
echo "\n\033[1;33m$arpa\033[0m\n";
$arpa_ns = $arpa;
$dns_arpa_array = explode('.', $arpa);
array_shift($dns_arpa_array);
$arpa = implode('.', $dns_arpa_array);
} while (!count($dns_arpa) || count($arpa) == 2);
if (count($dns_arpa)) {
$dns_records = dns_get_record($arpa_ns, DNS_NS);
if (!count($dns_records)) {
echo "\n\033[1;33mhost $arpa_ns not found\033[0m\n";
}
$dns_servers = array();
foreach ($dns_records as $dns_record) {
foreach (gethostbynamel($dns_record['target']) as $ip) {
array_push($dns_servers, $ip);
}
}
$domain_list = array();
foreach ($dns_servers as $dns_server) {
echo "\n\033[1;32m" . $dns_server . ' (' . gethostbyaddr($dns_server) . ") AXFR $arpa_ns\033[0m\n";
$result = NULL;
$r = new Net_DNS2_Resolver(array('nameservers' => array($dns_server)));
try {
$result = $r->query($arpa_ns, 'AXFR');
} catch (Net_DNS2_Exception $e) {
echo "\033[1;31m::query() failed: ", $e->getMessage(), "\033[0m\n";
}
if ($result) {
foreach ($result->answer as $rr) {
if (preg_match("/$domain/i", $rr)) {
$rr = "\033[1;35m$rr\033[0m";
echo "$rr\n";
array_push($domain_list, $rr);
} else {
echo "$rr\n";
}
}
}
}
if ($domain_list) {
echo "\n";
}
foreach ($domain_list as $domain_record) {
echo "$domain_record\n";
}
} else {
echo "\033[1;31m$arpa\033[0m\n";
}
}
?>