OpenVAS Scanner 23.32.3
nasl_misc_funcs.c
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Greenbone AG
2 * SPDX-FileCopyrightText: 2002-2004 Tenable Network Security
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
11
12#include "nasl_misc_funcs.h"
13
14#include "../misc/ftp_funcs.h" /* for ftp_log_in */
15#include "../misc/heartbeat.h" /* plug_get_host_open_port */
16#include "../misc/network.h" /* read_stream_connection_min */
17#include "../misc/plugutils.h" /* plug_get_host_open_port */
18#include "../misc/vendorversion.h" /* for vendor_version_get */
19#include "byteorder.h"
20#include "exec.h"
21#include "nasl_debug.h"
22#include "nasl_func.h"
23#include "nasl_global_ctxt.h"
24#include "nasl_lex_ctxt.h"
25#include "nasl_packet_forgery.h"
26#include "nasl_tree.h"
27#include "nasl_var.h"
28
29#include <errno.h> /* for errno */
30#include <glib.h>
31#include <gvm/util/compressutils.h> /* for gvm_uncompress */
32#include <gvm/util/kb.h> /* for KB_TYPE_STR */
33#include <stdbool.h> /* for boolean */
34#include <stdlib.h> /* for lrand48 */
35#include <string.h> /* for bzero */
36#include <sys/time.h> /* for gettimeofday */
37#include <unistd.h> /* for usleep */
38
39#define uint32 unsigned int
40
41#define NASL_EXIT_DEPRECATED 66
42#define NASL_EXIT_NOTVULN 99
43
44/*---------------------------------------------------------------------*/
47{
48 (void) lexic;
49 tree_cell *retc;
51 retc->x.i_val = lrand48 ();
52 return retc;
53}
54
55/*---------------------------------------------------------------------*/
58{
59 int slp = get_int_var_by_num (lexic, 0, 0);
60 usleep (slp);
61 return FAKE_CELL;
62}
63
66{
67 int slp = get_int_var_by_num (lexic, 0, 0);
68 sleep (slp);
69 return FAKE_CELL;
70}
71
72/*---------------------------------------------------------------------*/
73
76{
77 char *u, *p;
78 int soc;
79 tree_cell *retc;
80 int res;
81
82 soc = get_int_var_by_name (lexic, "socket", 0);
83 if (soc <= 0)
84 return NULL;
85
86 u = get_str_var_by_name (lexic, "user");
87 if (u == NULL)
88 u = "";
89
90 p = get_str_var_by_name (lexic, "pass");
91 if (p == NULL)
92 p = "";
93
94 res = ftp_log_in (soc, u, p) == 0;
95
97 retc->x.i_val = res;
98
99 return retc;
100}
101
102tree_cell *
104{
105 int soc;
106 struct sockaddr_in addr;
107 tree_cell *retc;
108
109 soc = get_int_var_by_name (lexic, "socket", 0);
110 if (soc <= 0)
111 return NULL;
112
113 bzero (&addr, sizeof (addr));
114 ftp_get_pasv_address (soc, &addr);
115
117 retc->x.i_val = ntohs (addr.sin_port);
118 return retc;
119}
120
121/*---------------------------------------------------------------------*/
122
123tree_cell *
125{
126 int soc = get_int_var_by_num (lexic, 0, -1);
127 int opts; /* number of options recorded */
128 unsigned char buffer[1024];
129#define iac buffer[0]
130#define code buffer[1]
131#define option buffer[2]
132 tree_cell *retc;
133 int n = 0, n2;
134 int lm = 0;
135
136 if (soc <= 0)
137 {
138 nasl_perror (lexic, "Syntax error in the telnet_init() function\n");
139 nasl_perror (lexic,
140 "Correct syntax is : output = telnet_init(<socket>)\n");
141 return NULL;
142 }
143
144 iac = 255;
145 opts = 0;
146 while (iac == 255)
147 {
148 n = read_stream_connection_min (soc, buffer, 3, 3);
149 if ((iac != 255) || (n <= 0) || (n != 3))
150 break;
151 if ((code == 251) || (code == 252))
152 code = 254; /* WILL , WONT -> DON'T */
153 else if ((code == 253) || (code == 254))
154 code = 252; /* DO,DONT -> WONT */
155 write_stream_connection (soc, buffer, 3);
156 if (lm == 0)
157 {
158 code = 253;
159 option = 0x22;
160 write_stream_connection (soc, buffer, 3);
161 lm++;
162 }
163 opts++;
164 if (opts > 100)
165 break;
166 }
167 if (n <= 0)
168 {
169 if (opts == 0)
170 return NULL;
171 else
172 n = 0;
173 }
174
175 if (opts > 100) /* remote telnet server is crazy */
176 {
177 nasl_perror (lexic, "More than 100 options received by telnet_init() "
178 "function! exiting telnet_init.\n");
179 return NULL;
180 }
181
182 n2 = read_stream_connection (soc, buffer + n, sizeof (buffer) - n);
183 if (n2 > 0)
184 n += n2;
186 retc->size = n;
187 retc->x.str_val = g_malloc0 (n + 1);
188 memcpy (retc->x.str_val, buffer, n + 1);
189#undef iac
190#undef data
191#undef option
192
193 return retc;
194}
195
196/*---------------------------------------------------------------------*/
197
198tree_cell *
200{
201 struct script_infos *script_infos = lexic->script_infos;
202 int to = lexic->recv_timeout;
204 int soc;
205 int alive = 0;
206 tree_cell *p;
207
208 if (port)
209 {
211 if (soc >= 0)
212 {
215
216 return FAKE_CELL;
217 }
218 }
219
220 p = nasl_tcp_ping (lexic);
221 if (p != NULL)
222 alive = p->x.i_val;
223
225 deref_cell (p);
226
227 return FAKE_CELL;
228}
229
230tree_cell *
232{
233 int port = lexic->script_infos->denial_port;
234 int soc;
235 int to = lexic->recv_timeout;
236 struct script_infos *script_infos = lexic->script_infos;
237 kb_t kb = plug_get_kb (script_infos);
238 tree_cell *retc = NULL;
239 char *bogus_data;
240
241 /*
242 * We must wait the time the DoS does its effect
243 */
244 sleep (10);
245
246 if (!port)
247 {
248 int ping = script_infos->alive;
249
250 if (ping)
251 return nasl_tcp_ping (lexic);
252 else
253 {
255 retc->x.i_val = 1;
256 return retc;
257 }
258 }
259 else
260 {
262
264 if (soc > 0)
265 {
266 /* Send some data */
267 bogus_data = g_strdup_printf (
268 "Network Security Scan by %s in progress", vendor_version_get ());
269 if ((nsend (soc, bogus_data, strlen (bogus_data), 0)) >= 0)
270 {
271 g_free (bogus_data);
272 retc->x.i_val = 1;
274 return retc;
275 }
276 g_free (bogus_data);
277 }
278 }
279
280 // Services seem to not respond.
281 // Last test with boreas
283 retc->x.i_val = 1;
284 else
285 retc->x.i_val = 0;
286 return retc;
287}
288
289/*---------------------------------------------------------------------*/
290
291tree_cell *
293{
294 dump_ctxt (lexic->up_ctxt);
295 return FAKE_CELL;
296}
297
298static void
299simple_register_host_detail (lex_ctxt *lexic, char *name, char *value)
300{
301 char detail[128];
302 const char *oid = lexic->oid;
303
304 plug_set_key (lexic->script_infos, "HostDetails", ARG_STRING, name);
305 plug_set_key (lexic->script_infos, "HostDetails/NVT", ARG_STRING,
306 (void *) oid);
307
308 g_snprintf (detail, sizeof (detail), "HostDetails/NVT/%s/%s", oid, name);
309 plug_set_key (lexic->script_infos, detail, ARG_STRING, value);
310}
311
312tree_cell *
314{
315 int retcode = get_int_var_by_num (lexic, 0, 0);
317 retc->x.i_val = retcode;
318
319 if (retcode == NASL_EXIT_NOTVULN)
320 simple_register_host_detail (lexic, "EXIT_CODE", "EXIT_NOTVULN");
321
322 // if (retcode == NASL_EXIT_DEPRECATED)
323 // This return code is reserved for future handling.
324
325 while (lexic != NULL)
326 {
327 lexic->ret_val = retc;
328 ref_cell (retc);
329 lexic = lexic->up_ctxt;
330 }
331 return retc;
332}
333
334/*---------------------------------------------------------------------*/
335
336tree_cell *
338{
339 int t;
340 tree_cell *retc;
341
342 t = get_var_type_by_num (lexic, 0);
344 retc->x.i_val = (t == VAR2_UNDEF);
345 return retc;
346}
347
353tree_cell *
355{
356 tree_cell *retc = NULL;
357 int i, j, vi;
358 anon_nasl_var *v;
359 named_nasl_var *vn;
360 nasl_array *a, *a2;
361
363 retc->x.ref_val = a = g_malloc0 (sizeof (nasl_array));
364
365 for (i = vi = 0;
366 (v = nasl_get_var_by_num (lexic, &lexic->ctx_vars, vi, 0)) != NULL; vi++)
367 {
368 switch (v->var_type)
369 {
370 case VAR2_INT:
371 case VAR2_STRING:
372 case VAR2_DATA:
373 add_var_to_list (a, i++, v);
374 break;
375
376 case VAR2_ARRAY:
377 a2 = &v->v.v_arr;
378
379 for (j = 0; j < a2->max_idx; j++)
380 if (add_var_to_list (a, i, a2->num_elt[j]) >= 1)
381 i++;
382
383 if (a2->hash_elt != NULL)
384 {
385 for (j = 0; j < VAR_NAME_HASH; j++)
386 for (vn = a2->hash_elt[j]; vn != NULL; vn = vn->next_var)
387 if (vn->u.var_type != VAR2_UNDEF)
388 if (add_var_to_list (a, i, &vn->u) >= 1)
389 i++;
390 }
391
392 break;
393
394 case VAR2_UNDEF:
395 nasl_perror (lexic,
396 "nasl_make_list: undefined variable #%d skipped\n", i);
397 continue;
398
399 default:
401 lexic, "nasl_make_list: unhandled variable type 0x%x - skipped\n",
402 v->var_type);
403 continue;
404 }
405 }
406
407 return retc;
408}
409
410/*
411 * This function takes any _even_ number of arguments and makes
412 * an array from them. In each pair, the 1st argument is the index, the
413 * 2nd the value.
414 * Illegal types are dropped with a warning
415 */
416
417tree_cell *
419{
420 tree_cell *retc = NULL;
421 int vi;
422 anon_nasl_var *v, *v2;
423 nasl_array *a;
424
426 retc->x.ref_val = a = g_malloc0 (sizeof (nasl_array));
427
428 vi = 0;
429 while ((v = nasl_get_var_by_num (lexic, &lexic->ctx_vars, vi++, 0)) != NULL)
430 {
431 v2 = nasl_get_var_by_num (lexic, &lexic->ctx_vars, vi++, 0);
432 if (v2 == NULL)
433 {
434 nasl_perror (lexic, "make_array: odd number (%d) of argument?\n", vi);
435 break;
436 }
437
438 switch (v2->var_type)
439 {
440 case VAR2_INT:
441 case VAR2_STRING:
442 case VAR2_DATA:
443 switch (v->var_type)
444 {
445 case VAR2_INT:
446 add_var_to_list (a, v->v.v_int, v2);
447 break;
448 case VAR2_STRING:
449 case VAR2_DATA:
450 add_var_to_array (a, (char *) var2str (v), v2);
451 break;
452 }
453 break;
454 case VAR2_UNDEF:
455 default:
456 nasl_perror (lexic, "make_array: bad value type %d for arg #%d\n",
457 v2->var_type, vi);
458 break;
459 }
460 }
461
462 return retc;
463}
464
465tree_cell *
467{
468 tree_cell *retc = NULL;
469 anon_nasl_var *v, myvar;
470 named_nasl_var *vn;
471 nasl_array *a, *a2;
472 int i, j, vi;
473
475 retc->x.ref_val = a2 = g_malloc0 (sizeof (nasl_array));
476
477 bzero (&myvar, sizeof (myvar));
478
479 for (i = vi = 0;
480 (v = nasl_get_var_by_num (lexic, &lexic->ctx_vars, vi, 0)) != NULL; vi++)
481 {
482 if (v->var_type == VAR2_ARRAY)
483 {
484 a = &v->v.v_arr;
485 /* First the numerical index */
486 for (j = 0; j < a->max_idx; j++)
487 if (a->num_elt[j] != NULL && a->num_elt[j]->var_type != VAR2_UNDEF)
488 {
489 myvar.var_type = VAR2_INT;
490 myvar.v.v_int = j;
491 add_var_to_list (a2, i++, &myvar);
492 }
493 /* Then the string index */
494 if (a->hash_elt != NULL)
495 for (j = 0; j < VAR_NAME_HASH; j++)
496 for (vn = a->hash_elt[j]; vn != NULL; vn = vn->next_var)
497 if (vn->u.var_type != VAR2_UNDEF)
498 {
499 myvar.var_type = VAR2_STRING;
500 myvar.v.v_str.s_val = (unsigned char *) vn->var_name;
501 myvar.v.v_str.s_siz = strlen (vn->var_name);
502 add_var_to_list (a2, i++, &myvar);
503 }
504 }
505 else
506 nasl_perror (lexic, "nasl_keys: bad variable #%d skipped\n", vi);
507 }
508
509 return retc;
510}
511
512tree_cell *
514{
515 tree_cell *retc;
516 anon_nasl_var *v;
517 nasl_array *a;
518
519 v = nasl_get_var_by_num (lexic, &lexic->ctx_vars, 0, 0);
520 if (v == NULL)
521 return NULL;
522 if (v->var_type != VAR2_ARRAY)
523 return NULL;
524
525 a = &v->v.v_arr;
526
528 retc->x.i_val = array_max_index (a);
529
530 return retc;
531}
532
533tree_cell *
535{
536 tree_cell *retc;
537 anon_nasl_var *u;
538 const char *s;
539
541 u = nasl_get_var_by_num (lexic, &lexic->ctx_vars, 0, 0);
542
543 if (u == NULL)
544 s = "null";
545 else
546 switch (u->var_type)
547 {
548 case VAR2_UNDEF:
549 s = "undef";
550 break;
551 case VAR2_INT:
552 s = "int";
553 break;
554 case VAR2_STRING:
555 s = "string";
556 break;
557 case VAR2_DATA:
558 s = "data";
559 break;
560 case VAR2_ARRAY:
561 s = "array";
562 break;
563 default:
564 s = "unknown";
565 break;
566 }
567 retc->size = strlen (s);
568 retc->x.str_val = g_strdup (s);
569 return retc;
570}
571
572tree_cell *
574{
575 void *f;
576 char *s;
577 tree_cell *retc;
578
579 s = get_str_var_by_num (lexic, 0);
580 if (s == NULL)
581 {
582 nasl_perror (lexic, "defined_func: missing parameter\n");
583 return NULL;
584 }
585
586 f = get_func_ref_by_name (lexic, s);
588 retc->x.i_val = (f != NULL);
589 return retc;
590}
591
592/* Sorts an array */
593
594static lex_ctxt *mylexic = NULL;
595
596static int
597var_cmp (const void *a, const void *b)
598{
599 anon_nasl_var **pv1 = (anon_nasl_var **) a, **pv2 = (anon_nasl_var **) b;
600 tree_cell *t1, *t2;
601 int ret;
602
603 t1 = var2cell ((anon_nasl_var *) *pv1);
604 t2 = var2cell ((anon_nasl_var *) *pv2);
605 ret = cell_cmp (mylexic, t1, t2);
606 deref_cell (t1);
607 deref_cell (t2);
608
609 return ret;
610}
611
612tree_cell *
614{
615 tree_cell *retc = NULL;
616 nasl_array *a;
617
618 if (mylexic != NULL)
619 {
620 nasl_perror (lexic, "sort: this function is not reentrant!\n");
621 return NULL;
622 }
623 mylexic = lexic;
624 retc = nasl_make_list (lexic);
625 if (retc != NULL)
626 {
627 a = retc->x.ref_val;
628 if (a->num_elt != NULL)
629 {
630 qsort (a->num_elt, a->max_idx, sizeof (a->num_elt[0]), var_cmp);
631 }
632 }
633 mylexic = NULL;
634 return retc;
635}
636
637tree_cell *
639{
640 tree_cell *retc;
641
642 (void) lexic;
644 retc->x.i_val = time (NULL);
645 return retc;
646}
647
648tree_cell *
650{
651 tree_cell *retc;
652 struct timeval t;
653 char str[64];
654
655 if (gettimeofday (&t, NULL) < 0)
656 {
657 nasl_perror (lexic, "gettimeofday: %s\n", strerror (errno));
658 return NULL;
659 }
660 sprintf (str, "%u.%06u", (unsigned int) t.tv_sec, (unsigned int) t.tv_usec);
662 retc->size = strlen (str);
663 retc->x.str_val = g_malloc0 (retc->size);
664 strcpy (retc->x.str_val, str);
665 return retc;
666}
667
668tree_cell *
670{
671 tree_cell *retc;
672 struct tm ptm;
673 time_t tictac;
674 int utc;
675 nasl_array *a;
677 bool success;
678
679 tictac = get_int_var_by_num (lexic, 0, 0);
680 if (tictac == 0)
681 tictac = time (NULL);
682 utc = get_int_var_by_name (lexic, "utc", 0);
683
684 success = true;
685 if (utc)
686 {
687 if (gmtime_r (&tictac, &ptm) == NULL)
688 {
689 success = false;
690 }
691 }
692 else
693 {
694 if (localtime_r (&tictac, &ptm) == NULL)
695 {
696 success = false;
697 }
698 }
699
700 if (!success)
701 {
702 nasl_perror (lexic, "localtime(%d,utc=%d): %s\n", tictac, utc,
703 strerror (errno));
704 return NULL;
705 }
706
708 retc->x.ref_val = a = g_malloc0 (sizeof (nasl_array));
709 memset (&v, 0, sizeof (v));
710 v.var_type = VAR2_INT;
711
712 v.v.v_int = ptm.tm_sec;
713 add_var_to_array (a, "sec", &v); /* seconds */
714 v.v.v_int = ptm.tm_min;
715 add_var_to_array (a, "min", &v); /* minutes */
716 v.v.v_int = ptm.tm_hour;
717 add_var_to_array (a, "hour", &v); /* hours */
718 v.v.v_int = ptm.tm_mday;
719 add_var_to_array (a, "mday", &v); /* day of the month */
720 v.v.v_int = ptm.tm_mon + 1;
721 add_var_to_array (a, "mon", &v); /* month */
722 v.v.v_int = ptm.tm_year + 1900;
723 add_var_to_array (a, "year", &v); /* year */
724 v.v.v_int = ptm.tm_wday;
725 add_var_to_array (a, "wday", &v); /* day of the week */
726 v.v.v_int = ptm.tm_yday + 1;
727 add_var_to_array (a, "yday", &v); /* day in the year */
728 v.v.v_int = ptm.tm_isdst;
729 add_var_to_array (a, "isdst", &v); /* daylight saving time */
730
731 return retc;
732}
733
734tree_cell *
736{
737 struct tm tm;
738 tree_cell *retc;
739 time_t tictac;
740
741 tm.tm_sec = get_int_var_by_name (lexic, "sec", 0); /* seconds */
742 tm.tm_min = get_int_var_by_name (lexic, "min", 0); /* minutes */
743 tm.tm_hour = get_int_var_by_name (lexic, "hour", 0); /* hours */
744 tm.tm_mday = get_int_var_by_name (lexic, "mday", 0); /* day of the month */
745 tm.tm_mon = get_int_var_by_name (lexic, "mon", 1); /* month */
746 tm.tm_mon -= 1;
747 tm.tm_year = get_int_var_by_name (lexic, "year", 0); /* year */
748 if (tm.tm_year >= 1900)
749 tm.tm_year -= 1900;
750 tm.tm_isdst =
751 get_int_var_by_name (lexic, "isdst", -1); /* daylight saving time */
752 errno = 0;
753 tictac = mktime (&tm);
754 if (tictac == (time_t) (-1))
755 {
756 nasl_perror (lexic,
757 "mktime(sec=%02d min=%02d hour=%02d mday=%02d mon=%02d "
758 "year=%04d isdst=%d): %s\n",
759 tm.tm_sec, tm.tm_min, tm.tm_hour, tm.tm_mday, tm.tm_mon + 1,
760 tm.tm_year + 1900, tm.tm_isdst,
761 errno ? strerror (errno) : "invalid value?");
762 return NULL;
763 }
765 retc->x.i_val = tictac;
766 return retc;
767}
768
769tree_cell *
771{
772 tree_cell *retc;
773 int ret, type, forced_type = KB_TYPE_INT;
774 int timeout = 30, tcp = 0;
775 unsigned short port = 88, *port_aux = NULL;
776 char *hostname = NULL, *tcp_str; /* Domain name for windows */
778
779 script_infos = lexic->script_infos;
780
781 hostname = plug_get_key (script_infos, "Secret/kdc_hostname", &type, NULL, 0);
782 if (!hostname || type != KB_TYPE_STR)
783 return NULL;
784
785 port_aux = (unsigned short *) plug_get_key (script_infos, "Secret/kdc_port",
786 &forced_type, NULL, 0);
787 if (port_aux)
788 {
789 port = *port_aux;
790 g_free (port_aux);
791 }
792 if (port <= 0 || forced_type != KB_TYPE_INT)
793 return NULL;
794
795 tcp_str = plug_get_key (script_infos, "Secret/kdc_use_tcp", &type, NULL, 0);
796 tcp = GPOINTER_TO_SIZE (tcp_str);
797 g_free (tcp_str);
798 if (tcp < 0 || type != KB_TYPE_INT)
799 tcp = 0;
800
801 if (tcp == 0)
802 ret = open_sock_opt_hn (hostname, port, SOCK_DGRAM, IPPROTO_UDP, timeout);
803 else
804 ret = open_sock_opt_hn (hostname, port, SOCK_STREAM, IPPROTO_TCP, timeout);
805 g_free (hostname);
806
807 if (ret < 0)
808 return NULL;
809
811 retc->x.i_val = ret;
812 return retc;
813}
814
815tree_cell *
817{
818 tree_cell *retc;
819 void *data, *uncompressed;
820 unsigned long datalen, uncomplen;
821
822 data = get_str_var_by_name (lexic, "data");
823 if (data == NULL)
824 return NULL;
825 datalen = get_var_size_by_name (lexic, "data");
826 if (datalen <= 0)
827 return NULL;
828
829 uncompressed = gvm_uncompress (data, datalen, &uncomplen);
830 if (uncompressed == NULL)
831 return NULL;
832
834 retc->size = uncomplen;
835 retc->x.str_val = uncompressed;
836
837 return retc;
838}
839
840tree_cell *
842{
843 tree_cell *retc;
844 void *data, *compressed, *headerformat;
845 unsigned long datalen, complen;
846
847 data = get_str_var_by_name (lexic, "data");
848 if (data == NULL)
849 return NULL;
850 datalen = get_var_size_by_name (lexic, "data");
851 if (datalen <= 0)
852 return NULL;
853
854 headerformat = get_str_var_by_name (lexic, "headformat");
855 if (!g_strcmp0 (headerformat, "gzip"))
856 {
857 compressed = gvm_compress_gzipheader (data, datalen, &complen);
858 if (compressed == NULL)
859 return NULL;
860 }
861 else
862 {
863 compressed = gvm_compress (data, datalen, &complen);
864 if (compressed == NULL)
865 return NULL;
866 }
867
869 retc->size = complen;
870 retc->x.str_val = compressed;
871
872 return retc;
873}
874
875tree_cell *
877{
878 /*converts integer to 4 byte buffer */
879 (void) lexic;
880 int num = get_int_var_by_name (lexic, "num", -1);
881 if (num == -1)
882 {
883 nasl_perror (lexic, "Syntax : dec2str(num:<n>)\n");
884 return NULL;
885 }
886 char *ret = g_malloc0 (sizeof (num));
887 SIVAL (ret, 0, num);
888 tree_cell *retc;
890 retc->size = sizeof (num);
891 retc->x.str_val = ret;
892 return retc;
893}
894
898tree_cell *
900{
901 (void) lexic;
902 tree_cell *retc;
903 short w = 0x0001;
904 char *p = (char *) &w;
905 int val;
906
907 val = (*p == 1);
908
910 retc->x.i_val = val;
911 return retc;
912}
Unix SMB/CIFS implementation. SMB Byte handling.
#define SIVAL(buf, pos, val)
Definition byteorder.h:117
long int cell_cmp(lex_ctxt *lexic, tree_cell *c1, tree_cell *c2)
Definition exec.c:218
int ftp_get_pasv_address(int soc, struct sockaddr_in *addr)
Definition ftp_funcs.c:101
int ftp_log_in(int soc, char *username, char *passwd)
Definition ftp_funcs.c:17
Header file for module ftp_funcs.
heartbeat.c headerfile.
const char * oid
static struct timeval timeval(unsigned long val)
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition nasl_debug.c:105
nasl_func * get_func_ref_by_name(lex_ctxt *ctxt, const char *name)
Definition nasl_func.c:82
const char * name
Definition nasl_init.c:439
const char * val
Definition nasl_init.c:440
void dump_ctxt(lex_ctxt *c)
int get_var_type_by_num(lex_ctxt *, int)
Returns NASL variable/cell type, VAR2_UNDEF if value is NULL.
Definition nasl_var.c:1155
struct struct_lex_ctxt lex_ctxt
int get_var_size_by_name(lex_ctxt *, const char *)
Definition nasl_var.c:1138
char * get_str_var_by_name(lex_ctxt *, const char *)
Definition nasl_var.c:1118
char * get_str_var_by_num(lex_ctxt *, int)
Definition nasl_var.c:1108
long int get_int_var_by_num(lex_ctxt *, int, int)
Definition nasl_var.c:1094
long int get_int_var_by_name(lex_ctxt *, const char *, int)
Definition nasl_var.c:1101
tree_cell * nasl_telnet_init(lex_ctxt *lexic)
tree_cell * nasl_rand(lex_ctxt *lexic)
tree_cell * nasl_localtime(lex_ctxt *lexic)
static void simple_register_host_detail(lex_ctxt *lexic, char *name, char *value)
tree_cell * nasl_ftp_get_pasv_address(lex_ctxt *lexic)
tree_cell * nasl_unixtime(lex_ctxt *lexic)
tree_cell * nasl_make_list(lex_ctxt *lexic)
tree_cell * nasl_mktime(lex_ctxt *lexic)
tree_cell * nasl_dec2str(lex_ctxt *lexic)
tree_cell * nasl_sleep(lex_ctxt *lexic)
tree_cell * nasl_isnull(lex_ctxt *lexic)
tree_cell * nasl_dump_ctxt(lex_ctxt *lexic)
tree_cell * nasl_open_sock_kdc(lex_ctxt *lexic)
#define code
static int var_cmp(const void *a, const void *b)
tree_cell * nasl_gunzip(lex_ctxt *lexic)
tree_cell * nasl_defined_func(lex_ctxt *lexic)
tree_cell * nasl_keys(lex_ctxt *lexic)
tree_cell * nasl_do_exit(lex_ctxt *lexic)
#define NASL_EXIT_NOTVULN
tree_cell * nasl_typeof(lex_ctxt *lexic)
tree_cell * nasl_get_byte_order(lex_ctxt *lexic)
tree_cell * nasl_start_denial(lex_ctxt *lexic)
tree_cell * nasl_end_denial(lex_ctxt *lexic)
tree_cell * nasl_sort_array(lex_ctxt *lexic)
tree_cell * nasl_gzip(lex_ctxt *lexic)
tree_cell * nasl_ftp_log_in(lex_ctxt *lexic)
tree_cell * nasl_usleep(lex_ctxt *lexic)
#define iac
tree_cell * nasl_max_index(lex_ctxt *lexic)
#define option
tree_cell * nasl_make_array(lex_ctxt *lexic)
static lex_ctxt * mylexic
tree_cell * nasl_gettimeofday(lex_ctxt *lexic)
tree_cell * nasl_tcp_ping(lex_ctxt *lexic)
Launches a “TCP ping” against the target host.
void ref_cell(tree_cell *c)
Definition nasl_tree.c:164
tree_cell * alloc_typed_cell(int typ)
Definition nasl_tree.c:25
void deref_cell(tree_cell *c)
Definition nasl_tree.c:178
@ CONST_DATA
Definition nasl_tree.h:82
@ DYN_ARRAY
Definition nasl_tree.h:90
@ CONST_INT
Definition nasl_tree.h:79
struct TC tree_cell
#define FAKE_CELL
Definition nasl_tree.h:110
int add_var_to_array(nasl_array *a, char *name, const anon_nasl_var *v)
Definition nasl_var.c:1277
const char * var2str(anon_nasl_var *v)
Definition nasl_var.c:1062
anon_nasl_var * nasl_get_var_by_num(void *ctxt, nasl_array *a, int num, int create)
Definition nasl_var.c:43
int array_max_index(nasl_array *a)
Definition nasl_var.c:1302
int add_var_to_list(nasl_array *a, int i, const anon_nasl_var *v)
Definition nasl_var.c:1245
tree_cell * var2cell(anon_nasl_var *v)
Definition nasl_var.c:168
struct st_a_nasl_var anon_nasl_var
#define VAR_NAME_HASH
Definition nasl_var.h:22
struct st_nasl_array nasl_array
@ VAR2_STRING
Definition nasl_var.h:17
@ VAR2_DATA
Definition nasl_var.h:18
@ VAR2_ARRAY
Definition nasl_var.h:19
@ VAR2_INT
Definition nasl_var.h:16
@ VAR2_UNDEF
Definition nasl_var.h:15
struct st_n_nasl_var named_nasl_var
int open_sock_opt_hn(const char *hostname, unsigned int port, int type, int protocol, int timeout)
Definition network.c:1890
int nsend(int fd, void *data, int length, int i_opt)
Definition network.c:1589
int read_stream_connection_min(int fd, void *buf0, int min_len, int max_len)
Definition network.c:1397
int read_stream_connection(int fd, void *buf0, int len)
Definition network.c:1457
int write_stream_connection(int fd, void *buf0, int n)
Definition network.c:1583
int open_stream_connection(struct script_infos *args, unsigned int port, int transport, int timeout)
Definition network.c:1175
int close_stream_connection(int fd)
Definition network.c:1705
Header file for module network.
@ OPENVAS_ENCAPS_IP
Definition network.h:31
const char * hostname
unsigned int plug_get_host_open_port(struct script_infos *desc)
Definition plugutils.c:1323
const char * plug_current_vhost(void)
Definition plugutils.c:93
void plug_set_key(struct script_infos *args, char *name, int type, const void *value)
Definition plugutils.c:1055
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:1226
kb_t plug_get_kb(struct script_infos *args)
Definition plugutils.c:1152
Header file for module plugutils.
#define ARG_STRING
Definition plugutils.h:19
int size
Definition nasl_tree.h:99
long int i_val
Definition nasl_tree.h:104
union TC::@332262321161220155002104006201360276211317150140 x
char * str_val
Definition nasl_tree.h:103
void * ref_val
Definition nasl_tree.h:105
nasl_string_t v_str
Definition nasl_var.h:47
nasl_array v_arr
Definition nasl_var.h:49
union st_a_nasl_var::@154137074032032170165360023270032033276061363156 v
long int v_int
Definition nasl_var.h:48
char * var_name
Definition nasl_var.h:58
struct st_n_nasl_var * next_var
Definition nasl_var.h:62
struct st_a_nasl_var u
Definition nasl_var.h:56
struct st_n_nasl_var ** hash_elt
Definition nasl_var.h:36
struct st_a_nasl_var ** num_elt
Definition nasl_var.h:35
unsigned char * s_val
Definition nasl_var.h:26
nasl_array ctx_vars
struct script_infos * script_infos
tree_cell * ret_val
const char * oid
struct struct_lex_ctxt * up_ctxt
int check_host_still_alive(kb_t, const char *)
Check if the hosts is still alive and set it as dead if not.
Definition heartbeat.c:33
const gchar * vendor_version_get()
Get vendor version.
Header file: vendor version functions prototypes.