|
OpenVAS Scanner 23.32.3
|
A bunch of miscellaneous functions, mostly file conversions. More...
#include "utils.h"#include "../misc/plugutils.h"#include "../misc/scanneraux.h"#include "base/networking.h"#include <errno.h>#include <fcntl.h>#include <gvm/base/prefs.h>#include <gvm/boreas/cli.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/ioctl.h>#include <sys/wait.h>
Go to the source code of this file.
Macros | |
| #define | G_LOG_DOMAIN "sd main" |
| GLib log domain. | |
Functions | |
| static void | files_add_translation (struct scan_globals *globals, const char *file_hash, char *contents) |
| Adds a 'translation' entry for a file sent by the client. | |
| static void | files_add_size_translation (struct scan_globals *globals, const char *file_hash, const long filesize) |
| Adds a 'content size' entry for a file sent by the client. | |
| int | store_file (struct scan_globals *globals, const char *file, const char *file_hash) |
| Stores a file type preference in a hash table. | |
| int | get_max_hosts_number (void) |
| int | get_max_checks_number (void) |
| int | process_alive (pid_t pid) |
| int | data_left (int soc) |
| void | wait_for_children1 (void) |
| int | is_scanner_only_pref (const char *pref) |
| void | write_script_stats (const char *buf, const char *path, int mode) |
| Writes scripts stats into a file. | |
| void | write_host_stats (kb_t kb, const char *scan_id, const char *ip) |
| Reads the script stats from the kb and generate a string in json format to be stored in the disk. | |
Variables | |
| int | global_max_hosts |
| int | global_max_checks |
A bunch of miscellaneous functions, mostly file conversions.
Definition in file utils.c.
| int data_left | ( | int | soc | ) |
|
static |
Adds a 'content size' entry for a file sent by the client.
Files sent by the client are stored in memory on the server side. Because they may be binary we need to store the size of the uploaded file as well. This function sets up a mapping from the original name sent by the client to the file size.
| globals | Global struct. |
| file_hash | hash to reference the file. |
| filesize | Size of the file in bytes. |
Definition at line 78 of file utils.c.
References scan_globals::files_size_translation.
Referenced by store_file().

|
static |
Adds a 'translation' entry for a file sent by the client.
Files sent by the client are stored in memory on the server side. In order to access these files, their original name ('local' to the client) can be 'translated' into the file contents of the in-memory copy of the file on the server side.
| globals | Global struct. |
| file_hash | hash to reference the file. |
| contents | Contents of the file. |
Definition at line 51 of file utils.c.
References scan_globals::files_translation.
Referenced by store_file().

| int get_max_checks_number | ( | void | ) |
Get the max number of plugins to launch against the remote host at the same time
Definition at line 168 of file utils.c.
References global_max_checks.
Referenced by attack_network(), and pluginlaunch_init().

| int get_max_hosts_number | ( | void | ) |
Get the max number of hosts to test at the same time.
Definition at line 137 of file utils.c.
References global_max_hosts.
Referenced by attack_network().

| int is_scanner_only_pref | ( | const char * | pref | ) |
Definition at line 238 of file utils.c.
Referenced by overwrite_openvas_prefs_with_prefs_from_client().

| int process_alive | ( | pid_t | pid | ) |
Determines if a process is alive - as reliably as we can
Definition at line 198 of file utils.c.
References pid.
Referenced by attack_host(), next_free_process(), and update_running_processes().

| int store_file | ( | struct scan_globals * | globals, |
| const char * | file, | ||
| const char * | file_hash ) |
Stores a file type preference in a hash table.
| globals | Global struct. |
| file | File content. |
| file_hash | hash to reference the file. |
Definition at line 104 of file utils.c.
References files_add_size_translation(), and files_add_translation().
Referenced by overwrite_openvas_prefs_with_prefs_from_client().


| void wait_for_children1 | ( | void | ) |
| void write_host_stats | ( | kb_t | kb, |
| const char * | scan_id, | ||
| const char * | ip ) |
Reads the script stats from the kb and generate a string in json format to be stored in the disk.
| kb | the host knowledge base to get the information from. |
| scan_id | Scan ID for the file name. |
| ip | target IP address. |
Definition at line 308 of file utils.c.
References scan_id, and write_script_stats().
Referenced by attack_host().


| void write_script_stats | ( | const char * | buf, |
| const char * | path, | ||
| int | mode ) |
Writes scripts stats into a file.
| buf | String to write. |
| path | Path to the file to write into. |
| mode | 2 to create the file, 0 to append text to the file, 1 to finish the json list removing the trailing comma before appending the last text in the buffer. |
Definition at line 271 of file utils.c.
Referenced by attack_network(), and write_host_stats().

|
extern |
Definition at line 85 of file openvas.c.
Referenced by get_max_checks_number(), and set_globals_from_preferences().
|
extern |
Globals that should not be touched (used in utils module).
Definition at line 84 of file openvas.c.
Referenced by get_max_hosts_number(), and set_globals_from_preferences().