Skip to content

Commit

Permalink
Change: extend nasl_wmi_connect*() functions. (#1073)
Browse files Browse the repository at this point in the history
Now accept an optional 'options' parameter which accept options like [sign,seal] or [spnego] [ntlm]. See openvas-smb/samba/librpc/rpc/dcerpc_util.c for more options.
  • Loading branch information
jjnicola authored Mar 28, 2022
1 parent b5a1869 commit fc0f08b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions nasl/nasl_wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ nasl_wmi_connect (lex_ctxt *lexic)
IMPORT (username);
IMPORT (password);
IMPORT (ns);
IMPORT (options);

if (ns == NULL)
ns = "root\\cimv2";
Expand All @@ -172,7 +173,7 @@ nasl_wmi_connect (lex_ctxt *lexic)
argv[0] = g_strdup ("wmic");
argv[1] = g_strdup ("-U");
argv[2] = g_strdup_printf ("%s%%%s", username, password);
argv[3] = g_strdup_printf ("//%s", ip);
argv[3] = g_strdup_printf ("//%s%s", ip, options ? options : "");
argv[4] = g_strdup (ns);
g_free (ip);

Expand Down Expand Up @@ -292,6 +293,8 @@ nasl_wmi_connect_rsop (lex_ctxt *lexic)
char *ip;
IMPORT (username);
IMPORT (password);
IMPORT (options);

char *argv[4];
WMI_HANDLE handle;
int argc = 4;
Expand All @@ -314,7 +317,7 @@ nasl_wmi_connect_rsop (lex_ctxt *lexic)
argv[0] = g_strdup ("wmic");
argv[1] = g_strdup ("-U");
argv[2] = g_strdup_printf ("%s%%%s", username, password);
argv[3] = g_strdup_printf ("//%s", ip);
argv[3] = g_strdup_printf ("//%s%s", ip, options ? options : "");
g_free (ip);

tree_cell *retc = alloc_typed_cell (CONST_INT);
Expand Down Expand Up @@ -403,6 +406,8 @@ nasl_wmi_connect_reg (lex_ctxt *lexic)
char *ip;
IMPORT (username);
IMPORT (password);
IMPORT (options);

char *argv[4];
WMI_HANDLE handle;
int argc = 4;
Expand All @@ -425,7 +430,7 @@ nasl_wmi_connect_reg (lex_ctxt *lexic)
argv[0] = g_strdup ("wmic");
argv[1] = g_strdup ("-U");
argv[2] = g_strdup_printf ("%s%%%s", username, password);
argv[3] = g_strdup_printf ("//%s", ip);
argv[3] = g_strdup_printf ("//%s%s", ip, options ? options : "");
g_free (ip);

tree_cell *retc = alloc_typed_cell (CONST_INT);
Expand Down

0 comments on commit fc0f08b

Please sign in to comment.