OpenVAS Scanner
21.4.1
|
Launches the plugins, and manages multithreading. More...
#include "attack.h"
#include "../misc/network.h"
#include "../misc/nvt_categories.h"
#include "../misc/pcap_openvas.h"
#include "../nasl/nasl_debug.h"
#include "hosts.h"
#include "pluginlaunch.h"
#include "pluginload.h"
#include "pluginscheduler.h"
#include "plugs_req.h"
#include "processes.h"
#include "sighand.h"
#include "utils.h"
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <glib.h>
#include <gvm/base/hosts.h>
#include <gvm/base/networking.h>
#include <gvm/base/prefs.h>
#include <gvm/base/proctitle.h>
#include <gvm/boreas/alivedetection.h>
#include <gvm/boreas/boreas_io.h>
#include <gvm/util/nvticache.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
Data Structures | |
struct | attack_start_args |
Macros | |
#define | ERR_HOST_DEAD -1 |
#define | ERR_CANT_FORK -2 |
#define | MAX_FORK_RETRIES 10 |
#define | KB_RETRY_DELAY 3 /*In sec*/ |
#define | PROGRESS_BAR_STYLE 1 |
#define | INVALID_TARGET_LIST "-1" |
#define | G_LOG_DOMAIN "sd main" |
GLib log domain. More... | |
Functions | |
static int | connect_main_kb (kb_t *main_kb) |
Connect to the main kb. Must be released with kb_lnk_reset() after use. More... | |
static void | set_kb_readable (int host_kb_index) |
Add the Host KB index to the list of readable KBs used by ospd-openvas. More... | |
static void | set_scan_status (char *status) |
Set scan status. This helps ospd-openvas to identify if a scan crashed or finished cleanly. More... | |
static int | comm_send_status (kb_t main_kb, char *hostname, int curr, int max) |
Sends the status of a host's scan. More... | |
static void | message_to_client (kb_t kb, const char *msg, const char *ip_str, const char *port, const char *type) |
static void | report_kb_failure (int errcode) |
static void | fork_sleep (int n) |
static void | scan_stop_cleanup (void) |
static int | scan_is_stopped (void) |
static int | nvti_category_is_safe (int category) |
Checks that an NVT category is safe. More... | |
static int | get_check_new_vhosts_flag (void) |
Return check_new_vhosts_flag. After reading must be clean with unset_check_new_vhosts_flag(), to avoid fetching unnecessarily. More... | |
static void | set_check_new_vhosts_flag () |
Set global check_new_vhosts_flag to indicate that new vhosts must be fetched. More... | |
static void | unset_check_new_vhosts_flag (void) |
Unset global check_new_vhosts_flag. Must be called once the vhosts have been fetched. More... | |
static void | check_new_vhosts (void) |
Check if a plugin process pushed a new vhost value. More... | |
static int | launch_plugin (struct scan_globals *globals, struct scheduler_plugin *plugin, struct in6_addr *ip, GSList *vhosts, kb_t kb, kb_t main_kb) |
Launches a nvt. Respects safe check preference (i.e. does not try. More... | |
static void | attack_host (struct scan_globals *globals, struct in6_addr *ip, GSList *vhosts, plugins_scheduler_t sched, kb_t kb, kb_t main_kb) |
Attack one host. More... | |
static int | host_authorized (const gvm_host_t *host, const struct in6_addr *addr, const gvm_hosts_t *hosts_allow, const gvm_hosts_t *hosts_deny) |
static char * | vhosts_to_str (GSList *list) |
static void | check_deprecated_prefs () |
Check if any deprecated prefs are in pref table and print warning. More... | |
static int | check_host_authorization (gvm_host_t *host, const struct in6_addr *addr) |
static void | attack_start (struct attack_start_args *args) |
Set up some data and jump into attack_host() More... | |
static void | apply_hosts_excluded (gvm_hosts_t *hosts) |
static void | apply_hosts_preferences_ordering (gvm_hosts_t *hosts) |
static void | apply_hosts_reverse_lookup_preferences (gvm_hosts_t *hosts) |
static int | str_in_comma_list (const char *str, const char *comma_list) |
static int | iface_authorized (const char *iface) |
static int | apply_source_iface_preference (void) |
static int | check_kb_access (void) |
static void | set_alive_detection_tid (pthread_t tid) |
static pthread_t | get_alive_detection_tid () |
static gboolean | ad_thread_joined (gboolean joined) |
Set and get if alive detection thread was already joined by main thread. More... | |
static void | handle_scan_stop_signal () |
void | attack_network (struct scan_globals *globals) |
Attack a whole network. More... | |
Variables | |
int | global_scan_stop = 0 |
static kb_t | host_kb = NULL |
static GSList * | host_vhosts = NULL |
static int | check_new_vhosts_flag = 0 |
static pthread_t | alive_detection_tid |
Launches the plugins, and manages multithreading.
#define ERR_CANT_FORK -2 |
#define ERR_HOST_DEAD -1 |
#define G_LOG_DOMAIN "sd main" |
GLib log domain.
#define INVALID_TARGET_LIST "-1" |
Define value to be sent to the client for invalid target list.
#define KB_RETRY_DELAY 3 /*In sec*/ |
Wait KB_RETRY_DELAY seconds until trying again to get a new kb.
#define MAX_FORK_RETRIES 10 |
#define PROGRESS_BAR_STYLE 1 |
It switches progress bar styles. If set to 1, time oriented style and it take into account only alive host. If set to 0, it not reflect progress adequately in case of dead host, which will take into account with 0% processed, producing jumps in the process bar.
|
static |
Set and get if alive detection thread was already joined by main thread.
The status can only be set to TRUE once in the lifetime of the program and retrieved as often as needed. After it is set to TRUE it can not be unset.
joined | TRUE to set status to joined and FALSE to retrieve status of join. |
|
static |
|
static |
|
static |
|
static |
|
static |
Attack one host.
void attack_network | ( | struct scan_globals * | globals | ) |
Attack a whole network.
|
static |
Set up some data and jump into attack_host()
|
static |
Check if any deprecated prefs are in pref table and print warning.
|
static |
|
static |
|
static |
Check if a plugin process pushed a new vhost value.
kb | Host scan KB. |
vhosts | List of vhosts to add new vhosts to. |
|
static |
Sends the status of a host's scan.
|
static |
Connect to the main kb. Must be released with kb_lnk_reset() after use.
[out] | main_kb | The connection to the kb. |
|
static |
|
static |
|
static |
Return check_new_vhosts_flag. After reading must be clean with unset_check_new_vhosts_flag(), to avoid fetching unnecessarily.
|
static |
|
static |
|
static |
|
static |
Launches a nvt. Respects safe check preference (i.e. does not try.
destructive nvt if save_checks is yes).
Does not launch a plugin twice if !save_kb_replay.
|
static |
|
static |
Checks that an NVT category is safe.
category | Category to check. |
|
static |
|
static |
|
static |
|
static |
|
static |
Set global check_new_vhosts_flag to indicate that new vhosts must be fetched.
|
static |
Add the Host KB index to the list of readable KBs used by ospd-openvas.
|
static |
Set scan status. This helps ospd-openvas to identify if a scan crashed or finished cleanly.
[in] | status | Status to set. |
|
static |
|
static |
Unset global check_new_vhosts_flag. Must be called once the vhosts have been fetched.
|
static |
|
static |
|
static |
int global_scan_stop = 0 |
|
static |
|
static |