1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Show TTL in default output if "--reason -v" is asked for.

This commit is contained in:
jay
2014-07-22 01:55:04 +00:00
parent f85416b75a
commit d70f5b364a
4 changed files with 16 additions and 0 deletions

View File

@@ -347,6 +347,7 @@ void NmapOps::Initialize() {
gettimeofday(&start_time, NULL); gettimeofday(&start_time, NULL);
pTrace = vTrace = false; pTrace = vTrace = false;
reason = false; reason = false;
show_ttl = false;
adler32 = false; adler32 = false;
if (datadir) free(datadir); if (datadir) free(datadir);
datadir = NULL; datadir = NULL;

View File

@@ -367,6 +367,7 @@ class NmapOps {
bool traceroute; bool traceroute;
bool reason; bool reason;
bool show_ttl;
bool adler32; bool adler32;
FILE *excludefd; FILE *excludefd;
char *exclude_spec; char *exclude_spec;

View File

@@ -1465,6 +1465,9 @@ void apply_delayed_options() {
if (o.verbose > 1) if (o.verbose > 1)
o.reason = true; o.reason = true;
if (o.verbose && o.reason)
o.show_ttl = true;
// ISO 8601 date/time -- http://www.cl.cam.ac.uk/~mgk25/iso-time.html // ISO 8601 date/time -- http://www.cl.cam.ac.uk/~mgk25/iso-time.html
if (strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M %Z", local_time) <= 0) if (strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M %Z", local_time) <= 0)
fatal("Unable to properly format time"); fatal("Unable to properly format time");

View File

@@ -554,6 +554,7 @@ void printportoutput(Target *currenths, PortList *plist) {
int servicecol = -1; // service or protocol name int servicecol = -1; // service or protocol name
int versioncol = -1; int versioncol = -1;
int reasoncol = -1; int reasoncol = -1;
int ttlcol = -1;
int colno = 0; int colno = 0;
unsigned int rowno; unsigned int rowno;
int numrows; int numrows;
@@ -666,6 +667,8 @@ void printportoutput(Target *currenths, PortList *plist) {
servicecol = colno++; servicecol = colno++;
if (o.reason) if (o.reason)
reasoncol = colno++; reasoncol = colno++;
if (o.show_ttl)
ttlcol = colno++;
if (o.servicescan) if (o.servicescan)
versioncol = colno++; versioncol = colno++;
@@ -694,6 +697,8 @@ void printportoutput(Target *currenths, PortList *plist) {
Tbl->addItem(0, versioncol, false, "VERSION", 7); Tbl->addItem(0, versioncol, false, "VERSION", 7);
if (reasoncol > 0) if (reasoncol > 0)
Tbl->addItem(0, reasoncol, false, "REASON", 6); Tbl->addItem(0, reasoncol, false, "REASON", 6);
if (ttlcol > 0)
Tbl->addItem(0, ttlcol, false, "TTL", 3);
log_write(LOG_MACHINE, "\t%s: ", (o.ipprotscan) ? "Protocols" : "Ports"); log_write(LOG_MACHINE, "\t%s: ", (o.ipprotscan) ? "Protocols" : "Ports");
@@ -708,6 +713,8 @@ void printportoutput(Target *currenths, PortList *plist) {
first = 0; first = 0;
if (o.reason) if (o.reason)
Tbl->addItem(rowno, reasoncol, true, port_reason_str(current->reason)); Tbl->addItem(rowno, reasoncol, true, port_reason_str(current->reason));
if (o.show_ttl)
Tbl->addItemFormatted(rowno, ttlcol, false, "%d", current->reason.ttl);
state = statenum2str(current->state); state = statenum2str(current->state);
proto = nmap_getprotbynum(current->portno); proto = nmap_getprotbynum(current->portno);
Snprintf(portinfo, sizeof(portinfo), "%s", proto ? proto->p_name : "unknown"); Snprintf(portinfo, sizeof(portinfo), "%s", proto ? proto->p_name : "unknown");
@@ -768,6 +775,8 @@ void printportoutput(Target *currenths, PortList *plist) {
Tbl->addItem(rowno, servicecol, true, serviceinfo); Tbl->addItem(rowno, servicecol, true, serviceinfo);
if (o.reason) if (o.reason)
Tbl->addItem(rowno, reasoncol, true, port_reason_str(current->reason)); Tbl->addItem(rowno, reasoncol, true, port_reason_str(current->reason));
if (o.show_ttl)
Tbl->addItemFormatted(rowno, ttlcol, false, "%d", current->reason.ttl);
sd.populateFullVersionString(fullversion, sizeof(fullversion)); sd.populateFullVersionString(fullversion, sizeof(fullversion));
if (*fullversion && versioncol > 0) if (*fullversion && versioncol > 0)
@@ -1476,6 +1485,8 @@ void write_host_status(Target *currenths) {
log_write(LOG_PLAIN, "Host is up"); log_write(LOG_PLAIN, "Host is up");
if (o.reason) if (o.reason)
log_write(LOG_PLAIN, ", %s", target_reason_str(currenths)); log_write(LOG_PLAIN, ", %s", target_reason_str(currenths));
if (o.show_ttl)
log_write(LOG_PLAIN, " TTL %d", currenths->reason.ttl);
if (currenths->to.srtt != -1) if (currenths->to.srtt != -1)
log_write(LOG_PLAIN, " (%ss latency)", log_write(LOG_PLAIN, " (%ss latency)",
num_to_string_sigdigits(currenths->to.srtt / 1000000.0, 2)); num_to_string_sigdigits(currenths->to.srtt / 1000000.0, 2));