From 5067f767b7272e3aebea50879268be31aca27d71 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 4 May 2012 15:04:41 +0000 Subject: [PATCH] Add the new element to XML output. This element is intended to report information about command-line target specifications. Now it's used with status="skipped" to indicate that a specification was ignored. --- CHANGELOG | 6 ++++++ docs/nmap.dtd | 8 +++++++- targets.cc | 17 ++++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 58e81fb10..eccf48d9c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,11 @@ # Nmap Changelog ($Id$); -*-text-*- +o Added a new element to XML output that indicates when a + target specification was ignored, perhaps because of a syntax error + or DNS failure. It looks like this: + + [David Fifield] + o [NSE] Added the script mmouse-exec that connects to a Mobile Mouse server, starts an application, and sends a sequence of keystrokes to it. [Patrik Karlsson] diff --git a/docs/nmap.dtd b/docs/nmap.dtd index c0f0cdc13..26084a87c 100644 --- a/docs/nmap.dtd +++ b/docs/nmap.dtd @@ -72,7 +72,7 @@ It represents to the topmost element of the output document. --> + + + element to the XML stating that a target specification was + ignored. This can be because of, for example, a DNS resolution failure, or a + syntax error. */ +static void log_bogus_target(const char *expr) { + xml_open_start_tag("target"); + xml_attribute("specification", "%s", expr); + xml_attribute("status", "skipped"); + xml_attribute("reason", "invalid"); + xml_close_empty_tag(); + xml_newline(); +} + Target *nexthost(HostGroupState *hs, const addrset *exclude_group, struct scan_lists *ports, int pingtype) { int i; @@ -400,7 +413,9 @@ Target *nexthost(HostGroupState *hs, const addrset *exclude_group, while (hs->next_expression < hs->num_expressions) { const char *expr; expr = hs->target_expressions[hs->next_expression++]; - if (hs->current_expression.parse_expr(expr, o.af()) == 0) + if (hs->current_expression.parse_expr(expr, o.af()) != 0) + log_bogus_target(expr); + else break; } } else break;