forked from kirei/dnsqproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdt.pl
114 lines (95 loc) · 3.12 KB
/
pdt.pl
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/perl
use utf8;
use warnings;
use strict;
use JSON;
my $zone = "se";
my @servers = (
"192.36.144.107", # a.ns.se.
"2a01:3f0:0:301::53", # a.ns.se.
"192.36.133.107", # b.ns.se.
"2001:67c:254c:301::53", # b.ns.se.
"192.36.135.107", # c.ns.se.
"2001:67c:2554:301::53", # c.ns.se.
"81.228.8.16", # d.ns.se.
"81.228.10.57", # e.ns.se.
"192.71.53.53", # f.ns.se.
"2a01:3f0:0:305::53", # f.ns.se.
"130.239.5.114", # g.ns.se.
"2001:6b0:e:3::1", # g.ns.se.
"194.146.106.22", # i.ns.se.
"2001:67c:1010:5::53", # i.ns.se.
"199.254.63.1", # j.ns.se.
"2001:500:2c::1", # j.ns.se.
);
my $known_good_qname = "whois.nic.$zone";
my $known_good_qtype = "A";
my $known_bad_qname = "xx--example.$zone";
my $known_bad_qtype = "SOA";
my $recursive_qname = "example.com";
my $recursive_qtype = "SOA";
my @transports = ( "udp", "tcp" );
my %template = (
#'tcp_timeout' => 8,
#'udp_timeout' => 3,
# quick test timers
'tcp_timeout' => 1,
'retrans' => 5,
'retry' => 2,
# EDNS0 buffer size
'bufsize' => 1400,
);
sub xmit($) {
my $json = to_json( shift );
print STDERR "QUERY: ", $json, "\n";
print $json, "\n";
}
foreach my $server ( @servers ) {
foreach my $transport ( @transports ) {
my %query = %template;
$query{address} = $server;
$query{transport} = $transport;
# SOA without DO=1 (DNS02, DNS03, DNS07)
$query{tag} = "t1";
$query{qname} = $zone;
$query{qtype} = "SOA";
$query{flags} = { do => 0, cd => 0, rd => 0, ad => 0 };
xmit( \%query );
# SOA with DO=1 (DNS02, DNS03, DNS07)
$query{tag} = "t2";
$query{qname} = $zone;
$query{qtype} = "SOA";
$query{flags} = { do => 1, cd => 0, rd => 0, ad => 0 };
xmit( \%query );
# NS (DNS05, DNS06, DNS08)
$query{tag} = "t3";
$query{qname} = $zone;
$query{qtype} = "NS";
$query{flags} = { do => 1, cd => 0, rd => 0, ad => 0 };
xmit( \%query );
# DNSKEY (DNS16)
$query{tag} = "t4";
$query{qname} = $zone;
$query{qtype} = "DNSKEY";
$query{flags} = { do => 1, cd => 0, rd => 0, ad => 0 };
xmit( \%query );
# DELEGATION resulting in referal (ADD11)
$query{tag} = "t5";
$query{qname} = $known_good_qname;
$query{qtype} = $known_good_qtype;
$query{flags} = { do => 1, cd => 0, rd => 0, ad => 0 };
xmit( \%query );
# DELEGATION resulting in NXDOMAIN (DNS17)
$query{tag} = "t6";
$query{qname} = $known_bad_qname;
$query{qtype} = $known_bad_qtype;
$query{flags} = { do => 1, cd => 0, rd => 0, ad => 0 };
xmit( \%query );
# RECURSION (DNS11)
$query{tag} = "t7";
$query{qname} = $recursive_qname;
$query{qtype} = $recursive_qtype;
$query{flags} = { do => 0, cd => 0, rd => 1, ad => 0 };
xmit( \%query );
}
}