diff -r -u nmap-3.28/NmapOps.h nmap-3.28[]/NmapOps.h --- nmap-3.28/NmapOps.h 2003-04-08 06:05:24.000000000 +0300 +++ nmap-3.28[]/NmapOps.h 2003-06-15 21:12:07.000000000 +0300 @@ -82,6 +82,7 @@ // setPacketTrace(false) has been called void setPacketTrace(bool pt) { pTrace = pt; } int verbose; + int count; int randomize_hosts; int spoofsource; /* -S used */ char device[64]; diff -r -u nmap-3.28/nmap.cc nmap-3.28[]/nmap.cc --- nmap-3.28/nmap.cc 2003-06-14 00:45:41.000000000 +0300 +++ nmap-3.28[]/nmap.cc 2003-06-15 21:15:19.000000000 +0300 @@ -177,6 +177,7 @@ { {"version", no_argument, 0, 'V'}, {"verbose", no_argument, 0, 'v'}, + {"count", no_argument, 0, 'c'}, {"datadir", required_argument, 0, 0}, {"debug", optional_argument, 0, 'd'}, {"help", no_argument, 0, 'h'}, @@ -626,6 +627,7 @@ exit(0); break; case 'v': o.verbose++; break; + case 'c': o.count=1; break; } } @@ -1286,6 +1288,7 @@ " -p ports to scan. Example range: '1-1024,1080,6666,31337'\n" " -F Only scans ports listed in nmap-services\n" " -v Verbose. Its use is recommended. Use twice for greater effect.\n" + " -c [] Counting stats [] \n" " -P0 Don't ping hosts (needed to scan www.microsoft.com and others)\n" "* -Ddecoy_host1,decoy2[,...] Hide scan using many decoys\n" " -6 scans via IPv6 rather than IPv4\n" diff -r -u nmap-3.28/scan_engine.cc nmap-3.28[]/scan_engine.cc --- nmap-3.28/scan_engine.cc 2003-04-28 21:37:14.000000000 +0300 +++ nmap-3.28[]/scan_engine.cc 2003-06-15 21:27:18.000000000 +0300 @@ -600,6 +600,16 @@ struct scanstats ss; int rawsd = -1; int scanflags = 0; + int iii=0; + int itports=0; + int itsec=0; + int itimes=0; + int itotal=0; + int iresends = 0; + int imax=0; + int iloop=0; + int iports[5]; + int isec[5]; int victim; int senddelay = 0; pcap_t *pd = NULL; @@ -609,6 +619,8 @@ int res; int connecterror = 0; time_t starttime; + time_t checkedtime; + time_t lastcheckedtime; struct sockaddr_storage sock; struct sockaddr_in *sin = (struct sockaddr_in *) &sock; #if HAVE_IPV6 @@ -763,7 +775,7 @@ } starttime = time(NULL); - + lastcheckedtime = starttime; if (scantype != SYN_SCAN) ack_number = get_random_uint(); else ack_number = 0; @@ -979,6 +991,35 @@ current->state = PORT_TESTING; current->trynum = 0; /* if (!testinglist) testinglist = current; */ + if (o.count) { + itimes++; + checkedtime=time(NULL); + if ( checkedtime != lastcheckedtime ) { + isec[iloop]=checkedtime - lastcheckedtime; + lastcheckedtime = checkedtime; + iports[iloop]=itimes; + itotal=itotal+itimes; + itimes=0; + iii=0; + itports=0; + itsec=0; + while(iii <= imax) { + itports=itports+iports[iii]; + itsec=itsec+isec[iii]; + iii++; + } + iloop++; + if(imax<4) imax++; + if(iloop==5) iloop=0; + + log_write(LOG_STDOUT, "Tried: %5d (%d resends) \nP/S: %8.2f ETS: %7.0f \e[38D\e[A", itotal , iresends , (double) itports / itsec , (double) ( numports - itotal + iresends ) / ( (double) itports / itsec ) ); + log_flush(LOG_STDOUT); + } + } + + + + ss.numqueries_outstanding++; gettimeofday(¤t->sent[0], NULL); if ((scantype == SYN_SCAN) || (scantype == WINDOW_SCAN) || @@ -1121,6 +1162,7 @@ current->state = PORT_FRESH; current->trynum = 0; current->sd[0] = current->sd[1] = current->sd[2] = -1; + iresends++; } pil.firewalled = NULL; } else { @@ -1307,7 +1349,16 @@ double fallback_percent = 0.7; int rawsd; int scanflags = 0; - + int iii=0; + int itports=0; + int itsec=0; + int itimes=0; + int itotal=0; + int iresends = 0; + int imax=0; + int iloop=0; + int iports[5]; + int isec[5]; int dropped = 0; /* These three are for UDP squelching */ int freshportstried = 0; int senddelay = 0; @@ -1324,6 +1375,9 @@ int tries = 0; int tmp = 0; time_t starttime; + time_t checkedtime; + time_t lastcheckedtime; + u16 newport; int newstate = 999; /* This ought to break something if used illegally */ struct portinfo *scan, *openlist, *current, *testinglist, *next; @@ -1416,7 +1470,7 @@ fatal("Unknown scan type for super_scan"); } starttime = time(NULL); - + lastcheckedtime = starttime; if (o.debugging || o.verbose) { struct tm *tm = localtime(&starttime); assert(tm); @@ -1500,6 +1554,34 @@ /* lets send a packet! */ current->state = PORT_TESTING; /* if (!testinglist) testinglist = current; */ + if (o.count) { + itimes++; + checkedtime=time(NULL); + if ( checkedtime != lastcheckedtime ) { + isec[iloop]=checkedtime - lastcheckedtime; + lastcheckedtime = checkedtime; + iports[iloop]=itimes; + itotal=itotal+itimes; + itimes=0; + iii=0; + itports=0; + itsec=0; + while(iii <= imax) { + itports=itports+iports[iii]; + itsec=itsec+isec[iii]; + iii++; + } + iloop++; + if(imax<4) imax++; + if(iloop==5) iloop=0; + + log_write(LOG_STDOUT, "Tried: %5d (%d resends) \nP/S: %8.2f ETS: %7.0f \e[38D\e[A", itotal , iresends , (double) itports / itsec , (double) ( numports - itotal + iresends ) / ( (double) itports / itsec ) ); + log_flush(LOG_STDOUT); + } + } + + + numqueries_outstanding++; gettimeofday(¤t->sent[0], NULL); if (o.fragscan) @@ -1724,6 +1806,7 @@ for(current = openlist; current; current = (current->next >= 0)? &scan[current->next] : NULL) { current->state = PORT_FRESH; current->trynum = 0; + iresends++; if (o.debugging) { log_write(LOG_STDOUT, "Preparing for retry, open port %lu noted\n", current->portno); }