diff --git a/CHANGELOG b/CHANGELOG index a05c34fc1..aa0573125 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,12 @@ # Nmap Changelog ($Id$); -*-text-*- +o Nmap now reports scan start and end times for individual hosts + within a larger scan. The information is added to the XML host + element like so: [host starttime="1198292349" endtime="1198292370"] + (but of couse with angle brackets rather than square ones). It is + also printed in normal output if -d or "-v -v" are + specified. [Brandon, Kris, Fyodor] + o "make uninstall" now uninstalls Zenmap as well. The uninstall_zenmap script now deletes directories that were installed. [David] diff --git a/Target.cc b/Target.cc index 1ef8fa381..2ef7bd2d3 100644 --- a/Target.cc +++ b/Target.cc @@ -139,6 +139,7 @@ void Target::Initialize() { MACaddress_set = SrcMACaddress_set = NextHopMACaddress_set = false; htn.msecs_used = 0; htn.toclock_running = false; + htn.host_start = htn.host_end = 0; interface_type = devt_other; devname[0] = '\0'; devfullname[0] = '\0'; @@ -389,6 +390,7 @@ void Target::startTimeOutClock(const struct timeval *now) { htn.toclock_running = true; if (now) htn.toclock_start = *now; else gettimeofday(&htn.toclock_start, NULL); + if (!htn.host_start) htn.host_start = htn.toclock_start.tv_sec; } /* The complement to startTimeOutClock. */ void Target::stopTimeOutClock(const struct timeval *now) { @@ -398,6 +400,7 @@ void Target::stopTimeOutClock(const struct timeval *now) { if (now) tv = *now; else gettimeofday(&tv, NULL); htn.msecs_used += TIMEVAL_MSEC_SUBTRACT(tv, htn.toclock_start); + htn.host_end = tv.tv_sec; } /* Returns whether the host is timedout. If the timeoutclock is running, counts elapsed time for that. Pass NULL if you don't have the @@ -473,3 +476,4 @@ void Target::osscanSetFlag(int flag) { osscan_flag = flag; } + diff --git a/Target.h b/Target.h index 361b2a10a..517c7de08 100644 --- a/Target.h +++ b/Target.h @@ -126,6 +126,7 @@ struct host_timeout_nfo { unsigned long msecs_used; /* How many msecs has this Target used? */ bool toclock_running; /* Is the clock running right now? */ struct timeval toclock_start; /* When did the clock start? */ + time_t host_start, host_end; /* The absolute start and end for this host */ }; class Target { @@ -222,6 +223,9 @@ class Target { current time handy. You might as well also pass NULL if the clock is not running, as the func won't need the time. */ bool timedOut(const struct timeval *now); + /* Return time_t for the start and end time of this host */ + time_t StartTime() { return htn.host_start; } + time_t EndTime() { return htn.host_end; } /* Takes a 6-byte MAC address */ int setMACAddress(const u8 *addy); diff --git a/docs/nmap.dtd b/docs/nmap.dtd index 5a6e23688..372016f7f 100644 --- a/docs/nmap.dtd +++ b/docs/nmap.dtd @@ -135,6 +135,10 @@ smurf | ports | os | distance | uptime | tcpsequence | ipidsequence | tcptssequence | hostscript | trace)*, times ) > + diff --git a/nmap.cc b/nmap.cc index 45818631e..77f6d5eae 100644 --- a/nmap.cc +++ b/nmap.cc @@ -1765,7 +1765,9 @@ int nmap_main(int argc, char *argv[]) { for(targetno = 0; targetno < Targets.size(); targetno++) { currenths = Targets[targetno]; /* Now I can do the output and such for each host */ - log_write(LOG_XML, ""); + log_write(LOG_XML, "", + (unsigned long) currenths->StartTime(), + (unsigned long) currenths->EndTime()); write_host_status(currenths, o.resolve_all); if (currenths->timedOut(NULL)) { log_write(LOG_PLAIN,"Skipping host %s due to host timeout\n", @@ -2766,3 +2768,4 @@ int nmap_fetchfile(char *filename_returned, int bufferlen, const char *file) { } + diff --git a/output.cc b/output.cc index 6b124f9ff..a1c8a6f31 100644 --- a/output.cc +++ b/output.cc @@ -502,6 +502,19 @@ void printportoutput(Target *currenths, PortList *plist) { return; } + if (o.verbose > 1 || o.debugging) { + time_t tm_secs, tm_sece; + struct tm *tm; + char tbufs[128]; + tm_secs = currenths->StartTime(); + tm_sece = currenths->EndTime(); + tm = localtime(&tm_secs); + if (strftime(tbufs, sizeof(tbufs), "%Y-%m-%d %H:%M:%S %Z", tm) <= 0) + fatal("Unable to properly format host start time"); + + log_write(LOG_PLAIN,"Scanned at %s for %lds\n", + tbufs, tm_sece - tm_secs); + } log_write(LOG_PLAIN,"Interesting %s on %s:\n", (o.ipprotscan)? "protocols" : "ports", currenths->NameIP(hostname, sizeof(hostname)));