1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-02 04:49:02 +00:00

Updated sort-prints script to work with 2nd gen format, sorted the current DB, updated Makefile to do sort when building distro

This commit is contained in:
fyodor
2006-09-30 09:03:45 +00:00
parent bb44323041
commit ce0e8da169
3 changed files with 399 additions and 380 deletions

View File

@@ -38,7 +38,7 @@ web:
xnmap.1 nmap.usage.txt nmap.dtd nmap.xsl \
leet-nmap-ascii-art.txt $(wroot)/nmap/data/
cp $(wroot)/nmapguide/build/nmap-man.xml $(wroot)/nmap/data/nmap-man.xml
# ./sort-prints.pl ../nmap-os-fingerprints > nos && mv nos ../nmap-os-fingerprints
./sort-prints.pl ../nmap-os-db > nos && mv nos ../nmap-os-db
./produceosclasschoosebox.pl ../nmap-os-fingerprints > $(wroot)/nmap/data/os-classes.txt
cd .. && cp -a CHANGELOG HACKING COPYING COPYING.OpenSSL INSTALL \
$(DATAFILES) README-WIN32 mswin32/nmap_performance.reg $(wroot)/nmap/data

View File

@@ -2,12 +2,21 @@
sub usage() {
print STDERR "Usage: sort-prints.pl <nmap-os-fingerprints file>\n" .
"Slurps up the given nmap-os-fingerprints file, sorts it appropriately (Class, then name string), then spits it out to stdout. Some minor canonicalization is done too.\n\n";
"Slurps up the given nmap-os-fingerprints file, sorts it appropriately (headertext, then MatchPoints, then fingerprintes sorted by first class, then name string), then spits it out to stdout. Some minor canonicalization is done too.\n\n";
exit(0);
}
sub fprintsort {
if ($a->{type} eq "MatchPoints") {
if ($b->{type} eq "MatchPoints") {
print STDERR "ERROR: More than one MatchPoints section found in fingerprint DB\n";
usage();
}
return -1;
}
if ($b->{type} eq "MatchPoints") {
return 1;
}
lc($a->{firstClass}) cmp lc($b->{firstClass})
or
lc($a->{name}) cmp lc($b->{name});
@@ -65,10 +74,15 @@ while($nxtline = <OSFILE>) {
}
if ($state eq "fprint-name") {
if ($nxtline =~ /^Fingerprint (\S.*\S)\s*$/) {
if ($nxtline =~ /^Fingerprint (\S.*\S)\s*$/i) {
$newFP{name} = $1;
$newFP{type} = "Fingerprint";
$state = "fprint-class";
next;
} elsif ($nxtline =~ /^MatchPoints/) {
$newFP{type} = "MatchPoints";
$state = "fprint-tests";
next;
}
die "ERROR: Parse error on $osfile:$lineno -- expected Fingerprint directive";
}
@@ -120,9 +134,14 @@ foreach $print (@sortedprints) {
if ($firstline) {
$firstline = 0;
} else { print "\n"; }
if ($print->{comments}) {
print $print->{comments};
}
print "Fingerprint $print->{name}\n";
if ($print->{type} eq "MatchPoints") {
print "MatchPoints\n";
} else {
print "Fingerprint $print->{name}\n";
}
print "$print->{data}";
}