OpenVAS Scanner
7.0.0~git
|
Plugin-specific stuff. More...
#include "plugutils.h"
#include "network.h"
#include <errno.h>
#include <gvm/base/hosts.h>
#include <gvm/base/networking.h>
#include <gvm/base/prefs.h>
#include <gvm/util/nvticache.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
Go to the source code of this file.
Macros | |
#define | G_LOG_DOMAIN "lib misc" |
GLib logging domain. More... | |
#define | MAX_CANDIDATES 16 |
Functions | |
const char * | plug_current_vhost (void) |
static int | plug_fork_child (kb_t) |
void | plug_set_dep (struct script_infos *args, const char *depname) |
void | host_add_port_proto (struct script_infos *args, int portnum, char *proto) |
static int | unscanned_ports_as_closed (port_protocol_t ptype) |
Report state of preferences "unscanned_closed". More... | |
int | kb_get_port_state_proto (kb_t kb, int portnum, char *proto) |
int | host_get_port_state_proto (struct script_infos *args, int portnum, char *proto) |
int | host_get_port_state (struct script_infos *plugdata, int portnum) |
int | host_get_port_state_udp (struct script_infos *plugdata, int portnum) |
int | plug_add_host_fqdn (struct script_infos *args, const char *hostname, const char *source) |
char * | plug_get_host_fqdn (struct script_infos *args) |
GSList * | plug_get_host_fqdn_list (struct script_infos *args) |
char * | plug_get_host_source (struct script_infos *args, const char *hostname) |
struct in6_addr * | plug_get_host_ip (struct script_infos *args) |
char * | plug_get_host_ip_str (struct script_infos *desc) |
void | proto_post_wrapped (const char *oid, struct script_infos *desc, int port, const char *proto, const char *action, const char *what) |
Post a security message (e.g. LOG, NOTE, WARNING ...). More... | |
void | proto_post_alarm (const char *oid, struct script_infos *desc, int port, const char *proto, const char *action) |
void | post_alarm (const char *oid, struct script_infos *desc, int port, const char *action) |
void | proto_post_log (const char *oid, struct script_infos *desc, int port, const char *proto, const char *action) |
Post a log message. More... | |
void | post_log (const char *oid, struct script_infos *desc, int port, const char *action) |
Post a log message about a tcp port. More... | |
void | proto_post_error (const char *oid, struct script_infos *desc, int port, const char *proto, const char *action) |
void | post_error (const char *oid, struct script_infos *desc, int port, const char *action) |
char * | get_plugin_preference (const char *oid, const char *name) |
const char * | get_plugin_preference_fname (struct script_infos *desc, const char *filename) |
Get the file name of a plugins preference that is of type "file". More... | |
char * | get_plugin_preference_file_content (struct script_infos *desc, const char *identifier) |
Get the file contents of a plugins preference that is of type "file". More... | |
long | get_plugin_preference_file_size (struct script_infos *desc, const char *identifier) |
Get the file size of a plugins preference that is of type "file". More... | |
void | plug_set_key_len (struct script_infos *args, char *name, int type, const void *value, size_t len) |
void | plug_set_key (struct script_infos *args, char *name, int type, const void *value) |
void | plug_replace_key_len (struct script_infos *args, char *name, int type, void *value, size_t len) |
void | plug_replace_key (struct script_infos *args, char *name, int type, void *value) |
void | scanner_add_port (struct script_infos *args, int port, char *proto) |
kb_t | plug_get_kb (struct script_infos *args) |
static void | plug_get_key_sigchld () |
static void | sig_n (int signo, void(*fnc)(int)) |
static void | sig_term (void(*fcn)()) |
static void | sig_chld (void(*fcn)()) |
void * | plug_get_key (struct script_infos *args, char *name, int *type, size_t *len, int single) |
Get values from a kb under the given key name. More... | |
unsigned int | plug_get_host_open_port (struct script_infos *desc) |
void | plug_set_port_transport (struct script_infos *args, int port, int tr) |
int | plug_get_port_transport (struct script_infos *args, int port) |
static void | plug_set_ssl_item (struct script_infos *args, char *item, char *itemfname) |
void | plug_set_ssl_cert (struct script_infos *args, char *cert) |
void | plug_set_ssl_key (struct script_infos *args, char *key) |
void | plug_set_ssl_pem_password (struct script_infos *args, char *key) |
void | plug_set_ssl_CA_file (struct script_infos *args, char *key) |
Variables | |
int | global_nasl_debug = 0 |
gvm_vhost_t * | current_vhost = NULL |
Plugin-specific stuff.
Definition in file plugutils.c.
#define G_LOG_DOMAIN "lib misc" |
GLib logging domain.
Definition at line 45 of file plugutils.c.
#define MAX_CANDIDATES 16 |
char* get_plugin_preference | ( | const char * | oid, |
const char * | name | ||
) |
Definition at line 396 of file plugutils.c.
References name, oid, and prefix().
Referenced by _http_req(), add_scantype_arguments(), add_timing_arguments(), build_cmd_line(), nmap_create(), plugin_do_run(), plugin_run_find_service(), script_get_preference(), script_get_preference_file_content(), and script_get_preference_file_location().
char* get_plugin_preference_file_content | ( | struct script_infos * | desc, |
const char * | identifier | ||
) |
Get the file contents of a plugins preference that is of type "file".
As files sent to the scanner (e.g. as plugin preference) are stored in a hash table with an identifier supplied by the client as the key, the contents have to be looked up here.
identifier | Identifier that was supplied by the client when the file was uploaded. |
identifier
, NULL if not found or setup broken. Definition at line 510 of file plugutils.c.
References scan_globals::files_translation, and script_infos::globals.
Referenced by get_plugin_preference_fname(), and script_get_preference_file_content().
long get_plugin_preference_file_size | ( | struct script_infos * | desc, |
const char * | identifier | ||
) |
Get the file size of a plugins preference that is of type "file".
Files sent to the scanner (e.g. as plugin preference) are stored in a hash table with an identifier supplied by the client as the key. The size of the file is stored in a separate hash table with the same identifier as key, which can be looked up here.
identifier | Identifier that was supplied by the client when the file was uploaded. |
identifier
, -1 if not found or setup broken. Definition at line 541 of file plugutils.c.
References scan_globals::files_size_translation, and script_infos::globals.
Referenced by get_plugin_preference_fname(), and script_get_preference_file_content().
const char* get_plugin_preference_fname | ( | struct script_infos * | desc, |
const char * | filename | ||
) |
Get the file name of a plugins preference that is of type "file".
As files sent to the server (e.g. as plugin preference) are stored at pseudo-random locations with different names, the "real" file name has to be looked up in a hashtable.
filename
, NULL if not found or setup broken. Definition at line 455 of file plugutils.c.
References get_plugin_preference_file_content(), and get_plugin_preference_file_size().
Referenced by nmap_create(), plugin_run_find_service(), and script_get_preference_file_location().
void host_add_port_proto | ( | struct script_infos * | args, |
int | portnum, | ||
char * | proto | ||
) |
Definition at line 85 of file plugutils.c.
References ARG_INT, and plug_set_key().
Referenced by scanner_add_port().
int host_get_port_state | ( | struct script_infos * | plugdata, |
int | portnum | ||
) |
Definition at line 154 of file plugutils.c.
References host_get_port_state_proto().
Referenced by get_port_state(), and open_sock_tcp().
int host_get_port_state_proto | ( | struct script_infos * | args, |
int | portnum, | ||
char * | proto | ||
) |
Definition at line 148 of file plugutils.c.
References kb_get_port_state_proto(), and script_infos::key.
Referenced by host_get_port_state(), and host_get_port_state_udp().
int host_get_port_state_udp | ( | struct script_infos * | plugdata, |
int | portnum | ||
) |
Definition at line 160 of file plugutils.c.
References host_get_port_state_proto().
Referenced by get_udp_port_state().
int kb_get_port_state_proto | ( | kb_t | kb, |
int | portnum, | ||
char * | proto | ||
) |
proto | Protocol (udp/tcp). If NULL, "tcp" will be used. |
Definition at line 110 of file plugutils.c.
References unscanned_ports_as_closed().
Referenced by get_closed_ports(), and host_get_port_state_proto().
int plug_add_host_fqdn | ( | struct script_infos * | args, |
const char * | hostname, | ||
const char * | source | ||
) |
Definition at line 166 of file plugutils.c.
References hostname, and script_infos::vhosts.
Referenced by add_hostname().
const char* plug_current_vhost | ( | void | ) |
Definition at line 57 of file plugutils.c.
References current_vhost.
Referenced by open_sock_tcp().
|
static |
Definition at line 664 of file plugutils.c.
References pid, and sig_term().
Referenced by plug_get_host_fqdn(), and plug_get_key().
char* plug_get_host_fqdn | ( | struct script_infos * | args | ) |
Definition at line 211 of file plugutils.c.
References current_vhost, script_infos::ip, script_infos::key, pid, plug_fork_child(), and script_infos::vhosts.
Referenced by _http_req(), get_hostname(), open_stream_connection_ext(), plug_get_host_source(), plugin_do_run(), and socket_negotiate_ssl().
GSList* plug_get_host_fqdn_list | ( | struct script_infos * | args | ) |
Definition at line 239 of file plugutils.c.
References script_infos::ip, and script_infos::vhosts.
Referenced by get_hostnames().
struct in6_addr* plug_get_host_ip | ( | struct script_infos * | args | ) |
Definition at line 285 of file plugutils.c.
References script_infos::ip.
Referenced by forge_ip_packet(), forge_ipv6_packet(), get_host_ip(), nasl_islocalhost(), nasl_islocalnet(), nasl_open_privileged_socket(), nasl_open_sock_udp(), nasl_pcap_next(), nasl_send_capture(), nasl_send_packet(), nasl_send_v6packet(), nasl_smb_connect(), nasl_ssh_connect(), nasl_target_is_ipv6(), nasl_tcp_ping(), nasl_tcp_v6_ping(), nasl_this_host(), nasl_win_cmd_exec(), nasl_wmi_connect(), nasl_wmi_connect_reg(), nasl_wmi_connect_rsop(), open_sock_option(), plug_get_host_ip_str(), plugin_run_synscan(), and proto_post_wrapped().
char* plug_get_host_ip_str | ( | struct script_infos * | desc | ) |
Definition at line 291 of file plugutils.c.
References plug_get_host_ip().
Referenced by open_sock_tcp().
unsigned int plug_get_host_open_port | ( | struct script_infos * | desc | ) |
Don't always return the first open port, otherwise we might get bitten by OSes doing active SYN flood countermeasures. Also, avoid returning 80 and 21 as open ports, as many transparent proxies are acting for these...
Definition at line 786 of file plugutils.c.
References MAX_CANDIDATES, and plug_get_kb().
Referenced by get_host_open_port(), nasl_start_denial(), nasl_tcp_ping(), and nasl_tcp_v6_ping().
char* plug_get_host_source | ( | struct script_infos * | args, |
const char * | hostname | ||
) |
Definition at line 257 of file plugutils.c.
References current_vhost, hostname, plug_get_host_fqdn(), and script_infos::vhosts.
Referenced by get_hostname_source().
kb_t plug_get_kb | ( | struct script_infos * | args | ) |
Definition at line 627 of file plugutils.c.
References script_infos::key.
Referenced by _http_req(), exec_nasl_script(), get_kb_list(), get_script_args(), get_script_list(), nasl_ssh_set_login(), nasl_ssh_userauth(), open_sock_tcp(), open_stream_connection_ext(), plug_get_host_open_port(), plug_get_port_transport(), plug_replace_key_len(), plug_set_key_len(), plugin_run_find_service(), proto_post_wrapped(), and socket_negotiate_ssl().
void* plug_get_key | ( | struct script_infos * | args, |
char * | name, | ||
int * | type, | ||
size_t * | len, | ||
int | single | ||
) |
Get values from a kb under the given key name.
[in] | args | The script infos where to get the kb from. |
[in] | name | Key name to search in the kb. |
[in/out] | type If 1 is given, the answer is forced to be KB_TYPE_INT type. Otherwise it returns the fetched type. | |
[in] | len | Desired string length to be returned. |
[in] | single | In case of a list, fetch only the last element |
Definition at line 699 of file plugutils.c.
References script_infos::key, name, pid, plug_fork_child(), plug_get_key_sigchld(), and sig_chld().
Referenced by banner_grab(), get_kb_item(), get_ssh_port(), nasl_open_sock_kdc(), and plugin_do_run().
|
static |
Definition at line 633 of file plugutils.c.
Referenced by plug_get_key().
int plug_get_port_transport | ( | struct script_infos * | args, |
int | port | ||
) |
Definition at line 854 of file plugutils.c.
References OPENVAS_ENCAPS_IP, and plug_get_kb().
Referenced by get_port_transport(), and open_stream_auto_encaps_ext().
void plug_replace_key | ( | struct script_infos * | args, |
char * | name, | ||
int | type, | ||
void * | value | ||
) |
Definition at line 615 of file plugutils.c.
References name, and plug_replace_key_len().
Referenced by mark_acap_server(), mark_adsgone(), mark_exchg_routing_server(), mark_ftp_server(), mark_fw1(), mark_http_server(), mark_imap_server(), mark_linuxconf(), mark_locked_adsubtract_server(), mark_mon_server(), mark_ncacn_http_server(), mark_nntp_server(), mark_pop3pw_server(), mark_pop_server(), mark_psybnc(), mark_rmserver(), mark_shoutcast_server(), mark_smtp_server(), mark_snpp_server(), mark_unknown_svc(), mark_uucp_server(), mark_vnc_server(), mark_vtun_server(), mark_whois_plus2_server(), mark_zebra_server(), plugin_do_run(), register_service(), and replace_kb_item().
void plug_replace_key_len | ( | struct script_infos * | args, |
char * | name, | ||
int | type, | ||
void * | value, | ||
size_t | len | ||
) |
Definition at line 592 of file plugutils.c.
References ARG_INT, ARG_STRING, global_nasl_debug, name, and plug_get_kb().
Referenced by plug_replace_key(), and replace_kb_item().
void plug_set_dep | ( | struct script_infos * | args, |
const char * | depname | ||
) |
Definition at line 65 of file plugutils.c.
References script_infos::nvti.
Referenced by script_dependencies().
void plug_set_key | ( | struct script_infos * | args, |
char * | name, | ||
int | type, | ||
const void * | value | ||
) |
Definition at line 585 of file plugutils.c.
References name, and plug_set_key_len().
Referenced by banner_grab(), host_add_port_proto(), mark_unknown_svc(), mark_wrapped_svc(), plug_set_port_transport(), plug_set_ssl_item(), plugin_do_run(), plugin_run_openvas_tcp_scanner(), plugin_run_synscan(), register_service(), save_detected_os(), save_host_state(), save_hostscripts(), save_ipidseq_details(), save_open_ports(), save_portscripts(), save_tcpseq_details(), save_traceroute_details(), scan(), set_kb_item(), and simple_register_host_detail().
void plug_set_key_len | ( | struct script_infos * | args, |
char * | name, | ||
int | type, | ||
const void * | value, | ||
size_t | len | ||
) |
Definition at line 563 of file plugutils.c.
References ARG_INT, ARG_STRING, global_nasl_debug, name, and plug_get_kb().
Referenced by plug_set_key(), and set_kb_item().
void plug_set_port_transport | ( | struct script_infos * | args, |
int | port, | ||
int | tr | ||
) |
Definition at line 841 of file plugutils.c.
References ARG_INT, and plug_set_key().
Referenced by open_stream_auto_encaps_ext(), and plugin_do_run().
void plug_set_ssl_CA_file | ( | struct script_infos * | args, |
char * | key | ||
) |
Definition at line 900 of file plugutils.c.
References plug_set_ssl_item().
Referenced by plugin_run_find_service().
void plug_set_ssl_cert | ( | struct script_infos * | args, |
char * | cert | ||
) |
Definition at line 878 of file plugutils.c.
References plug_set_ssl_item().
Referenced by plugin_run_find_service().
|
static |
Definition at line 870 of file plugutils.c.
References ARG_STRING, and plug_set_key().
Referenced by plug_set_ssl_CA_file(), plug_set_ssl_cert(), plug_set_ssl_key(), and plug_set_ssl_pem_password().
void plug_set_ssl_key | ( | struct script_infos * | args, |
char * | key | ||
) |
Definition at line 884 of file plugutils.c.
References plug_set_ssl_item().
Referenced by plugin_run_find_service().
void plug_set_ssl_pem_password | ( | struct script_infos * | args, |
char * | key | ||
) |
Definition at line 890 of file plugutils.c.
References plug_set_ssl_item().
Referenced by plugin_run_find_service().
void post_alarm | ( | const char * | oid, |
struct script_infos * | desc, | ||
int | port, | ||
const char * | action | ||
) |
Definition at line 355 of file plugutils.c.
References oid, and proto_post_alarm().
Referenced by mark_fssniffer(), mark_netbus_server(), mark_sub7_server(), mark_wild_shell(), and security_message().
void post_error | ( | const char * | oid, |
struct script_infos * | desc, | ||
int | port, | ||
const char * | action | ||
) |
Definition at line 389 of file plugutils.c.
References oid, and proto_post_error().
Referenced by error_message().
void post_log | ( | const char * | oid, |
struct script_infos * | desc, | ||
int | port, | ||
const char * | action | ||
) |
Post a log message about a tcp port.
Definition at line 375 of file plugutils.c.
References oid, and proto_post_log().
Referenced by log_message(), mark_acap_server(), mark_adsgone(), mark_auth_server(), mark_avotus_mm_server(), mark_BitTorrent_server(), mark_chargen_server(), mark_citrix_server(), mark_cvslockserver(), mark_cvspserver(), mark_cvsupserver(), mark_dameware_server(), mark_dictd_server(), mark_direct_connect_hub(), mark_echo_server(), mark_eggdrop_server(), mark_ens_server(), mark_exchg_routing_server(), mark_finger_server(), mark_ftp_server(), mark_fw1(), mark_giop_server(), mark_gnocatan_server(), mark_gnome14_server(), mark_gnuserv(), mark_gopher_server(), mark_http_proxy(), mark_http_server(), mark_imap_server(), mark_interscan_viruswall(), mark_ircxpro_admin_server(), mark_iss_realsecure(), mark_jabber_server(), mark_linuxconf(), mark_LISa_server(), mark_listserv_server(), mark_locked_adsubtract_server(), mark_lpd_server(), mark_lyskom_server(), mark_mldonkey(), mark_mon_server(), mark_msdtc_server(), mark_mysql(), mark_nagiosd_server(), mark_nntp_server(), mark_ofa_express_server(), mark_pblocald_server(), mark_pbmaster_server(), mark_ph_server(), mark_pnsclient(), mark_pop3pw_server(), mark_pop_server(), mark_postgresql(), mark_ppp_daemon(), mark_psybnc(), mark_quicktime_streaming_server(), mark_remote_nc_server(), mark_rmserver(), mark_rsync(), mark_shoutcast_server(), mark_smppd_server(), mark_smtp_server(), mark_smux_server(), mark_snpp_server(), mark_socks_proxy(), mark_spamd_server(), mark_sphinxql(), mark_ssh_server(), mark_stonegate_auth_server(), mark_tcpmux_server(), mark_teamspeak2_server(), mark_telnet_server(), mark_time_server(), mark_unknown_svc(), mark_upsmon_server(), mark_uucp_server(), mark_veritas_backup(), mark_vmware_auth(), mark_vtun_server(), mark_websm_server(), mark_whois_plus2_server(), mark_wrapped_svc(), mark_zebra_server(), and plugin_do_run().
void proto_post_alarm | ( | const char * | oid, |
struct script_infos * | desc, | ||
int | port, | ||
const char * | proto, | ||
const char * | action | ||
) |
Definition at line 348 of file plugutils.c.
References oid, and proto_post_wrapped().
Referenced by post_alarm(), and security_message().
void proto_post_error | ( | const char * | oid, |
struct script_infos * | desc, | ||
int | port, | ||
const char * | proto, | ||
const char * | action | ||
) |
Definition at line 382 of file plugutils.c.
References oid, and proto_post_wrapped().
Referenced by error_message(), and post_error().
void proto_post_log | ( | const char * | oid, |
struct script_infos * | desc, | ||
int | port, | ||
const char * | proto, | ||
const char * | action | ||
) |
Post a log message.
Definition at line 365 of file plugutils.c.
References oid, and proto_post_wrapped().
Referenced by log_message(), and post_log().
void proto_post_wrapped | ( | const char * | oid, |
struct script_infos * | desc, | ||
int | port, | ||
const char * | proto, | ||
const char * | action, | ||
const char * | what | ||
) |
Post a security message (e.g. LOG, NOTE, WARNING ...).
oid | The oid of the NVT |
desc | The script infos where to get settings. |
port | Port number related to the issue. |
proto | Protocol related to the issue (tcp or udp). |
action | The actual result text |
what | The type, like "LOG". |
Definition at line 307 of file plugutils.c.
References current_vhost, hostname, oid, plug_get_host_ip(), plug_get_kb(), and script_infos::vhosts.
Referenced by proto_post_alarm(), proto_post_error(), and proto_post_log().
void scanner_add_port | ( | struct script_infos * | args, |
int | port, | ||
char * | proto | ||
) |
Definition at line 621 of file plugutils.c.
References host_add_port_proto().
Referenced by banner_grab(), nasl_scanner_add_port(), sendpacket(), and v6_sendpacket().
|
static |
Definition at line 658 of file plugutils.c.
References sig_n().
Referenced by plug_get_key().
|
static |
Definition at line 641 of file plugutils.c.
Referenced by sig_chld(), and sig_term().
|
static |
Definition at line 652 of file plugutils.c.
References sig_n().
Referenced by plug_fork_child().
|
static |
Report state of preferences "unscanned_closed".
Definition at line 98 of file plugutils.c.
Referenced by kb_get_port_state_proto().
gvm_vhost_t* current_vhost = NULL |
Definition at line 53 of file plugutils.c.
Referenced by plug_current_vhost(), plug_get_host_fqdn(), plug_get_host_source(), and proto_post_wrapped().
int global_nasl_debug = 0 |
Definition at line 48 of file plugutils.c.
Referenced by main(), plug_replace_key_len(), and plug_set_key_len().