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

Include the reason why a host is down with --reason. It looks like this:

Nmap scan report for 1.2.3.4 [host down, received time-exceeded]
Nmap scan report for 1.2.3.5 [host down, received no-response]
This commit is contained in:
david
2009-11-16 19:38:37 +00:00
parent 3c0a38d281
commit 682b8cbc53
2 changed files with 7 additions and 4 deletions

View File

@@ -1425,10 +1425,14 @@ static char *num_to_string_sigdigits(double d, int digits) {
including host status and DNS records. */
void write_host_header(Target *currenths) {
if ((currenths->flags & HOST_UP) || o.verbose || o.resolve_all) {
if (currenths->flags & HOST_UP)
if (currenths->flags & HOST_UP) {
log_write(LOG_PLAIN, "Nmap scan report for %s\n", currenths->NameIP());
else if (currenths->flags & HOST_DOWN)
log_write(LOG_PLAIN, "Nmap scan report for %s [host down]\n", currenths->NameIP());
} else if (currenths->flags & HOST_DOWN) {
log_write(LOG_PLAIN, "Nmap scan report for %s [host down", currenths->NameIP());
if (o.reason)
log_write(LOG_PLAIN, ", %s", target_reason_str(currenths));
log_write(LOG_PLAIN, "]\n");
}
}
write_host_status(currenths, o.resolve_all);
if (currenths->TargetName() != NULL

View File

@@ -357,7 +357,6 @@ void print_xml_state_summary(PortList *Ports, int state) {
char *target_reason_str(Target *t) {
static char reason[128];
memset(reason,'\0', 128);
assert(t->reason.reason_id != ER_NORESPONSE);
Snprintf(reason, 128, "received %s", reason_str(t->reason.reason_id, SINGULAR));
return reason;
}