OpenVAS Scanner
7.0.0~git
|
Advanced wrapper for nmap. Perform comprehensive network scanning. More...
#include "../misc/plugutils.h"
#include "nasl_lex_ctxt.h"
#include <glib.h>
#include <gvm/base/logging.h>
#include <gvm/base/prefs.h>
#include <gvm/util/kb.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
Go to the source code of this file.
Data Structures | |
struct | nse_script |
Handle the results of a NSE script. More... | |
struct | traceroute_hop |
Describe a detected hop on the route. More... | |
struct | nmap_port |
Store port information. More... | |
struct | nmap_host |
Store host information. More... | |
struct | nmap_parser |
Handle states for XML parsing. More... | |
struct | nmap_t |
Main nmap execution handler. More... | |
struct | nmap_opt_t |
Describe an nmap command line option. More... | |
Macros | |
#define | CHUNK_LEN 512 |
Input chunks size for the XML parser. More... | |
#define | MAX_TRACE_HOPS 64 |
Maximum number of hops to the target. More... | |
#define | NMAP_CMD "nmap" |
Nmap command to call. More... | |
#define | PREF_TREAT_ALL_HOST_ONLINE "Treat all hosts as online" |
Plugin parameter description: skip alive hosts discovery phase. More... | |
#define | PREF_TRACEROUTE "Trace hop path to each host" |
Plugin parameter description: perform traceroute. More... | |
#define | PREF_NO_DNS "Disable DNS resolution" |
Plugin parameter description: don't perform reverse resolution on discovered IP addresses. More... | |
#define | PREF_TCP_SCANNING_TECHNIQUE "TCP scanning technique" |
Plugin parameter description: TCP port scanning technique to use. More... | |
#define | PREF_SERVICE_SCAN "Service scan" |
Plugin parameter description: perform service/version detection scan. More... | |
#define | PREF_RPC_PORT_SCAN "RPC port scan" |
Plugin parameter description: perform RPC port scan. More... | |
#define | PREF_IDENTIFY_REMOTE_OS "Identify the remote OS" |
Plugin parameter description: perform remote OS fingerprinting. More... | |
#define | PREF_AGGRESSIVE_OS_DETECT "Aggressive OS detection" |
Plugin parameter description: guess OS from closest match if necessary. More... | |
#define | PREF_FRAGMENT_IP "Fragment IP packets (bypasses firewalls)" |
Plugin parameter description: try to evade defense by fragmenting IP packets. More... | |
#define | PREF_SOURCE_PORT "Source port" |
Plugin parameter description: set source port. More... | |
#define | PREF_TIMING_POLICY "Timing policy" |
Plugin parameter description: select timing template. More... | |
#define | PREF_HOST_TIMEOUT "Host Timeout (ms)" |
Plugin parameter description: give up on host after this time elapsed. More... | |
#define | PREF_MIN_RTT_TIMEOUT "Min RTT Timeout (ms)" |
Plugin parameter description: probe round trip time hint (minimal value) More... | |
#define | PREF_MAX_RTT_TIMEOUT "Max RTT Timeout (ms)" |
Plugin parameter description: probe round trip time hint (maximal value). More... | |
#define | PREF_INITIAL_RTT_TIMEOUT "Initial RTT timeout (ms)" |
Plugin parameter description: probe round trip time hint (initial value). More... | |
#define | PREF_MIN_PARALLELISM "Ports scanned in parallel (min)" |
Plugin parameter description: force minimum number of parallel active probes. More... | |
#define | PREF_MAX_PARALLELISM "Ports scanned in parallel (max)" |
Plugin parameter description: force maximum number of parallel active probes. More... | |
#define | PREF_MIN_HOSTGROUP "Hosts scanned in parallel (min)" |
Plugin parameter description: force minimum number of hosts to scan in parallel. More... | |
#define | PREF_MAX_HOSTGROUP "Hosts scanned in parallel (max)" |
Plugin parameter description: force maximum number of hosts to scan in parallel. More... | |
#define | PREF_INTERPROBE_DELAY "Minimum wait between probes (ms)" |
Plugin parameter description: set idle interval between probes. More... | |
#define | PREF_EXCLUDE_HOSTS "Exclude hosts" |
Plugin parameter description: comma-separated list of hosts to exclude from the scan. More... | |
#define | PREF_IMPORT_XML_FILE "File containing XML results" |
Plugin parameter description: import XML file. More... | |
#define | OPT_SET "yes" |
Checkbox value (when set). More... | |
#define | OPT_UNSET "no" |
Checkbox value (when unset). More... | |
#define | list_free(list, dtor, udata) |
#define | PRINT_NOT_NULL(x) ((x) ? (x) : "") |
Functions | |
static nmap_t * | nmap_create (lex_ctxt *lexic) |
Instantiate a new nmap handler, rebuild command line or open XML file to parse. More... | |
static void | nmap_destroy (nmap_t *nmap) |
Release a nmap handler and associated resources. More... | |
static int | build_cmd_line (nmap_t *nmap) |
Rebuild command line to run according to plugin parameters. More... | |
static int | add_arg (nmap_t *nmap, const gchar *name, const gchar *value) |
Add a couple argument/value on the command line. More... | |
static int | add_nse_arguments (nmap_t *nmap) |
Add NSE (nmap scripting engine) related arguments to the command line according to user script selection and preferences. More... | |
static gchar * | get_script_list (nmap_t *nmap) |
Make the comma-separated list of NSE scripts selected by the user. More... | |
static gchar * | get_script_args (nmap_t *nmap) |
Make the comma-separated list of NSE arguments set by the user. More... | |
static int | add_scantype_arguments (nmap_t *nmap) |
Add the TCP scantype flag to the command line. More... | |
static int | add_timing_arguments (nmap_t *nmap) |
Add timing template argument to the command line. More... | |
static int | add_portrange (nmap_t *nmap) |
Add the range of ports to scan to the command line. More... | |
static void | setup_xml_parser (nmap_t *nmap) |
Setup XML parser internals. More... | |
static void | set_opentag_callbacks (GHashTable *open) |
Populate the callbacks hashtable with handlers for opening tags. More... | |
static void | set_closetag_callbacks (GHashTable *close) |
Populate the callbacks hashtable with handlers for closing tags. More... | |
static int | add_target (nmap_t *nmap) |
Append scan target to the command line. More... | |
static void | dbg_display_cmdline (nmap_t *nmap) |
Display the final command line for debug. More... | |
static void | sig_h () |
Signal handler (Halt). More... | |
static void | sig_c () |
Signal handler (Child). More... | |
static int | nmap_run_and_parse (nmap_t *nmap) |
Run nmap and parse its XML output (or load an external file if requested). More... | |
static void | current_host_reset (nmap_t *nmap) |
Clear the current host object. More... | |
static void | port_destroy (gpointer data, gpointer udata) |
Completely release a port object. More... | |
static void | nse_script_destroy (gpointer data, gpointer udata) |
Completely release a NSE script object. More... | |
static void | simple_item_destroy (gpointer data, gpointer udata) |
Simple wrapper to call g_free from within g_slist_foreach statements. More... | |
static void | tmphost_add_port (nmap_t *nmap) |
Add port information to the current host object. More... | |
static void | tmphost_add_nse_hostscript (nmap_t *nmap, gchar *name, gchar *output) |
Add NSE hostscript result to the current host object. More... | |
static void | tmphost_add_nse_portscript (nmap_t *nmap, gchar *name, gchar *output) |
Add NSE portscript result to a port of the current host. More... | |
static void | xml_start_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer user_data, GError **error) |
Top level XML parser callback: handle an opening tag and call the corresponding method. More... | |
static void | xml_end_element (GMarkupParseContext *context, const gchar *element_name, gpointer user_data, GError **error) |
Top level XML parser callback: handle an closing tag and call the corresponding method. More... | |
static void | xml_read_text (GMarkupParseContext *context, const gchar *text, gsize text_len, gpointer user_data, GError **error) |
Top level XML parser callback: handle text sections and store it into the read buffer if enable_read is set to TRUE. More... | |
static void | xmltag_open_host (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening host tag. More... | |
static void | xmltag_open_status (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening status tag. More... | |
static void | xmltag_open_address (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening address tag. More... | |
static void | xmltag_open_ports (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening ports tag. More... | |
static void | xmltag_open_port (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening port tag. More... | |
static void | xmltag_open_state (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening state tag. More... | |
static void | xmltag_open_service (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening service tag. More... | |
static void | xmltag_open_cpe (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening cpe tag. More... | |
static void | xmltag_open_hostscript (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening hostscript tag. More... | |
static void | xmltag_open_osmatch (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening osmatch tag. More... | |
static void | xmltag_open_script (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening script tag. More... | |
static void | xmltag_open_tcpsequence (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening tcpsequence tag. More... | |
static void | xmltag_open_ipidsequence (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening ipidsequence tag. More... | |
static void | xmltag_open_hop (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening hop tag. More... | |
static void | xmltag_open_distance (nmap_t *nmap, const gchar **attrnames, const gchar **attrval) |
Sublevel XML parser callback: handle an opening distance tag. More... | |
static void | xmltag_close_host (nmap_t *nmap) |
Sublevel XML parser callback: handle an closing host tag. More... | |
static void | xmltag_close_ports (nmap_t *nmap) |
Sublevel XML parser callback: handle an closing host tag. More... | |
static void | xmltag_close_port (nmap_t *nmap) |
Sublevel XML parser callback: handle an closing port tag. More... | |
static void | xmltag_close_cpe (nmap_t *nmap) |
Sublevel XML parser callback: handle an closing cpe tag. More... | |
static void | xmltag_close_hostscript (nmap_t *nmap) |
Sublevel XML parser callback: handle an closing hostscript tag. More... | |
static gchar * | get_attr_value (const gchar *name, const gchar **attribute_names, const gchar **attribute_values) |
Helper function: get attribute value from the separate name/value tables. More... | |
static void | current_host_saveall (nmap_t *nmap) |
Dump current host object state into the knowledge base. More... | |
static void | save_host_state (nmap_t *nmap) |
Store host state (host alive/dead) into the knowledge base. More... | |
static void | save_open_ports (nmap_t *nmap) |
Save information about open ports for the current host into the knowledge base. More... | |
static void | register_service (nmap_t *nmap, struct nmap_port *p) |
Save information about a detected service (version) into the knowledge base. More... | |
static void | save_detected_os (nmap_t *nmap) |
Save information about detected operating system into the knowledge base. More... | |
static void | save_tcpseq_details (nmap_t *nmap) |
Save information about TCP sequence number generation into the knowledge base. More... | |
static void | save_ipidseq_details (nmap_t *nmap) |
Save information about IP ID generation into the knowledge base. More... | |
static void | save_traceroute_details (nmap_t *nmap) |
Save information about network topology to the target (traceroute) into the knowledge base. More... | |
static void | save_portscripts (nmap_t *nmap) |
Save information about postrule NSE scripts into the knowledge base. More... | |
static void | save_hostscripts (nmap_t *nmap) |
Save information about hostrule NSE scripts into the knowledge base. More... | |
tree_cell * | plugin_run_nmap (lex_ctxt *lexic) |
Run the nmap_net subsystem. More... | |
Variables | |
static pid_t | pid = 0 |
Advanced wrapper for nmap. Perform comprehensive network scanning.
This plugin was designed to be executed only once per network. It generates the nmap command line according to the specified options, runs nmap, parses the output and stores results for each host in the knowledge base.
Definition in file nasl_builtin_nmap.c.
#define CHUNK_LEN 512 |
Input chunks size for the XML parser.
Definition at line 67 of file nasl_builtin_nmap.c.
#define list_free | ( | list, | |
dtor, | |||
udata | |||
) |
Definition at line 1189 of file nasl_builtin_nmap.c.
#define MAX_TRACE_HOPS 64 |
Maximum number of hops to the target.
Definition at line 72 of file nasl_builtin_nmap.c.
#define NMAP_CMD "nmap" |
Nmap command to call.
Definition at line 77 of file nasl_builtin_nmap.c.
#define OPT_SET "yes" |
Checkbox value (when set).
Definition at line 207 of file nasl_builtin_nmap.c.
#define OPT_UNSET "no" |
Checkbox value (when unset).
Definition at line 212 of file nasl_builtin_nmap.c.
#define PREF_AGGRESSIVE_OS_DETECT "Aggressive OS detection" |
Plugin parameter description: guess OS from closest match if necessary.
Definition at line 122 of file nasl_builtin_nmap.c.
#define PREF_EXCLUDE_HOSTS "Exclude hosts" |
Plugin parameter description: comma-separated list of hosts to exclude from the scan.
Definition at line 197 of file nasl_builtin_nmap.c.
#define PREF_FRAGMENT_IP "Fragment IP packets (bypasses firewalls)" |
Plugin parameter description: try to evade defense by fragmenting IP packets.
Definition at line 128 of file nasl_builtin_nmap.c.
#define PREF_HOST_TIMEOUT "Host Timeout (ms)" |
Plugin parameter description: give up on host after this time elapsed.
Definition at line 144 of file nasl_builtin_nmap.c.
#define PREF_IDENTIFY_REMOTE_OS "Identify the remote OS" |
Plugin parameter description: perform remote OS fingerprinting.
Definition at line 116 of file nasl_builtin_nmap.c.
#define PREF_IMPORT_XML_FILE "File containing XML results" |
Plugin parameter description: import XML file.
Definition at line 202 of file nasl_builtin_nmap.c.
#define PREF_INITIAL_RTT_TIMEOUT "Initial RTT timeout (ms)" |
Plugin parameter description: probe round trip time hint (initial value).
Definition at line 162 of file nasl_builtin_nmap.c.
#define PREF_INTERPROBE_DELAY "Minimum wait between probes (ms)" |
Plugin parameter description: set idle interval between probes.
Definition at line 191 of file nasl_builtin_nmap.c.
#define PREF_MAX_HOSTGROUP "Hosts scanned in parallel (max)" |
Plugin parameter description: force maximum number of hosts to scan in parallel.
Definition at line 186 of file nasl_builtin_nmap.c.
#define PREF_MAX_PARALLELISM "Ports scanned in parallel (max)" |
Plugin parameter description: force maximum number of parallel active probes.
Definition at line 174 of file nasl_builtin_nmap.c.
#define PREF_MAX_RTT_TIMEOUT "Max RTT Timeout (ms)" |
Plugin parameter description: probe round trip time hint (maximal value).
Definition at line 156 of file nasl_builtin_nmap.c.
#define PREF_MIN_HOSTGROUP "Hosts scanned in parallel (min)" |
Plugin parameter description: force minimum number of hosts to scan in parallel.
Definition at line 180 of file nasl_builtin_nmap.c.
#define PREF_MIN_PARALLELISM "Ports scanned in parallel (min)" |
Plugin parameter description: force minimum number of parallel active probes.
Definition at line 168 of file nasl_builtin_nmap.c.
#define PREF_MIN_RTT_TIMEOUT "Min RTT Timeout (ms)" |
Plugin parameter description: probe round trip time hint (minimal value)
Definition at line 150 of file nasl_builtin_nmap.c.
#define PREF_NO_DNS "Disable DNS resolution" |
Plugin parameter description: don't perform reverse resolution on discovered IP addresses.
Definition at line 95 of file nasl_builtin_nmap.c.
#define PREF_RPC_PORT_SCAN "RPC port scan" |
Plugin parameter description: perform RPC port scan.
Definition at line 111 of file nasl_builtin_nmap.c.
#define PREF_SERVICE_SCAN "Service scan" |
Plugin parameter description: perform service/version detection scan.
Definition at line 106 of file nasl_builtin_nmap.c.
#define PREF_SOURCE_PORT "Source port" |
Plugin parameter description: set source port.
Definition at line 133 of file nasl_builtin_nmap.c.
#define PREF_TCP_SCANNING_TECHNIQUE "TCP scanning technique" |
Plugin parameter description: TCP port scanning technique to use.
Definition at line 100 of file nasl_builtin_nmap.c.
#define PREF_TIMING_POLICY "Timing policy" |
Plugin parameter description: select timing template.
Definition at line 138 of file nasl_builtin_nmap.c.
#define PREF_TRACEROUTE "Trace hop path to each host" |
Plugin parameter description: perform traceroute.
Definition at line 89 of file nasl_builtin_nmap.c.
#define PREF_TREAT_ALL_HOST_ONLINE "Treat all hosts as online" |
Plugin parameter description: skip alive hosts discovery phase.
Definition at line 84 of file nasl_builtin_nmap.c.
#define PRINT_NOT_NULL | ( | x | ) | ((x) ? (x) : "") |
|
static |
Add a couple argument/value on the command line.
[in,out] | nmap | Handler to use. |
[in] | name | Name of the flag/option. |
[in] | value | Value of the option (or NULL for simple flags). |
Definition at line 715 of file nasl_builtin_nmap.c.
References nmap_t::arg_idx, nmap_t::args, and name.
Referenced by add_nse_arguments(), add_portrange(), add_scantype_arguments(), add_target(), add_timing_arguments(), and build_cmd_line().
|
static |
Add NSE (nmap scripting engine) related arguments to the command line according to user script selection and preferences.
[in,out] | nmap | Handler to use. |
Definition at line 758 of file nasl_builtin_nmap.c.
References add_arg(), get_script_args(), and get_script_list().
Referenced by build_cmd_line().
|
static |
Add the range of ports to scan to the command line.
[in,out] | nmap | Handler to use. |
Definition at line 928 of file nasl_builtin_nmap.c.
References add_arg().
Referenced by build_cmd_line().
|
static |
Add the TCP scantype flag to the command line.
[in,out] | nmap | Handler to use. |
Definition at line 868 of file nasl_builtin_nmap.c.
References add_arg(), get_plugin_preference(), nmap_t::oid, nmap_opt_t::optname, and PREF_TCP_SCANNING_TECHNIQUE.
Referenced by build_cmd_line().
|
static |
Append scan target to the command line.
[in,out] | nmap | Handler to use. |
Definition at line 1029 of file nasl_builtin_nmap.c.
References add_arg(), nmap_t::env, script_infos::globals, and scan_globals::network_targets.
Referenced by build_cmd_line().
|
static |
Add timing template argument to the command line.
[in,out] | nmap | Handler to use. |
Definition at line 899 of file nasl_builtin_nmap.c.
References add_arg(), get_plugin_preference(), nmap_t::oid, nmap_opt_t::optname, and PREF_TIMING_POLICY.
Referenced by build_cmd_line().
|
static |
Rebuild command line to run according to plugin parameters.
[in,out] | nmap | Handler to use. |
Definition at line 614 of file nasl_builtin_nmap.c.
References add_arg(), add_nse_arguments(), add_portrange(), add_scantype_arguments(), add_target(), add_timing_arguments(), get_plugin_preference(), NMAP_CMD, nmap_t::oid, OPT_SET, nmap_opt_t::optname, PREF_AGGRESSIVE_OS_DETECT, PREF_EXCLUDE_HOSTS, PREF_FRAGMENT_IP, PREF_HOST_TIMEOUT, PREF_IDENTIFY_REMOTE_OS, PREF_INITIAL_RTT_TIMEOUT, PREF_INTERPROBE_DELAY, PREF_MAX_HOSTGROUP, PREF_MAX_PARALLELISM, PREF_MAX_RTT_TIMEOUT, PREF_MIN_HOSTGROUP, PREF_MIN_PARALLELISM, PREF_MIN_RTT_TIMEOUT, PREF_NO_DNS, PREF_RPC_PORT_SCAN, PREF_SERVICE_SCAN, PREF_SOURCE_PORT, PREF_TRACEROUTE, and PREF_TREAT_ALL_HOST_ONLINE.
Referenced by nmap_create().
|
static |
Clear the current host object.
[in,out] | nmap | Handler to use. |
Definition at line 1207 of file nasl_builtin_nmap.c.
References traceroute_hop::addr, nmap_host::addr, nmap_host::best_os, traceroute_hop::host, nmap_host::host_scripts, nmap_host::ipidseq, list_free, MAX_TRACE_HOPS, nse_script_destroy(), nmap_host::os_cpes, port_destroy(), nmap_host::ports, traceroute_hop::rtt, simple_item_destroy(), nmap_host::state, nmap_host::tcpseq_difficulty, nmap_host::tcpseq_index, nmap_t::tmphost, and nmap_host::trace.
Referenced by xmltag_close_host().
|
static |
Dump current host object state into the knowledge base.
[in] | nmap | Handler to use. |
Definition at line 1862 of file nasl_builtin_nmap.c.
References save_detected_os(), save_host_state(), save_hostscripts(), save_ipidseq_details(), save_open_ports(), save_portscripts(), save_tcpseq_details(), and save_traceroute_details().
Referenced by xmltag_close_host().
|
static |
Display the final command line for debug.
[in,out] | nmap | Handler to use. |
Definition at line 1057 of file nasl_builtin_nmap.c.
References nmap_t::args.
Referenced by nmap_create().
|
static |
Helper function: get attribute value from the separate name/value tables.
[in] | name | Name of the attribute to lookup. |
[in] | attribute_names | Table of the attribute names. |
[in] | attribute_values | Table of the attribute values. |
Definition at line 1845 of file nasl_builtin_nmap.c.
References name.
Referenced by xmltag_open_address(), xmltag_open_distance(), xmltag_open_hop(), xmltag_open_ipidsequence(), xmltag_open_osmatch(), xmltag_open_port(), xmltag_open_script(), xmltag_open_service(), xmltag_open_state(), xmltag_open_status(), and xmltag_open_tcpsequence().
|
static |
Make the comma-separated list of NSE arguments set by the user.
[in,out] | nmap | Handler to use. |
Definition at line 829 of file nasl_builtin_nmap.c.
References nmap_t::env, and plug_get_kb().
Referenced by add_nse_arguments().
|
static |
Make the comma-separated list of NSE scripts selected by the user.
[in,out] | nmap | Handler to use. |
Definition at line 787 of file nasl_builtin_nmap.c.
References nmap_t::env, and plug_get_kb().
Referenced by add_nse_arguments().
Instantiate a new nmap handler, rebuild command line or open XML file to parse.
[in] | lexic | NASL state |
Definition at line 540 of file nasl_builtin_nmap.c.
References build_cmd_line(), dbg_display_cmdline(), nmap_t::env, nmap_t::filename, get_plugin_preference(), get_plugin_preference_fname(), nmap_destroy(), struct_lex_ctxt::oid, nmap_t::oid, PREF_IMPORT_XML_FILE, struct_lex_ctxt::script_infos, and setup_xml_parser().
Referenced by plugin_run_nmap().
|
static |
Release a nmap handler and associated resources.
[in,out] | nmap | Handler to free. |
Definition at line 582 of file nasl_builtin_nmap.c.
References nmap_t::arg_idx, nmap_t::args, nmap_parser::closetag, nmap_parser::opentag, and nmap_t::parser.
Referenced by nmap_create(), and plugin_run_nmap().
|
static |
Run nmap and parse its XML output (or load an external file if requested).
[in,out] | nmap | Handler to use. |
Definition at line 1099 of file nasl_builtin_nmap.c.
References nmap_t::args, CHUNK_LEN, nmap_t::filename, pid, sig_c(), sig_h(), xml_end_element(), xml_read_text(), and xml_start_element().
Referenced by plugin_run_nmap().
|
static |
Completely release a NSE script object.
[in] | data | List item data pointer (according to GFunc specification). A struct nse_script * is expected here. |
[in] | udata | User defined data pointer (according to GFunc specification). A nmap_t * is expected here. |
Definition at line 1272 of file nasl_builtin_nmap.c.
References nse_script::name, and nse_script::output.
Referenced by current_host_reset(), and port_destroy().
Run the nmap_net subsystem.
[in] | lexic | NASL state. |
Definition at line 509 of file nasl_builtin_nmap.c.
References FAKE_CELL, nmap_create(), nmap_destroy(), and nmap_run_and_parse().
|
static |
Completely release a port object.
[in] | data | List item data pointer (according to GFunc specification). A struct nmap_port * is expected here. |
[in] | udata | User defined data pointer (according to GFunc specification). A nmap_t * is expected here. |
Definition at line 1241 of file nasl_builtin_nmap.c.
References list_free, nse_script_destroy(), nmap_port::port_scripts, nmap_port::portno, nmap_port::proto, nmap_port::service, simple_item_destroy(), nmap_port::state, nmap_port::version, and nmap_port::version_cpes.
Referenced by current_host_reset().
Save information about a detected service (version) into the knowledge base.
[in] | nmap | Handler to use. |
[in] | p | Service description. |
Definition at line 1940 of file nasl_builtin_nmap.c.
References nmap_host::addr, ARG_INT, ARG_STRING, nmap_t::env, plug_set_key(), nmap_port::portno, nmap_port::proto, nmap_port::service, nmap_t::tmphost, nmap_port::version, and nmap_port::version_cpes.
Referenced by save_open_ports().
|
static |
Save information about detected operating system into the knowledge base.
[in] | nmap | Handler to use. |
Definition at line 1990 of file nasl_builtin_nmap.c.
References nmap_host::addr, ARG_STRING, nmap_host::best_os, nmap_t::env, nmap_host::os_cpes, plug_set_key(), and nmap_t::tmphost.
Referenced by current_host_saveall().
|
static |
Store host state (host alive/dead) into the knowledge base.
[in] | nmap | Handler to use. |
Definition at line 1891 of file nasl_builtin_nmap.c.
References nmap_host::addr, ARG_STRING, nmap_t::env, plug_set_key(), nmap_host::state, and nmap_t::tmphost.
Referenced by current_host_saveall().
|
static |
Save information about hostrule NSE scripts into the knowledge base.
[in] | nmap | Handler to use. |
Definition at line 2131 of file nasl_builtin_nmap.c.
References nmap_host::addr, ARG_STRING, nmap_t::env, nmap_host::host_scripts, nse_script::name, nse_script::output, plug_set_key(), and nmap_t::tmphost.
Referenced by current_host_saveall().
|
static |
Save information about IP ID generation into the knowledge base.
[in] | nmap | Handler to use. |
Definition at line 2040 of file nasl_builtin_nmap.c.
References nmap_host::addr, ARG_STRING, nmap_t::env, nmap_host::ipidseq, plug_set_key(), and nmap_t::tmphost.
Referenced by current_host_saveall().
|
static |
Save information about open ports for the current host into the knowledge base.
[in] | nmap | Handler to use. |
Definition at line 1909 of file nasl_builtin_nmap.c.
References nmap_host::addr, ARG_INT, nmap_t::env, plug_set_key(), nmap_port::portno, nmap_host::ports, nmap_port::proto, register_service(), nmap_port::state, and nmap_t::tmphost.
Referenced by current_host_saveall().
|
static |
Save information about postrule NSE scripts into the knowledge base.
[in] | nmap | Handler to use. |
Definition at line 2092 of file nasl_builtin_nmap.c.
References nmap_host::addr, ARG_STRING, nmap_t::env, nse_script::name, nse_script::output, plug_set_key(), nmap_port::port_scripts, nmap_port::portno, nmap_host::ports, nmap_port::proto, and nmap_t::tmphost.
Referenced by current_host_saveall().
|
static |
Save information about TCP sequence number generation into the knowledge base.
[in] | nmap | Handler to use. |
Definition at line 2019 of file nasl_builtin_nmap.c.
References nmap_host::addr, ARG_STRING, nmap_t::env, plug_set_key(), nmap_host::tcpseq_difficulty, nmap_host::tcpseq_index, and nmap_t::tmphost.
Referenced by current_host_saveall().
|
static |
Save information about network topology to the target (traceroute) into the knowledge base.
[in] | nmap | Handler to use. |
Definition at line 2058 of file nasl_builtin_nmap.c.
References traceroute_hop::addr, nmap_host::addr, ARG_INT, ARG_STRING, nmap_host::distance, nmap_t::env, traceroute_hop::host, MAX_TRACE_HOPS, plug_set_key(), traceroute_hop::rtt, nmap_t::tmphost, and nmap_host::trace.
Referenced by current_host_saveall().
|
static |
Populate the callbacks hashtable with handlers for closing tags.
[out] | close | The hashtable to populate. |
Definition at line 1003 of file nasl_builtin_nmap.c.
References xmltag_close_cpe(), xmltag_close_host(), xmltag_close_hostscript(), xmltag_close_port(), and xmltag_close_ports().
Referenced by setup_xml_parser().
|
static |
Populate the callbacks hashtable with handlers for opening tags.
[out] | open | The hashtable to populate. |
Definition at line 969 of file nasl_builtin_nmap.c.
References xmltag_open_address(), xmltag_open_cpe(), xmltag_open_distance(), xmltag_open_hop(), xmltag_open_host(), xmltag_open_hostscript(), xmltag_open_ipidsequence(), xmltag_open_osmatch(), xmltag_open_port(), xmltag_open_ports(), xmltag_open_script(), xmltag_open_service(), xmltag_open_state(), xmltag_open_status(), and xmltag_open_tcpsequence().
Referenced by setup_xml_parser().
|
static |
Setup XML parser internals.
[in,out] | nmap | Handler to use. |
Definition at line 947 of file nasl_builtin_nmap.c.
References nmap_parser::closetag, nmap_parser::enable_read, nmap_parser::in_host, nmap_parser::in_hostscript, nmap_parser::in_port, nmap_parser::in_ports, nmap_parser::opentag, nmap_t::parser, set_closetag_callbacks(), and set_opentag_callbacks().
Referenced by nmap_create().
|
static |
Signal handler (Child).
Definition at line 1084 of file nasl_builtin_nmap.c.
References pid.
Referenced by nmap_run_and_parse().
|
static |
Signal handler (Halt).
Definition at line 1074 of file nasl_builtin_nmap.c.
References pid.
Referenced by nmap_run_and_parse().
|
static |
Simple wrapper to call g_free from within g_slist_foreach statements.
[in] | data | List item data pointer (according to GFunc specification). A struct nse_script * is expected here. |
[in] | udata | User defined data pointer (according to GFunc specification). This parameter is not used. |
Definition at line 1296 of file nasl_builtin_nmap.c.
Referenced by current_host_reset(), and port_destroy().
|
static |
Add NSE hostscript result to the current host object.
[in,out] | nmap | Handler to use. |
[in] | name | Name of the NSE script that produced the output. |
[in] | output | Output produced by this NSE script. |
Definition at line 1325 of file nasl_builtin_nmap.c.
References nmap_host::host_scripts, nse_script::name, name, nse_script::output, and nmap_t::tmphost.
Referenced by xmltag_open_script().
|
static |
Add NSE portscript result to a port of the current host.
[in,out] | nmap | Handler to use. |
[in] | name | Name of the NSE script that produced the output. |
[in] | output | Output produced by this NSE script. |
Definition at line 1343 of file nasl_builtin_nmap.c.
References nse_script::name, name, nse_script::output, nmap_port::port_scripts, and nmap_t::tmpport.
Referenced by xmltag_open_script().
|
static |
Add port information to the current host object.
[in,out] | nmap | Handler to use. |
Definition at line 1308 of file nasl_builtin_nmap.c.
References nmap_host::ports, nmap_t::tmphost, and nmap_t::tmpport.
Referenced by xmltag_close_port().
|
static |
Top level XML parser callback: handle an closing tag and call the corresponding method.
[in] | context | The XML parser. |
[in] | element_name | The name of the current tag. |
[in] | user_data | A pointer to the current nmap_t structure. |
[in] | error | Return location of a GError. |
Definition at line 1390 of file nasl_builtin_nmap.c.
References nmap_parser::closetag, and nmap_t::parser.
Referenced by nmap_run_and_parse().
|
static |
Top level XML parser callback: handle text sections and store it into the read buffer if enable_read is set to TRUE.
[in] | context | The XML parser. |
[in] | text | The current text chunk. |
[in] | text_len | Chunk size. |
[in] | user_data | A pointer to the current nmap_t structure. |
[in] | error | Return location of a GError. |
Definition at line 1414 of file nasl_builtin_nmap.c.
References nmap_parser::enable_read, nmap_t::parser, and nmap_parser::rbuff.
Referenced by nmap_run_and_parse().
|
static |
Top level XML parser callback: handle an opening tag and call the corresponding method.
[in] | context | The XML parser. |
[in] | element_name | The name of the current tag. |
[in] | attribute_names | NULL terminated list of attributes names. |
[in] | attribute_values | NULL terminated list of attributes values. |
[in] | user_data | A pointer to the current nmap_t structure. |
[in] | error | Return location of a GError. |
Definition at line 1365 of file nasl_builtin_nmap.c.
References nmap_parser::opentag, and nmap_t::parser.
Referenced by nmap_run_and_parse().
|
static |
Sublevel XML parser callback: handle an closing cpe tag.
[in] | nmap | Handler to use. |
Definition at line 1806 of file nasl_builtin_nmap.c.
References nmap_parser::enable_read, nmap_parser::in_port, nmap_host::os_cpes, nmap_t::parser, nmap_parser::rbuff, nmap_t::tmphost, nmap_t::tmpport, and nmap_port::version_cpes.
Referenced by set_closetag_callbacks().
|
static |
Sublevel XML parser callback: handle an closing host tag.
[in] | nmap | Handler to use. |
Definition at line 1769 of file nasl_builtin_nmap.c.
References current_host_reset(), current_host_saveall(), nmap_parser::in_host, and nmap_t::parser.
Referenced by set_closetag_callbacks().
|
static |
Sublevel XML parser callback: handle an closing hostscript tag.
[in] | nmap | Handler to use. |
Definition at line 1829 of file nasl_builtin_nmap.c.
References nmap_parser::in_hostscript, and nmap_t::parser.
Referenced by set_closetag_callbacks().
|
static |
Sublevel XML parser callback: handle an closing port tag.
[in] | nmap | Handler to use. |
Definition at line 1793 of file nasl_builtin_nmap.c.
References nmap_parser::in_port, nmap_t::parser, tmphost_add_port(), and nmap_t::tmpport.
Referenced by set_closetag_callbacks().
|
static |
Sublevel XML parser callback: handle an closing host tag.
[in] | nmap | Handler to use. |
Definition at line 1782 of file nasl_builtin_nmap.c.
References nmap_parser::in_ports, and nmap_t::parser.
Referenced by set_closetag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening address tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1479 of file nasl_builtin_nmap.c.
References nmap_host::addr, get_attr_value(), nmap_parser::in_host, nmap_t::parser, and nmap_t::tmphost.
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening cpe tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1580 of file nasl_builtin_nmap.c.
References nmap_parser::enable_read, nmap_t::parser, and nmap_parser::rbuff.
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening distance tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1708 of file nasl_builtin_nmap.c.
References nmap_host::distance, get_attr_value(), nmap_parser::in_host, nmap_t::parser, and nmap_t::tmphost.
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening hop tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1732 of file nasl_builtin_nmap.c.
References traceroute_hop::addr, get_attr_value(), traceroute_hop::host, nmap_parser::in_host, MAX_TRACE_HOPS, nmap_t::parser, traceroute_hop::rtt, nmap_t::tmphost, and nmap_host::trace.
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening host tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1447 of file nasl_builtin_nmap.c.
References nmap_parser::in_host, and nmap_t::parser.
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening hostscript tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1601 of file nasl_builtin_nmap.c.
References nmap_parser::in_hostscript, and nmap_t::parser.
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening ipidsequence tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1691 of file nasl_builtin_nmap.c.
References get_attr_value(), nmap_parser::in_host, nmap_host::ipidseq, nmap_t::parser, and nmap_t::tmphost.
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening osmatch tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1617 of file nasl_builtin_nmap.c.
References nmap_host::best_os, get_attr_value(), nmap_host::os_confidence, and nmap_t::tmphost.
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening port tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1511 of file nasl_builtin_nmap.c.
References get_attr_value(), nmap_parser::in_port, nmap_t::parser, nmap_port::portno, nmap_port::proto, and nmap_t::tmpport.
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening ports tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1496 of file nasl_builtin_nmap.c.
References nmap_parser::in_ports, and nmap_t::parser.
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening script tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1647 of file nasl_builtin_nmap.c.
References get_attr_value(), nmap_parser::in_host, nmap_parser::in_port, name, nse_script::output, nmap_t::parser, tmphost_add_nse_hostscript(), and tmphost_add_nse_portscript().
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening service tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1542 of file nasl_builtin_nmap.c.
References get_attr_value(), nmap_parser::in_port, nmap_t::parser, nmap_port::portno, PRINT_NOT_NULL, nmap_port::proto, nmap_port::service, nmap_t::tmpport, and nmap_port::version.
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening state tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1526 of file nasl_builtin_nmap.c.
References get_attr_value(), nmap_parser::in_port, nmap_t::parser, nmap_port::portno, nmap_port::proto, nmap_port::state, and nmap_t::tmpport.
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening status tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1462 of file nasl_builtin_nmap.c.
References get_attr_value(), nmap_parser::in_host, nmap_t::parser, nmap_host::state, and nmap_t::tmphost.
Referenced by set_opentag_callbacks().
|
static |
Sublevel XML parser callback: handle an opening tcpsequence tag.
[in] | nmap | Handler to use. |
[in] | attrnames | NULL terminated list of attributes names. |
[in] | attrval | NULL terminated list of attributes values. |
Definition at line 1672 of file nasl_builtin_nmap.c.
References get_attr_value(), nmap_parser::in_host, nmap_t::parser, nmap_host::tcpseq_difficulty, nmap_host::tcpseq_index, and nmap_t::tmphost.
Referenced by set_opentag_callbacks().
|
static |
Definition at line 499 of file nasl_builtin_nmap.c.
Referenced by attack_network(), create_process(), get_connection_fd(), hosts_set_pid(), launch_plugin(), let_em_die(), main(), next_free_process(), nmap_run_and_parse(), plug_fork_child(), plug_get_host_fqdn(), plug_get_key(), plugin_launch(), pluginlaunch_stop(), process_alive(), sig_c(), sig_h(), sighand_chld(), stop_single_task_scan(), terminate_process(), timeout_running_processes(), and update_running_processes().