📄 output.cc
字号:
else { log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "OS details: %s", FPR->prints[0]->OS_name); i = 1; while(FPR->accuracy[i] == 1) { log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,", %s", FPR->prints[i]->OS_name); i++; } } } else { if ((o.verbose > 1 || o.debugging) && reason) log_write(LOG_NORMAL|LOG_SKID_NOXLT|LOG_STDOUT, "OS fingerprint not ideal because: %s\n", reason); if ((o.osscan_guess || reason) && FPR->num_matches > 0) { /* Print the best guesses available */ log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,"Aggressive OS guesses: %s (%d%%)", FPR->prints[0]->OS_name, (int) (FPR->accuracy[0] * 100)); for(i=1; i < 10 && FPR->num_matches > i && FPR->accuracy[i] > FPR->accuracy[0] - 0.10; i++) { char *p; log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,", %s (%d%%)", FPR->prints[i]->OS_name, (int) (FPR->accuracy[i] * 100)); log_write(LOG_XML, "<osmatch name=\"%s\" accuracy=\"%d\" line=\"%d\"/>\n", p = xml_convert(FPR->prints[i]->OS_name), (int) (FPR->accuracy[i] * 100), FPR->prints[i]->line); free(p); } log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "\n"); } if (osscanSys == 2 && !reason) { log_write(LOG_NORMAL|LOG_SKID_NOXLT|LOG_STDOUT,"No exact OS matches for host (If you know what OS is running on it, see http://insecure.org/nmap/submit/ ).\nTCP/IP fingerprint:\n%s\n", mergeFPs(FPR->FPs, FPR->numFPs, true, currenths->v4hostip(), distance, currenths->MACAddress(), FPR->osscan_opentcpport, FPR->osscan_closedtcpport, FPR->osscan_closedudpport, true)); } else { log_write(LOG_NORMAL|LOG_SKID_NOXLT|LOG_STDOUT,"No exact OS matches for host (test conditions non-ideal)."); if (o.verbose > 1 || o.debugging) log_write(LOG_NORMAL|LOG_SKID_NOXLT|LOG_STDOUT, "\nTCP/IP fingerprint by osscan system #%d:\n%s", osscanSys, mergeFPs(FPR->FPs, FPR->numFPs, false, currenths->v4hostip(), distance, currenths->MACAddress(), FPR->osscan_opentcpport, FPR->osscan_closedtcpport, FPR->osscan_closedudpport, false)); } } log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,"\n"); if (FPR->goodFP >= 0 && (o.debugging || o.verbose > 1) && FPR->num_perfect_matches > 0 ) { log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,"OS Fingerprint:\n%s\n", mergeFPs(FPR->FPs, FPR->numFPs, !reason, currenths->v4hostip(), distance, currenths->MACAddress(), FPR->osscan_opentcpport, FPR->osscan_closedtcpport, FPR->osscan_closedudpport, true)); } } else if (FPR->overall_results == OSSCAN_NOMATCHES) { const char *reason = FPR->OmitSubmissionFP(); if ((o.verbose > 1 || o.debugging) && reason) log_write(LOG_NORMAL|LOG_SKID_NOXLT|LOG_STDOUT,"OS fingerprint not ideal because: %s\n", reason); if (osscanSys == 2 && !reason) { log_write(LOG_NORMAL|LOG_SKID_NOXLT|LOG_STDOUT,"No OS matches for host (If you know what OS is running on it, see http://insecure.org/nmap/submit/ ).\nTCP/IP fingerprint:\n%s\n", mergeFPs(FPR->FPs, FPR->numFPs, true, currenths->v4hostip(), distance, currenths->MACAddress(), FPR->osscan_opentcpport, FPR->osscan_closedtcpport, FPR->osscan_closedudpport, true)); } else { log_write(LOG_NORMAL|LOG_SKID_NOXLT|LOG_STDOUT,"No OS matches for host\n"); if (o.verbose > 1) log_write(LOG_NORMAL|LOG_SKID_NOXLT|LOG_STDOUT, "\nTCP/IP fingerprint by osscan system #%d:\n%s", osscanSys, mergeFPs(FPR->FPs, FPR->numFPs, false, currenths->v4hostip(), distance, currenths->MACAddress(), FPR->osscan_opentcpport, FPR->osscan_closedtcpport, FPR->osscan_closedudpport, false)); } } else if (FPR->overall_results == OSSCAN_TOOMANYMATCHES || (FPR->num_perfect_matches > 8 && !o.debugging)) { log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,"Too many fingerprints match this host to give specific OS details\n"); if (o.debugging || o.verbose > 1) { log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,"TCP/IP fingerprint by osscan system #%d:\n%s", osscanSys, mergeFPs(FPR->FPs, FPR->numFPs, false, currenths->v4hostip(), distance, currenths->MACAddress(), FPR->osscan_opentcpport, FPR->osscan_closedtcpport, FPR->osscan_closedudpport, false)); } } else { assert(0); } if (o.debugging || o.verbose) { log_write(LOG_XML,"<osfingerprint fingerprint=\"\n%s\" />\n", mergeFPs(FPR->FPs, FPR->numFPs, false, currenths->v4hostip(), distance, currenths->MACAddress(), FPR->osscan_opentcpport, FPR->osscan_closedtcpport, FPR->osscan_closedudpport, false)); } log_write(LOG_XML, "</os>\n"); if (currenths->seq.lastboot) { char tmbuf[128]; struct timeval tv; gettimeofday(&tv, NULL); strncpy(tmbuf, ctime(&(currenths->seq.lastboot)), sizeof(tmbuf)); chomp(tmbuf); log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,"Uptime: %.3f days (since %s)\n", (double) (tv.tv_sec - currenths->seq.lastboot) / 86400, tmbuf); log_write(LOG_XML, "<uptime seconds=\"%li\" lastboot=\"%s\" />\n", tv.tv_sec - currenths->seq.lastboot, tmbuf); } if (distance!=-1) { log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "Network Distance: %d hop%s\n", distance, (distance == 1)? "" : "s"); log_write(LOG_XML, "<distance value=\"%d\" />\n", distance); } if (currenths->seq.responses > 3) { p=numlst; for(i=0; i < currenths->seq.responses; i++) { if (p - numlst > (int) (sizeof(numlst) - 15)) fatal("STRANGE ERROR #3877 -- please report to fyodor@insecure.org\n"); if (p != numlst) *p++=','; sprintf(p, "%X", currenths->seq.seqs[i]); while(*p) p++; } log_write(LOG_XML, "<tcpsequence index=\"%li\" class=\"%s\" difficulty=\"%s\" values=\"%s\" />\n", (long) currenths->seq.index, seqclass2ascii(currenths->seq.seqclass), seqidx2difficultystr(currenths->seq.index), numlst); if (o.verbose) { if (osscanSys == 1) log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,"%s", seqreport1(&(currenths->seq))); else if(osscanSys == 2) log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,"%s", seqreport(&(currenths->seq))); } log_write(LOG_MACHINE,"\tSeq Index: %d", currenths->seq.index); } if (currenths->seq.responses > 2) { p=numlst; for(i=0; i < currenths->seq.responses; i++) { if (p - numlst > (int) (sizeof(numlst) - 15)) fatal("STRANGE ERROR #3876 -- please report to fyodor@insecure.org\n"); if (p != numlst) *p++=','; sprintf(p, "%hX", currenths->seq.ipids[i]); while(*p) p++; } log_write(LOG_XML, "<ipidsequence class=\"%s\" values=\"%s\" />\n", ipidclass2ascii(currenths->seq.ipid_seqclass), numlst); if (o.verbose) log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,"IPID Sequence Generation: %s\n", ipidclass2ascii(currenths->seq.ipid_seqclass)); log_write(LOG_MACHINE,"\tIPID Seq: %s", ipidclass2ascii(currenths->seq.ipid_seqclass)); p=numlst; for(i=0; i < currenths->seq.responses; i++) { if (p - numlst > (int) (sizeof(numlst) - 15)) fatal("STRANGE ERROR #3877 -- please report to fyodor@insecure.org\n"); if (p != numlst) *p++=','; sprintf(p, "%X", currenths->seq.timestamps[i]); while(*p) p++; } log_write(LOG_XML, "<tcptssequence class=\"%s\"", tsseqclass2ascii(currenths->seq.ts_seqclass)); if (currenths->seq.ts_seqclass != TS_SEQ_UNSUPPORTED) { log_write(LOG_XML, " values=\"%s\"", numlst); } log_write(LOG_XML, " />\n"); } log_flush_all();}/* An auxillary function for printserviceinfooutput(). Returns non-zero if a and b are considered the same hostnames. */static int hostcmp(const char *a, const char *b) { return strcasestr(a, b)? 1 : 0;}/* Prints the alternate hostname/OS/device information we got from the * service scan (if it was performed) */void printserviceinfooutput(Target *currenths) { Port *p = NULL; struct serviceDeductions sd; int i, numhostnames=0, numostypes=0, numdevicetypes=0; char hostname_tbl[MAX_SERVICE_INFO_FIELDS][MAXHOSTNAMELEN]; char ostype_tbl[MAX_SERVICE_INFO_FIELDS][64]; char devicetype_tbl[MAX_SERVICE_INFO_FIELDS][64]; char *delim; for (i=0; i<MAX_SERVICE_INFO_FIELDS; i++) hostname_tbl[i][0] = ostype_tbl[i][0] = devicetype_tbl[i][0] = '\0'; while ((p = currenths->ports.nextPort(p, TCPANDUDP, PORT_OPEN))) { // The following 2 lines (from portlist.h) tell us that we don't // need to worry about free()ing anything in the serviceDeductions struct. // pass in an allocated struct serviceDeductions (don't wory about initializing, and // you don't have to free any internal ptrs. p->getServiceDeductions(&sd); if (sd.hostname && !hostcmp(currenths->HostName(), sd.hostname)) { for (i=0; i<MAX_SERVICE_INFO_FIELDS; i++) { if (hostname_tbl[i][0] && hostcmp(&hostname_tbl[i][0], sd.hostname)) break; if (!hostname_tbl[i][0]) { numhostnames++; strncpy(&hostname_tbl[i][0], sd.hostname, sizeof(hostname_tbl[i])); break; } } } if (sd.ostype) { for (i=0; i<MAX_SERVICE_INFO_FIELDS; i++) { if (ostype_tbl[i][0] && !strcmp(&ostype_tbl[i][0], sd.ostype)) break; if (!ostype_tbl[i][0]) { numostypes++; strncpy(&ostype_tbl[i][0], sd.ostype, sizeof(ostype_tbl[i])); break; } } } if (sd.devicetype) { for (i=0; i<MAX_SERVICE_INFO_FIELDS; i++) { if (devicetype_tbl[i][0] && !strcmp(&devicetype_tbl[i][0], sd.devicetype)) break; if (!devicetype_tbl[i][0]) { numdevicetypes++; strncpy(&devicetype_tbl[i][0], sd.devicetype, sizeof(devicetype_tbl[i])); break; } } } } if (!numhostnames && !numostypes && !numdevicetypes) return; log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "Service Info:"); delim = " "; if (numhostnames) { log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "%sHost%s: %s", delim, numhostnames==1? "" : "s", &hostname_tbl[0][0]); for (i=1; i<MAX_SERVICE_INFO_FIELDS; i++) if (hostname_tbl[i][0]) log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, ", %s", &hostname_tbl[i][0]); delim="; "; } if (numostypes) { log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "%sOS%s: %s", delim, numostypes==1? "" : "s", &ostype_tbl[0][0]); for (i=1; i<MAX_SERVICE_INFO_FIELDS; i++) if (ostype_tbl[i][0]) log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, ", %s", &ostype_tbl[i][0]); delim="; "; } if (numdevicetypes) { log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "%sDevice%s: %s", delim, numdevicetypes==1? "" : "s", &devicetype_tbl[0][0]); for (i=1; i<MAX_SERVICE_INFO_FIELDS; i++) if (devicetype_tbl[i][0]) log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, ", %s", &devicetype_tbl[i][0]); delim="; "; } log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "\n"); log_flush_all();}/* Prints a status message while the program is running */void printStatusMessage() { // Pre-computations struct timeval tv; gettimeofday(&tv, NULL); int time = (int) (o.TimeSinceStartMS(&tv) / 1000.0); log_write(LOG_STDOUT, "Stats: %d:%02d:%02d elapsed; %d hosts completed (%d up), %d undergoing %s\n", time/60/24, time/60 % 24, time % 60, o.numhosts_scanned - o.numhosts_scanning, o.numhosts_up, o.numhosts_scanning, scantype2str(o.current_scantype));}/* Prints the statistics and other information that goes at the very end of an Nmap run */void printfinaloutput() { time_t timep; char mytime[128]; struct timeval tv; char statbuf[128]; gettimeofday(&tv, NULL); timep = time(NULL); if (o.numhosts_scanned == 0) fprintf(stderr, "WARNING: No targets were specified, so 0 hosts scanned.\n"); if (o.numhosts_scanned == 1 && o.numhosts_up == 0 && !o.listscan && o.pingtype != PINGTYPE_NONE) log_write(LOG_STDOUT, "Note: Host seems down. If it is really up, but blocking our ping probes, try -P0\n"); else if (o.numhosts_up > 0) { if (o.osscan && o.servicescan) log_write(LOG_STDOUT|LOG_NORMAL|LOG_SKID, "OS and Service detection performed. Please report any incorrect results at http://insecure.org/nmap/submit/ .\n"); else if (o.osscan) log_write(LOG_STDOUT|LOG_NORMAL|LOG_SKID, "OS detection performed. Please report any incorrect results at http://insecure.org/nmap/submit/ .\n"); else if (o.servicescan) log_write(LOG_STDOUT|LOG_NORMAL|LOG_SKID, "Service detection performed. Please report any incorrect results at http://insecure.org/nmap/submit/ .\n"); } log_write(LOG_STDOUT|LOG_SKID, "Nmap finished: %d %s (%d %s up) scanned in %.3f seconds\n", o.numhosts_scanned, (o.numhosts_scanned == 1)? "IP address" : "IP addresses", o.numhosts_up, (o.numhosts_up == 1)? "host" : "hosts", o.TimeSinceStartMS(&tv) / 1000.0); if (o.verbose && o.isr00t && o.RawScan()) log_write(LOG_STDOUT|LOG_SKID, " %s\n", getFinalPacketStats(statbuf, sizeof(statbuf))); Strncpy(mytime, ctime(&timep), sizeof(mytime)); chomp(mytime); log_write(LOG_XML, "<runstats><finished time=\"%lu\" timestr=\"%s\"/><hosts up=\"%d\" down=\"%d\" total=\"%d\" />\n", (unsigned long) timep, mytime, o.numhosts_up, o.numhosts_scanned - o.numhosts_up, o.numhosts_scanned); log_write(LOG_XML, "<!-- Nmap run completed at %s; %d %s (%d %s up) scanned in %.3f seconds -->\n", mytime, o.numhosts_scanned, (o.numhosts_scanned == 1)? "IP address" : "IP addresses", o.numhosts_up, (o.numhosts_up == 1)? "host" : "hosts", o.TimeSinceStartMS(&tv) / 1000.0 ); log_write(LOG_NORMAL|LOG_MACHINE, "# Nmap run completed at %s -- %d %s (%d %s up) scanned in %.3f seconds\n", mytime, o.numhosts_scanned, (o.numhosts_scanned == 1)? "IP address" : "IP addresses", o.numhosts_up, (o.numhosts_up == 1)? "host" : "hosts", o.TimeSinceStartMS(&tv) / 1000.0 ); log_write(LOG_XML, "</runstats></nmaprun>\n"); log_flush_all();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -