mirror of
https://github.com/nmap/nmap.git
synced 2026-02-04 20:46:33 +00:00
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]
This commit is contained in:
@@ -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]
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
4
Target.h
4
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);
|
||||
|
||||
@@ -135,6 +135,10 @@
|
||||
smurf | ports | os | distance | uptime |
|
||||
tcpsequence | ipidsequence | tcptssequence |
|
||||
hostscript | trace)*, times ) >
|
||||
<!ATTLIST host
|
||||
starttime %attr_numeric; #IMPLIED
|
||||
endtime %attr_numeric; #IMPLIED
|
||||
>
|
||||
|
||||
<!-- these elements are written by output.c:write_xml_initial_hostinfo() -->
|
||||
<!ELEMENT status EMPTY >
|
||||
|
||||
5
nmap.cc
5
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, "<host>");
|
||||
log_write(LOG_XML, "<host starttime=\"%lu\" endtime=\"%lu\">",
|
||||
(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) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
13
output.cc
13
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)));
|
||||
|
||||
Reference in New Issue
Block a user