OpenVAS Scanner
7.0.1~git
|
Go to the documentation of this file.
32 #include "../misc/plugutils.h"
35 #include <arpa/inet.h>
37 #include <gvm/base/logging.h>
38 #include <gvm/base/networking.h>
39 #include <netinet/in.h>
42 #include <sys/socket.h>
45 #define IMPORT(var) char *var = get_str_var_by_name (lexic, #var)
51 #define G_LOG_DOMAIN "lib nasl"
73 retc->
size = strlen (version);
103 if ((
host == NULL) || (username == NULL) || (password == NULL)
106 g_message (
"nasl_smb_connect: Invalid input arguments");
110 ip = addr6_as_str (
host);
111 if ((strlen (password) == 0) || (strlen (username) == 0) || (strlen (ip) == 0)
112 || (strlen (share) == 0))
114 g_message (
"nasl_smb_connect: Invalid input arguments");
120 value =
smb_connect (ip, share, username, password, &handle);
125 g_message (
"nasl_smb_connect: SMB Connect failed");
182 g_message (
"smb_file_SDDL failed: Invalid filename");
188 g_message (
"smb_file_SDDL failed: Invalid smb_handle");
201 retc->
size = strlen (buffer);
225 g_message (
"smb_file_owner_sid failed: Invalid filename");
231 g_message (
"smb_file_owner_sid failed: Invalid smb_handle");
244 retc->
size = strlen (buffer);
268 g_message (
"smb_file_group_sid failed: Invalid filename");
274 g_message (
"smb_file_group_sid failed: Invalid smb_handle");
287 retc->
size = strlen (buffer);
311 g_message (
"smb_file_trustee_rights failed: Invalid filename");
317 g_message (
"smb_file_trustee_rights failed: Invalid smb_handle");
330 retc->
size = strlen (buffer);
353 char *ip, *argv[4], *unicode, target[2048], *c;
355 GString *
string = NULL;
363 if ((
host == NULL) || (username == NULL) || (password == NULL)
366 g_message (
"win_cmd_exec: Invalid input arguments");
370 ip = addr6_as_str (
host);
371 if ((strlen (password) == 0) || (strlen (username) == 0) || strlen (ip) == 0)
373 g_message (
"win_cmd_exec: Invalid input arguments");
379 if ((c = strchr (username,
'\\')))
381 argv[0] =
"impacket-wmiexec";
382 snprintf (target,
sizeof (target),
"%s:%s@%s", username, password, ip);
386 ret = g_spawn_async_with_pipes (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL,
387 NULL, NULL, NULL, &sout, NULL, &err);
391 g_warning (
"win_cmd_exec: %s", err ? err->message :
"Error");
397 string = g_string_new (
"");
403 bytes = read (sout, buf,
sizeof (buf));
407 g_string_append_len (
string, buf, bytes);
410 g_warning (
"win_cmd_exec: %s", strerror (errno));
411 g_string_free (
string, TRUE);
418 if (g_str_has_prefix (string->str,
"[-]"))
420 g_warning (
"win_cmd_exec: %s", string->str);
421 g_string_free (
string, TRUE);
424 else if ((unicode = strstr (string->str,
"\xff\xfe")))
431 diff = unicode -
string->str + 1;
432 tmp = g_convert (unicode + 2, string->len - diff,
"UTF-8",
"UTF-16", NULL,
436 g_warning (
"win_cmd_exec: %s", err->message);
437 g_string_free (
string, TRUE);
441 g_free (string->str);
442 string->len = length;
448 retc->
size =
string->len;
char * smb_versioninfo(void)
Return version info for SMB implementation.
tree_cell * nasl_win_cmd_exec(lex_ctxt *lexic)
Execute the command in windows.
struct in6_addr * plug_get_host_ip(struct script_infos *args)
tree_cell * nasl_smb_close(lex_ctxt *lexic)
Close SMB service handle.
char * smb_file_GroupSID(SMB_HANDLE, const char *)
Obtain the SID of the Group for a given file/path.
char * get_str_var_by_name(lex_ctxt *, const char *)
tree_cell * nasl_smb_file_owner_sid(lex_ctxt *lexic)
Obtain File Owner SID.
tree_cell * nasl_smb_file_SDDL(lex_ctxt *lexic)
Obtain Security Descriptor in SDDL format.
char * smb_file_TrusteeRights(SMB_HANDLE, const char *)
Obtain the Trustee SID and their rights for a given file/path.
long int get_int_var_by_name(lex_ctxt *, const char *, int)
tree_cell * nasl_smb_connect(lex_ctxt *lexic)
Connect to SMB service and return a handle for it.
char * smb_file_SDDL(SMB_HANDLE, const char *)
Obtain Windows file rights in SDDL format.
int smb_connect(const char *, const char *, const char *, const char *, SMB_HANDLE *)
Establish connection to a SMB service.
struct script_infos * script_infos
tree_cell * nasl_smb_file_group_sid(lex_ctxt *lexic)
Obtain File Group SID.
Host information, implemented as doubly linked list.
API protos describing the interface of a smb interface implementation.
int smb_close(SMB_HANDLE)
Close the connection handle for SMB service.
tree_cell * alloc_typed_cell(int typ)
char * smb_file_OwnerSID(SMB_HANDLE, const char *)
Obtain the SID of the Owner for a given file/path.
tree_cell * nasl_smb_versioninfo(lex_ctxt *lexic)
Get a version string of the SMB implementation.
tree_cell * nasl_smb_file_trustee_rights(lex_ctxt *lexic)
Obtain File Trustee SID with Access Mask.