OpenVAS Scanner  6.0.0~git
Data Structures | Macros | Functions | Variables
nasl_builtin_nmap.c File Reference

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>

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_tnmap_create (lex_ctxt *lexic)
 Instanciate 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_cellplugin_run_nmap (lex_ctxt *lexic)
 Run the nmap_net subsystem. More...
 

Variables

static pid_t pid = 0
 

Detailed Description

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.

Macro Definition Documentation

◆ CHUNK_LEN

#define CHUNK_LEN   512

Input chunks size for the XML parser.

◆ list_free

#define list_free (   list,
  dtor,
  udata 
)
Value:
do \
{ \
if (list) \
{ \
g_slist_foreach (list, (GFunc) dtor, udata); \
g_slist_free (list); \
list = NULL; \
} \
} \
while (0)
Definition: nasl_builtin_synscan.c:259

◆ MAX_TRACE_HOPS

#define MAX_TRACE_HOPS   64

Maximum number of hops to the target.

◆ NMAP_CMD

#define NMAP_CMD   "nmap"

Nmap command to call.

◆ OPT_SET

#define OPT_SET   "yes"

Checkbox value (when set).

◆ OPT_UNSET

#define OPT_UNSET   "no"

Checkbox value (when unset).

◆ PREF_AGGRESSIVE_OS_DETECT

#define PREF_AGGRESSIVE_OS_DETECT   "Aggressive OS detection"

Plugin parameter description: guess OS from closest match if necessary.

◆ PREF_EXCLUDE_HOSTS

#define PREF_EXCLUDE_HOSTS   "Exclude hosts"

Plugin parameter description: comma-separated list of hosts to exclude from the scan.

◆ PREF_FRAGMENT_IP

#define PREF_FRAGMENT_IP   "Fragment IP packets (bypasses firewalls)"

Plugin parameter description: try to evade defense by fragmenting IP packets.

◆ PREF_HOST_TIMEOUT

#define PREF_HOST_TIMEOUT   "Host Timeout (ms)"

Plugin parameter description: give up on host after this time elapsed.

◆ PREF_IDENTIFY_REMOTE_OS

#define PREF_IDENTIFY_REMOTE_OS   "Identify the remote OS"

Plugin parameter description: perform remote OS fingerprinting.

◆ PREF_IMPORT_XML_FILE

#define PREF_IMPORT_XML_FILE   "File containing XML results"

Plugin parameter description: import XML file.

◆ PREF_INITIAL_RTT_TIMEOUT

#define PREF_INITIAL_RTT_TIMEOUT   "Initial RTT timeout (ms)"

Plugin parameter description: probe round trip time hint (initial value).

◆ PREF_INTERPROBE_DELAY

#define PREF_INTERPROBE_DELAY   "Minimum wait between probes (ms)"

Plugin parameter description: set idle interval between probes.

◆ PREF_MAX_HOSTGROUP

#define PREF_MAX_HOSTGROUP   "Hosts scanned in parallel (max)"

Plugin parameter description: force maximum number of hosts to scan in parallel.

◆ PREF_MAX_PARALLELISM

#define PREF_MAX_PARALLELISM   "Ports scanned in parallel (max)"

Plugin parameter description: force maximum number of parallel active probes.

◆ PREF_MAX_RTT_TIMEOUT

#define PREF_MAX_RTT_TIMEOUT   "Max RTT Timeout (ms)"

Plugin parameter description: probe round trip time hint (maximal value).

◆ PREF_MIN_HOSTGROUP

#define PREF_MIN_HOSTGROUP   "Hosts scanned in parallel (min)"

Plugin parameter description: force minimum number of hosts to scan in parallel.

◆ PREF_MIN_PARALLELISM

#define PREF_MIN_PARALLELISM   "Ports scanned in parallel (min)"

Plugin parameter description: force minimum number of parallel active probes.

◆ PREF_MIN_RTT_TIMEOUT

#define PREF_MIN_RTT_TIMEOUT   "Min RTT Timeout (ms)"

Plugin parameter description: probe round trip time hint (minimal value)

◆ PREF_NO_DNS

#define PREF_NO_DNS   "Disable DNS resolution"

Plugin parameter description: don't perform reverse resolution on discovered IP addresses.

◆ PREF_RPC_PORT_SCAN

#define PREF_RPC_PORT_SCAN   "RPC port scan"

Plugin parameter description: perform RPC port scan.

◆ PREF_SERVICE_SCAN

#define PREF_SERVICE_SCAN   "Service scan"

Plugin parameter description: perform service/version detection scan.

◆ PREF_SOURCE_PORT

#define PREF_SOURCE_PORT   "Source port"

Plugin parameter description: set source port.

◆ PREF_TCP_SCANNING_TECHNIQUE

#define PREF_TCP_SCANNING_TECHNIQUE   "TCP scanning technique"

Plugin parameter description: TCP port scanning technique to use.

◆ PREF_TIMING_POLICY

#define PREF_TIMING_POLICY   "Timing policy"

Plugin parameter description: select timing template.

◆ PREF_TRACEROUTE

#define PREF_TRACEROUTE   "Trace hop path to each host"

Plugin parameter description: perform traceroute.

◆ PREF_TREAT_ALL_HOST_ONLINE

#define PREF_TREAT_ALL_HOST_ONLINE   "Treat all hosts as online"

Plugin parameter description: skip alive hosts discovery phase.

◆ PRINT_NOT_NULL

#define PRINT_NOT_NULL (   x)    ((x) ? (x) : "")

Function Documentation

◆ add_arg()

int add_arg ( nmap_t nmap,
const gchar *  name,
const gchar *  value 
)
static

Add a couple argument/value on the command line.

Parameters
[in,out]nmapHandler to use.
[in]nameName of the flag/option.
[in]valueValue of the option (or NULL for simple flags).
Returns
-1 on failure or 1 on success.

◆ add_nse_arguments()

int add_nse_arguments ( nmap_t nmap)
static

Add NSE (nmap scripting engine) related arguments to the command line according to user script selection and preferences.

Parameters
[in,out]nmapHandler to use.
Returns
1 success

◆ add_portrange()

int add_portrange ( nmap_t nmap)
static

Add the range of ports to scan to the command line.

Parameters
[in,out]nmapHandler to use.
Returns
-1 on failure or 1 on success.

◆ add_scantype_arguments()

int add_scantype_arguments ( nmap_t nmap)
static

Add the TCP scantype flag to the command line.

Parameters
[in,out]nmapHandler to use.
Returns
-1 on failure or 1 on success.

◆ add_target()

int add_target ( nmap_t nmap)
static

Append scan target to the command line.

Parameters
[in,out]nmapHandler to use.
Returns
-1 on failure or 1 on success.

◆ add_timing_arguments()

int add_timing_arguments ( nmap_t nmap)
static

Add timing template argument to the command line.

Parameters
[in,out]nmapHandler to use.
Returns
-1 on failure or 1 on success.

◆ build_cmd_line()

int build_cmd_line ( nmap_t nmap)
static

Rebuild command line to run according to plugin parameters.

Parameters
[in,out]nmapHandler to use.
Returns
-1 on failure and 1 on success.

◆ current_host_reset()

void current_host_reset ( nmap_t nmap)
static

Clear the current host object.

Parameters
[in,out]nmapHandler to use.

◆ current_host_saveall()

void current_host_saveall ( nmap_t nmap)
static

Dump current host object state into the knowledge base.

Parameters
[in]nmapHandler to use.

◆ dbg_display_cmdline()

void dbg_display_cmdline ( nmap_t nmap)
static

Display the final command line for debug.

Parameters
[in,out]nmapHandler to use.

◆ get_attr_value()

gchar * get_attr_value ( const gchar *  name,
const gchar **  attribute_names,
const gchar **  attribute_values 
)
static

Helper function: get attribute value from the separate name/value tables.

Parameters
[in]nameName of the attribute to lookup.
[in]attribute_namesTable of the attribute names.
[in]attribute_valuesTable of the attribute values.
Returns
the desired value or NULL if nothing was found

◆ get_script_args()

gchar * get_script_args ( nmap_t nmap)
static

Make the comma-separated list of NSE arguments set by the user.

Parameters
[in,out]nmapHandler to use.
Returns
A dynamically allocated string containing the list of NSE arguments to use

◆ get_script_list()

gchar * get_script_list ( nmap_t nmap)
static

Make the comma-separated list of NSE scripts selected by the user.

Parameters
[in,out]nmapHandler to use.
Returns
A dynamically allocated string containing the list of NSE scripts to run.

◆ nmap_create()

nmap_t * nmap_create ( lex_ctxt lexic)
static

Instanciate a new nmap handler, rebuild command line or open XML file to parse.

Parameters
[in]lexicNASL state
Returns
The newly allocated nmap handler or NULL on error.

◆ nmap_destroy()

void nmap_destroy ( nmap_t nmap)
static

Release a nmap handler and associated resources.

Parameters
[in,out]nmapHandler to free.

◆ nmap_run_and_parse()

int nmap_run_and_parse ( nmap_t nmap)
static

Run nmap and parse its XML output (or load an external file if requested).

Parameters
[in,out]nmapHandler to use.
Returns
-1 on failure or 1 on success.

◆ nse_script_destroy()

void nse_script_destroy ( gpointer  data,
gpointer  udata 
)
static

Completely release a NSE script object.

Parameters
[in]dataList item data pointer (according to GFunc specification). A struct nse_script * is expected here.
[in]udataUser defined data pointer (according to GFunc specification). A nmap_t * is expected here.

◆ plugin_run_nmap()

tree_cell* plugin_run_nmap ( lex_ctxt lexic)

Run the nmap_net subsystem.

Parameters
[in]lexicNASL state.
Returns
NULL on error, FAKE_CELL on success.

◆ port_destroy()

void port_destroy ( gpointer  data,
gpointer  udata 
)
static

Completely release a port object.

Parameters
[in]dataList item data pointer (according to GFunc specification). A struct nmap_port * is expected here.
[in]udataUser defined data pointer (according to GFunc specification). A nmap_t * is expected here.

◆ register_service()

void register_service ( nmap_t nmap,
struct nmap_port p 
)
static

Save information about a detected service (version) into the knowledge base.

Parameters
[in]nmapHandler to use.
[in]pService description.

◆ save_detected_os()

void save_detected_os ( nmap_t nmap)
static

Save information about detected operating system into the knowledge base.

Parameters
[in]nmapHandler to use.

◆ save_host_state()

void save_host_state ( nmap_t nmap)
static

Store host state (host alive/dead) into the knowledge base.

Parameters
[in]nmapHandler to use.

◆ save_hostscripts()

void save_hostscripts ( nmap_t nmap)
static

Save information about hostrule NSE scripts into the knowledge base.

Parameters
[in]nmapHandler to use.

◆ save_ipidseq_details()

void save_ipidseq_details ( nmap_t nmap)
static

Save information about IP ID generation into the knowledge base.

Parameters
[in]nmapHandler to use.

◆ save_open_ports()

void save_open_ports ( nmap_t nmap)
static

Save information about open ports for the current host into the knowledge base.

Parameters
[in]nmapHandler to use.

◆ save_portscripts()

void save_portscripts ( nmap_t nmap)
static

Save information about postrule NSE scripts into the knowledge base.

Parameters
[in]nmapHandler to use.

◆ save_tcpseq_details()

void save_tcpseq_details ( nmap_t nmap)
static

Save information about TCP sequence number generation into the knowledge base.

Parameters
[in]nmapHandler to use.

◆ save_traceroute_details()

void save_traceroute_details ( nmap_t nmap)
static

Save information about network topology to the target (traceroute) into the knowledge base.

Parameters
[in]nmapHandler to use.

◆ set_closetag_callbacks()

void set_closetag_callbacks ( GHashTable *  close)
static

Populate the callbacks hashtable with handlers for closing tags.

Parameters
[out]closeThe hashtable to populate.

◆ set_opentag_callbacks()

void set_opentag_callbacks ( GHashTable *  open)
static

Populate the callbacks hashtable with handlers for opening tags.

Parameters
[out]openThe hashtable to populate.

◆ setup_xml_parser()

void setup_xml_parser ( nmap_t nmap)
static

Setup XML parser internals.

Parameters
[in,out]nmapHandler to use.

◆ sig_c()

void sig_c ( )
static

Signal handler (Child).

◆ sig_h()

void sig_h ( )
static

Signal handler (Halt).

◆ simple_item_destroy()

void simple_item_destroy ( gpointer  data,
gpointer  udata 
)
static

Simple wrapper to call g_free from within g_slist_foreach statements.

Parameters
[in]dataList item data pointer (according to GFunc specification). A struct nse_script * is expected here.
[in]udataUser defined data pointer (according to GFunc specification). This parameter is not used.

◆ tmphost_add_nse_hostscript()

void tmphost_add_nse_hostscript ( nmap_t nmap,
gchar *  name,
gchar *  output 
)
static

Add NSE hostscript result to the current host object.

Parameters
[in,out]nmapHandler to use.
[in]nameName of the NSE script that produced the output.
[in]outputOutput produced by this NSE script.

◆ tmphost_add_nse_portscript()

void tmphost_add_nse_portscript ( nmap_t nmap,
gchar *  name,
gchar *  output 
)
static

Add NSE portscript result to a port of the current host.

Parameters
[in,out]nmapHandler to use.
[in]nameName of the NSE script that produced the output.
[in]outputOutput produced by this NSE script.

◆ tmphost_add_port()

void tmphost_add_port ( nmap_t nmap)
static

Add port information to the current host object.

Parameters
[in,out]nmapHandler to use.

◆ xml_end_element()

void xml_end_element ( GMarkupParseContext *  context,
const gchar *  element_name,
gpointer  user_data,
GError **  error 
)
static

Top level XML parser callback: handle an closing tag and call the corresponding method.

Parameters
[in]contextThe XML parser.
[in]element_nameThe name of the current tag.
[in]user_dataA pointer to the current nmap_t structure.
[in]errorReturn location of a GError.

◆ xml_read_text()

void xml_read_text ( GMarkupParseContext *  context,
const gchar *  text,
gsize  text_len,
gpointer  user_data,
GError **  error 
)
static

Top level XML parser callback: handle text sections and store it into the read buffer if enable_read is set to TRUE.

Parameters
[in]contextThe XML parser.
[in]textThe current text chunk.
[in]text_lenChunk size.
[in]user_dataA pointer to the current nmap_t structure.
[in]errorReturn location of a GError.

◆ xml_start_element()

void xml_start_element ( GMarkupParseContext *  context,
const gchar *  element_name,
const gchar **  attribute_names,
const gchar **  attribute_values,
gpointer  user_data,
GError **  error 
)
static

Top level XML parser callback: handle an opening tag and call the corresponding method.

Parameters
[in]contextThe XML parser.
[in]element_nameThe name of the current tag.
[in]attribute_namesNULL terminated list of attributes names.
[in]attribute_valuesNULL terminated list of attributes values.
[in]user_dataA pointer to the current nmap_t structure.
[in]errorReturn location of a GError.

◆ xmltag_close_cpe()

void xmltag_close_cpe ( nmap_t nmap)
static

Sublevel XML parser callback: handle an closing cpe tag.

Parameters
[in]nmapHandler to use.

◆ xmltag_close_host()

void xmltag_close_host ( nmap_t nmap)
static

Sublevel XML parser callback: handle an closing host tag.

Parameters
[in]nmapHandler to use.

◆ xmltag_close_hostscript()

void xmltag_close_hostscript ( nmap_t nmap)
static

Sublevel XML parser callback: handle an closing hostscript tag.

Parameters
[in]nmapHandler to use.

◆ xmltag_close_port()

void xmltag_close_port ( nmap_t nmap)
static

Sublevel XML parser callback: handle an closing port tag.

Parameters
[in]nmapHandler to use.

◆ xmltag_close_ports()

void xmltag_close_ports ( nmap_t nmap)
static

Sublevel XML parser callback: handle an closing host tag.

Parameters
[in]nmapHandler to use.

◆ xmltag_open_address()

void xmltag_open_address ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening address tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_cpe()

void xmltag_open_cpe ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening cpe tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_distance()

void xmltag_open_distance ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening distance tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_hop()

void xmltag_open_hop ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening hop tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_host()

void xmltag_open_host ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening host tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_hostscript()

void xmltag_open_hostscript ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening hostscript tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_ipidsequence()

void xmltag_open_ipidsequence ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening ipidsequence tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_osmatch()

void xmltag_open_osmatch ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening osmatch tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_port()

void xmltag_open_port ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening port tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_ports()

void xmltag_open_ports ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening ports tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_script()

void xmltag_open_script ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening script tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_service()

void xmltag_open_service ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening service tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_state()

void xmltag_open_state ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening state tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_status()

void xmltag_open_status ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening status tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

◆ xmltag_open_tcpsequence()

void xmltag_open_tcpsequence ( nmap_t nmap,
const gchar **  attrnames,
const gchar **  attrval 
)
static

Sublevel XML parser callback: handle an opening tcpsequence tag.

Parameters
[in]nmapHandler to use.
[in]attrnamesNULL terminated list of attributes names.
[in]attrvalNULL terminated list of attributes values.

Variable Documentation

◆ pid

pid_t pid = 0
static