Attack a whole network.
Definition at line 1008 of file attack.c.
1010 int max_hosts = 0, max_checks;
1011 const char *hostlist;
1014 int fork_retries = 0;
1019 gboolean network_phase = FALSE;
1020 gboolean do_network_scan = FALSE;
1024 gettimeofday (&then, NULL);
1026 if (prefs_get_bool (
"network_scan"))
1027 do_network_scan = TRUE;
1029 do_network_scan = FALSE;
1035 if (do_network_scan)
1043 network_phase = FALSE;
1047 network_phase = TRUE;
1051 globals->network_scan_status = g_strdup (
"busy");
1052 network_phase = TRUE;
1063 hostlist = prefs_get (
"TARGET");
1064 if (hostlist == NULL)
1070 port_range = prefs_get (
"port_range");
1071 if (validate_port_range (port_range))
1077 int plugins_init_error = 0;
1079 prefs_get_bool (
"auto_enable_dependencies"),
1080 network_phase, &plugins_init_error);
1083 g_message (
"Couldn't initialize the plugin scheduler");
1087 if (plugins_init_error > 0)
1090 int i = atoi (prefs_get (
"ov_maindbid"));
1091 kb_t main_kb = NULL;
1094 "%d errors were found during the plugin scheduling. "
1095 "Some plugins have not been launched.",
1096 plugins_init_error);
1098 main_kb = kb_direct_conn (prefs_get (
"db_address"), i);
1100 kb_lnk_reset (main_kb);
1111 "WARNING: In network phase, but without targets! Stopping.");
1118 g_message (
"Start a new scan. Target(s) : %s, "
1119 "in network phase with target %s",
1122 rc = kb_new (network_kb, prefs_get (
"db_address"));
1129 kb_lnk_reset (*network_kb);
1133 g_message (
"Starts a new scan. Target(s) : %s, with max_hosts = %d and "
1135 hostlist, max_hosts, max_checks);
1137 hosts = gvm_hosts_new (hostlist);
1138 unresolved = gvm_hosts_resolve (
hosts);
1141 g_warning (
"Couldn't resolve hostname '%s'", (
char *) unresolved->data);
1142 unresolved = unresolved->next;
1144 g_slist_free_full (unresolved, g_free);
1151 gvm_hosts_free (
hosts);
1170 rc = kb_new (&
host_kb, prefs_get (
"db_address"));
1171 if (rc < 0 && rc != -2)
1185 host_str = gvm_host_value_str (
host);
1200 args.net_kb = network_kb;
1212 g_debug (
"fork() failed - %s. %s won't be tested",
1213 strerror (errno), host_str);
1218 g_debug (
"fork() failed - "
1219 "sleeping %d seconds and trying again...",
1242 g_message (
"Test complete");
1248 g_hash_table_destroy (files);
1252 gvm_hosts_free (
hosts);
1258 gettimeofday (&now, NULL);
1259 g_message (
"Total time to scan all hosts : %ld seconds",
1260 now.tv_sec - then.tv_sec);
References apply_hosts_preferences(), apply_source_iface_preference(), attack_network(), attack_start(), check_kb_access(), create_process(), error_message_to_client2(), scan_globals::files_translation, fork_sleep(), get_max_checks_number(), get_max_hosts_number(), attack_start_args::globals, handle_scan_stop_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().