-
Notifications
You must be signed in to change notification settings - Fork 2
/
dnsscan.php
66 lines (61 loc) · 1.92 KB
/
dnsscan.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
61
62
63
64
65
66
<html>
<style>
body {
background-color: #000000;
color: #00ffff;
}
h1 {
color: #ff0000;
}
</style>
<h1>Welcome to SynthMesc's open recursive DNS scanner!</h1>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="GET">
DNS Server list URL/File: <input name="url">
<input type ="submit" value="Scan">
</form>
<?php
error_reporting(0);
set_time_limit(0);
if (isset($_GET['url'])) {
$servers = explode("\n", file_get_contents($_GET['url']));
foreach($servers as &$server) {
checkForRecursion($server);
}
}
function checkForRecursion($target) {
$request = "\xde\xad"; // Transaction-ID 0xdead
$request .= "\x01\x00"; // flags (recursion desired)
$request .= "\x00\x01"; // 1 question
$request .= "\x00\x00"; // 0 answers
$request .= "\x00\x00"; // 0 authority
$request .= "\x00\x00"; // 0 additional
$request .= "\x03www\x09wikipedia\x03org\x00"; // www.wikipedia.org
$request .= "\x00\x01"; // type A
$request .= "\x00\x01"; // class IN
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($sock,SOL_SOCKET,SO_RCVTIMEO,array("sec"=>0,"usec"=>75000));
$len = strlen($request);
$port = 53;
socket_sendto($sock, $request, $len, 0, $target, $port);
$r = socket_recvfrom($sock, $response, 1024, 0, $target, $port);
if ($response[3] == "\x80") {
echo "<font color='#00ff00'><b>[+]</b></font> Recursion appears to be enabled on $target!<br>\n";
$logfile="DNSw00t.txt";
$fp = fopen($logfile, "a") or die("Unable to open file!"); fwrite($fp, $target . "\n") or die("Unable to write to file!");
fflush($fp);
fclose($fp);
return true;
} else if ($response == "") {
echo "<font color='#ff0000'><b>[-]</b></font> No response from $target<br>\n";
return false;
} else {
echo "<font color='#ff0000'><b>[-]</b></font> Recursion appears to be disabled on $target<br>\n";
return false;
}
ob_flush();
socket_close($sock);
}
?>
</body>
</html>