8a9 > static int xmlhostopen; 263c264,265 < char *machinefilename = NULL, *kiddiefilename = NULL, *normalfilename = NULL; --- > char *kiddiefilename = NULL, *normalfilename = NULL; > char *machinefilename = NULL, *xmlfilename = NULL; 301c303 < {"oH", required_argument, 0, 0}, --- > {"oX", required_argument, 0, 0}, 329a332,333 > xmlhostopen = 0; > 383a388,389 > } else if (strcmp(long_options[option_index].name, "oX") == 0) { > xmlfilename = optarg; 386,387d391 < } else if (strcmp(long_options[option_index].name, "oH") == 0) { < fatal("HTML output is not yet supported"); 620a625,626 > if (xmlfilename) > log_open(LOG_XML, o.append_output, xmlfilename); 786a793,795 > log_write(LOG_XML, "\n\n"); > log_write(LOG_XML, "\n"); > log_write(LOG_XML, "<%s version=\"%s\">\n",NMAP_NAME,NMAP_VERSION); > > /* Before we randomize the ports scanned, lets output them to > machine parseable and xml output */ > if (o.verbose) { 794a808,809 > output_ports_to_xml_output(ports, o.numports, o.windowscan|o.synscan|o.connectscan|o.fragscan|o.finscan|o.maimonscan|o.bouncescan|o.nullscan|o.xmasscan|o.ackscan,o.udpscan); > } 880c895,899 < log_write(LOG_MACHINE, "Host: %s (%s)\tStatus: Down\n", inet_ntoa(currenths->host), currenths->name); --- > log_write(LOG_MACHINE, "Host: %s (%s)\tStatus: Down\n", > inet_ntoa(currenths->host), currenths->name); > xmlhostopen = 1; > log_write(LOG_XML, "%s (%s)\n", > inet_ntoa(currenths->host), currenths->name); 888a908,910 > xmlhostopen = 1; > log_write(LOG_XML, "%s (%s)\n", > inet_ntoa(currenths->host), currenths->name); 895a918,920 > xmlhostopen = 1; > log_write(LOG_XML, "%s (%s)\n", > inet_ntoa(currenths->host), currenths->name); 905a931,933 > xmlhostopen = 1; > log_write(LOG_XML, "%s (%s)%d\n", > inet_ntoa(currenths->host), currenths->name, currenths->wierd_responses); 963a992,994 > xmlhostopen = 1; > log_write(LOG_XML,"%s (%s)\n", > inet_ntoa(currenths->host), currenths->name); 973a1005 > log_write(LOG_XML,"%d", currenths->seq.index); 976a1009 > log_write(LOG_XML,"%s", currenths->FP_matches[0]->OS_name); 979a1013 > log_write(LOG_XML,"%s", currenths->FP_matches[i]->OS_name); 998c1032 < log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,"\n"); --- > log_write(LOG_XML|LOG_NORMAL|LOG_SKID|LOG_STDOUT,"\n"); 1018a1053,1056 > if (xmlhostopen) { > log_write(LOG_XML,"\n"); > xmlhostopen = 0; > } 1030a1069 > log_write(LOG_XML, "\n",NMAP_NAME); 1036a1076,1079 > log_write(LOG_XML, > "\n", > mytime, numhosts_scanned, (numhosts_scanned == 1)? "IP address" : "IP addresses", > numhosts_up, (numhosts_up == 1)? "host" : "hosts", i, (i == 1)? "second": "seconds"); 1513a1557,1558 > log_write(LOG_XML,"%s (%s)", > inet_ntoa(currenths->host), currenths->name); 1517,1520c1562,1568 < log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,"Interesting ports on %s (%s):\n", currenths->name, < inet_ntoa(currenths->host)); < log_write(LOG_MACHINE,"Host: %s (%s)", inet_ntoa(currenths->host), < currenths->name); --- > log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,"Interesting ports on %s (%s):\n", > currenths->name, inet_ntoa(currenths->host)); > log_write(LOG_MACHINE,"Host: %s (%s)", > inet_ntoa(currenths->host), currenths->name); > xmlhostopen = 1; > log_write(LOG_XML,"%s (%s)\n", > inet_ntoa(currenths->host), currenths->name); 1532a1581,1582 > log_write(LOG_XML,"\n"); > log_write(LOG_XML,""); 1544c1594,1597 < if (!first) log_write(LOG_MACHINE,", "); --- > if (!first) { > log_write(LOG_MACHINE,", "); > log_write(LOG_XML,"\n"); > } 1592c1645,1652 < --- > log_write(LOG_XML,"%d", current->portno); > if (state[0]) log_write(LOG_XML,"%s", state); > if (protocol[0]) log_write(LOG_XML,"%s", protocol); > if (current->owner && current->owner[0]) > log_write(LOG_XML,"%s", current->owner); > if (service && service->s_name[0]) > log_write(LOG_XML,"%s", service->s_name); > if (rpcmachineinfo[0]) log_write(LOG_XML,"%s", rpcmachineinfo); 1595a1656,1657 > log_write(LOG_XML,"\n"); > log_write(LOG_XML,"\n"); 1597c1659,1662 < log_write(LOG_MACHINE, "\tIgnored State: %s (%d)", statenum2str(plist->ignored_port_state), plist->state_counts[plist->ignored_port_state]); --- > log_write(LOG_MACHINE, "\tIgnored State: %s (%d)", > statenum2str(plist->ignored_port_state), plist->state_counts[plist->ignored_port_state]); > log_write(LOG_XML, "%s (%d)", > statenum2str(plist->ignored_port_state), plist->state_counts[plist->ignored_port_state]); 3656c3721 < char *logtypes[LOG_TYPES]={"normal","machine","HTML","$cR1pT |<1dd13"}; --- > char *logtypes[LOG_TYPES]={"normal","machine","XML","$cR1pT |<1dd13"}; 3814c3879 < log_close(LOG_MACHINE|LOG_NORMAL|LOG_SKID); --- > log_close(LOG_XML|LOG_MACHINE|LOG_NORMAL|LOG_SKID); 3942a4008,4051 > } > > /* XML output based on machine output */ > void output_rangelist_given_ports_to_xml_output(unsigned short *ports, > int numports) { > int i, previous_port = -2, range_start = -2, port; > char outpbuf[128]; > > for(i=0; i <= numports; i++) { > port = (i < numports)? ports[i] : 0xABCDE; > if (port != previous_port + 1) { > outpbuf[0] = '\0'; > if (range_start != previous_port && range_start != -2) > sprintf(outpbuf, "-%hi", previous_port); > if (port != 0xABCDE) { > if (range_start != -2) > strcat(outpbuf, ","); > sprintf(outpbuf + strlen(outpbuf), "%hi", port); > } > log_write(LOG_XML, "%s", outpbuf); > range_start = port; > } > previous_port = port; > } > } > > void output_ports_to_xml_output(unsigned short *ports, > int numports, int tcpscan, > int udpscan) { > int tcpportsscanned = (tcpscan)? numports : 0; > int udpportsscanned = (udpscan)? numports : 0; > log_write(LOG_XML, "\n"); > if (tcpportsscanned) { > log_write(LOG_XML, "\n", tcpportsscanned); > output_rangelist_given_ports_to_xml_output(ports, tcpportsscanned); > log_write(LOG_XML, "\n"); > } > > if (udpportsscanned) { > log_write(LOG_XML, "\n", udpportsscanned); > output_rangelist_given_ports_to_xml_output(ports, udpportsscanned); > log_write(LOG_XML, "\n"); > } > log_write(LOG_XML, "\n");