From d4d8bcf9f6b23d45db360e45653ebc96a4838e40 Mon Sep 17 00:00:00 2001 From: fyodor Date: Tue, 12 Sep 2006 03:02:34 +0000 Subject: [PATCH] Update fingerdiff to use fingerlib --- scripts/Makefile | 2 +- scripts/fingerdiff.cc | 80 +------------------------------------------ 2 files changed, 2 insertions(+), 80 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index 388c1a300..0d6a4622e 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -25,7 +25,7 @@ fingermatch: dummy $(CXX) $(CXXFLAGS) -Wall $(INCLUDE_FLAGS) $(LINK_FLAGS) $(DEFINES) -o $@ $@.cc fingerlib.o $(NMAP_OBJS) -lm -lnbase -lpcap -lpcre -lssl -lcrypt fingerdiff: dummy - $(CXX) $(CXXFLAGS) -Wall $(INCLUDE_FLAGS) $(LINK_FLAGS) $(DEFINES) -o $@ $@.cc $(NMAP_OBJS) -lm -lnbase -lpcap -lpcre -lssl -lcrypt + $(CXX) $(CXXFLAGS) -Wall $(INCLUDE_FLAGS) $(LINK_FLAGS) $(DEFINES) -o $@ $@.cc fingerlib.o $(NMAP_OBJS) -lm -lnbase -lpcap -lpcre -lssl -lcrypt servicematch: dummy $(CXX) $(CXXFLAGS) -Wall $(INCLUDE_FLAGS) $(LINK_FLAGS) $(DEFINES) -o $@ $@.cc $(NMAP_OBJS) -lm -lnbase -lpcap -lpcre -lssl -lcrypt diff --git a/scripts/fingerdiff.cc b/scripts/fingerdiff.cc index 16f017772..0b27d9520 100644 --- a/scripts/fingerdiff.cc +++ b/scripts/fingerdiff.cc @@ -104,6 +104,7 @@ #include "nbase.h" #include "nmap.h" #include "osscan.h" +#include "fingerlib.h" void usage(char *err_fmt, ...) { va_list ap; @@ -121,85 +122,6 @@ void usage(char *err_fmt, ...) { exit(1); } -/* Returns -1 (or exits) for failure */ -int readFP(FILE *filep, char *newFP, int newFPsz ) { - char line[512], lasttestname[64]; - int linelen; - int lastlinelen = 0; - int printlen = 0; - int adjusted = 0; /* Flags if we have adjusted the entered fingerprint */ - char *p; - - if (newFPsz < 50) return -1; - - newFP[0] = lasttestname[0] = '\0'; - - while((fgets(line, sizeof(line), filep))) { - if (*line == '\n' || *line == '.') - break; - - linelen = strlen(line); - /* Check if it is a duplicate testname */ - if (*line == '#') - continue; - p = strchr(line, '('); - if (p) { - *p = '\0'; - if (strcmp(line, lasttestname) == 0) { - adjusted = 1; - if (lastlinelen >= linelen) - continue; - /* The new one is longer (and thus probably better) -- clobber the last - line */ - printlen -= lastlinelen; - newFP[printlen] = '\0'; - } - Strncpy(lasttestname, line, sizeof(lasttestname)); - lastlinelen = linelen; - *p = '('; - } else { - /* The only legitimate non-comment line that doesn't have a ( is the - initial Fingerprint and the following Class line(s) */ - if (strncmp(line, "Class ", 6) == 0) { - char *q = line + 6; - while(*q && isspace(*q)) q++; - if (!*q) continue; // Empty class line - } else if (strncmp(line, "Fingerprint ", 12) != 0) { - printf("Warning: Bogus line skipped\n"); - continue; - } - } - if (printlen + linelen >= newFPsz - 5) - fatal("Overflow!"); - strcpy(newFP + printlen, line); - printlen += linelen; - } - - if (adjusted) { - printf("\n**WARNING**: Adjusted fingerprint due to duplicated tests (we only look at the first). Results are based on this adjusted fingerprint:\n%s\n", - newFP); - } - - /* Now we validate that all elements are present */ - p = newFP; - if (!strstr(p, "SEQ(") || !strstr(p, "OPS(") || !strstr(p, "WIN(") || - !strstr(p, "ECN(") || !strstr(p, "T1(") || !strstr(p, "T2(") || - !strstr(p, "T3(") || !strstr(p, "T4(") || !strstr(p, "T5(") || - !strstr(p, "T6(") || !strstr(p, "T7(") || !strstr(p, "U1(") || - !strstr(p, "IE(")) { - /* This ought to get my attention :) */ - printf("\n" - "********************************************************\n" - "***WARNING: Fingerprint is missing at least 1 element***\n" - "********************************************************\n" - ); - - } - if (printlen < 1) - return -1; - return 0; -} - int main(int argc, char *argv[]) { FingerPrint *referenceFP; FingerPrint *observedFP;