1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-17 21:19:01 +00:00

Don't repeat the host name and IP address in "Host is up/down" messages.

Don't print the "Nmap scan report" header if there's nothing to put
under it.
This commit is contained in:
david
2009-10-27 05:26:40 +00:00
parent cb9222bd20
commit 030411ffd8
2 changed files with 8 additions and 14 deletions

View File

@@ -1728,7 +1728,7 @@ int nmap_main(int argc, char *argv[]) {
) || o.listscan) { ) || o.listscan) {
/* We're done with the hosts */ /* We're done with the hosts */
log_write(LOG_XML, "<host>"); log_write(LOG_XML, "<host>");
write_host_status(currenths, o.resolve_all); write_host_header(currenths);
printmacinfo(currenths); printmacinfo(currenths);
// if (currenths->flags & HOST_UP) // if (currenths->flags & HOST_UP)
// log_write(LOG_PLAIN,"\n"); // log_write(LOG_PLAIN,"\n");

View File

@@ -1424,6 +1424,7 @@ static char *num_to_string_sigdigits(double d, int digits) {
/* Writes a heading for a full scan report ("Nmap scan report for..."), /* Writes a heading for a full scan report ("Nmap scan report for..."),
including host status and DNS records. */ including host status and DNS records. */
void write_host_header(Target *currenths) { void write_host_header(Target *currenths) {
if ((currenths->flags & HOST_UP) || o.verbose || o.resolve_all)
log_write(LOG_PLAIN, "Nmap scan report for %s\n", currenths->NameIP()); log_write(LOG_PLAIN, "Nmap scan report for %s\n", currenths->NameIP());
write_host_status(currenths, o.resolve_all); write_host_status(currenths, o.resolve_all);
/* Print reverse DNS if it differs. */ /* Print reverse DNS if it differs. */
@@ -1440,12 +1441,9 @@ void write_host_header(Target *currenths) {
machine log. resolve_all should be passed nonzero if the user asked machine log. resolve_all should be passed nonzero if the user asked
for all hosts (even down ones) to be resolved */ for all hosts (even down ones) to be resolved */
void write_host_status(Target * currenths, int resolve_all) { void write_host_status(Target * currenths, int resolve_all) {
char hostname[1200];
if (o.listscan) { if (o.listscan) {
/* write "unknown" to stdout, machine, and xml */ /* write "unknown" to stdout, machine, and xml */
log_write(LOG_PLAIN, "Host %s not scanned\n", log_write(LOG_PLAIN, "Host not scanned\n");
currenths->NameIP(hostname, sizeof(hostname)));
log_write(LOG_MACHINE, "Host: %s (%s)\tStatus: Unknown\n", log_write(LOG_MACHINE, "Host: %s (%s)\tStatus: Unknown\n",
currenths->targetipstr(), currenths->HostName()); currenths->targetipstr(), currenths->HostName());
write_xml_initial_hostinfo(currenths, "unknown"); write_xml_initial_hostinfo(currenths, "unknown");
@@ -1462,13 +1460,11 @@ void write_host_status(Target * currenths, int resolve_all) {
currenths->weird_responses); currenths->weird_responses);
if (o.noportscan) { if (o.noportscan) {
log_write(LOG_PLAIN, "Host %s seems to be a subnet broadcast address (returned %d extra pings).%s\n", log_write(LOG_PLAIN, "Host seems to be a subnet broadcast address (returned %d extra pings).%s\n",
currenths->NameIP(hostname, sizeof(hostname)),
currenths->weird_responses, currenths->weird_responses,
(currenths->flags & HOST_UP) ? " Note -- the actual IP also responded." : ""); (currenths->flags & HOST_UP) ? " Note -- the actual IP also responded." : "");
} else { } else {
log_write(LOG_PLAIN, "Host %s seems to be a subnet broadcast address (returned %d extra pings). %s.\n", log_write(LOG_PLAIN, "Host seems to be a subnet broadcast address (returned %d extra pings). %s.\n",
currenths->NameIP(hostname, sizeof(hostname)),
currenths->weird_responses, currenths->weird_responses,
(currenths->flags & HOST_UP) ? " Still scanning it due to ping response from its own IP" : "Skipping host"); (currenths->flags & HOST_UP) ? " Still scanning it due to ping response from its own IP" : "Skipping host");
} }
@@ -1478,8 +1474,7 @@ void write_host_status(Target * currenths, int resolve_all) {
write_xml_initial_hostinfo(currenths, (currenths->flags & HOST_UP) ? "up" : "down"); write_xml_initial_hostinfo(currenths, (currenths->flags & HOST_UP) ? "up" : "down");
if (o.noportscan || o.verbose) { if (o.noportscan || o.verbose) {
if (currenths->flags & HOST_UP) { if (currenths->flags & HOST_UP) {
log_write(LOG_PLAIN, "Host %s is up", log_write(LOG_PLAIN, "Host is up");
currenths->NameIP(hostname, sizeof(hostname)));
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 (currenths->to.srtt != -1) if (currenths->to.srtt != -1)
@@ -1490,8 +1485,7 @@ void write_host_status(Target * currenths, int resolve_all) {
log_write(LOG_MACHINE, "Host: %s (%s)\tStatus: Up\n", log_write(LOG_MACHINE, "Host: %s (%s)\tStatus: Up\n",
currenths->targetipstr(), currenths->HostName()); currenths->targetipstr(), currenths->HostName());
} else if (o.verbose || resolve_all) { } else if (o.verbose || resolve_all) {
log_write(resolve_all ? LOG_PLAIN : LOG_STDOUT, log_write(resolve_all ? LOG_PLAIN : LOG_STDOUT, "Host is down.\n");
"Host %s is down.\n", currenths->NameIP(hostname, sizeof (hostname)));
log_write(LOG_MACHINE, "Host: %s (%s)\tStatus: Down\n", log_write(LOG_MACHINE, "Host: %s (%s)\tStatus: Down\n",
currenths->targetipstr(), currenths->HostName()); currenths->targetipstr(), currenths->HostName());
} }