OpenVAS Scanner
7.0.1~git
|
The NASL socket API. More...
#include "../misc/network.h"
#include "../misc/plugutils.h"
#include "exec.h"
#include "nasl.h"
#include "nasl_debug.h"
#include "nasl_func.h"
#include "nasl_global_ctxt.h"
#include "nasl_lex_ctxt.h"
#include "nasl_packet_forgery.h"
#include "nasl_tree.h"
#include "nasl_var.h"
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <gnutls/gnutls.h>
#include <gvm/base/logging.h>
#include <gvm/base/networking.h>
#include <gvm/base/prefs.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
Go to the source code of this file.
Data Structures | |
struct | udp_record |
struct | jmg |
Macros | |
#define | EADDRNOTAVAIL EADDRINUSE |
#define | G_LOG_DOMAIN "lib nasl" |
GLib logging domain. More... | |
Variables | |
int | lowest_socket = 0 |
static struct jmg * | jmg_desc = NULL |
static int | jmg_max = 0 |
The NASL socket API.
This file contains all the functions related to the handling of the sockets within a NASL script - for example the implementation of the NASL built-ins open_sock_tcp, send, recv, recv_line, and close.
Definition in file nasl_socket.c.
#define EADDRNOTAVAIL EADDRINUSE |
Definition at line 57 of file nasl_socket.c.
Referenced by nasl_open_privileged_socket().
#define G_LOG_DOMAIN "lib nasl" |
GLib logging domain.
Definition at line 64 of file nasl_socket.c.
|
static |
Definition at line 164 of file nasl_socket.c.
References udp_record::data, udp_record::len, and script_infos::udp_data.
Referenced by nasl_send().
|
static |
Definition at line 86 of file nasl_socket.c.
Referenced by nasl_open_privileged_socket().
|
static |
Definition at line 187 of file nasl_socket.c.
References udp_record::data, udp_record::len, and script_infos::udp_data.
Referenced by nasl_recv().
Definition at line 905 of file nasl_socket.c.
References close_stream_connection(), FAKE_CELL, fd_is_stream(), get_int_var_by_num(), lowest_socket, nasl_perror(), rm_udp_data(), struct_lex_ctxt::script_infos, and wait_before_next_probe().
Referenced by http_close_socket().
Get info pertaining to a socket.
This function is used to retrieve various information about an active socket. It requires the NASL socket number and a string to select the information to retrieve.
Supported keywords are:
[in] | lexic | Lexical context of the NASL interpreter. |
Definition at line 1190 of file nasl_socket.c.
References add_var_to_list(), alloc_typed_cell(), CONST_INT, CONST_STR, DYN_ARRAY, FAKE_CELL, get_encaps_name(), get_int_var_by_name(), get_int_var_by_num(), get_sock_infos(), get_str_var_by_num(), get_var_type_by_num(), TC::i_val, nasl_perror(), TC::ref_val, st_nasl_string::s_siz, st_nasl_string::s_val, TC::size, TC::str_val, st_a_nasl_var::v, st_a_nasl_var::v_str, VAR2_DATA, VAR2_STRING, st_a_nasl_var::var_type, and TC::x.
Definition at line 1048 of file nasl_socket.c.
References alloc_typed_cell(), CONST_INT, fd_is_stream(), get_int_var_by_num(), TC::i_val, nasl_perror(), openvas_get_socket_from_connection(), and TC::x.
Definition at line 950 of file nasl_socket.c.
References alloc_typed_cell(), CONST_INT, jmg::count, get_str_var_by_num(), jmg::in, jmg_desc, jmg_max, nasl_perror(), and jmg::s.
Definition at line 1016 of file nasl_socket.c.
References FAKE_CELL, get_str_var_by_num(), jmg_desc, jmg_max, and nasl_perror().
Definition at line 403 of file nasl_socket.c.
References nasl_open_privileged_socket().
Definition at line 409 of file nasl_socket.c.
References nasl_open_privileged_socket().
Definition at line 223 of file nasl_socket.c.
References alloc_typed_cell(), block_socket(), CONST_INT, EADDRNOTAVAIL, FAKE_CELL, get_int_var_by_name(), TC::i_val, lowest_socket, nasl_perror(), OPENVAS_ENCAPS_IP, openvas_register_connection(), plug_get_host_ip(), struct_lex_ctxt::recv_timeout, struct_lex_ctxt::script_infos, timeval(), unblock_socket(), wait_before_next_probe(), and TC::x.
Referenced by nasl_open_priv_sock_tcp(), and nasl_open_priv_sock_udp().
Open a TCP socket to the target host.
This function is used to create a TCP connection to the target host. It requires the port number as its argument and has various optional named arguments to control encapsulation, timeout and buffering.
[in] | lexic | Lexical context of the NASL interpreter. |
Definition at line 517 of file nasl_socket.c.
References nasl_open_sock_tcp_bufsz().
Definition at line 417 of file nasl_socket.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), get_int_var_by_num(), get_str_var_by_name(), get_var_type_by_name(), TC::i_val, nasl_perror(), open_stream_auto_encaps_ext(), open_stream_connection_ext(), OPENVAS_ENCAPS_TLScustom, struct_lex_ctxt::recv_timeout, struct_lex_ctxt::script_infos, stream_set_buffer(), VAR2_DATA, VAR2_STRING, wait_before_next_probe(), and TC::x.
Referenced by http_open_socket(), and nasl_open_sock_tcp().
Definition at line 529 of file nasl_socket.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_num(), TC::i_val, lowest_socket, plug_get_host_ip(), struct_lex_ctxt::script_infos, and TC::x.
Definition at line 701 of file nasl_socket.c.
References alloc_typed_cell(), CONST_DATA, fd_is_stream(), get_int_var_by_name(), get_udp_data(), read_stream_connection_min(), struct_lex_ctxt::recv_timeout, struct_lex_ctxt::script_infos, TC::size, TC::str_val, stream_set_timeout(), timeval(), and TC::x.
Definition at line 795 of file nasl_socket.c.
References alloc_typed_cell(), CONST_DATA, fd_is_stream(), get_int_var_by_name(), nasl_perror(), read_stream_connection_min(), TC::size, TC::str_val, stream_get_buffer_sz(), stream_set_buffer(), and TC::x.
Definition at line 861 of file nasl_socket.c.
References add_udp_data(), alloc_typed_cell(), CONST_INT, fd_is_stream(), get_int_var_by_name(), get_str_var_by_name(), get_var_size_by_name(), TC::i_val, nasl_perror(), nsend(), option, struct_lex_ctxt::script_infos, wait_before_next_probe(), and TC::x.
Referenced by nasl_send_capture().
Verify a certificate.
This function is used to retrieve and verify a certificate from an active socket. It requires the NASL socket number.
[in] | lexic | Lexical context of the NASL interpreter. |
Definition at line 1389 of file nasl_socket.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), get_sock_infos(), TC::i_val, nasl_perror(), and TC::x.
Definition at line 623 of file nasl_socket.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), nasl_perror(), TC::size, socket_get_cert(), TC::str_val, and TC::x.
Definition at line 1088 of file nasl_socket.c.
References alloc_typed_cell(), CONST_INT, fd_is_stream(), get_int_var_by_num(), TC::i_val, NASL_ERR_ECONNRESET, NASL_ERR_ETIMEDOUT, NASL_ERR_EUNREACH, NASL_ERR_NOERR, stream_get_err(), and TC::x.
Definition at line 684 of file nasl_socket.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), TC::i_val, socket_get_ssl_ciphersuite(), and TC::x.
Definition at line 645 of file nasl_socket.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), nasl_perror(), TC::size, socket_get_ssl_session_id(), TC::str_val, and TC::x.
Definition at line 668 of file nasl_socket.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), TC::i_val, socket_get_ssl_version(), and TC::x.
Definition at line 590 of file nasl_socket.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), TC::i_val, IS_ENCAPS_SSL, nasl_perror(), OPENVAS_ENCAPS_TLScustom, struct_lex_ctxt::script_infos, socket_negotiate_ssl(), and TC::x.
|
static |
Definition at line 210 of file nasl_socket.c.
References script_infos::udp_data.
Referenced by nasl_close_socket().
|
static |
Definition at line 69 of file nasl_socket.c.
Referenced by nasl_open_privileged_socket().
|
static |
Definition at line 103 of file nasl_socket.c.
References timeval().
Referenced by nasl_close_socket(), nasl_open_privileged_socket(), nasl_open_sock_tcp_bufsz(), and nasl_send().
|
static |
Referenced by nasl_join_multicast_group(), and nasl_leave_multicast_group().
|
static |
Definition at line 947 of file nasl_socket.c.
Referenced by nasl_join_multicast_group(), and nasl_leave_multicast_group().
int lowest_socket = 0 |
Definition at line 220 of file nasl_socket.c.
Referenced by nasl_close_socket(), nasl_open_privileged_socket(), nasl_open_sock_udp(), and nasl_ssh_connect().