|
OpenVAS Scanner 22.7.9
|
Header file for module network. More...
#include "scanneraux.h"#include <gnutls/gnutls.h>#include <gnutls/x509.h>#include <netinet/in.h>#include <sys/select.h>

Go to the source code of this file.
Macros | |
| #define | IS_ENCAPS_SSL(x) ((x) >= OPENVAS_ENCAPS_SSLv23 && (x) <= OPENVAS_ENCAPS_TLScustom) |
| #define | NO_PRIORITY_FLAGS 0 |
| #define | INSECURE_DH_PRIME_BITS (1 << 0) |
Typedefs | |
| typedef enum openvas_encaps | openvas_encaps_t |
Functions | |
| int | open_sock_tcp (struct script_infos *, unsigned int, int) |
| int | open_sock_option (struct script_infos *, unsigned int, int, int, int) |
| int | recv_line (int, char *, size_t) |
| Reads a text from the socket stream into the argument buffer, always. | |
| int | nrecv (int, void *, int, int) |
| int | socket_close (int) |
| int | get_sock_infos (int sock, int *r_transport, void **r_tls_session) |
| unsigned short * | getpts (char *, int *) |
| Converts a string like "-100,200-1024,3000-4000,60000-" into an array. | |
| void | open_stream_tls_default_priorities (const char *p, const int pflag) |
| int | open_stream_connection (struct script_infos *, unsigned int, int, int) |
| int | open_stream_connection_ext (struct script_infos *, unsigned int, int, int, const char *, int) |
| int | open_stream_auto_encaps_ext (struct script_infos *, unsigned int port, int timeout, int force) |
| int | write_stream_connection (int, void *buf, int n) |
| int | read_stream_connection (int, void *, int) |
| int | read_stream_connection_min (int, void *, int, int) |
| int | nsend (int, void *, int, int) |
| void | add_close_stream_connection_hook (int(*)(int)) |
| int | close_stream_connection (int) |
| const char * | get_encaps_name (openvas_encaps_t) |
| const char * | get_encaps_through (openvas_encaps_t) |
| int | open_sock_opt_hn (const char *, unsigned int, int, int, int) |
| int | openvas_SSL_init (void) |
| Initializes SSL support. | |
| int | stream_set_buffer (int, int) |
| int | stream_get_buffer_sz (int) |
| int | stream_get_err (int) |
| int | openvas_register_connection (int s, void *ssl, gnutls_certificate_credentials_t certcred, openvas_encaps_t encaps) |
| int | openvas_deregister_connection (int) |
| int | openvas_get_socket_from_connection (int) |
| gnutls_session_t | ovas_get_tlssession_from_connection (int) |
| int | stream_zero (fd_set *) |
| int | stream_set (int, fd_set *) |
| int | os_send (int, void *, int, int) |
| int | os_recv (int, void *, int, int) |
| int | fd_is_stream (int) |
| int | stream_set_timeout (int, int) |
| int | socket_ssl_safe_renegotiation_status (int) |
| Check if Secure Renegotiation is supported in the server side. | |
| int | socket_ssl_do_handshake (int) |
| Do a re-handshake of the TLS/SSL protocol. | |
| int | socket_negotiate_ssl (int, openvas_encaps_t, struct script_infos *) |
| Upgrade an ENCAPS_IP socket to an SSL/TLS encapsulated one. | |
| void | socket_get_cert (int, void **, int *) |
| int | socket_get_ssl_version (int) |
| void | socket_get_ssl_session_id (int, void **, size_t *) |
| int | socket_get_ssl_compression (int) |
| int | socket_get_ssl_ciphersuite (int) |
Header file for module network.
Definition in file network.h.
| #define IS_ENCAPS_SSL | ( | x | ) | ((x) >= OPENVAS_ENCAPS_SSLv23 && (x) <= OPENVAS_ENCAPS_TLScustom) |
| typedef enum openvas_encaps openvas_encaps_t |
| enum openvas_encaps |
| void add_close_stream_connection_hook | ( | int(*)(int) | ) |
| int close_stream_connection | ( | int | fd | ) |
Definition at line 1705 of file network.c.
References OPENVAS_STREAM, OVAS_CONNECTION_FROM_FD, openvas_connection::port, release_connection_fd(), run_csc_hooks(), and socket_close().
Referenced by nasl_close_socket(), nasl_end_denial(), nasl_start_denial(), and plugin_do_run().


| int fd_is_stream | ( | int | fd | ) |
Definition at line 2152 of file network.c.
References OPENVAS_STREAM.
Referenced by nasl_close_socket(), nasl_get_source_port(), nasl_recv(), nasl_recv_line(), nasl_send(), nasl_socket_get_error(), socket_get_cert(), socket_get_ssl_ciphersuite(), socket_get_ssl_session_id(), socket_get_ssl_version(), socket_negotiate_ssl(), socket_ssl_do_handshake(), and socket_ssl_safe_renegotiation_status().

| const char * get_encaps_name | ( | openvas_encaps_t | code | ) |
Definition at line 1733 of file network.c.
References code, OPENVAS_ENCAPS_AUTO, OPENVAS_ENCAPS_IP, OPENVAS_ENCAPS_SSLv2, OPENVAS_ENCAPS_SSLv23, OPENVAS_ENCAPS_SSLv3, OPENVAS_ENCAPS_TLScustom, OPENVAS_ENCAPS_TLSv1, OPENVAS_ENCAPS_TLSv11, OPENVAS_ENCAPS_TLSv12, and OPENVAS_ENCAPS_TLSv13.
Referenced by get_port_transport(), nasl_get_sock_info(), and plugin_do_run().

| const char * get_encaps_through | ( | openvas_encaps_t | code | ) |
Definition at line 1766 of file network.c.
References code, OPENVAS_ENCAPS_IP, OPENVAS_ENCAPS_SSLv2, OPENVAS_ENCAPS_SSLv23, OPENVAS_ENCAPS_SSLv3, OPENVAS_ENCAPS_TLScustom, OPENVAS_ENCAPS_TLSv1, OPENVAS_ENCAPS_TLSv11, OPENVAS_ENCAPS_TLSv12, and OPENVAS_ENCAPS_TLSv13.
Referenced by mark_acap_server(), mark_adsgone(), mark_avotus_mm_server(), mark_BitTorrent_server(), mark_citrix_server(), mark_dameware_server(), mark_dictd_server(), mark_direct_connect_hub(), mark_eggdrop_server(), mark_ens_server(), mark_exchg_routing_server(), mark_finger_server(), mark_fssniffer(), mark_ftp_server(), mark_fw1(), mark_giop_server(), mark_gnocatan_server(), mark_gnome14_server(), mark_http_proxy(), mark_http_server(), mark_imap_server(), mark_interscan_viruswall(), mark_ircxpro_admin_server(), mark_jabber_server(), mark_LISa_server(), mark_listserv_server(), mark_locked_adsubtract_server(), mark_lpd_server(), mark_lyskom_server(), mark_mon_server(), 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_ppp_daemon(), mark_psybnc(), mark_quicktime_streaming_server(), mark_remote_nc_server(), mark_rmserver(), mark_shoutcast_server(), mark_smppd_server(), mark_smtp_server(), mark_smux_server(), mark_snpp_server(), mark_spamd_server(), mark_stonegate_auth_server(), mark_sub7_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(), and mark_zebra_server().
| int get_sock_infos | ( | int | sock, |
| int * | r_transport, | ||
| void ** | r_tls_session | ||
| ) |
Definition at line 2256 of file network.c.
References connections, OPENVAS_FD_OFF, OPENVAS_STREAM, openvas_connection::tls_session, and openvas_connection::transport.
Referenced by nasl_get_sock_info(), and nasl_socket_cert_verify().

| unsigned short * getpts | ( | char * | origexpr, |
| int * | len | ||
| ) |
Converts a string like "-100,200-1024,3000-4000,60000-" into an array.
of port numbers
This function is (c) Fyodor fyodo.nosp@m.r@dh.nosp@m.p.com and was taken from his excellent and outstanding scanner Nmap See http://www.insecure.org/nmap/ for details about Nmap
Definition at line 2296 of file network.c.
References len, and qsort_compar().
Referenced by nasl_scanner_get_port(), and scan().


| int nrecv | ( | int | fd, |
| void * | data, | ||
| int | length, | ||
| int | i_opt | ||
| ) |
Definition at line 1628 of file network.c.
References block_socket(), connections, length, OPENVAS_FD_OFF, OPENVAS_STREAM, and read_stream_connection().

| int nsend | ( | int | fd, |
| void * | data, | ||
| int | length, | ||
| int | i_opt | ||
| ) |
Definition at line 1589 of file network.c.
References block_socket(), connections, length, OPENVAS_FD_OFF, OPENVAS_STREAM, os_send(), timeval(), and write_stream_connection4().
Referenced by nasl_end_denial(), and nasl_send().


| int open_sock_opt_hn | ( | const char * | hostname, |
| unsigned int | port, | ||
| int | type, | ||
| int | protocol, | ||
| int | timeout | ||
| ) |
Definition at line 1890 of file network.c.
References hostname, open_socket(), and protocol.
Referenced by nasl_open_sock_kdc().


| int open_sock_option | ( | struct script_infos * | args, |
| unsigned int | port, | ||
| int | type, | ||
| int | protocol, | ||
| int | timeout | ||
| ) |
Definition at line 1996 of file network.c.
References open_socket(), plug_get_host_ip(), and protocol.
Referenced by open_sock_tcp().


| int open_sock_tcp | ( | struct script_infos * | args, |
| unsigned int | port, | ||
| int | timeout | ||
| ) |
Definition at line 1919 of file network.c.
References get_main_kb(), host_get_port_state(), script_infos::ip, kb_item_push_str_with_main_kb_check(), kb_item_set_int_with_main_kb_check(), open_sock_option(), plug_current_vhost(), plug_get_host_ip_str(), and plug_get_kb().
Referenced by open_stream_connection_ext().


| int open_stream_auto_encaps_ext | ( | struct script_infos * | args, |
| unsigned int | port, | ||
| int | timeout, | ||
| int | force | ||
| ) |
Definition at line 1185 of file network.c.
References open_stream_connection(), OPENVAS_ENCAPS_IP, OPENVAS_ENCAPS_TLScustom, plug_get_port_transport(), and plug_set_port_transport().
Referenced by nasl_open_sock_tcp_bufsz().


| int open_stream_connection | ( | struct script_infos * | args, |
| unsigned int | port, | ||
| int | transport, | ||
| int | timeout | ||
| ) |
Definition at line 1175 of file network.c.
References open_stream_connection_ext(), tls_priorities, and tls_priority_flag.
Referenced by nasl_end_denial(), nasl_start_denial(), open_stream_auto_encaps_ext(), plugin_do_run(), and retry_stream_connection().


| int open_stream_connection_ext | ( | struct script_infos * | args, |
| unsigned int | port, | ||
| int | transport, | ||
| int | timeout, | ||
| const char * | priority, | ||
| int | flags | ||
| ) |
Definition at line 1046 of file network.c.
References openvas_connection::fd, get_connection_fd(), hostname, openvas_connection::last_err, script_infos::name, open_sock_tcp(), open_SSL_connection(), OPENVAS_ENCAPS_IP, OPENVAS_ENCAPS_SSLv2, OPENVAS_ENCAPS_SSLv23, OPENVAS_ENCAPS_SSLv3, OPENVAS_ENCAPS_TLScustom, OPENVAS_ENCAPS_TLSv1, OPENVAS_ENCAPS_TLSv11, OPENVAS_ENCAPS_TLSv12, OPENVAS_ENCAPS_TLSv13, OVAS_CONNECTION_FROM_FD, plug_get_host_fqdn(), plug_get_kb(), openvas_connection::port, openvas_connection::priority, release_connection_fd(), TIMEOUT, openvas_connection::timeout, and openvas_connection::transport.
Referenced by nasl_open_sock_tcp_bufsz(), open_stream_connection(), and retry_stream_connection().


| void open_stream_tls_default_priorities | ( | const char * | p, |
| const int | pflag | ||
| ) |
Definition at line 1168 of file network.c.
References tls_priorities, and tls_priority_flag.
Referenced by retry_stream_connection().

| int openvas_deregister_connection | ( | int | fd | ) |
Definition at line 259 of file network.c.
References connections, OPENVAS_FD_OFF, OPENVAS_STREAM, openvas_connection::priority, and openvas_connection::transport.
| int openvas_get_socket_from_connection | ( | int | fd | ) |
Definition at line 357 of file network.c.
References connections, openvas_connection::fd, OPENVAS_FD_OFF, OPENVAS_STREAM, and openvas_connection::transport.
Referenced by nasl_get_source_port(), nasl_ssh_connect(), and plugin_do_run().

| int openvas_register_connection | ( | int | soc, |
| void * | ssl, | ||
| gnutls_certificate_credentials_t | certcred, | ||
| openvas_encaps_t | encaps | ||
| ) |
| soc | Socket to use. |
Definition at line 234 of file network.c.
References openvas_connection::fd, get_connection_fd(), openvas_connection::last_err, OVAS_CONNECTION_FROM_FD, openvas_connection::port, openvas_connection::priority, TIMEOUT, openvas_connection::timeout, openvas_connection::tls_cred, openvas_connection::tls_session, and openvas_connection::transport.
Referenced by nasl_open_privileged_socket().


| int openvas_SSL_init | ( | void | ) |
Initializes SSL support.
Definition at line 341 of file network.c.
References log_message_gnutls(), and tlserror().
Referenced by check_tls(), and main().


| int os_recv | ( | int | soc, |
| void * | buf, | ||
| int | len, | ||
| int | opt | ||
| ) |
Definition at line 2235 of file network.c.
References len.
| int os_send | ( | int | soc, |
| void * | buf, | ||
| int | len, | ||
| int | opt | ||
| ) |
Definition at line 2216 of file network.c.
References len.
Referenced by nsend().

| gnutls_session_t ovas_get_tlssession_from_connection | ( | int | fd | ) |
Definition at line 377 of file network.c.
References connections, OPENVAS_FD_OFF, OPENVAS_STREAM, and openvas_connection::tls_session.
Referenced by socket_get_cert(), socket_get_ssl_ciphersuite(), socket_get_ssl_session_id(), and socket_get_ssl_version().

| int read_stream_connection | ( | int | fd, |
| void * | buf0, | ||
| int | len | ||
| ) |
Definition at line 1457 of file network.c.
References len, and read_stream_connection_min().
Referenced by nasl_telnet_init(), nrecv(), and plugin_do_run().


| int read_stream_connection_min | ( | int | fd, |
| void * | buf0, | ||
| int | min_len, | ||
| int | max_len | ||
| ) |
Definition at line 1397 of file network.c.
References openvas_connection::buf, openvas_connection::bufcnt, openvas_connection::bufptr, openvas_connection::bufsz, OPENVAS_STREAM, OVAS_CONNECTION_FROM_FD, and read_stream_connection_unbuffered().
Referenced by nasl_recv(), nasl_recv_line(), nasl_telnet_init(), plugin_do_run(), read_stream_connection(), and recv_line().


| int recv_line | ( | int | soc, |
| char * | buf, | ||
| size_t | bufsiz | ||
| ) |
Reads a text from the socket stream into the argument buffer, always.
appending a '\0' byte.
| buf | Buffer to read into. |
Definition at line 2040 of file network.c.
References OPENVAS_STREAM, and read_stream_connection_min().
Referenced by ftp_get_pasv_address(), and ftp_log_in().


| int socket_close | ( | int | soc | ) |
Definition at line 2142 of file network.c.
Referenced by close_stream_connection(), open_socket(), and release_connection_fd().

| void socket_get_cert | ( | int | fd, |
| void ** | cert, | ||
| int * | certlen | ||
| ) |
Definition at line 887 of file network.c.
References fd_is_stream(), and ovas_get_tlssession_from_connection().
Referenced by nasl_socket_get_cert().


| int socket_get_ssl_ciphersuite | ( | int | fd | ) |
Definition at line 1006 of file network.c.
References fd_is_stream(), mac(), and ovas_get_tlssession_from_connection().
Referenced by nasl_socket_get_ssl_ciphersuite().


| int socket_get_ssl_compression | ( | int | ) |
| void socket_get_ssl_session_id | ( | int | fd, |
| void ** | sid, | ||
| size_t * | ssize | ||
| ) |
Definition at line 966 of file network.c.
References fd_is_stream(), ovas_get_tlssession_from_connection(), and tlserror().
Referenced by nasl_socket_get_ssl_session_id().


| int socket_get_ssl_version | ( | int | fd | ) |
Definition at line 923 of file network.c.
References fd_is_stream(), OPENVAS_ENCAPS_SSLv3, OPENVAS_ENCAPS_TLSv1, OPENVAS_ENCAPS_TLSv11, OPENVAS_ENCAPS_TLSv12, OPENVAS_ENCAPS_TLSv13, and ovas_get_tlssession_from_connection().
Referenced by nasl_socket_get_ssl_version().


| int socket_negotiate_ssl | ( | int | fd, |
| openvas_encaps_t | transport, | ||
| struct script_infos * | args | ||
| ) |
Upgrade an ENCAPS_IP socket to an SSL/TLS encapsulated one.
| [in] | fd | Socket file descriptor. |
| [in] | transport | Encapsulation type. |
| [in] | arg | Script args. |
Definition at line 820 of file network.c.
References fd_is_stream(), hostname, nasl_get_plugin_filename(), NO_PRIORITY_FLAGS, open_SSL_connection(), OVAS_CONNECTION_FROM_FD, plug_get_host_fqdn(), plug_get_host_ip_str(), plug_get_kb(), openvas_connection::port, openvas_connection::priority, release_connection_fd(), and openvas_connection::transport.
Referenced by nasl_socket_negotiate_ssl().


| int socket_ssl_do_handshake | ( | int | fd | ) |
Do a re-handshake of the TLS/SSL protocol.
| [in] | fd | Socket file descriptor. |
Definition at line 737 of file network.c.
References openvas_connection::fd, fd_is_stream(), openvas_connection::last_err, OVAS_CONNECTION_FROM_FD, pid_perror(), openvas_connection::timeout, timeval(), and openvas_connection::tls_session.
Referenced by nasl_socket_ssl_do_handshake().


| int socket_ssl_safe_renegotiation_status | ( | int | fd | ) |
Check if Secure Renegotiation is supported in the server side.
| [in] | fd | Socket file descriptor. |
Definition at line 716 of file network.c.
References fd_is_stream(), OVAS_CONNECTION_FROM_FD, and openvas_connection::tls_session.
Referenced by nasl_socket_check_ssl_safe_renegotiation().


| int stream_get_buffer_sz | ( | int | fd | ) |
Definition at line 2158 of file network.c.
References openvas_connection::bufsz, OPENVAS_STREAM, and OVAS_CONNECTION_FROM_FD.
Referenced by nasl_recv_line().

| int stream_get_err | ( | int | fd | ) |
Definition at line 132 of file network.c.
References openvas_connection::last_err, OPENVAS_STREAM, and OVAS_CONNECTION_FROM_FD.
Referenced by nasl_socket_get_error().

| int stream_set | ( | int | , |
| fd_set * | |||
| ) |
| int stream_set_buffer | ( | int | fd, |
| int | sz | ||
| ) |
Definition at line 2168 of file network.c.
References openvas_connection::buf, openvas_connection::bufcnt, openvas_connection::bufptr, openvas_connection::bufsz, OPENVAS_STREAM, and OVAS_CONNECTION_FROM_FD.
Referenced by nasl_open_sock_tcp_bufsz(), and nasl_recv_line().

| int stream_set_timeout | ( | int | fd, |
| int | timeout | ||
| ) |
Definition at line 1216 of file network.c.
References OPENVAS_STREAM, OVAS_CONNECTION_FROM_FD, and openvas_connection::timeout.
Referenced by nasl_recv(), and plugin_do_run().

| int stream_zero | ( | fd_set * | ) |
| int write_stream_connection | ( | int | fd, |
| void * | buf, | ||
| int | n | ||
| ) |
Definition at line 1583 of file network.c.
References write_stream_connection4().
Referenced by ftp_get_pasv_address(), ftp_log_in(), nasl_telnet_init(), and plugin_do_run().

