Attack a whole network.
Definition at line 977 of file attack.c.
979 int max_hosts = 0, max_checks;
980 const char *hostlist;
983 int fork_retries = 0;
988 gboolean network_phase = FALSE;
989 gboolean do_network_scan = FALSE;
993 gettimeofday (&then, NULL);
995 if (prefs_get_bool (
"network_scan"))
996 do_network_scan = TRUE;
998 do_network_scan = FALSE;
1004 if (do_network_scan)
1012 network_phase = FALSE;
1016 network_phase = TRUE;
1020 globals->network_scan_status = g_strdup (
"busy");
1021 network_phase = TRUE;
1032 hostlist = prefs_get (
"TARGET");
1033 if (hostlist == NULL)
1039 port_range = prefs_get (
"port_range");
1040 if (validate_port_range (port_range))
1047 prefs_get_bool (
"auto_enable_dependencies"),
1051 g_message (
"Couldn't initialize the plugin scheduler");
1063 "WARNING: In network phase, but without targets! Stopping.");
1070 g_message (
"Start a new scan. Target(s) : %s, "
1071 "in network phase with target %s",
1074 rc = kb_new (network_kb, prefs_get (
"db_address"));
1081 kb_lnk_reset (*network_kb);
1085 g_message (
"Starts a new scan. Target(s) : %s, with max_hosts = %d and "
1087 hostlist, max_hosts, max_checks);
1089 hosts = gvm_hosts_new (hostlist);
1090 unresolved = gvm_hosts_resolve (
hosts);
1093 g_warning (
"Couldn't resolve hostname '%s'", (
char *) unresolved->data);
1094 unresolved = unresolved->next;
1096 g_slist_free_full (unresolved, g_free);
1103 gvm_hosts_free (
hosts);
1123 rc = kb_new (&
host_kb, prefs_get (
"db_address"));
1124 if (rc < 0 && rc != -2)
1138 host_str = gvm_host_value_str (
host);
1153 args.net_kb = network_kb;
1165 g_debug (
"fork() failed - %s. %s won't be tested",
1166 strerror (errno), host_str);
1171 g_debug (
"fork() failed - "
1172 "sleeping %d seconds and trying again...",
1195 g_message (
"Test complete");
1202 g_hash_table_destroy (files);
1210 gvm_hosts_free (
hosts);
1216 gettimeofday (&now, NULL);
1217 g_message (
"Total time to scan all hosts : %ld seconds",
1218 now.tv_sec - then.tv_sec);
References all_scans_are_stopped(), apply_hosts_preferences(), apply_source_iface_preference(), attack_network(), attack_start(), check_kb_access(), create_process(), scan_globals::files_translation, fork_sleep(), get_max_checks_number(), get_max_hosts_number(), attack_start_args::globals, handle_scan_stop_signal(), handle_stop_all_scans_signal(), attack_start_args::host, attack_start_args::host_kb, host_kb, hosts, hosts_init(), hosts_new(), hosts_read(), hosts_set_pid(), KB_RETRY_DELAY, MAX_FORK_RETRIES, attack_start_args::net_kb, scan_globals::network_scan_status, network_scan_status(), scan_globals::network_targets, network_targets(), NSS_BUSY, NSS_DONE, openvas_signal, pid, plugins_scheduler_free(), plugins_scheduler_init(), report_kb_failure(), scan_is_stopped(), attack_start_args::sched, set_scan_status(), and timeval().
Referenced by attack_network(), and handle_client().