mirror of
https://github.com/nmap/nmap.git
synced 2025-12-21 23:19:03 +00:00
Fix grepable output when all scanned ports are ignored
Previous behavior was to output an extra host status line "Status: up" New behavior outputs an empty "Ports: \t" then the "Ignored State" field.
This commit is contained in:
12
output.cc
12
output.cc
@@ -553,8 +553,16 @@ void printportoutput(Target *currenths, PortList *plist) {
|
|||||||
log_write(LOG_PLAIN, "All %d scanned ports on %s are ",
|
log_write(LOG_PLAIN, "All %d scanned ports on %s are ",
|
||||||
numignoredports,
|
numignoredports,
|
||||||
currenths->NameIP(hostname, sizeof(hostname)));
|
currenths->NameIP(hostname, sizeof(hostname)));
|
||||||
|
log_write(LOG_MACHINE, "Host: %s (%s)\t%s: ",
|
||||||
|
currenths->targetipstr(), currenths->HostName(),
|
||||||
|
(o.ipprotscan) ? "Protocols" : "Ports");
|
||||||
|
|
||||||
if (plist->numIgnoredStates() == 1) {
|
if (plist->numIgnoredStates() == 1) {
|
||||||
log_write(LOG_PLAIN, "%s", statenum2str(plist->nextIgnoredState(PORT_UNKNOWN)));
|
istate = plist->nextIgnoredState(PORT_UNKNOWN);
|
||||||
|
log_write(LOG_PLAIN, "%s", statenum2str(istate));
|
||||||
|
/* Grepable output supports only one ignored state. */
|
||||||
|
log_write(LOG_MACHINE, "\tIgnored State: %s (%d)",
|
||||||
|
statenum2str(istate), plist->getStateCounts(istate));
|
||||||
} else {
|
} else {
|
||||||
prevstate = PORT_UNKNOWN;
|
prevstate = PORT_UNKNOWN;
|
||||||
while ((istate = plist->nextIgnoredState(prevstate)) != PORT_UNKNOWN) {
|
while ((istate = plist->nextIgnoredState(prevstate)) != PORT_UNKNOWN) {
|
||||||
@@ -570,8 +578,6 @@ void printportoutput(Target *currenths, PortList *plist) {
|
|||||||
log_write(LOG_PLAIN, "\n");
|
log_write(LOG_PLAIN, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
log_write(LOG_MACHINE, "Host: %s (%s)\tStatus: Up",
|
|
||||||
currenths->targetipstr(), currenths->HostName());
|
|
||||||
xml_end_tag(); /* ports */
|
xml_end_tag(); /* ports */
|
||||||
xml_newline();
|
xml_newline();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user