OpenVAS Scanner  7.0.0~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 
395 char *
396 get_plugin_preference (const char *oid, const char *name)
397 {
398  GHashTable *prefs;
399  GHashTableIter iter;
400  char *cname, *retval = NULL;
401  void *itername, *itervalue;
402  char prefix[1024], suffix[1024];
403 
404  prefs = preferences_get ();
405  if (!prefs || !nvticache_initialized () || !oid || !name)
406  return NULL;
407 
408  cname = g_strdup (name);
409  g_strchomp (cname);
410  g_hash_table_iter_init (&iter, prefs);
411  snprintf (prefix, sizeof (prefix), "%s:", oid);
412  snprintf (suffix, sizeof (suffix), ":%s", cname);
413  /* NVT preferences receiveed in OID:PrefID:PrefType:PrefName form */
414  while (g_hash_table_iter_next (&iter, &itername, &itervalue))
415  {
416  if (g_str_has_prefix (itername, prefix)
417  && g_str_has_suffix (itername, suffix))
418  {
419  retval = g_strdup (itervalue);
420  break;
421  }
422  }
423  /* If no value set by the user, get the default one. */
424  if (!retval)
425  {
426  GSList *nprefs, *tmp;
427 
428  tmp = nprefs = nvticache_get_prefs (oid);
429  while (tmp)
430  {
431  if (!strcmp (cname, nvtpref_name (tmp->data)))
432  {
433  retval = g_strdup (nvtpref_default (tmp->data));
434  break;
435  }
436  tmp = tmp->next;
437  }
438  g_slist_free_full (nprefs, (void (*) (void *)) nvtpref_free);
439  }
440  g_free (cname);
441  return retval;
442 }
443 
454 const char *
455 get_plugin_preference_fname (struct script_infos *desc, const char *filename)
456 {
457  const char *content;
458  long contentsize = 0;
459  gint tmpfile;
460  gchar *tmpfilename;
461  GError *error = NULL;
462 
463  content = get_plugin_preference_file_content (desc, filename);
464  if (content == NULL)
465  {
466  return NULL;
467  }
468  contentsize = get_plugin_preference_file_size (desc, filename);
469  if (contentsize <= 0)
470  return NULL;
471 
472  tmpfile =
473  g_file_open_tmp ("openvas-file-upload.XXXXXX", &tmpfilename, &error);
474  if (tmpfile == -1)
475  {
476  g_message ("get_plugin_preference_fname: Could not open temporary"
477  " file for %s: %s",
478  filename, error->message);
479  g_error_free (error);
480  return NULL;
481  }
482  close (tmpfile);
483 
484  if (!g_file_set_contents (tmpfilename, content, contentsize, &error))
485  {
486  g_message ("get_plugin_preference_fname: could set contents of"
487  " temporary file for %s: %s",
488  filename, error->message);
489  g_error_free (error);
490  return NULL;
491  }
492 
493  return tmpfilename;
494 }
495 
509 char *
511  const char *identifier)
512 {
513  struct scan_globals *globals = desc->globals;
514  GHashTable *trans;
515 
516  if (!globals)
517  return NULL;
518 
519  trans = globals->files_translation;
520  if (!trans)
521  return NULL;
522 
523  return g_hash_table_lookup (trans, identifier);
524 }
525 
540 long
542  const char *identifier)
543 {
544  struct scan_globals *globals = desc->globals;
545  GHashTable *trans;
546  gchar *filesize_str;
547 
548  if (!globals)
549  return -1;
550 
551  trans = globals->files_size_translation;
552  if (!trans)
553  return -1;
554 
555  filesize_str = g_hash_table_lookup (trans, identifier);
556  if (filesize_str == NULL)
557  return -1;
558 
559  return atol (filesize_str);
560 }
561 
562 void
563 plug_set_key_len (struct script_infos *args, char *name, int type,
564  const void *value, size_t len)
565 {
566  kb_t kb = plug_get_kb (args);
567 
568  if (name == NULL || value == NULL)
569  return;
570 
571  if (type == ARG_STRING)
572  kb_item_add_str_unique (kb, name, value, len);
573  else if (type == ARG_INT)
574  kb_item_add_int_unique (kb, name, GPOINTER_TO_SIZE (value));
575  if (global_nasl_debug == 1)
576  {
577  if (type == ARG_STRING)
578  g_message ("set key %s -> %s", name, (char *) value);
579  else if (type == ARG_INT)
580  g_message ("set key %s -> %d", name, (int) GPOINTER_TO_SIZE (value));
581  }
582 }
583 
584 void
585 plug_set_key (struct script_infos *args, char *name, int type,
586  const void *value)
587 {
588  plug_set_key_len (args, name, type, value, 0);
589 }
590 
591 void
592 plug_replace_key_len (struct script_infos *args, char *name, int type,
593  void *value, size_t len)
594 {
595  kb_t kb = plug_get_kb (args);
596 
597  if (name == NULL || value == NULL)
598  return;
599 
600  if (type == ARG_STRING)
601  kb_item_set_str (kb, name, value, len);
602  else if (type == ARG_INT)
603  kb_item_set_int (kb, name, GPOINTER_TO_SIZE (value));
604  if (global_nasl_debug == 1)
605  {
606  if (type == ARG_STRING)
607  g_message ("replace key %s -> %s", name, (char *) value);
608  else if (type == ARG_INT)
609  g_message ("replace key %s -> %d", name,
610  (int) GPOINTER_TO_SIZE (value));
611  }
612 }
613 
614 void
615 plug_replace_key (struct script_infos *args, char *name, int type, void *value)
616 {
617  plug_replace_key_len (args, name, type, value, 0);
618 }
619 
620 void
621 scanner_add_port (struct script_infos *args, int port, char *proto)
622 {
623  host_add_port_proto (args, port, proto);
624 }
625 
626 kb_t
627 plug_get_kb (struct script_infos *args)
628 {
629  return args->key;
630 }
631 
632 static void
634 {
635  int status;
636 
637  wait (&status);
638 }
639 
640 static void
641 sig_n (int signo, void (*fnc) (int))
642 {
643  struct sigaction sa;
644 
645  sa.sa_handler = fnc;
646  sa.sa_flags = 0;
647  sigemptyset (&sa.sa_mask);
648  sigaction (signo, &sa, (struct sigaction *) 0);
649 }
650 
651 static void
652 sig_term (void (*fcn) ())
653 {
654  sig_n (SIGTERM, fcn);
655 }
656 
657 static void
658 sig_chld (void (*fcn) ())
659 {
660  sig_n (SIGCHLD, fcn);
661 }
662 
663 static int
665 {
666  pid_t pid;
667 
668  if ((pid = fork ()) == 0)
669  {
670  sig_term (_exit);
671  kb_lnk_reset (kb);
672  nvticache_reset ();
673  srand48 (getpid () + getppid () + time (NULL));
674  return 0;
675  }
676  else if (pid < 0)
677  {
678  g_warning ("%s(): fork() failed (%s)", __func__, strerror (errno));
679  return -1;
680  }
681  else
682  waitpid (pid, NULL, 0);
683  return 1;
684 }
685 
698 void *
699 plug_get_key (struct script_infos *args, char *name, int *type, size_t *len,
700  int single)
701 {
702  kb_t kb = args->key;
703  struct kb_item *res = NULL, *res_list;
704 
705  if (type != NULL && *type != KB_TYPE_INT)
706  *type = -1;
707 
708  if (kb == NULL)
709  return NULL;
710 
711  if (single && *type != KB_TYPE_INT)
712  res = kb_item_get_single (kb, name, KB_TYPE_UNSPEC);
713  else if (*type == KB_TYPE_INT)
714  res = kb_item_get_single (kb, name, KB_TYPE_INT);
715  else
716  res = kb_item_get_all (kb, name);
717 
718  if (res == NULL)
719  return NULL;
720 
721  if (!res->next) /* No fork - good */
722  {
723  void *ret;
724  if (res->type == KB_TYPE_INT)
725  {
726  if (type != NULL)
727  *type = KB_TYPE_INT;
728  ret = g_memdup (&res->v_int, sizeof (res->v_int));
729  }
730  else
731  {
732  if (type != NULL)
733  *type = KB_TYPE_STR;
734  if (len)
735  *len = res->len;
736  ret = g_memdup (res->v_str, res->len + 1);
737  }
738  kb_item_free (res);
739  return ret;
740  }
741 
742  /* More than one value - we will fork() then */
744  res_list = res;
745  while (res)
746  {
747  pid_t pid = plug_fork_child (kb);
748 
749  if (pid == 0)
750  {
751  /* Forked child. */
752  void *ret;
753 
754  if (res->type == KB_TYPE_INT)
755  {
756  if (type != NULL)
757  *type = KB_TYPE_INT;
758  ret = g_memdup (&res->v_int, sizeof (res->v_int));
759  }
760  else
761  {
762  if (type != NULL)
763  *type = KB_TYPE_STR;
764  if (len)
765  *len = res->len;
766  ret = g_memdup (res->v_str, res->len + 1);
767  }
768  kb_item_free (res_list);
769  return ret;
770  }
771  else if (pid == -1)
772  return NULL;
773  res = res->next;
774  }
775  kb_item_free (res_list);
776  exit (0);
777 }
778 
785 unsigned int
787 {
788  kb_t kb = plug_get_kb (desc);
789  struct kb_item *res, *k;
790  int open21 = 0, open80 = 0;
791 #define MAX_CANDIDATES 16
792  u_short candidates[MAX_CANDIDATES];
793  int num_candidates = 0;
794 
795  k = res = kb_item_get_pattern (kb, "Ports/tcp/*");
796  if (res == NULL)
797  return 0;
798  else
799  {
800  int ret;
801  char *s;
802 
803  for (;;)
804  {
805  s = res->name + sizeof ("Ports/tcp/") - 1;
806  ret = atoi (s);
807  if (ret == 21)
808  open21 = 1;
809  else if (ret == 80)
810  open80 = 1;
811  else
812  {
813  candidates[num_candidates++] = ret;
814  if (num_candidates >= MAX_CANDIDATES)
815  break;
816  }
817  res = res->next;
818  if (res == NULL)
819  break;
820  }
821 
822  kb_item_free (k);
823  if (num_candidates != 0)
824  return candidates[lrand48 () % num_candidates];
825  else if (open21)
826  return 21;
827  else if (open80)
828  return 80;
829  }
830 
831  /* Not reachable */
832  return 0;
833 }
834 
840 void
841 plug_set_port_transport (struct script_infos *args, int port, int tr)
842 {
843  char s[256];
844 
845  snprintf (s, sizeof (s), "Transports/TCP/%d", port);
846  plug_set_key (args, s, ARG_INT, GSIZE_TO_POINTER (tr));
847 }
848 
849 /* Return the transport encapsulation mode (OPENVAS_ENCAPS_*) for the
850  given PORT. If no such encapsulation mode has been stored in the
851  knowledge base (or its value is < 0), OPENVAS_ENCAPS_IP is
852  currently returned. */
853 int
854 plug_get_port_transport (struct script_infos *args, int port)
855 {
856  char s[256];
857  int trp;
858 
859  snprintf (s, sizeof (s), "Transports/TCP/%d", port);
860  trp = kb_item_get_int (plug_get_kb (args), s);
861  if (trp >= 0)
862  return trp;
863  else
864  return OPENVAS_ENCAPS_IP; /* Change this to 0 for ultra smart SSL
865  negotiation, at the expense of possibly
866  breaking stuff */
867 }
868 
869 static void
870 plug_set_ssl_item (struct script_infos *args, char *item, char *itemfname)
871 {
872  char s[256];
873  snprintf (s, sizeof (s), "SSL/%s", item);
874  plug_set_key (args, s, ARG_STRING, itemfname);
875 }
876 
877 void
878 plug_set_ssl_cert (struct script_infos *args, char *cert)
879 {
880  plug_set_ssl_item (args, "cert", cert);
881 }
882 
883 void
884 plug_set_ssl_key (struct script_infos *args, char *key)
885 {
886  plug_set_ssl_item (args, "key", key);
887 }
888 
889 void
890 plug_set_ssl_pem_password (struct script_infos *args, char *key)
891 {
892  plug_set_ssl_item (args, "password", key);
893 }
894 
899 void
900 plug_set_ssl_CA_file (struct script_infos *args, char *key)
901 {
902  plug_set_ssl_item (args, "CA", key);
903 }
host_add_port_proto
void host_add_port_proto(struct script_infos *args, int portnum, char *proto)
Definition: plugutils.c:85
script_infos::ip
struct in6_addr * ip
Definition: scanneraux.h:51
plug_set_dep
void plug_set_dep(struct script_infos *args, const char *depname)
Definition: plugutils.c:65
script_infos
Definition: scanneraux.h:43
plug_get_host_source
char * plug_get_host_source(struct script_infos *args, const char *hostname)
Definition: plugutils.c:257
host_get_port_state
int host_get_port_state(struct script_infos *plugdata, int portnum)
Definition: plugutils.c:154
plug_get_port_transport
int plug_get_port_transport(struct script_infos *args, int port)
Definition: plugutils.c:854
plug_replace_key
void plug_replace_key(struct script_infos *args, char *name, int type, void *value)
Definition: plugutils.c:615
post_alarm
void post_alarm(const char *oid, struct script_infos *desc, int port, const char *action)
Definition: plugutils.c:355
plug_get_key
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:699
OPENVAS_ENCAPS_IP
@ OPENVAS_ENCAPS_IP
Definition: network.h:45
plug_get_host_ip
struct in6_addr * plug_get_host_ip(struct script_infos *args)
Definition: plugutils.c:285
scan_globals::files_size_translation
GHashTable * files_size_translation
Definition: scanneraux.h:37
plug_get_kb
kb_t plug_get_kb(struct script_infos *args)
Definition: plugutils.c:627
script_infos::key
kb_t key
Definition: scanneraux.h:46
plug_get_host_fqdn
char * plug_get_host_fqdn(struct script_infos *args)
Definition: plugutils.c:211
plug_set_ssl_key
void plug_set_ssl_key(struct script_infos *args, char *key)
Definition: plugutils.c:884
script_infos::nvti
nvti_t * nvti
Definition: scanneraux.h:47
pid
static pid_t pid
Definition: nasl_builtin_nmap.c:499
plug_set_ssl_CA_file
void plug_set_ssl_CA_file(struct script_infos *args, char *key)
Definition: plugutils.c:900
post_error
void post_error(const char *oid, struct script_infos *desc, int port, const char *action)
Definition: plugutils.c:389
proto_post_error
void proto_post_error(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action)
Definition: plugutils.c:382
get_plugin_preference_file_content
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:510
plug_replace_key_len
void plug_replace_key_len(struct script_infos *args, char *name, int type, void *value, size_t len)
Definition: plugutils.c:592
post_log
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
name
const char * name
Definition: nasl_init.c:377
host_get_port_state_proto
int host_get_port_state_proto(struct script_infos *args, int portnum, char *proto)
Definition: plugutils.c:148
plug_add_host_fqdn
int plug_add_host_fqdn(struct script_infos *args, const char *hostname, const char *source)
Definition: plugutils.c:166
plug_current_vhost
const char * plug_current_vhost(void)
Definition: plugutils.c:57
plug_set_key_len
void plug_set_key_len(struct script_infos *args, char *name, int type, const void *value, size_t len)
Definition: plugutils.c:563
scan_globals::files_translation
GHashTable * files_translation
Definition: scanneraux.h:36
sig_n
static void sig_n(int signo, void(*fnc)(int))
Definition: plugutils.c:641
oid
const char * oid
Definition: nasl_builtin_find_service.c:57
plug_fork_child
static int plug_fork_child(kb_t)
Definition: plugutils.c:664
kb_get_port_state_proto
int kb_get_port_state_proto(kb_t kb, int portnum, char *proto)
Definition: plugutils.c:110
plug_get_host_open_port
unsigned int plug_get_host_open_port(struct script_infos *desc)
Definition: plugutils.c:786
sig_term
static void sig_term(void(*fcn)())
Definition: plugutils.c:652
script_infos::globals
struct scan_globals * globals
Definition: scanneraux.h:45
plug_set_port_transport
void plug_set_port_transport(struct script_infos *args, int port, int tr)
Definition: plugutils.c:841
current_vhost
gvm_vhost_t * current_vhost
Definition: plugutils.c:53
host_get_port_state_udp
int host_get_port_state_udp(struct script_infos *plugdata, int portnum)
Definition: plugutils.c:160
scanner_add_port
void scanner_add_port(struct script_infos *args, int port, char *proto)
Definition: plugutils.c:621
prefix
static void prefix(int n, int i)
Definition: nasl_tree.c:233
scan_globals
Definition: scanneraux.h:32
unscanned_ports_as_closed
static int unscanned_ports_as_closed(port_protocol_t ptype)
Report state of preferences "unscanned_closed".
Definition: plugutils.c:98
plug_get_key_sigchld
static void plug_get_key_sigchld()
Definition: plugutils.c:633
get_plugin_preference_fname
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:455
ARG_INT
#define ARG_INT
Definition: plugutils.h:34
script_infos::vhosts
GSList * vhosts
Definition: scanneraux.h:52
proto_post_wrapped
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
hostname
const char * hostname
Definition: pluginlaunch.c:76
network.h
Header file for module network.
plug_set_ssl_cert
void plug_set_ssl_cert(struct script_infos *args, char *cert)
Definition: plugutils.c:878
plug_set_ssl_pem_password
void plug_set_ssl_pem_password(struct script_infos *args, char *key)
Definition: plugutils.c:890
global_nasl_debug
int global_nasl_debug
Definition: plugutils.c:48
plug_set_key
void plug_set_key(struct script_infos *args, char *name, int type, const void *value)
Definition: plugutils.c:585
get_plugin_preference
char * get_plugin_preference(const char *oid, const char *name)
Definition: plugutils.c:396
get_plugin_preference_file_size
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:541
plugutils.h
Header file for module plugutils.
plug_set_ssl_item
static void plug_set_ssl_item(struct script_infos *args, char *item, char *itemfname)
Definition: plugutils.c:870
plug_get_host_ip_str
char * plug_get_host_ip_str(struct script_infos *desc)
Definition: plugutils.c:291
plug_get_host_fqdn_list
GSList * plug_get_host_fqdn_list(struct script_infos *args)
Definition: plugutils.c:239
ARG_STRING
#define ARG_STRING
Definition: plugutils.h:33
sig_chld
static void sig_chld(void(*fcn)())
Definition: plugutils.c:658
proto_post_log
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
MAX_CANDIDATES
#define MAX_CANDIDATES
proto_post_alarm
void proto_post_alarm(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action)
Definition: plugutils.c:348