mirror of
https://github.com/nmap/nmap.git
synced 2025-12-08 13:41:29 +00:00
Update fingerdiff to use fingerlib
This commit is contained in:
@@ -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
|
$(CXX) $(CXXFLAGS) -Wall $(INCLUDE_FLAGS) $(LINK_FLAGS) $(DEFINES) -o $@ $@.cc fingerlib.o $(NMAP_OBJS) -lm -lnbase -lpcap -lpcre -lssl -lcrypt
|
||||||
|
|
||||||
fingerdiff: dummy
|
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
|
servicematch: 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 $(NMAP_OBJS) -lm -lnbase -lpcap -lpcre -lssl -lcrypt
|
||||||
|
|||||||
@@ -104,6 +104,7 @@
|
|||||||
#include "nbase.h"
|
#include "nbase.h"
|
||||||
#include "nmap.h"
|
#include "nmap.h"
|
||||||
#include "osscan.h"
|
#include "osscan.h"
|
||||||
|
#include "fingerlib.h"
|
||||||
|
|
||||||
void usage(char *err_fmt, ...) {
|
void usage(char *err_fmt, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -121,85 +122,6 @@ void usage(char *err_fmt, ...) {
|
|||||||
exit(1);
|
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[]) {
|
int main(int argc, char *argv[]) {
|
||||||
FingerPrint *referenceFP;
|
FingerPrint *referenceFP;
|
||||||
FingerPrint *observedFP;
|
FingerPrint *observedFP;
|
||||||
|
|||||||
Reference in New Issue
Block a user