OpenVAS Scanner
7.0.0~git
|
Header file for built-in plugins.
More...
Go to the source code of this file.
Header file for built-in plugins.
Definition in file nasl_builtin_plugins.h.
◆ plugin_run_find_service()
Definition at line 2373 of file nasl_builtin_find_service.c.
2380 struct kb_item *kbitem, *kbitem_tmp;
2395 if (key && key[0] !=
'\0')
2400 if (cert && cert[0] !=
'\0')
2405 if (cafile && cafile[0] !=
'\0')
2410 if (test_ssl_s != NULL)
2412 if (strcmp (test_ssl_s,
"None") == 0)
2415 g_free (test_ssl_s);
2425 if (pempass != NULL)
2433 if (num_sons_s != NULL)
2434 num_sons = atoi (num_sons_s);
2435 g_free (num_sons_s);
2443 for (i = 0; i < num_sons; i++)
2446 sons_args[i] = NULL;
2452 kbitem = kb_item_get_pattern (kb,
"Ports/tcp/*");
2455 kbitem_tmp = kbitem;
2456 while (kbitem_tmp != NULL)
2459 kbitem_tmp = kbitem_tmp->next;
2462 port_per_son = num_ports / num_sons;
2467 kbitem_tmp = kbitem;
2469 for (i = 0; i < num_sons; i = i + 1)
2473 if (kbitem_tmp != NULL)
2475 for (j = 0; j < port_per_son && kbitem_tmp != NULL;)
2478 g_slist_prepend (sons_args[i], g_strdup (kbitem_tmp->name));
2480 kbitem_tmp = kbitem_tmp->next;
2487 for (i = 0; (i < num_ports % num_sons) && kbitem_tmp != NULL;)
2490 g_slist_prepend (sons_args[i], g_strdup (kbitem_tmp->name));
2492 kbitem_tmp = kbitem_tmp->next;
2495 kb_item_free (kbitem);
2497 for (i = 0; i < num_sons; i++)
2498 if (sons_args[i] == NULL)
2503 for (i = 0; i < num_sons; i++)
2506 if (sons_args[i] != NULL)
2513 signal (SIGTERM, _exit);
2522 g_slist_free_full (sons_args[i], g_free);
2530 for (i = 0; i < num_sons; i++)
2534 while (waitpid (
sons[i], NULL, WNOHANG) && errno == EINTR)
2537 if (kill (
sons[i], 0) >= 0)
References CA_FILE, CERT_FILE, get_plugin_preference(), get_plugin_preference_fname(), KEY_FILE, MAX_SONS, NUM_CHILDREN, struct_lex_ctxt::oid, oid, PEM_PASS, plug_get_kb(), plug_set_ssl_CA_file(), plug_set_ssl_cert(), plug_set_ssl_key(), plug_set_ssl_pem_password(), plugin_do_run(), struct_lex_ctxt::script_infos, sigchld(), sigterm(), sons, and TEST_SSL_PREF.
◆ plugin_run_nmap()
◆ plugin_run_openvas_tcp_scanner()
Definition at line 1060 of file nasl_builtin_openvas_tcp_scanner.c.
1063 const char *port_range = prefs_get (
"port_range");
1065 struct in6_addr *p_addr;
1066 unsigned int timeout = 0, max_cnx, min_cnx, x;
1069 p = prefs_get (
"checks_read_timeout");
1075 int max_host = 0, max_checks = 0, cur_sys_fd = 0, max_sys_fd = 0;
1079 double loadavg[3], maxloadavg = -1.0;
1080 int stderr_fd = dup (2);
1081 int devnull_fd = open (
"/dev/null", O_WRONLY);
1083 if (devnull_fd <= 0)
1085 if (stderr_fd != -1)
1089 dup2 (devnull_fd, 2);
1091 p = prefs_get (
"max_hosts");
1093 max_host = atoi (p);
1097 p = prefs_get (
"max_checks");
1099 max_checks = atoi (p);
1100 if (max_checks <= 0 || max_checks > 5)
1103 g_debug (
"openvas_tcp_scanner: max_checks forced to %d", max_checks);
1106 min_cnx = 8 * max_checks;
1108 max_cnx = 24 * max_checks;
1110 max_cnx = 80 * max_checks;
1112 getloadavg (loadavg, 3);
1113 for (i = 0; i < 3; i++)
1114 if (loadavg[i] > maxloadavg)
1115 maxloadavg = loadavg[i];
1117 if (max_sys_fd <= 0)
1119 fp = popen (
"sysctl fs.file-nr",
"r");
1122 if (fscanf (fp,
"%*s = %*d %d %d", &cur_sys_fd, &max_sys_fd) == 1)
1123 max_sys_fd -= cur_sys_fd;
1129 if (max_sys_fd <= 0)
1131 fp = popen (
"sysctl fs.file-max",
"r");
1134 if (fscanf (fp,
"%*s = %d", &max_sys_fd) < 1)
1140 if (max_sys_fd <= 0)
1142 fp = popen (
"sysctl kern.maxfiles",
"r");
1145 if (fscanf (fp,
"%*s = %d", &max_sys_fd) < 1)
1153 dup2 (stderr_fd, 2);
1156 if (maxloadavg >= 0.0)
1157 max_cnx /= (1.0 + maxloadavg);
1159 if (max_sys_fd <= 0)
1162 if (max_sys_fd < 1024)
1167 x = max_sys_fd / max_host;
1179 if (getrlimit (RLIMIT_NOFILE, &rlim) < 0)
1180 perror (
"getrlimit(RLIMIT_NOFILE)");
1184 if (rlim.rlim_cur != RLIM_INFINITY && max_cnx >= rlim.rlim_cur)
1185 max_cnx = rlim.rlim_cur - 1;
1189 min_cnx = x > 0 ? x : 1;
1195 if (
banner_grab (p_addr, port_range, timeout, min_cnx, max_cnx, desc) < 0)
References ARG_INT, banner_grab(), GRAB_MAX_SOCK, GRAB_MAX_SOCK_SAFE, GRAB_MIN_SOCK, script_infos::ip, plug_set_key(), safe_checks(), and struct_lex_ctxt::script_infos.
◆ plugin_run_synscan()
struct in6_addr * plug_get_host_ip(struct script_infos *args)
kb_t plug_get_kb(struct script_infos *args)
static pid_t sons[MAX_SONS]
#define GRAB_MAX_SOCK_SAFE
static void nmap_destroy(nmap_t *nmap)
Release a nmap handler and associated resources.
void plug_set_ssl_key(struct script_infos *args, char *key)
static int plugin_do_run(struct script_infos *desc, GSList *h, int test_ssl)
void plug_set_ssl_CA_file(struct script_infos *args, char *key)
static nmap_t * nmap_create(lex_ctxt *lexic)
Instantiate a new nmap handler, rebuild command line or open XML file to parse.
Main nmap execution handler.
int scan(struct script_infos *env, char *portrange, struct in6_addr *dst6, unsigned long rtt)
static int nmap_run_and_parse(nmap_t *nmap)
Run nmap and parse its XML output (or load an external file if requested).
int islocalhost(struct in_addr *addr)
Tests whether a packet sent to IP is LIKELY to route through the kernel localhost interface.
tree_cell * safe_checks(lex_ctxt *lexic)
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".
static void sigterm(int s)
void plug_set_ssl_cert(struct script_infos *args, char *cert)
void plug_set_ssl_pem_password(struct script_infos *args, char *key)
void plug_set_key(struct script_infos *args, char *name, int type, const void *value)
char * get_plugin_preference(const char *oid, const char *name)
static int banner_grab(const struct in6_addr *pia, const char *portrange, const int read_timeout, int min_cnx, int max_cnx, struct script_infos *desc)
static void sigchld(int s)