-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduceosclasschoosebox.pl
executable file
·48 lines (41 loc) · 1.21 KB
/
produceosclasschoosebox.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
#!/usr/bin/perl -w
if (!$ARGV[0]) {
print "Usage: produceosclasschoosebox.pl <nmap-os-fingerprints-filepath>\n\n"; exit;
}
# Kill leading and trailing whitespace
sub killws($) {
$str = shift;
$str =~ s/^\s+//g;
$str =~ s/\s+$//g;
return $str;
}
my @optionar;
my %unique_optvals;
while(<>) {
my %infohash;
if (/^Class /) {
s/Class //;
# Kill leading and trailing whitespace
my ($vendor, $osfam, $osgen, $type) = split /\|/;
$vendor = killws($vendor);
$osfam = killws($osfam);
$osgen = killws($osgen);
$type = killws($type);
$infohash{opval} = "$vendor|$osfam|$osgen|$type";
if (!$unique_optvals{$infohash{opval}}) {
$unique_optvals{$infohash{opval}} = 1;
$infohash{vendor} = $vendor;
$infohash{osfam} = $osfam;
$infohash{osgen} = $osgen;
$infohash{type} = $type;
if ($osgen) { $osgen = " $osgen"; }
if ($vendor eq $osfam) { $vendor = ""; } else {$vendor = "$vendor "; }
$infohash{fullname} = "$vendor$osfam$osgen $type";
push @optionar, \%infohash;
}
}
}
@optionar = sort { lc($a->{fullname}) cmp lc($b->{fullname}) } @optionar;
foreach $opt (@optionar) {
print qq|<option value="| . $opt->{opval} . qq|">| . $opt->{fullname} . "\n";
}