|
OpenVAS Scanner 23.32.3
|
NASL WMI functions. More...
#include "nasl_wmi.h"#include "../misc/plugutils.h"#include "openvas_wmi_interface.h"#include <arpa/inet.h>#include <ctype.h>#include <gvm/base/logging.h>#include <gvm/base/networking.h>#include <inttypes.h>#include <netinet/in.h>#include <stdio.h>#include <string.h>#include <sys/socket.h>
Go to the source code of this file.
Macros | |
| #define | IMPORT(var) |
| #define | max 5 |
| #define | G_LOG_DOMAIN "lib nasl" |
| GLib logging domain. | |
Functions | |
| static int | check_alpha (char *val) |
| static uint32_t | stoi_uint32_t (char *s) |
| static uint64_t | stoi_uint64_t (char *s) |
| tree_cell * | nasl_wmi_versioninfo (lex_ctxt *lexic) |
| Get a version string of the WMI implementation. | |
| tree_cell * | nasl_wmi_connect (lex_ctxt *lexic) |
| Connect to a WMI service and return a handle for it. | |
| tree_cell * | nasl_wmi_close (lex_ctxt *lexic) |
| Close WMI service handle. | |
| tree_cell * | nasl_wmi_query (lex_ctxt *lexic) |
| Perform WQL query. | |
| tree_cell * | nasl_wmi_connect_rsop (lex_ctxt *lexic) |
| Connect to a WMI RSOP service and return a handle for it. | |
| tree_cell * | nasl_wmi_query_rsop (lex_ctxt *lexic) |
| WMI RSOP query. | |
| tree_cell * | nasl_wmi_connect_reg (lex_ctxt *lexic) |
| Connect to a WMI Registry service and return a handle for it. | |
| tree_cell * | nasl_wmi_reg_get_sz (lex_ctxt *lexic) |
| Get string value from Registry. | |
| tree_cell * | nasl_wmi_reg_enum_value (lex_ctxt *lexic) |
| Enumerate registry values. | |
| tree_cell * | nasl_wmi_reg_enum_key (lex_ctxt *lexic) |
| Enumerate registry keys. | |
| tree_cell * | nasl_wmi_reg_get_bin_val (lex_ctxt *lexic) |
| Get registry binary value. | |
| tree_cell * | nasl_wmi_reg_get_dword_val (lex_ctxt *lexic) |
| Get registry DWORD value. | |
| tree_cell * | nasl_wmi_reg_get_ex_string_val (lex_ctxt *lexic) |
| Get registry expanded string value. | |
| tree_cell * | nasl_wmi_reg_get_mul_string_val (lex_ctxt *lexic) |
| Get registry multi valued strings. | |
| tree_cell * | nasl_wmi_reg_get_qword_val (lex_ctxt *lexic) |
| Get registry QWORD value. | |
| tree_cell * | nasl_wmi_reg_set_dword_val (lex_ctxt *lexic) |
| Set Registry DWORD value. | |
| tree_cell * | nasl_wmi_reg_set_qword_val (lex_ctxt *lexic) |
| Set Registry QWORD value. | |
| tree_cell * | nasl_wmi_reg_set_ex_string_val (lex_ctxt *lexic) |
| Set Registry Expanded string value. | |
| tree_cell * | nasl_wmi_reg_set_string_val (lex_ctxt *lexic) |
| Set Registry string value. | |
| tree_cell * | nasl_wmi_reg_create_key (lex_ctxt *lexic) |
| Create Registry key. | |
| tree_cell * | nasl_wmi_reg_delete_key (lex_ctxt *lexic) |
| Delete Registry key. | |
NASL WMI functions.
Provides WMI (Windows Management Instrumentation) functionalities via calling functions of a appropriate library. The API offers three groups of functions:
Definition in file nasl_wmi.c.
| #define G_LOG_DOMAIN "lib nasl" |
GLib logging domain.
Definition at line 40 of file nasl_wmi.c.
| #define IMPORT | ( | var | ) |
Definition at line 33 of file nasl_wmi.c.
Referenced by nasl_wmi_connect(), nasl_wmi_connect_reg(), and nasl_wmi_connect_rsop().
| #define max 5 |
Definition at line 34 of file nasl_wmi.c.
Referenced by comm_send_status(), and nasl_wmi_connect().
|
static |
Returns 0 if any alphabets are present
Definition at line 46 of file nasl_wmi.c.
References val.
Referenced by nasl_wmi_reg_set_dword_val(), and nasl_wmi_reg_set_qword_val().

Close WMI service handle.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variable "wmi_handle" from the lexical context and closes the respective handle.
Definition at line 191 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), TC::i_val, wmi_close(), and TC::x.

Connect to a WMI service and return a handle for it.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "host", "username", "password" and "ns" from the lexical context, performs and connects to this given WMI service returning a handle for the service as integer.
Definition at line 128 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_INT, IMPORT, max, plug_get_host_ip(), TC::ref_val, struct_lex_ctxt::script_infos, wmi_connect(), and TC::x.

Connect to a WMI Registry service and return a handle for it.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "host", "username", "password" from the lexical context, performs and connects to this given WMI service returning a handle for the service as integer.
Definition at line 388 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_INT, IMPORT, plug_get_host_ip(), TC::ref_val, struct_lex_ctxt::script_infos, wmi_connect_reg(), and TC::x.

Connect to a WMI RSOP service and return a handle for it.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "host", "username", "password" from the lexical context, performs and connects to this given WMI service returning a handle for the service as integer.
Definition at line 275 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_INT, IMPORT, plug_get_host_ip(), TC::ref_val, struct_lex_ctxt::script_infos, wmi_connect_rsop(), and TC::x.

Perform WQL query.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle" and "query" from the lexical context, performs a WMI query on the given handle and returns the result as a string.
Definition at line 220 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), TC::size, TC::str_val, wmi_query(), and TC::x.

WMI RSOP query.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "query" from the lexical context, performs the RSOP query returning results in string format.
Definition at line 334 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), TC::size, TC::str_val, wmi_query_rsop(), and TC::x.

Create Registry key.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "key" from the lexical context, performs the registry create operation for the key.
Definition at line 990 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), get_str_var_by_name(), TC::i_val, wmi_reg_create_key(), and TC::x.

Delete Registry key.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "key" from the lexical context, performs the registry delete operation for the key.
It will work only if the key exist
Definition at line 1029 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), get_str_var_by_name(), TC::i_val, wmi_reg_delete_key(), and TC::x.

Enumerate registry keys.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "hive", "key" from the lexical context, performs the registry query returning a string value.
Definition at line 536 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), TC::size, TC::str_val, wmi_reg_enum_key(), and TC::x.

Enumerate registry values.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "hive", "key" from the lexical context, performs the registry query returning a string value.
Definition at line 493 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), TC::size, TC::str_val, wmi_reg_enum_value(), and TC::x.

Get registry binary value.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "hive", "key", "val_name" from the lexical context, performs the registry operation querying binary value.
Definition at line 579 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), TC::size, TC::str_val, wmi_reg_get_bin_val(), and TC::x.

Get registry DWORD value.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "hive", "key", "val_name" from the lexical context, performs the registry operation querying DWORD value.
Definition at line 624 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), TC::size, TC::str_val, wmi_reg_get_dword_val(), and TC::x.

Get registry expanded string value.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "hive", "key", "val_name" from the lexical context, performs the registry operation querying Expanded string value.
Definition at line 672 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), TC::size, TC::str_val, wmi_reg_get_ex_string_val(), and TC::x.

Get registry multi valued strings.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "hive", "key", "val_name" from the lexical context, performs the registry operation querying Expanded string value.
Definition at line 717 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), TC::size, TC::str_val, wmi_reg_get_mul_string_val(), and TC::x.

Get registry QWORD value.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "hive", "key", "val_name" from the lexical context, performs the registry operation querying 64-bit unsigned integer.
Definition at line 762 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), TC::size, TC::str_val, wmi_reg_get_qword_val(), and TC::x.

Get string value from Registry.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "hive", "key", "key_name" from the lexical context, performs the registry query returning a string value.
Definition at line 448 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), TC::size, TC::str_val, wmi_reg_get_sz(), and TC::x.

Set Registry DWORD value.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "key", "val_name", "val" from the lexical context, performs the registry set/create operation for double word data type.
It will work only if the key exist
Definition at line 808 of file nasl_wmi.c.
References alloc_typed_cell(), check_alpha(), CONST_INT, get_int_var_by_name(), get_str_var_by_name(), TC::i_val, stoi_uint32_t(), val, wmi_reg_set_dword_val(), and TC::x.

Set Registry Expanded string value.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "key", "val_name", "val" from the lexical context, performs the registry set/create operation for string value.
It will work only if the key exist
Definition at line 908 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), get_str_var_by_name(), TC::i_val, val, wmi_reg_set_ex_string_val(), and TC::x.

Set Registry QWORD value.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "key", "val_name", "val" from the lexical context, performs the registry set/create operation for 64-bit unsigned integer.
It will work only if the key exist
Definition at line 858 of file nasl_wmi.c.
References alloc_typed_cell(), check_alpha(), CONST_INT, get_int_var_by_name(), get_str_var_by_name(), TC::i_val, stoi_uint64_t(), val, wmi_reg_set_qword_val(), and TC::x.

Set Registry string value.
| [in] | lexic | Lexical context of NASL interpreter. |
Retrieves local variables "wmi_handle", "key", "val_name", "val" from the lexical context, performs the registry set/create operation for string value.
It will work only if the key exist
Definition at line 950 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), get_str_var_by_name(), TC::i_val, val, wmi_reg_set_string_val(), and TC::x.

Get a version string of the WMI implementation.
| [in] | lexic | Lexical context of NASL interpreter. |
Definition at line 94 of file nasl_wmi.c.
References alloc_typed_cell(), CONST_DATA, TC::size, TC::str_val, wmi_versioninfo(), and TC::x.

|
static |
Convert string to unsign int 32 bit
Definition at line 67 of file nasl_wmi.c.
Referenced by nasl_wmi_reg_set_dword_val().

|
static |
Convert string to unsign int 64 bit
Definition at line 78 of file nasl_wmi.c.
Referenced by nasl_wmi_reg_set_qword_val().
