OpenVAS Scanner  7.0.1~git
nasl_wmi.c
Go to the documentation of this file.
1 /* Copyright (C) 2009-2019 Greenbone Networks GmbH
2  *
3  * SPDX-License-Identifier: GPL-2.0-or-later
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
32 #include "nasl_wmi.h"
33 
34 #include "../misc/plugutils.h"
35 #include "openvas_wmi_interface.h"
36 
37 #include <arpa/inet.h>
38 #include <ctype.h>
39 #include <gvm/base/logging.h>
40 #include <gvm/base/networking.h>
41 #include <inttypes.h>
42 #include <netinet/in.h>
43 #include <stdio.h>
44 #include <string.h>
45 #include <sys/socket.h>
46 
47 #define IMPORT(var) char *var = get_str_var_by_name (lexic, #var)
48 #define max 5
49 
50 #undef G_LOG_DOMAIN
51 
54 #define G_LOG_DOMAIN "lib nasl"
55 
59 int
61 {
62  int i, val_len;
63  val_len = strlen (val);
64 
65  if ((strcmp (val, "-1")) != 0)
66  {
67  for (i = 0; i < val_len; i++)
68  if (!isdigit (val[i]))
69  return 0;
70  }
71  else
72  return 0;
73 
74  return 1;
75 }
76 
80 uint32_t
81 stoi_uint32_t (char *s)
82 {
83  uint32_t v;
84  sscanf (s, "%" PRIu32, &v);
85  return v;
86 }
87 
91 uint64_t
92 stoi_uint64_t (char *s)
93 {
94  uint64_t v;
95  sscanf (s, "%" PRIu64, &v);
96  return v;
97 }
98 
107 tree_cell *
109 {
110  char *version = wmi_versioninfo ();
111  tree_cell *retc;
112  (void) lexic;
113 
114  if (!version)
115  return NULL;
116 
117  retc = alloc_typed_cell (CONST_DATA);
118  retc->x.str_val = strdup (version);
119  retc->size = strlen (version);
120  return retc;
121 }
122 
123 /*
124 ################################################################################
125  WMI_FUNCTIONS
126 ################################################################################
127 */
128 
141 tree_cell *
143 {
144  struct script_infos *script_infos = lexic->script_infos;
145  struct in6_addr *host = plug_get_host_ip (script_infos);
146  char *ip;
147  char *argv[max];
148  WMI_HANDLE handle;
149  int argc = 5;
150  IMPORT (username);
151  IMPORT (password);
152  IMPORT (ns);
153 
154  if (ns == NULL)
155  ns = "root\\cimv2";
156 
157  if ((host == NULL) || (username == NULL) || (password == NULL))
158  {
159  g_message ("nasl_wmi_connect: Invalid input arguments");
160  return NULL;
161  }
162 
163  ip = addr6_as_str (host);
164  if ((strlen (password) == 0) || (strlen (username) == 0) || strlen (ip) == 0)
165  {
166  g_message ("nasl_wmi_connect: Invalid input arguments");
167  g_free (ip);
168  return NULL;
169  }
170 
171  // Construct the WMI query
172  argv[0] = g_strdup ("wmic");
173  argv[1] = g_strdup ("-U");
174  argv[2] = g_strdup_printf ("%s%%%s", username, password);
175  argv[3] = g_strdup_printf ("//%s", ip);
176  argv[4] = g_strdup (ns);
177  g_free (ip);
178 
180  handle = wmi_connect (argc, argv);
181  if (!handle)
182  {
183  g_message ("nasl_wmi_connect: WMI Connect failed");
184  return NULL;
185  }
186 
187  retc->x.ref_val = handle;
188  return retc;
189 }
190 
202 tree_cell *
204 {
205  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
206  if (!handle)
207  return NULL;
208 
210 
211  if (wmi_close (handle) == 0)
212  {
213  retc->x.i_val = 1;
214  return retc;
215  }
216  return NULL;
217 }
218 
231 tree_cell *
233 {
234  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
235  char *query = get_str_var_by_name (lexic, "query");
236  char *res = NULL;
237  int value;
238 
239  if (!handle)
240  return NULL;
241 
243  retc->x.str_val = NULL;
244  retc->size = 0;
245 
246  value = wmi_query (handle, query, &res);
247 
248  if ((value == -1) || (res == NULL))
249  {
250  g_message ("wmi_query: WMI query failed '%s'", query);
251  return NULL;
252  }
253 
254  retc->x.str_val = strdup (res);
255  retc->size = strlen (res);
256 
257  return retc;
258 }
259 
260 /*
261 ################################################################################
262  WMI_RSOP_FUNCTIONS
263 ################################################################################
264 */
265 
278 tree_cell *
280 {
281  struct script_infos *script_infos = lexic->script_infos;
282  struct in6_addr *host = plug_get_host_ip (script_infos);
283  char *ip;
284  IMPORT (username);
285  IMPORT (password);
286  char *argv[4];
287  WMI_HANDLE handle;
288  int argc = 4;
289 
290  if ((host == NULL) || (username == NULL) || (password == NULL))
291  {
292  g_message ("nasl_wmi_connect_rsop: Invalid input arguments");
293  return NULL;
294  }
295 
296  ip = addr6_as_str (host);
297  if ((strlen (password) == 0) || (strlen (username) == 0) || strlen (ip) == 0)
298  {
299  g_message ("nasl_wmi_connect_rsop: Invalid input arguments");
300  g_free (ip);
301  return NULL;
302  }
303 
304  // Construct the WMI query
305  argv[0] = g_strdup ("wmic");
306  argv[1] = g_strdup ("-U");
307  argv[2] = g_strdup_printf ("%s%%%s", username, password);
308  argv[3] = g_strdup_printf ("//%s", ip);
309  g_free (ip);
310 
312  handle = wmi_connect_rsop (argc, argv);
313  if (!handle)
314  {
315  g_message ("nasl_wmi_connect_rsop: WMI Connect failed");
316  return NULL;
317  }
318 
319  retc->x.ref_val = handle;
320  return retc;
321 }
322 
334 tree_cell *
336 {
337  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
338  if (!handle)
339  return NULL;
340 
341  char *query = get_str_var_by_name (lexic, "query"); // WQL query
342  char *res = NULL;
343  int value;
345  retc->x.str_val = NULL;
346  retc->size = 0;
347 
348  value = wmi_query_rsop (handle, query, &res);
349  if ((value == -1) || (res == NULL))
350  {
351  g_message ("wmi_query_rsop: WMI query failed");
352  return NULL;
353  }
354  retc->x.str_val = strdup (res);
355  retc->size = strlen (res);
356 
357  return retc;
358 }
359 
360 /*
361 ################################################################################
362  WMI_REGISTRY_FUNCTIONS
363 ################################################################################
364 */
365 
378 tree_cell *
380 {
381  struct script_infos *script_infos = lexic->script_infos;
382  struct in6_addr *host = plug_get_host_ip (script_infos);
383  char *ip;
384  IMPORT (username);
385  IMPORT (password);
386  char *argv[4];
387  WMI_HANDLE handle;
388  int argc = 4;
389 
390  if ((host == NULL) || (username == NULL) || (password == NULL))
391  {
392  g_message ("nasl_wmi_connect_reg: Invalid input arguments");
393  return NULL;
394  }
395 
396  ip = addr6_as_str (host);
397  if ((strlen (password) == 0) || (strlen (username) == 0) || strlen (ip) == 0)
398  {
399  g_message ("nasl_wmi_connect_reg: Invalid input arguments");
400  g_free (ip);
401  return NULL;
402  }
403 
404  // Construct the WMI query
405  argv[0] = g_strdup ("wmic");
406  argv[1] = g_strdup ("-U");
407  argv[2] = g_strdup_printf ("%s%%%s", username, password);
408  argv[3] = g_strdup_printf ("//%s", ip);
409  g_free (ip);
410 
412  handle = wmi_connect_reg (argc, argv);
413  if (!handle)
414  {
415  g_message ("nasl_wmi_connect_reg: WMI Connect failed");
416  return NULL;
417  }
418 
419  retc->x.ref_val = handle;
420  return retc;
421 }
422 
435 tree_cell *
437 {
438  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
439 
440  if (!handle)
441  return NULL;
442 
443  unsigned int hive = get_int_var_by_name (lexic, "hive", 0); // REGISTRY Hive
444  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
445  char *key_name =
446  get_str_var_by_name (lexic, "key_name"); // REGISTRY value name
447 
448  char *res = NULL;
449  int value;
451  retc->x.str_val = NULL;
452  retc->size = 0;
453 
454  value = wmi_reg_get_sz (handle, hive, key, key_name, &res);
455 
456  if ((value == -1) || (res == NULL))
457  {
458  g_message ("nasl_wmi_reg_get_sz: WMI Registry get failed");
459  return NULL;
460  }
461 
462  retc->x.str_val = strdup (res);
463  retc->size = strlen (res);
464 
465  return retc;
466 }
467 
480 tree_cell *
482 {
483  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
484 
485  if (!handle)
486  return NULL;
487 
488  unsigned int hive = get_int_var_by_name (lexic, "hive", 0); // REGISTRY Hive
489  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
490 
491  char *res = NULL;
492  int value;
494  retc->x.str_val = NULL;
495  retc->size = 0;
496 
497  value = wmi_reg_enum_value (handle, hive, key, &res);
498 
499  if ((value == -1) || (res == NULL))
500  {
501  g_message ("nasl_wmi_reg_enum_value: WMI query failed");
502  return NULL;
503  }
504 
505  retc->x.str_val = strdup (res);
506  retc->size = strlen (res);
507 
508  return retc;
509 }
510 
523 tree_cell *
525 {
526  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
527 
528  if (!handle)
529  return NULL;
530 
531  unsigned int hive = get_int_var_by_name (lexic, "hive", 0); // REGISTRY Hive
532  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
533 
534  char *res = NULL;
535  int value;
537  retc->x.str_val = NULL;
538  retc->size = 0;
539 
540  value = wmi_reg_enum_key (handle, hive, key, &res);
541 
542  if ((value == -1) || (res == NULL))
543  {
544  g_message ("nasl_wmi_reg_enum_key: WMI query failed");
545  return NULL;
546  }
547 
548  retc->x.str_val = strdup (res);
549  retc->size = strlen (res);
550 
551  return retc;
552 }
553 
566 tree_cell *
568 {
569  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
570 
571  if (!handle)
572  return NULL;
573 
574  unsigned int hive = get_int_var_by_name (lexic, "hive", 0); // REGISTRY Hive
575  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
576  char *val_name =
577  get_str_var_by_name (lexic, "val_name"); // REGISTRY VALUE NAME
578 
579  char *res = NULL;
580  int value;
581 
583  retc->x.str_val = NULL;
584  retc->size = 0;
585 
586  value = wmi_reg_get_bin_val (handle, hive, key, val_name, &res);
587 
588  if ((value == -1) || (res == NULL))
589  {
590  g_message ("nasl_wmi_reg_get_bin_val: WMI query failed");
591  return NULL;
592  }
593 
594  retc->x.str_val = strdup (res);
595  retc->size = strlen (res);
596  return retc;
597 }
598 
611 tree_cell *
613 {
614  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
615 
616  if (!handle)
617  return NULL;
618 
619  unsigned int hive = get_int_var_by_name (lexic, "hive", 0); // REGISTRY Hive
620  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
621  char *val_name =
622  get_str_var_by_name (lexic, "val_name"); // REGISTRY VALUE NAME
623 
624  char *res = NULL;
625  int value;
626 
628  retc->x.str_val = NULL;
629  retc->size = 0;
630 
631  value = wmi_reg_get_dword_val (handle, hive, key, val_name, &res);
632 
633  if ((value == 0) && (res == 0))
634  res = "0";
635 
636  if ((value == -1) || (res == NULL))
637  {
638  g_message ("nasl_wmi_reg_get_dword_val: WMI query failed");
639  return NULL;
640  }
641 
642  retc->x.str_val = strdup (res);
643  retc->size = strlen (res);
644  return retc;
645 }
646 
659 tree_cell *
661 {
662  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
663 
664  if (!handle)
665  return NULL;
666 
667  unsigned int hive = get_int_var_by_name (lexic, "hive", 0); // REGISTRY Hive
668  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
669  char *val_name =
670  get_str_var_by_name (lexic, "val_name"); // REGISTRY VALUE NAME
671 
672  char *res = NULL;
673  int value;
674 
676  retc->x.str_val = NULL;
677  retc->size = 0;
678 
679  value = wmi_reg_get_ex_string_val (handle, hive, key, val_name, &res);
680 
681  if ((value == -1) || (res == NULL))
682  {
683  g_message ("nasl_wmi_reg_get_ex_string_val: WMI query failed");
684  return NULL;
685  }
686 
687  retc->x.str_val = strdup (res);
688  retc->size = strlen (res);
689  return retc;
690 }
691 
704 tree_cell *
706 {
707  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
708 
709  if (!handle)
710  return NULL;
711 
712  unsigned int hive = get_int_var_by_name (lexic, "hive", 0); // REGISTRY Hive
713  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
714  char *val_name =
715  get_str_var_by_name (lexic, "val_name"); // REGISTRY VALUE NAME
716 
717  char *res = NULL;
718  int value;
719 
721  retc->x.str_val = NULL;
722  retc->size = 0;
723 
724  value = wmi_reg_get_mul_string_val (handle, hive, key, val_name, &res);
725 
726  if ((value == -1) || (res == NULL))
727  {
728  g_message ("nasl_wmi_reg_get_mul_string_val: WMI query failed");
729  return NULL;
730  }
731 
732  retc->x.str_val = strdup (res);
733  retc->size = strlen (res);
734  return retc;
735 }
736 
749 tree_cell *
751 {
752  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
753 
754  if (!handle)
755  return NULL;
756 
757  unsigned int hive = get_int_var_by_name (lexic, "hive", 0); // REGISTRY Hive
758  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
759  char *val_name =
760  get_str_var_by_name (lexic, "val_name"); // REGISTRY VALUE NAME
761 
762  char *res = NULL;
763  int value;
764 
766  retc->x.str_val = NULL;
767  retc->size = 0;
768 
769  value = wmi_reg_get_qword_val (handle, hive, key, val_name, &res);
770 
771  if ((value == -1) || (res == NULL))
772  {
773  g_message ("nasl_wmi_reg_get_qword_val: WMI query failed");
774  return NULL;
775  }
776 
777  retc->x.str_val = strdup (res);
778  retc->size = strlen (res);
779  return retc;
780 }
781 
795 tree_cell *
797 {
798  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
799 
800  if (!handle)
801  return NULL;
802 
803  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
804  char *val_name =
805  get_str_var_by_name (lexic, "val_name"); // REGISTRY VALUE NAME
806  char *val = get_str_var_by_name (lexic, "val"); // REGISTERY VALUE TO SET
807 
808  uint32_t val1;
809  int value;
810 
811  // Return NULL if any alphabet is present
812  if (check_alpha (val) == 0)
813  return NULL;
814 
815  // Convert string to proper 64 bit integer
816  val1 = stoi_uint32_t (val);
817 
819  retc->x.i_val = 1;
820 
821  value = wmi_reg_set_dword_val (handle, key, val_name, val1);
822 
823  if (value == -1)
824  {
825  g_message ("nasl_wmi_reg_set_dword_val: WMI registry set"
826  " operation failed");
827  return NULL;
828  }
829  return retc;
830 }
831 
845 tree_cell *
847 {
848  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
849 
850  if (!handle)
851  return NULL;
852 
853  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
854  char *val_name =
855  get_str_var_by_name (lexic, "val_name"); // REGISTRY VALUE NAME
856  char *val = get_str_var_by_name (lexic, "val"); // REGISTERY VALUE TO SET
857 
858  uint64_t val1;
859  int value;
860 
861  // Return if alphabets present
862  if (check_alpha (val) == 0)
863  return NULL;
864 
865  // Convert string to proper integer
866  val1 = stoi_uint64_t (val);
867 
869  retc->x.i_val = 1;
870 
871  value = wmi_reg_set_qword_val (handle, key, val_name, val1);
872 
873  if (value == -1)
874  {
875  g_message ("nasl_wmi_reg_set_qword_val: WMI register"
876  " set operation failed");
877  return NULL;
878  }
879  return retc;
880 }
881 
895 tree_cell *
897 {
898  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
899 
900  if (!handle)
901  return NULL;
902 
903  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
904  char *val_name =
905  get_str_var_by_name (lexic, "val_name"); // REGISTRY VALUE NAME
906  char *val = get_str_var_by_name (lexic, "val"); // REGISTERY VALUE TO SET
907 
908  int value;
909 
911  retc->x.i_val = 1;
912 
913  value = wmi_reg_set_ex_string_val (handle, key, val_name, val);
914 
915  if (value == -1)
916  {
917  g_message (
918  "nasl_wmi_reg_set_ex_string_val: WMI registery set operation failed");
919  return NULL;
920  }
921  return retc;
922 }
923 
937 tree_cell *
939 {
940  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
941 
942  if (!handle)
943  return NULL;
944 
945  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
946  char *val_name =
947  get_str_var_by_name (lexic, "val_name"); // REGISTRY VALUE NAME
948  char *val = get_str_var_by_name (lexic, "val"); // REGISTERY VALUE TO SET
949 
950  int value;
951 
953  retc->x.i_val = 1;
954 
955  value = wmi_reg_set_string_val (handle, key, val_name, val);
956 
957  if (value == -1)
958  {
959  g_message ("nasl_wmi_reg_set_string_val: WMI registery"
960  " set operation failed");
961  return NULL;
962  }
963  return retc;
964 }
965 
977 tree_cell *
979 {
980  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
981 
982  if (!handle)
983  return NULL;
984 
985  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
986 
987  int value;
988 
990  retc->x.i_val = 1;
991 
992  value = wmi_reg_create_key (handle, key);
993 
994  if (value == -1)
995  {
996  g_message ("nasl_wmi_reg_create_key: WMI registery key create"
997  " operation failed");
998  return NULL;
999  }
1000  return retc;
1001 }
1002 
1016 tree_cell *
1018 {
1019  WMI_HANDLE handle = (WMI_HANDLE) get_int_var_by_name (lexic, "wmi_handle", 0);
1020 
1021  if (!handle)
1022  return NULL;
1023 
1024  char *key = get_str_var_by_name (lexic, "key"); // REGISTRY KEY
1025 
1026  int value;
1027 
1029  retc->x.i_val = 1;
1030 
1031  value = wmi_reg_delete_key (handle, key);
1032 
1033  if (value == -1)
1034  {
1035  g_message ("nasl_wmi_reg_delete_key: WMI registery key"
1036  " delete operation failed");
1037  return NULL;
1038  }
1039  return retc;
1040 }
wmi_close
int wmi_close(WMI_HANDLE)
Close the connection handle for a WMI service.
Definition: wmi_interface_stub.c:71
stoi_uint64_t
uint64_t stoi_uint64_t(char *s)
Definition: nasl_wmi.c:92
script_infos
Definition: scanneraux.h:43
CONST_DATA
@ CONST_DATA
Definition: nasl_tree.h:93
openvas_wmi_interface.h
API protos describing the interface of a wmi interface implementation.
check_alpha
int check_alpha(char *val)
Definition: nasl_wmi.c:60
wmi_reg_create_key
int wmi_reg_create_key(WMI_HANDLE, const char *)
Create Registry Key.
Definition: wmi_interface_stub.c:462
nasl_wmi_reg_set_dword_val
tree_cell * nasl_wmi_reg_set_dword_val(lex_ctxt *lexic)
Set Registry DWORD value.
Definition: nasl_wmi.c:796
plug_get_host_ip
struct in6_addr * plug_get_host_ip(struct script_infos *args)
Definition: plugutils.c:285
TC::str_val
char * str_val
Definition: nasl_tree.h:112
nasl_wmi_reg_set_ex_string_val
tree_cell * nasl_wmi_reg_set_ex_string_val(lex_ctxt *lexic)
Set Registry Expanded string value.
Definition: nasl_wmi.c:896
wmi_reg_set_qword_val
int wmi_reg_set_qword_val(WMI_HANDLE, const char *, const char *, uint64_t)
Set Registry QWORD value.
Definition: wmi_interface_stub.c:398
wmi_reg_enum_key
int wmi_reg_enum_key(WMI_HANDLE, unsigned int, const char *, char **)
Enumerate Registry keys.
Definition: wmi_interface_stub.c:218
TC::x
union TC::@2 x
get_str_var_by_name
char * get_str_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1127
nasl_wmi_connect
tree_cell * nasl_wmi_connect(lex_ctxt *lexic)
Connect to a WMI service and return a handle for it.
Definition: nasl_wmi.c:142
nasl_wmi_query
tree_cell * nasl_wmi_query(lex_ctxt *lexic)
Perform WQL query.
Definition: nasl_wmi.c:232
nasl_wmi_reg_get_ex_string_val
tree_cell * nasl_wmi_reg_get_ex_string_val(lex_ctxt *lexic)
Get registry expanded string value.
Definition: nasl_wmi.c:660
nasl_wmi_reg_get_sz
tree_cell * nasl_wmi_reg_get_sz(lex_ctxt *lexic)
Get string value from Registry.
Definition: nasl_wmi.c:436
wmi_connect_reg
WMI_HANDLE wmi_connect_reg(int argc, char **argv)
Establish connection to a WMI Registry service.
Definition: wmi_interface_stub.c:144
wmi_reg_set_string_val
int wmi_reg_set_string_val(WMI_HANDLE, const char *, const char *, const char *)
Set Registry string value.
Definition: wmi_interface_stub.c:442
max
#define max
Definition: nasl_wmi.c:48
wmi_reg_get_bin_val
int wmi_reg_get_bin_val(WMI_HANDLE, unsigned int, const char *, const char *, char **)
Get Registry binary value.
Definition: wmi_interface_stub.c:244
nasl_wmi_reg_get_bin_val
tree_cell * nasl_wmi_reg_get_bin_val(lex_ctxt *lexic)
Get registry binary value.
Definition: nasl_wmi.c:567
wmi_reg_get_ex_string_val
int wmi_reg_get_ex_string_val(WMI_HANDLE, unsigned int, const char *, const char *, char **)
Get Registry Expanded string value.
Definition: wmi_interface_stub.c:298
nasl_wmi_close
tree_cell * nasl_wmi_close(lex_ctxt *lexic)
Close WMI service handle.
Definition: nasl_wmi.c:203
IMPORT
#define IMPORT(var)
Definition: nasl_wmi.c:47
TC::size
int size
Definition: nasl_tree.h:109
nasl_wmi_reg_enum_key
tree_cell * nasl_wmi_reg_enum_key(lex_ctxt *lexic)
Enumerate registry keys.
Definition: nasl_wmi.c:524
nasl_wmi_reg_set_string_val
tree_cell * nasl_wmi_reg_set_string_val(lex_ctxt *lexic)
Set Registry string value.
Definition: nasl_wmi.c:938
get_int_var_by_name
long int get_int_var_by_name(lex_ctxt *, const char *, int)
Definition: nasl_var.c:1113
nasl_wmi.h
Protos for NASL WMI API.
wmi_reg_get_dword_val
int wmi_reg_get_dword_val(WMI_HANDLE, unsigned int, const char *, const char *, char **)
Get Registry DWORD value.
Definition: wmi_interface_stub.c:271
wmi_reg_get_qword_val
int wmi_reg_get_qword_val(WMI_HANDLE, unsigned int, const char *, const char *, char **)
Get Registry QWORD value.
Definition: wmi_interface_stub.c:352
wmi_connect
WMI_HANDLE wmi_connect(int argc, char **argv)
Establish connection to a WMI service.
Definition: wmi_interface_stub.c:56
TC::ref_val
void * ref_val
Definition: nasl_tree.h:114
nasl_wmi_reg_set_qword_val
tree_cell * nasl_wmi_reg_set_qword_val(lex_ctxt *lexic)
Set Registry QWORD value.
Definition: nasl_wmi.c:846
wmi_reg_enum_value
int wmi_reg_enum_value(WMI_HANDLE, unsigned int, const char *, char **)
Enumerate Registry values.
Definition: wmi_interface_stub.c:193
wmi_reg_set_ex_string_val
int wmi_reg_set_ex_string_val(WMI_HANDLE, const char *, const char *, const char *)
Set Registry Expanded string value.
Definition: wmi_interface_stub.c:420
nasl_wmi_reg_delete_key
tree_cell * nasl_wmi_reg_delete_key(lex_ctxt *lexic)
Delete Registry key.
Definition: nasl_wmi.c:1017
struct_lex_ctxt::script_infos
struct script_infos * script_infos
Definition: nasl_lex_ctxt.h:41
TC
Definition: nasl_tree.h:104
struct_lex_ctxt
Definition: nasl_lex_ctxt.h:33
wmi_query_rsop
int wmi_query_rsop(WMI_HANDLE, const char *, char **)
WMI RSOP query.
Definition: wmi_interface_stub.c:126
nasl_wmi_reg_create_key
tree_cell * nasl_wmi_reg_create_key(lex_ctxt *lexic)
Create Registry key.
Definition: nasl_wmi.c:978
nasl_wmi_versioninfo
tree_cell * nasl_wmi_versioninfo(lex_ctxt *lexic)
Get a version string of the WMI implementation.
Definition: nasl_wmi.c:108
wmi_reg_set_dword_val
int wmi_reg_set_dword_val(WMI_HANDLE, const char *, const char *, uint32_t)
Set Registry DWORD value.
Definition: wmi_interface_stub.c:376
nasl_wmi_connect_rsop
tree_cell * nasl_wmi_connect_rsop(lex_ctxt *lexic)
Connect to a WMI RSOP service and return a handle for it.
Definition: nasl_wmi.c:279
host
Host information, implemented as doubly linked list.
Definition: hosts.c:47
wmi_versioninfo
char * wmi_versioninfo(void)
Return version info for WMI implementation.
Definition: wmi_interface_stub.c:41
WMI_HANDLE
void * WMI_HANDLE
Definition: openvas_wmi_interface.h:33
nasl_wmi_reg_get_dword_val
tree_cell * nasl_wmi_reg_get_dword_val(lex_ctxt *lexic)
Get registry DWORD value.
Definition: nasl_wmi.c:612
CONST_INT
@ CONST_INT
Definition: nasl_tree.h:90
val
const char * val
Definition: nasl_init.c:378
wmi_connect_rsop
WMI_HANDLE wmi_connect_rsop(int argc, char **argv)
Establish connection to a WMI RSOP service.
Definition: wmi_interface_stub.c:107
nasl_wmi_reg_get_qword_val
tree_cell * nasl_wmi_reg_get_qword_val(lex_ctxt *lexic)
Get registry QWORD value.
Definition: nasl_wmi.c:750
wmi_query
int wmi_query(WMI_HANDLE, const char *, char **)
Query WMI service using a WQL query.
Definition: wmi_interface_stub.c:89
nasl_wmi_query_rsop
tree_cell * nasl_wmi_query_rsop(lex_ctxt *lexic)
WMI RSOP query.
Definition: nasl_wmi.c:335
alloc_typed_cell
tree_cell * alloc_typed_cell(int typ)
Definition: nasl_tree.c:40
wmi_reg_delete_key
int wmi_reg_delete_key(WMI_HANDLE, const char *)
Delete Registry Key.
Definition: wmi_interface_stub.c:479
nasl_wmi_reg_enum_value
tree_cell * nasl_wmi_reg_enum_value(lex_ctxt *lexic)
Enumerate registry values.
Definition: nasl_wmi.c:481
stoi_uint32_t
uint32_t stoi_uint32_t(char *s)
Definition: nasl_wmi.c:81
nasl_wmi_connect_reg
tree_cell * nasl_wmi_connect_reg(lex_ctxt *lexic)
Connect to a WMI Registry service and return a handle for it.
Definition: nasl_wmi.c:379
nasl_wmi_reg_get_mul_string_val
tree_cell * nasl_wmi_reg_get_mul_string_val(lex_ctxt *lexic)
Get registry multi valued strings.
Definition: nasl_wmi.c:705
wmi_reg_get_mul_string_val
int wmi_reg_get_mul_string_val(WMI_HANDLE, unsigned int, const char *, const char *, char **)
Get Registry multi-valued strings.
Definition: wmi_interface_stub.c:325
TC::i_val
long int i_val
Definition: nasl_tree.h:113
wmi_reg_get_sz
int wmi_reg_get_sz(WMI_HANDLE, unsigned int, const char *, const char *, char **)
Get Registry string value.
Definition: wmi_interface_stub.c:167