Attack a whole network.
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);
static void apply_hosts_preferences(gvm_hosts_t *hosts)
void(*)(int) openvas_signal(int signum, void(*handler)(int))
static void attack_start(struct attack_start_args *args)
Set up some data and jump into attack_host()
plugins_scheduler_t plugins_scheduler_init(const char *plugins_list, int autoload, int only_network, int *error)
static int scan_is_stopped()
int hosts_new(char *name, kb_t kb)
static enum net_scan_status network_scan_status(struct scan_globals *globals)
GHashTable * files_translation
static void handle_scan_stop_signal()
static struct host * hosts
char * network_scan_status
static int check_kb_access()
void plugins_scheduler_free(plugins_scheduler_t sched)
static void error_message_to_client2(kb_t kb, const char *msg, const char *port)
static int apply_source_iface_preference()
int hosts_read(void)
Returns -1 if client asked to stop all tests or connection was lost or error. 0 otherwise.
Host information, implemented as doubly linked list.
struct scan_globals * globals
plugins_scheduler_t sched
int get_max_hosts_number(void)
void(* process_func_t)(void *)
struct timeval timeval(unsigned long val)
static void fork_sleep(int n)
int hosts_init(int max_hosts)
int hosts_set_pid(char *name, pid_t pid)
void attack_network(struct scan_globals *globals, kb_t *network_kb)
Attack a whole network.
static void report_kb_failure(int errcode)
tree_cell * network_targets(lex_ctxt *lexic)
pid_t create_process(process_func_t function, void *argument)
Create a new process (fork).
int get_max_checks_number(void)
static void set_scan_status(char *status)
Set scan status. This helps ospd-openvas to identify if a scan crashed or finished cleanly...