-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenfilter.pl
44 lines (40 loc) · 892 Bytes
/
genfilter.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
#Wireshark filter gen tool
my @domains = qw (
tinymta.com
tinymta.us.to
gh.tinymta.us.to
tiles1.tinymta.us.to
tiles2.tinymta.us.to
wvoice.us.to
api.weather.com
collector-otp-prod.camsys-apps.com
otp-mta-prod.camsys-apps.com
backend-unified.mylirr.org
);
my %blocks = ('1.1.1' => 1, '4.2.2' => 1, '8.8.8' => 1);
my $o;
my @ips;
my @nets;
foreach my $domain (@domains) {
$o = `nslookup $domain`;
$o =~ s/^Address: .+$//m;
@ips = $o =~ /(\d{1,3}(?:\.\d{1,3}){3})/g;
foreach my $ip (@ips) {
$ip =~ /^(\d{1,3}.\d{1,3}.\d{1,3})/;
$blocks{$1} = 1;
}
}
#run 2x to deal with DNS LBs, aka CF
foreach my $domain (@domains) {
$o = `nslookup $domain`;
$o =~ s/^Address: .+$//m;
@ips = $o =~ /(\d{1,3}(?:\.\d{1,3}){3})/g;
foreach my $ip (@ips) {
$ip =~ /^(\d{1,3}.\d{1,3}.\d{1,3})/;
$blocks{$1} = 1;
}
}
foreach( keys %blocks ) {
push @nets, "net ".$_.".0/24";
}
print join(' or ', @nets);