OpenVAS Scanner  7.0.1~git
plugutils.c
Go to the documentation of this file.
1 /* Portions Copyright (C) 2009-2019 Greenbone Networks GmbH
2  * Based on work Copyright (C) 1998 - 2003 Renaud Deraison
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
26 #include "plugutils.h"
27 
28 #include "network.h" // for OPENVAS_ENCAPS_IP
29 
30 #include <errno.h> // for errno
31 #include <gvm/base/hosts.h> // for g_vhost_t
32 #include <gvm/base/networking.h> // for port_protocol_t
33 #include <gvm/base/prefs.h> // for prefs_get_bool
34 #include <gvm/util/nvticache.h> // for nvticache_initialized
35 #include <stdio.h> // for snprintf
36 #include <stdlib.h> // for exit
37 #include <string.h> // for strcmp
38 #include <sys/wait.h> // for wait
39 #include <unistd.h> // for fork
40 
41 #undef G_LOG_DOMAIN
42 
45 #define G_LOG_DOMAIN "lib misc"
46 
47 /* Used to allow debugging for openvas-nasl */
49 
50 /* In case of multiple vhosts fork, this holds the value of the current vhost
51  * we're scanning.
52  */
53 gvm_vhost_t *current_vhost = NULL;
54 
55 /* @brief: Return the currently scanned vhost. */
56 const char *
58 {
59  return current_vhost->value;
60 }
61 
62 static int plug_fork_child (kb_t);
63 
64 void
65 plug_set_dep (struct script_infos *args, const char *depname)
66 {
67  nvti_t *n = args->nvti;
68  gchar *old = nvti_dependencies (n);
69  gchar *new;
70 
71  if (!depname)
72  return;
73 
74  if (old)
75  {
76  new = g_strdup_printf ("%s, %s", old, depname);
77  nvti_set_dependencies (n, new);
78  g_free (new);
79  }
80  else
81  nvti_set_dependencies (n, depname);
82 }
83 
84 void
85 host_add_port_proto (struct script_infos *args, int portnum, char *proto)
86 {
87  char port_s[255];
88  snprintf (port_s, sizeof (port_s), "Ports/%s/%d", proto, portnum);
89  plug_set_key (args, port_s, ARG_INT, (void *) 1);
90 }
91 
97 static int
98 unscanned_ports_as_closed (port_protocol_t ptype)
99 {
100  if (ptype == PORT_PROTOCOL_UDP)
101  return prefs_get_bool ("unscanned_closed_udp") ? 0 : 1;
102 
103  return prefs_get_bool ("unscanned_closed") ? 0 : 1;
104 }
105 
109 int
110 kb_get_port_state_proto (kb_t kb, int portnum, char *proto)
111 {
112  char port_s[255], *kbstr;
113  const char *prange = prefs_get ("port_range");
114  port_protocol_t port_type;
115  array_t *port_ranges;
116 
117  if (!proto)
118  proto = "tcp";
119  if (!strcmp (proto, "udp"))
120  {
121  port_type = PORT_PROTOCOL_UDP;
122  kbstr = "Host/udp_scanned";
123  }
124  else
125  {
126  port_type = PORT_PROTOCOL_TCP;
127  kbstr = "Host/scanned";
128  }
129 
130  /* Check that we actually scanned the port */
131  if (kb_item_get_int (kb, kbstr) <= 0)
132  return unscanned_ports_as_closed (port_type);
133 
134  port_ranges = port_range_ranges (prange);
135  if (!port_in_port_ranges (portnum, port_type, port_ranges))
136  {
137  array_free (port_ranges);
138  return unscanned_ports_as_closed (port_type);
139  }
140  array_free (port_ranges);
141 
142  /* Ok, we scanned it. What is its state ? */
143  snprintf (port_s, sizeof (port_s), "Ports/%s/%d", proto, portnum);
144  return kb_item_get_int (kb, port_s) > 0;
145 }
146 
147 int
148 host_get_port_state_proto (struct script_infos *args, int portnum, char *proto)
149 {
150  return kb_get_port_state_proto (args->key, portnum, proto);
151 }
152 
153 int
154 host_get_port_state (struct script_infos *plugdata, int portnum)
155 {
156  return host_get_port_state_proto (plugdata, portnum, "tcp");
157 }
158 
159 int
160 host_get_port_state_udp (struct script_infos *plugdata, int portnum)
161 {
162  return host_get_port_state_proto (plugdata, portnum, "udp");
163 }
164 
165 int
166 plug_add_host_fqdn (struct script_infos *args, const char *hostname,
167  const char *source)
168 {
169  gvm_vhost_t *vhost;
170  GSList *vhosts;
171  char **excluded;
172 
173  if (!prefs_get_bool ("expand_vhosts") || !hostname || !source)
174  return -1;
175 
176  /* Check for duplicate vhost value. */
177  vhosts = args->vhosts;
178  while (vhosts)
179  {
180  gvm_vhost_t *tmp = vhosts->data;
181 
182  if (!strcmp (tmp->value, hostname))
183  {
184  g_warning ("%s: Value '%s' exists already", __FUNCTION__, hostname);
185  return -1;
186  }
187  vhosts = vhosts->next;
188  }
189  /* Check for excluded vhost value. */
190  if (prefs_get ("exclude_hosts"))
191  {
192  char **tmp = excluded = g_strsplit (prefs_get ("exclude_hosts"), ",", 0);
193 
194  while (*tmp)
195  {
196  if (!strcmp (g_strstrip (*tmp), hostname))
197  {
198  g_strfreev (excluded);
199  return -1;
200  }
201  tmp++;
202  }
203  g_strfreev (excluded);
204  }
205  vhost = gvm_vhost_new (g_strdup (hostname), g_strdup (source));
206  args->vhosts = g_slist_prepend (args->vhosts, vhost);
207  return 0;
208 }
209 
210 char *
212 {
213  GSList *vhosts = args->vhosts;
214 
215  if (!args->vhosts)
216  return addr6_as_str (args->ip);
217 
218  /* Workaround for rapid growth of forked processes ie. http_get() calls
219  * within foreach() loops. */
220  if (current_vhost)
221  return g_strdup (current_vhost->value);
222  while (vhosts)
223  {
224  pid_t pid = plug_fork_child (args->key);
225 
226  if (pid == 0)
227  {
228  current_vhost = vhosts->data;
229  return g_strdup (current_vhost->value);
230  }
231  else if (pid == -1)
232  return NULL;
233  vhosts = vhosts->next;
234  }
235  exit (0);
236 }
237 
238 GSList *
240 {
241  GSList *results = NULL, *vhosts = args->vhosts;
242 
243  if (!args->vhosts)
244  results = g_slist_prepend (results, addr6_as_str (args->ip));
245 
246  while (vhosts)
247  {
248  gvm_vhost_t *vhost = vhosts->data;
249 
250  results = g_slist_prepend (results, g_strdup (vhost->value));
251  vhosts = vhosts->next;
252  }
253  return results;
254 }
255 
256 char *
257 plug_get_host_source (struct script_infos *args, const char *hostname)
258 {
259  if (!args->vhosts)
260  return g_strdup ("IP-address");
261 
262  if (hostname)
263  {
264  GSList *vhosts = args->vhosts;
265 
266  /* Search for source of specified hostname/vhost. */
267  while (vhosts)
268  {
269  gvm_vhost_t *vhost = vhosts->data;
270 
271  if (!strcmp (vhost->value, hostname))
272  return g_strdup (vhost->source);
273  vhosts = vhosts->next;
274  }
275  return NULL;
276  }
277  /* Call plug_get_host_fqdn() to set current_vhost (and fork, in case of
278  * multiple vhosts.) */
279  if (!current_vhost)
280  g_free (plug_get_host_fqdn (args));
281  return g_strdup (current_vhost->source);
282 }
283 
284 struct in6_addr *
286 {
287  return args->ip;
288 }
289 
290 char *
292 {
293  return addr6_as_str (plug_get_host_ip (desc));
294 }
295 
306 void
307 proto_post_wrapped (const char *oid, struct script_infos *desc, int port,
308  const char *proto, const char *action, const char *what)
309 {
310  const char *hostname = "";
311  char *buffer, *data, port_s[16] = "general";
312  char ip_str[INET6_ADDRSTRLEN];
313  GString *action_str;
314  gsize length;
315  kb_t kb;
316 
317  /* Should not happen, just to avoid trouble stop here if no NVTI found */
318  if (!oid)
319  return;
320 
321  if (action == NULL)
322  action_str = g_string_new ("");
323  else
324  {
325  action_str = g_string_new (action);
326  g_string_append (action_str, "\n");
327  }
328 
329  if (port > 0)
330  snprintf (port_s, sizeof (port_s), "%d", port);
331  if (current_vhost)
332  hostname = current_vhost->value;
333  else if (desc->vhosts)
334  hostname = ((gvm_vhost_t *) desc->vhosts->data)->value;
335  addr6_to_str (plug_get_host_ip (desc), ip_str);
336  buffer = g_strdup_printf ("%s|||%s|||%s/%s|||%s|||%s", what, hostname ?: " ",
337  port_s, proto, oid, action_str->str);
338  /* Convert to UTF-8 before sending to Manager. */
339  data = g_convert (buffer, -1, "UTF-8", "ISO_8859-1", NULL, &length, NULL);
340  kb = plug_get_kb (desc);
341  kb_item_push_str (kb, "internal/results", data);
342  g_free (data);
343  g_free (buffer);
344  g_string_free (action_str, TRUE);
345 }
346 
347 void
348 proto_post_alarm (const char *oid, struct script_infos *desc, int port,
349  const char *proto, const char *action)
350 {
351  proto_post_wrapped (oid, desc, port, proto, action, "ALARM");
352 }
353 
354 void
355 post_alarm (const char *oid, struct script_infos *desc, int port,
356  const char *action)
357 {
358  proto_post_alarm (oid, desc, port, "tcp", action);
359 }
360 
364 void
365 proto_post_log (const char *oid, struct script_infos *desc, int port,
366  const char *proto, const char *action)
367 {
368  proto_post_wrapped (oid, desc, port, proto, action, "LOG");
369 }
370 
374 void
375 post_log (const char *oid, struct script_infos *desc, int port,
376  const char *action)
377 {
378  proto_post_log (oid, desc, port, "tcp", action);
379 }
380 
381 void
382 proto_post_error (const char *oid, struct script_infos *desc, int port,
383  const char *proto, const char *action)
384 {
385  proto_post_wrapped (oid, desc, port, proto, action, "ERRMSG");
386 }
387 
388 void
389 post_error (const char *oid, struct script_infos *desc, int port,
390  const char *action)
391 {
392  proto_post_error (oid, desc, port, "tcp", action);
393 }
394 
407 char *
408 get_plugin_preference (const char *oid, const char *name, int pref_id)
409 {
410  GHashTable *prefs;
411  GHashTableIter iter;
412  char *cname = NULL, *retval = NULL;
413  void *itername, *itervalue;
414  char prefix[1024], suffix[1024];
415 
416  prefs = preferences_get ();
417  if (!prefs || !nvticache_initialized () || !oid || (!name && pref_id < 1))
418  return NULL;
419 
420  g_hash_table_iter_init (&iter, prefs);
421 
422  if (pref_id > 0)
423  {
424  snprintf (prefix, sizeof (prefix), "%s:%d:", oid, pref_id);
425  while (g_hash_table_iter_next (&iter, &itername, &itervalue))
426  {
427  if (g_str_has_prefix (itername, prefix))
428  {
429  retval = g_strdup (itervalue);
430  break;
431  }
432  }
433  }
434  else
435  {
436  cname = g_strdup (name);
437  g_strchomp (cname);
438  snprintf (prefix, sizeof (prefix), "%s:", oid);
439  snprintf (suffix, sizeof (suffix), ":%s", cname);
440  /* NVT preferences received in OID:PrefID:PrefType:PrefName form */
441  while (g_hash_table_iter_next (&iter, &itername, &itervalue))
442  {
443  if (g_str_has_prefix (itername, prefix)
444  && g_str_has_suffix (itername, suffix))
445  {
446  retval = g_strdup (itervalue);
447  break;
448  }
449  }
450  }
451 
452  /* If no value set by the user, get the default one. */
453  if (!retval)
454  {
455  GSList *nprefs, *tmp;
456 
457  tmp = nprefs = nvticache_get_prefs (oid);
458  while (tmp)
459  {
460  if ((cname && !strcmp (cname, nvtpref_name (tmp->data)))
461  || (pref_id >= 0 && pref_id == nvtpref_id (tmp->data)))
462  {
463  retval = g_strdup (nvtpref_default (tmp->data));
464  break;
465  }
466  tmp = tmp->next;
467  }
468  g_slist_free_full (nprefs, (void (*) (void *)) nvtpref_free);
469  }
470  if (cname)
471  g_free (cname);
472  return retval;
473 }
474 
485 const char *
486 get_plugin_preference_fname (struct script_infos *desc, const char *filename)
487 {
488  const char *content;
489  long contentsize = 0;
490  gint tmpfile;
491  gchar *tmpfilename;
492  GError *error = NULL;
493 
494  content = get_plugin_preference_file_content (desc, filename);
495  if (content == NULL)
496  {
497  return NULL;
498  }
499  contentsize = get_plugin_preference_file_size (desc, filename);
500  if (contentsize <= 0)
501  return NULL;
502 
503  tmpfile =
504  g_file_open_tmp ("openvas-file-upload.XXXXXX", &tmpfilename, &error);
505  if (tmpfile == -1)
506  {
507  g_message ("get_plugin_preference_fname: Could not open temporary"
508  " file for %s: %s",
509  filename, error->message);
510  g_error_free (error);
511  return NULL;
512  }
513  close (tmpfile);
514 
515  if (!g_file_set_contents (tmpfilename, content, contentsize, &error))
516  {
517  g_message ("get_plugin_preference_fname: could set contents of"
518  " temporary file for %s: %s",
519  filename, error->message);
520  g_error_free (error);
521  return NULL;
522  }
523 
524  return tmpfilename;
525 }
526 
540 char *
542  const char *identifier)
543 {
544  struct scan_globals *globals = desc->globals;
545  GHashTable *trans;
546 
547  if (!globals)
548  return NULL;
549 
550  trans = globals->files_translation;
551  if (!trans)
552  return NULL;
553 
554  return g_hash_table_lookup (trans, identifier);
555 }
556 
571 long
573  const char *identifier)
574 {
575  struct scan_globals *globals = desc->globals;
576  GHashTable *trans;
577  gchar *filesize_str;
578 
579  if (!globals)
580  return -1;
581 
582  trans = globals->files_size_translation;
583  if (!trans)
584  return -1;
585 
586  filesize_str = g_hash_table_lookup (trans, identifier);
587  if (filesize_str == NULL)
588  return -1;
589 
590  return atol (filesize_str);
591 }
592 
593 void
594 plug_set_key_len (struct script_infos *args, char *name, int type,
595  const void *value, size_t len)
596 {
597  kb_t kb = plug_get_kb (args);
598 
599  if (name == NULL || value == NULL)
600  return;
601 
602  if (type == ARG_STRING)
603  kb_item_add_str_unique (kb, name, value, len);
604  else if (type == ARG_INT)
605  kb_item_add_int_unique (kb, name, GPOINTER_TO_SIZE (value));
606  if (global_nasl_debug == 1)
607  {
608  if (type == ARG_STRING)
609  g_message ("set key %s -> %s", name, (char *) value);
610  else if (type == ARG_INT)
611  g_message ("set key %s -> %d", name, (int) GPOINTER_TO_SIZE (value));
612  }
613 }
614 
615 void
616 plug_set_key (struct script_infos *args, char *name, int type,
617  const void *value)
618 {
619  plug_set_key_len (args, name, type, value, 0);
620 }
621 
622 void
623 plug_replace_key_len (struct script_infos *args, char *name, int type,
624  void *value, size_t len)
625 {
626  kb_t kb = plug_get_kb (args);
627 
628  if (name == NULL || value == NULL)
629  return;
630 
631  if (type == ARG_STRING)
632  kb_item_set_str (kb, name, value, len);
633  else if (type == ARG_INT)
634  kb_item_set_int (kb, name, GPOINTER_TO_SIZE (value));
635  if (global_nasl_debug == 1)
636  {
637  if (type == ARG_STRING)
638  g_message ("replace key %s -> %s", name, (char *) value);
639  else if (type == ARG_INT)
640  g_message ("replace key %s -> %d", name,
641  (int) GPOINTER_TO_SIZE (value));
642  }
643 }
644 
645 void
646 plug_replace_key (struct script_infos *args, char *name, int type, void *value)
647 {
648  plug_replace_key_len (args, name, type, value, 0);
649 }
650 
651 void
652 scanner_add_port (struct script_infos *args, int port, char *proto)
653 {
654  host_add_port_proto (args, port, proto);
655 }
656 
657 kb_t
658 plug_get_kb (struct script_infos *args)
659 {
660  return args->key;
661 }
662 
663 static void
665 {
666  int status;
667 
668  wait (&status);
669 }
670 
671 static void
672 sig_n (int signo, void (*fnc) (int))
673 {
674  struct sigaction sa;
675 
676  sa.sa_handler = fnc;
677  sa.sa_flags = 0;
678  sigemptyset (&sa.sa_mask);
679  sigaction (signo, &sa, (struct sigaction *) 0);
680 }
681 
682 static void
683 sig_term (void (*fcn) ())
684 {
685  sig_n (SIGTERM, fcn);
686 }
687 
688 static void
689 sig_chld (void (*fcn) ())
690 {
691  sig_n (SIGCHLD, fcn);
692 }
693 
694 static int
696 {
697  pid_t pid;
698 
699  if ((pid = fork ()) == 0)
700  {
701  sig_term (_exit);
702  kb_lnk_reset (kb);
703  nvticache_reset ();
704  srand48 (getpid () + getppid () + time (NULL));
705  return 0;
706  }
707  else if (pid < 0)
708  {
709  g_warning ("%s(): fork() failed (%s)", __func__, strerror (errno));
710  return -1;
711  }
712  else
713  waitpid (pid, NULL, 0);
714  return 1;
715 }
716 
729 void *
730 plug_get_key (struct script_infos *args, char *name, int *type, size_t *len,
731  int single)
732 {
733  kb_t kb = args->key;
734  struct kb_item *res = NULL, *res_list;
735 
736  if (type != NULL && *type != KB_TYPE_INT)
737  *type = -1;
738 
739  if (kb == NULL)
740  return NULL;
741 
742  if (single && *type != KB_TYPE_INT)
743  res = kb_item_get_single (kb, name, KB_TYPE_UNSPEC);
744  else if (*type == KB_TYPE_INT)
745  res = kb_item_get_single (kb, name, KB_TYPE_INT);
746  else
747  res = kb_item_get_all (kb, name);
748 
749  if (res == NULL)
750  return NULL;
751 
752  if (!res->next) /* No fork - good */
753  {
754  void *ret;
755  if (res->type == KB_TYPE_INT)
756  {
757  if (type != NULL)
758  *type = KB_TYPE_INT;
759  ret = g_memdup (&res->v_int, sizeof (res->v_int));
760  }
761  else
762  {
763  if (type != NULL)
764  *type = KB_TYPE_STR;
765  if (len)
766  *len = res->len;
767  ret = g_memdup (res->v_str, res->len + 1);
768  }
769  kb_item_free (res);
770  return ret;
771  }
772 
773  /* More than one value - we will fork() then */
775  res_list = res;
776  while (res)
777  {
778  pid_t pid = plug_fork_child (kb);
779 
780  if (pid == 0)
781  {
782  /* Forked child. */
783  void *ret;
784 
785  if (res->type == KB_TYPE_INT)
786  {
787  if (type != NULL)
788  *type = KB_TYPE_INT;
789  ret = g_memdup (&res->v_int, sizeof (res->v_int));
790  }
791  else
792  {
793  if (type != NULL)
794  *type = KB_TYPE_STR;
795  if (len)
796  *len = res->len;
797  ret = g_memdup (res->v_str, res->len + 1);
798  }
799  kb_item_free (res_list);
800  return ret;
801  }
802  else if (pid == -1)
803  return NULL;
804  res = res->next;
805  }
806  kb_item_free (res_list);
807  exit (0);
808 }
809 
816 unsigned int
818 {
819  kb_t kb = plug_get_kb (desc);
820  struct kb_item *res, *k;
821  int open21 = 0, open80 = 0;
822 #define MAX_CANDIDATES 16
823  u_short candidates[MAX_CANDIDATES];
824  int num_candidates = 0;
825 
826  k = res = kb_item_get_pattern (kb, "Ports/tcp/*");
827  if (res == NULL)
828  return 0;
829  else
830  {
831  int ret;
832  char *s;
833 
834  for (;;)
835  {
836  s = res->name + sizeof ("Ports/tcp/") - 1;
837  ret = atoi (s);
838  if (ret == 21)
839  open21 = 1;
840  else if (ret == 80)
841  open80 = 1;
842  else
843  {
844  candidates[num_candidates++] = ret;
845  if (num_candidates >= MAX_CANDIDATES)
846  break;
847  }
848  res = res->next;
849  if (res == NULL)
850  break;
851  }
852 
853  kb_item_free (k);
854  if (num_candidates != 0)
855  return candidates[lrand48 () % num_candidates];
856  else if (open21)
857  return 21;
858  else if (open80)
859  return 80;
860  }
861 
862  /* Not reachable */
863  return 0;
864 }
865 
871 void
872 plug_set_port_transport (struct script_infos *args, int port, int tr)
873 {
874  char s[256];
875 
876  snprintf (s, sizeof (s), "Transports/TCP/%d", port);
877  plug_set_key (args, s, ARG_INT, GSIZE_TO_POINTER (tr));
878 }
879 
880 /* Return the transport encapsulation mode (OPENVAS_ENCAPS_*) for the
881  given PORT. If no such encapsulation mode has been stored in the
882  knowledge base (or its value is < 0), OPENVAS_ENCAPS_IP is
883  currently returned. */
884 int
885 plug_get_port_transport (struct script_infos *args, int port)
886 {
887  char s[256];
888  int trp;
889 
890  snprintf (s, sizeof (s), "Transports/TCP/%d", port);
891  trp = kb_item_get_int (plug_get_kb (args), s);
892  if (trp >= 0)
893  return trp;
894  else
895  return OPENVAS_ENCAPS_IP; /* Change this to 0 for ultra smart SSL
896  negotiation, at the expense of possibly
897  breaking stuff */
898 }
899 
900 static void
901 plug_set_ssl_item (struct script_infos *args, char *item, char *itemfname)
902 {
903  char s[256];
904  snprintf (s, sizeof (s), "SSL/%s", item);
905  plug_set_key (args, s, ARG_STRING, itemfname);
906 }
907 
908 void
909 plug_set_ssl_cert (struct script_infos *args, char *cert)
910 {
911  plug_set_ssl_item (args, "cert", cert);
912 }
913 
914 void
915 plug_set_ssl_key (struct script_infos *args, char *key)
916 {
917  plug_set_ssl_item (args, "key", key);
918 }
919 
920 void
921 plug_set_ssl_pem_password (struct script_infos *args, char *key)
922 {
923  plug_set_ssl_item (args, "password", key);
924 }
925 
930 void
931 plug_set_ssl_CA_file (struct script_infos *args, char *key)
932 {
933  plug_set_ssl_item (args, "CA", key);
934 }
char * plug_get_host_fqdn(struct script_infos *args)
Definition: plugutils.c:211
Header file for module plugutils.
int plug_add_host_fqdn(struct script_infos *args, const char *hostname, const char *source)
Definition: plugutils.c:166
struct scan_globals * globals
Definition: scanneraux.h:45
int host_get_port_state_proto(struct script_infos *args, int portnum, char *proto)
Definition: plugutils.c:148
GHashTable * files_translation
Definition: scanneraux.h:36
void scanner_add_port(struct script_infos *args, int port, char *proto)
Definition: plugutils.c:652
static void sig_term(void(*fcn)())
Definition: plugutils.c:683
void plug_set_ssl_CA_file(struct script_infos *args, char *key)
Definition: plugutils.c:931
void plug_replace_key(struct script_infos *args, char *name, int type, void *value)
Definition: plugutils.c:646
const char * oid
GHashTable * files_size_translation
Definition: scanneraux.h:37
static void sig_n(int signo, void(*fnc)(int))
Definition: plugutils.c:672
kb_t plug_get_kb(struct script_infos *args)
Definition: plugutils.c:658
nvti_t * nvti
Definition: scanneraux.h:47
const char * get_plugin_preference_fname(struct script_infos *desc, const char *filename)
Get the file name of a plugins preference that is of type "file".
Definition: plugutils.c:486
static pid_t pid
void plug_set_ssl_key(struct script_infos *args, char *key)
Definition: plugutils.c:915
const char * plug_current_vhost(void)
Definition: plugutils.c:57
GSList * plug_get_host_fqdn_list(struct script_infos *args)
Definition: plugutils.c:239
static void sig_chld(void(*fcn)())
Definition: plugutils.c:689
char * plug_get_host_source(struct script_infos *args, const char *hostname)
Definition: plugutils.c:257
gvm_vhost_t * current_vhost
Definition: plugutils.c:53
void post_alarm(const char *oid, struct script_infos *desc, int port, const char *action)
Definition: plugutils.c:355
void plug_replace_key_len(struct script_infos *args, char *name, int type, void *value, size_t len)
Definition: plugutils.c:623
int host_get_port_state_udp(struct script_infos *plugdata, int portnum)
Definition: plugutils.c:160
void post_log(const char *oid, struct script_infos *desc, int port, const char *action)
Post a log message about a tcp port.
Definition: plugutils.c:375
void host_add_port_proto(struct script_infos *args, int portnum, char *proto)
Definition: plugutils.c:85
unsigned int plug_get_host_open_port(struct script_infos *desc)
Definition: plugutils.c:817
int plug_get_port_transport(struct script_infos *args, int port)
Definition: plugutils.c:885
static int unscanned_ports_as_closed(port_protocol_t ptype)
Report state of preferences "unscanned_closed".
Definition: plugutils.c:98
int host_get_port_state(struct script_infos *plugdata, int portnum)
Definition: plugutils.c:154
static void plug_get_key_sigchld()
Definition: plugutils.c:664
void plug_set_key_len(struct script_infos *args, char *name, int type, const void *value, size_t len)
Definition: plugutils.c:594
void proto_post_error(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action)
Definition: plugutils.c:382
char * get_plugin_preference_file_content(struct script_infos *desc, const char *identifier)
Get the file contents of a plugins preference that is of type "file".
Definition: plugutils.c:541
struct in6_addr * plug_get_host_ip(struct script_infos *args)
Definition: plugutils.c:285
void plug_set_key(struct script_infos *args, char *name, int type, const void *value)
Definition: plugutils.c:616
static void plug_set_ssl_item(struct script_infos *args, char *item, char *itemfname)
Definition: plugutils.c:901
int kb_get_port_state_proto(kb_t kb, int portnum, char *proto)
Definition: plugutils.c:110
struct in6_addr * ip
Definition: scanneraux.h:51
Header file for module network.
#define MAX_CANDIDATES
void proto_post_alarm(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action)
Definition: plugutils.c:348
void plug_set_port_transport(struct script_infos *args, int port, int tr)
Definition: plugutils.c:872
void proto_post_wrapped(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action, const char *what)
Post a security message (e.g. LOG, NOTE, WARNING ...).
Definition: plugutils.c:307
const char * name
Definition: nasl_init.c:377
void post_error(const char *oid, struct script_infos *desc, int port, const char *action)
Definition: plugutils.c:389
void * plug_get_key(struct script_infos *args, char *name, int *type, size_t *len, int single)
Get values from a kb under the given key name.
Definition: plugutils.c:730
#define ARG_INT
Definition: plugutils.h:34
char * get_plugin_preference(const char *oid, const char *name, int pref_id)
Get the a plugins preference.
Definition: plugutils.c:408
int global_nasl_debug
Definition: plugutils.c:48
static int plug_fork_child(kb_t)
Definition: plugutils.c:695
char * plug_get_host_ip_str(struct script_infos *desc)
Definition: plugutils.c:291
#define ARG_STRING
Definition: plugutils.h:33
const char * hostname
Definition: pluginlaunch.c:76
void plug_set_dep(struct script_infos *args, const char *depname)
Definition: plugutils.c:65
long get_plugin_preference_file_size(struct script_infos *desc, const char *identifier)
Get the file size of a plugins preference that is of type "file".
Definition: plugutils.c:572
static void prefix(int n, int i)
Definition: nasl_tree.c:233
void proto_post_log(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action)
Post a log message.
Definition: plugutils.c:365
void plug_set_ssl_cert(struct script_infos *args, char *cert)
Definition: plugutils.c:909
void plug_set_ssl_pem_password(struct script_infos *args, char *key)
Definition: plugutils.c:921
GSList * vhosts
Definition: scanneraux.h:52