OpenVAS Scanner  22.7.9
plugutils.h File Reference

Header file for module plugutils. More...

#include "scanneraux.h"
#include <gvm/base/nvti.h>
Include dependency graph for plugutils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ARG_STRING   1
 
#define ARG_INT   2
 
#define post_alarm_tcp   post_alarm
 
#define post_error_tcp   post_error
 
#define post_log_tcp   post_log
 

Enumerations

enum  msg_t {
  ERRMSG, HOST_START, HOST_END, LOG,
  HOST_DETAIL, ALARM, DEADHOST, HOSTS_COUNT
}
 

Functions

void scanner_add_port (struct script_infos *, int, char *)
 
void plug_set_dep (struct script_infos *, const char *)
 
void plug_set_ssl_cert (struct script_infos *, char *)
 
void plug_set_ssl_key (struct script_infos *, char *)
 
void plug_set_ssl_pem_password (struct script_infos *, char *)
 
void plug_set_ssl_CA_file (struct script_infos *, char *)
 
const char * plug_current_vhost (void)
 
char * plug_get_host_fqdn (struct script_infos *)
 
int plug_add_host_fqdn (struct script_infos *, const char *, const char *)
 
GSList * plug_get_host_fqdn_list (struct script_infos *)
 
char * plug_get_host_source (struct script_infos *, const char *)
 
unsigned int plug_get_host_open_port (struct script_infos *desc)
 
void plug_set_port_transport (struct script_infos *, int, int)
 
int plug_get_port_transport (struct script_infos *, int)
 
struct script_infosplug_create_from_nvti_and_prefs (const nvti_t *)
 
void proto_post_alarm (const char *, struct script_infos *, int, const char *, const char *, const char *)
 
void post_alarm (const char *, struct script_infos *, int, const char *, const char *)
 
void post_alarm_udp (struct script_infos *, int, const char *, const char *)
 
void proto_post_error (const char *, struct script_infos *, int, const char *, const char *, const char *)
 
void post_error (const char *, struct script_infos *, int, const char *, const char *)
 
void proto_post_log (const char *, struct script_infos *, int, const char *, const char *, const char *)
 Post a log message. More...
 
void post_log (const char *, struct script_infos *, int, const char *)
 Post a log message about a tcp port. More...
 
void post_log_with_uri (const char *, struct script_infos *, int, const char *, const char *)
 Post a log message about a tcp port with a uri. More...
 
int host_get_port_state (struct script_infos *, int)
 
int host_get_port_state_udp (struct script_infos *, int)
 
int check_kb_inconsistency (kb_t)
 Check if the current main kb corresponds to the original scan main kb. @description Compares the scan id in get_scan_id, set at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb. More...
 
int kb_item_push_str_with_main_kb_check (kb_t, const char *, const char *)
 Check if the current kb corresponds to the original scanid, if it matches it kb_item_push_str. @description Compares the scan id in get_scan_id, set at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb. More...
 
int kb_item_set_str_with_main_kb_check (kb_t, const char *, const char *, size_t)
 Check if the current kb corresponds to the original scanid, if it matches it call kb_item_set_str. @description Compares the scan id in get_scan_id, set at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb. More...
 
int kb_item_add_str_unique_with_main_kb_check (kb_t, const char *, const char *, size_t, int)
 Check if the current kb corresponds to the original scanid, if it matches it call kb_item_add_str_unique. @description Compares the scan id in get_scan_id, set at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb. More...
 
int kb_item_set_int_with_main_kb_check (kb_t, const char *, int)
 Check if the current kb corresponds to the original scanid, if it matches it call kb_item_set_int. @description Compares the scan id in get_scan_id, set at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb. More...
 
int kb_item_add_int_with_main_kb_check (kb_t, const char *, int)
 Check if the current kb corresponds to the original scanid, if it matches it call kb_item_add_int. @description Compares the scan id in get_scan_id, add at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb. More...
 
int kb_item_add_int_unique_with_main_kb_check (kb_t, const char *, int)
 Check if the current kb corresponds to the original scanid, if it matches it call kb_item_add_int_unique. @description Compares the scan id in get_scan_id, add at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb. More...
 
void plug_set_key (struct script_infos *, char *, int, const void *)
 
void plug_set_key_len (struct script_infos *, char *, int, const void *, size_t)
 
void plug_set_key_volatile (struct script_infos *, char *, int, const void *, int)
 Set volatile key with expire. More...
 
void plug_set_key_len_volatile (struct script_infos *, char *, int, const void *, int, size_t)
 Set volatile key with expire. More...
 
void plug_replace_key (struct script_infos *, char *, int, void *)
 
void plug_replace_key_len (struct script_infos *, char *, int, void *, size_t)
 
kb_t plug_get_kb (struct script_infos *)
 
void * plug_get_key (struct script_infos *, char *, int *, size_t *, int)
 Get values from a kb under the given key name. More...
 
struct in6_addr * plug_get_host_ip (struct script_infos *)
 
char * plug_get_host_ip_str (struct script_infos *)
 
char * get_plugin_preference (const char *, const char *, int)
 Get the a plugins preference. More...
 
const char * get_plugin_preference_fname (struct script_infos *, const char *)
 Get the file name of a plugins preference that is of type "file". More...
 
char * get_plugin_preference_file_content (struct script_infos *, const char *)
 Get the file contents of a plugins preference that is of type "file". More...
 
long get_plugin_preference_file_size (struct script_infos *, const char *)
 Get the file size of a plugins preference that is of type "file". More...
 
int kb_get_port_state_proto (kb_t kb, int portnum, char *proto)
 

Detailed Description

Header file for module plugutils.

Definition in file plugutils.h.

Macro Definition Documentation

◆ ARG_INT

#define ARG_INT   2

Definition at line 20 of file plugutils.h.

◆ ARG_STRING

#define ARG_STRING   1

Definition at line 19 of file plugutils.h.

◆ post_alarm_tcp

#define post_alarm_tcp   post_alarm

Definition at line 98 of file plugutils.h.

◆ post_error_tcp

#define post_error_tcp   post_error

Definition at line 107 of file plugutils.h.

◆ post_log_tcp

#define post_log_tcp   post_log

Definition at line 120 of file plugutils.h.

Enumeration Type Documentation

◆ msg_t

enum msg_t
Enumerator
ERRMSG 
HOST_START 
HOST_END 
LOG 
HOST_DETAIL 
ALARM 
DEADHOST 
HOSTS_COUNT 

Definition at line 75 of file plugutils.h.

76 {
77  ERRMSG,
78  HOST_START,
79  HOST_END,
80  LOG,
82  ALARM,
83  DEADHOST,
85 } msg_t;

Function Documentation

◆ check_kb_inconsistency()

int check_kb_inconsistency ( kb_t  main_kb)

Check if the current main kb corresponds to the original scan main kb. @description Compares the scan id in get_scan_id, set at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb.

Parameters
main_kbCurrent main kb.
Returns
0 on success, -1 on missing global scan_id, -2 on missing current_scan_id, -3 when inconsistent.

Definition at line 387 of file plugutils.c.

388 {
389  const char *original_scan_id;
390  char *current_scan_id;
391 
392  original_scan_id = get_scan_id ();
393  if (original_scan_id == NULL)
394  return -1;
395  current_scan_id = kb_item_get_str (main_kb, ("internal/scanid"));
396  if (current_scan_id == NULL)
397  return -2;
398 
399  if (!g_strcmp0 (original_scan_id, current_scan_id))
400  {
401  g_free (current_scan_id);
402  return 0;
403  }
404 
405  g_warning ("KB inconsitency. %s writing into %s KB", original_scan_id,
406  current_scan_id);
407  g_free (current_scan_id);
408  return -3;
409 }

References get_scan_id(), and main_kb.

Referenced by attack_host(), check_kb_inconsistency_log(), and set_scan_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_plugin_preference()

char* get_plugin_preference ( const char *  oid,
const char *  name,
int  pref_id 
)

Get the a plugins preference.

Search in the preferences set by the client. If it is not present, search in redis cache for the default.

Parameters
[in]oidScript OID to get the preference from
[in]nameName of the preference to get
[in]pref_idId of the preferences to get
Returns
script preference on success, Null otherwise.

Definition at line 743 of file plugutils.c.

744 {
745  GHashTable *prefs;
746  GHashTableIter iter;
747  char *cname = NULL, *retval = NULL;
748  void *itername, *itervalue;
749  char prefix[1024], suffix[1024];
750 
751  prefs = preferences_get ();
752  if (!prefs || !nvticache_initialized () || !oid || (!name && pref_id < 0))
753  return NULL;
754 
755  g_hash_table_iter_init (&iter, prefs);
756 
757  if (pref_id >= 0)
758  {
759  snprintf (prefix, sizeof (prefix), "%s:%d:", oid, pref_id);
760  while (g_hash_table_iter_next (&iter, &itername, &itervalue))
761  {
762  if (g_str_has_prefix (itername, prefix))
763  {
764  retval = g_strdup (itervalue);
765  break;
766  }
767  }
768  }
769  else
770  {
771  cname = g_strdup (name);
772  g_strchomp (cname);
773  snprintf (prefix, sizeof (prefix), "%s:", oid);
774  snprintf (suffix, sizeof (suffix), ":%s", cname);
775  /* NVT preferences received in OID:PrefID:PrefType:PrefName form */
776  while (g_hash_table_iter_next (&iter, &itername, &itervalue))
777  {
778  if (g_str_has_prefix (itername, prefix)
779  && g_str_has_suffix (itername, suffix))
780  {
781  retval = g_strdup (itervalue);
782  break;
783  }
784  }
785  }
786 
787  /* If no value set by the user, get the default one. */
788  if (!retval)
789  {
790  GSList *nprefs, *tmp;
791 
792  tmp = nprefs = nvticache_get_prefs (oid);
793  while (tmp)
794  {
795  if ((cname && !strcmp (cname, nvtpref_name (tmp->data)))
796  || (pref_id >= 0 && pref_id == nvtpref_id (tmp->data)))
797  {
798  if (!strcmp (nvtpref_type (tmp->data), "radio"))
799  {
800  char **opts =
801  g_strsplit (nvtpref_default (tmp->data), ";", -1);
802 
803  retval = g_strdup (opts[0]);
804  g_strfreev (opts);
805  }
806  else
807  retval = g_strdup (nvtpref_default (tmp->data));
808 
809  break;
810  }
811  tmp = tmp->next;
812  }
813  g_slist_free_full (nprefs, (void (*) (void *)) nvtpref_free);
814  }
815  if (cname)
816  g_free (cname);
817  return retval;
818 }

References name, oid, and prefix().

Referenced by plugin_do_run(), plugin_run_find_service(), plugin_timeout(), script_get_preference(), script_get_preference_file_content(), script_get_preference_file_location(), and user_agent_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_plugin_preference_file_content()

char* get_plugin_preference_file_content ( struct script_infos desc,
const char *  identifier 
)

Get the file contents of a plugins preference that is of type "file".

As files sent to the scanner (e.g. as plugin preference) are stored in a hash table with an identifier supplied by the client as the key, the contents have to be looked up here.

Parameters
identifierIdentifier that was supplied by the client when the file was uploaded.
Returns
Contents of the file identified by identifier, NULL if not found or setup broken.

Definition at line 886 of file plugutils.c.

888 {
889  struct scan_globals *globals = desc->globals;
890  GHashTable *trans;
891 
892  if (!globals)
893  return NULL;
894 
895  trans = globals->files_translation;
896  if (!trans)
897  return NULL;
898 
899  return g_hash_table_lookup (trans, identifier);
900 }

References scan_globals::files_translation, and script_infos::globals.

Referenced by get_plugin_preference_fname(), and script_get_preference_file_content().

Here is the caller graph for this function:

◆ get_plugin_preference_file_size()

long get_plugin_preference_file_size ( struct script_infos desc,
const char *  identifier 
)

Get the file size of a plugins preference that is of type "file".

Files sent to the scanner (e.g. as plugin preference) are stored in a hash table with an identifier supplied by the client as the key. The size of the file is stored in a separate hash table with the same identifier as key, which can be looked up here.

Parameters
identifierIdentifier that was supplied by the client when the file was uploaded.
Returns
Size of the file identified by identifier, -1 if not found or setup broken.

Definition at line 917 of file plugutils.c.

919 {
920  struct scan_globals *globals = desc->globals;
921  GHashTable *trans;
922  gchar *filesize_str;
923 
924  if (!globals)
925  return -1;
926 
927  trans = globals->files_size_translation;
928  if (!trans)
929  return -1;
930 
931  filesize_str = g_hash_table_lookup (trans, identifier);
932  if (filesize_str == NULL)
933  return -1;
934 
935  return atol (filesize_str);
936 }

References scan_globals::files_size_translation, and script_infos::globals.

Referenced by get_plugin_preference_fname(), and script_get_preference_file_content().

Here is the caller graph for this function:

◆ get_plugin_preference_fname()

const char* get_plugin_preference_fname ( struct script_infos desc,
const char *  filename 
)

Get the file name of a plugins preference that is of type "file".

As files sent to the server (e.g. as plugin preference) are stored at pseudo-random locations with different names, the "real" file name has to be looked up in a hashtable.

Returns
Filename on disc for filename, NULL if not found or setup broken.

Definition at line 831 of file plugutils.c.

832 {
833  const char *content;
834  long contentsize = 0;
835  gint tmpfile;
836  gchar *tmpfilename;
837  GError *error = NULL;
838 
839  content = get_plugin_preference_file_content (desc, filename);
840  if (content == NULL)
841  {
842  return NULL;
843  }
844  contentsize = get_plugin_preference_file_size (desc, filename);
845  if (contentsize <= 0)
846  return NULL;
847 
848  tmpfile =
849  g_file_open_tmp ("openvas-file-upload.XXXXXX", &tmpfilename, &error);
850  if (tmpfile == -1)
851  {
852  g_message ("get_plugin_preference_fname: Could not open temporary"
853  " file for %s: %s",
854  filename, error->message);
855  g_error_free (error);
856  return NULL;
857  }
858  close (tmpfile);
859 
860  if (!g_file_set_contents (tmpfilename, content, contentsize, &error))
861  {
862  g_message ("get_plugin_preference_fname: could set contents of"
863  " temporary file for %s: %s",
864  filename, error->message);
865  g_error_free (error);
866  return NULL;
867  }
868 
869  return tmpfilename;
870 }

References get_plugin_preference_file_content(), and get_plugin_preference_file_size().

Referenced by plugin_run_find_service(), and script_get_preference_file_location().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ host_get_port_state()

int host_get_port_state ( struct script_infos ,
int   
)

Definition at line 144 of file plugutils.c.

145 {
146  return (host_get_port_state_proto (plugdata, portnum, "tcp"));
147 }

References host_get_port_state_proto().

Referenced by get_port_state(), and open_sock_tcp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ host_get_port_state_udp()

int host_get_port_state_udp ( struct script_infos ,
int   
)

Definition at line 150 of file plugutils.c.

151 {
152  return (host_get_port_state_proto (plugdata, portnum, "udp"));
153 }

References host_get_port_state_proto().

Referenced by get_udp_port_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kb_get_port_state_proto()

int kb_get_port_state_proto ( kb_t  kb,
int  portnum,
char *  proto 
)
Parameters
protoProtocol (udp/tcp). If NULL, "tcp" will be used.

Definition at line 100 of file plugutils.c.

101 {
102  char port_s[255], *kbstr;
103  const char *prange = prefs_get ("port_range");
104  port_protocol_t port_type;
105  array_t *port_ranges;
106 
107  if (!proto)
108  proto = "tcp";
109  if (!strcmp (proto, "udp"))
110  {
111  port_type = PORT_PROTOCOL_UDP;
112  kbstr = "Host/udp_scanned";
113  }
114  else
115  {
116  port_type = PORT_PROTOCOL_TCP;
117  kbstr = "Host/scanned";
118  }
119 
120  /* Check that we actually scanned the port */
121  if (kb_item_get_int (kb, kbstr) <= 0)
122  return unscanned_ports_as_closed (port_type);
123 
124  port_ranges = port_range_ranges (prange);
125  if (!port_in_port_ranges (portnum, port_type, port_ranges))
126  {
127  array_free (port_ranges);
128  return unscanned_ports_as_closed (port_type);
129  }
130  array_free (port_ranges);
131 
132  /* Ok, we scanned it. What is its state ? */
133  snprintf (port_s, sizeof (port_s), "Ports/%s/%d", proto, portnum);
134  return kb_item_get_int (kb, port_s) > 0;
135 }

References unscanned_ports_as_closed().

Referenced by host_get_port_state_proto().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kb_item_add_int_unique_with_main_kb_check()

int kb_item_add_int_unique_with_main_kb_check ( kb_t  kb,
const char *  name,
int  value 
)

Check if the current kb corresponds to the original scanid, if it matches it call kb_item_add_int_unique. @description Compares the scan id in get_scan_id, add at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb.

Parameters
kbKb where to store the item into.
namekey for the given value.
valueto store under key within kb.
Returns
0 on success, -1 on inconsistency.

Definition at line 602 of file plugutils.c.

603 {
604  int result = check_kb_inconsistency_log ();
605  return result == 0 ? kb_item_add_int_unique (kb, name, value) : -1;
606 }

References check_kb_inconsistency_log(), and name.

Referenced by set_kb_readable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kb_item_add_int_with_main_kb_check()

int kb_item_add_int_with_main_kb_check ( kb_t  kb,
const char *  name,
int  value 
)

Check if the current kb corresponds to the original scanid, if it matches it call kb_item_add_int. @description Compares the scan id in get_scan_id, add at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb.

Parameters
kbKb where to store the item into.
namekey for the given value.
valueto store under key within kb.
Returns
0 on success, -1 on inconsistency.

Definition at line 578 of file plugutils.c.

579 {
580  int result = check_kb_inconsistency_log ();
581  return result == 0 ? kb_item_add_int (kb, name, value) : -1;
582 }

References check_kb_inconsistency_log(), and name.

Here is the call graph for this function:

◆ kb_item_add_str_unique_with_main_kb_check()

int kb_item_add_str_unique_with_main_kb_check ( kb_t  kb,
const char *  name,
const char *  value,
size_t  len,
int  pos 
)

Check if the current kb corresponds to the original scanid, if it matches it call kb_item_add_str_unique. @description Compares the scan id in get_scan_id, set at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb.

Parameters
kbKb where to store the item into.
namekey for the given value.
valueto store under key within kb.
Returns
0 on success, -1 on inconsistency.

Definition at line 528 of file plugutils.c.

531 {
532  int result = check_kb_inconsistency_log ();
533  return result == 0 ? kb_item_add_str_unique (kb, name, value, len, pos) : -1;
534 }

References check_kb_inconsistency_log(), len, and name.

Here is the call graph for this function:

◆ kb_item_push_str_with_main_kb_check()

int kb_item_push_str_with_main_kb_check ( kb_t  kb,
const char *  name,
const char *  value 
)

Check if the current kb corresponds to the original scanid, if it matches it kb_item_push_str. @description Compares the scan id in get_scan_id, set at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb.

Parameters
kbKb where to store the item into.
namekey for the given value.
valueto store under key within kb.
Returns
0 on success, -1 on inconsistency.

Definition at line 478 of file plugutils.c.

480 {
481  int result = check_kb_inconsistency_log ();
482  return result == 0 ? kb_item_push_str (kb, name, value) : -1;
483 }

References check_kb_inconsistency_log(), and name.

Referenced by attack_host(), comm_send_status(), comm_send_status_host_dead(), host_set_time(), message_to_client(), open_sock_tcp(), proto_post_wrapped(), and update_running_processes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kb_item_set_int_with_main_kb_check()

int kb_item_set_int_with_main_kb_check ( kb_t  kb,
const char *  name,
int  value 
)

Check if the current kb corresponds to the original scanid, if it matches it call kb_item_set_int. @description Compares the scan id in get_scan_id, set at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb.

Parameters
kbKb where to store the item into.
namekey for the given value.
valueto store under key within kb.
Returns
0 on success, -1 on inconsistency.

Definition at line 554 of file plugutils.c.

555 {
556  int result = check_kb_inconsistency_log ();
557  return result == 0 ? kb_item_set_int (kb, name, value) : -1;
558 }

References check_kb_inconsistency_log(), and name.

Referenced by check_host_still_alive(), open_sock_tcp(), and overwrite_openvas_prefs_with_prefs_from_client().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kb_item_set_str_with_main_kb_check()

int kb_item_set_str_with_main_kb_check ( kb_t  kb,
const char *  name,
const char *  value,
size_t  len 
)

Check if the current kb corresponds to the original scanid, if it matches it call kb_item_set_str. @description Compares the scan id in get_scan_id, set at the beginning of the scan, with the one found in the main kb. Therefore it is mandatory that the global main_kb variable to be set. It helps to detect that the kb was not taken by another task/scan, and that the current plugins does not stores results in a wrong kb.

Parameters
kbKb where to store the item into.
namekey for the given value.
valueto store under key within kb.
Returns
0 on success, -1 on inconsistency.

Definition at line 503 of file plugutils.c.

505 {
506  int result = check_kb_inconsistency_log ();
507  return result == 0 ? kb_item_set_str (kb, name, value, len) : -1;
508 }

References check_kb_inconsistency_log(), len, and name.

Referenced by attack_start(), overwrite_openvas_prefs_with_prefs_from_client(), and set_scan_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_add_host_fqdn()

int plug_add_host_fqdn ( struct script_infos ,
const char *  ,
const char *   
)

Definition at line 208 of file plugutils.c.

210 {
211  gvm_vhost_t *vhost;
212  char **excluded;
213 
214  if (!prefs_get_bool ("expand_vhosts") || !hostname || !source)
215  return -1;
216 
217  if (check_duplicated_vhost (args, hostname))
218  return -1;
219 
220  /* Check for excluded vhost value. */
221  if (prefs_get ("exclude_hosts"))
222  {
223  char **tmp = excluded = g_strsplit (prefs_get ("exclude_hosts"), ",", 0);
224 
225  while (*tmp)
226  {
227  if (!strcmp (g_strstrip (*tmp), hostname))
228  {
229  g_strfreev (excluded);
230  return -1;
231  }
232  tmp++;
233  }
234  g_strfreev (excluded);
235  }
236  vhost = gvm_vhost_new (g_strdup (hostname), g_strdup (source));
237  args->vhosts = g_slist_prepend (args->vhosts, vhost);
238  return 0;
239 }

References check_duplicated_vhost(), hostname, and script_infos::vhosts.

Referenced by add_hostname().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_create_from_nvti_and_prefs()

struct script_infos* plug_create_from_nvti_and_prefs ( const nvti_t *  )

◆ plug_current_vhost()

const char* plug_current_vhost ( void  )

Definition at line 47 of file plugutils.c.

48 {
49  return current_vhost->value;
50 }

References current_vhost.

Referenced by nasl_end_denial(), and open_sock_tcp().

Here is the caller graph for this function:

◆ plug_get_host_fqdn()

char* plug_get_host_fqdn ( struct script_infos )

Definition at line 242 of file plugutils.c.

243 {
244  GSList *vhosts = args->vhosts;
245 
246  if (!args->vhosts)
247  return addr6_as_str (args->ip);
248 
249  /* Workaround for rapid growth of forked processes ie. http_get() calls
250  * within foreach() loops. */
251  if (current_vhost)
252  return g_strdup (current_vhost->value);
253  while (vhosts)
254  {
255  int ret = plug_fork_child (args->key);
256 
257  if (ret == 0)
258  {
259  current_vhost = vhosts->data;
260  return g_strdup (current_vhost->value);
261  }
262  else if (ret == -1)
263  return NULL;
264  vhosts = vhosts->next;
265  }
266  _exit (0);
267 }

References current_vhost, script_infos::ip, script_infos::key, plug_fork_child(), and script_infos::vhosts.

Referenced by _http_req(), get_hostname(), open_stream_connection_ext(), plug_get_host_source(), plugin_do_run(), retry_stream_connection(), and socket_negotiate_ssl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_get_host_fqdn_list()

GSList* plug_get_host_fqdn_list ( struct script_infos )

Definition at line 270 of file plugutils.c.

271 {
272  GSList *results = NULL, *vhosts = args->vhosts;
273 
274  if (!args->vhosts)
275  results = g_slist_prepend (results, addr6_as_str (args->ip));
276 
277  while (vhosts)
278  {
279  gvm_vhost_t *vhost = vhosts->data;
280 
281  results = g_slist_prepend (results, g_strdup (vhost->value));
282  vhosts = vhosts->next;
283  }
284  return results;
285 }

References script_infos::ip, and script_infos::vhosts.

Referenced by get_hostnames().

Here is the caller graph for this function:

◆ plug_get_host_ip()

◆ plug_get_host_ip_str()

char* plug_get_host_ip_str ( struct script_infos )

Definition at line 322 of file plugutils.c.

323 {
324  return addr6_as_str (plug_get_host_ip (desc));
325 }

References plug_get_host_ip().

Referenced by nasl_snmpv1v2c_get(), nasl_snmpv3_get_action(), open_sock_tcp(), and socket_negotiate_ssl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_get_host_open_port()

unsigned int plug_get_host_open_port ( struct script_infos desc)

Don't always return the first open port, otherwise we might get bitten by OSes doing active SYN flood countermeasures. Also, avoid returning 80 and 21 as open ports, as many transparent proxies are acting for these...

Definition at line 1220 of file plugutils.c.

1221 {
1222  kb_t kb = plug_get_kb (desc);
1223  struct kb_item *res, *k;
1224  int open21 = 0, open80 = 0;
1225 #define MAX_CANDIDATES 16
1226  u_short candidates[MAX_CANDIDATES];
1227  int num_candidates = 0;
1228 
1229  k = res = kb_item_get_pattern (kb, "Ports/tcp/*");
1230  if (res == NULL)
1231  return 0;
1232  else
1233  {
1234  int ret;
1235  char *s;
1236 
1237  for (;;)
1238  {
1239  s = res->name + sizeof ("Ports/tcp/") - 1;
1240  ret = atoi (s);
1241  if (ret == 21)
1242  open21 = 1;
1243  else if (ret == 80)
1244  open80 = 1;
1245  else
1246  {
1247  candidates[num_candidates++] = ret;
1248  if (num_candidates >= MAX_CANDIDATES)
1249  break;
1250  }
1251  res = res->next;
1252  if (res == NULL)
1253  break;
1254  }
1255 
1256  kb_item_free (k);
1257  if (num_candidates != 0)
1258  return candidates[lrand48 () % num_candidates];
1259  else if (open21)
1260  return 21;
1261  else if (open80)
1262  return 80;
1263  }
1264 
1265  /* Not reachable */
1266  return 0;
1267 }

References MAX_CANDIDATES, and plug_get_kb().

Referenced by get_host_open_port(), nasl_start_denial(), nasl_tcp_ping(), and nasl_tcp_v6_ping().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_get_host_source()

char* plug_get_host_source ( struct script_infos ,
const char *   
)

Definition at line 288 of file plugutils.c.

289 {
290  if (!args->vhosts)
291  return g_strdup ("IP-address");
292 
293  if (hostname)
294  {
295  GSList *vhosts = args->vhosts;
296 
297  /* Search for source of specified hostname/vhost. */
298  while (vhosts)
299  {
300  gvm_vhost_t *vhost = vhosts->data;
301 
302  if (!strcmp (vhost->value, hostname))
303  return g_strdup (vhost->source);
304  vhosts = vhosts->next;
305  }
306  return NULL;
307  }
308  /* Call plug_get_host_fqdn() to set current_vhost (and fork, in case of
309  * multiple vhosts.) */
310  if (!current_vhost)
311  g_free (plug_get_host_fqdn (args));
312  return g_strdup (current_vhost->source);
313 }

References current_vhost, hostname, plug_get_host_fqdn(), and script_infos::vhosts.

Referenced by get_hostname_source().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_get_kb()

◆ plug_get_key()

void* plug_get_key ( struct script_infos args,
char *  name,
int *  type,
size_t *  len,
int  single 
)

Get values from a kb under the given key name.

Parameters
[in]argsThe script infos where to get the kb from.
[in]nameKey name to search in the kb.
[in/out]type If 1 is given, the answer is forced to be KB_TYPE_INT type. Otherwise it returns the fetched type.
[in]lenDesired string length to be returned.
[in]singleIn case of a list, fetch only the last element
Returns
Null if no result, or a void pointer to the result in success.

Definition at line 1129 of file plugutils.c.

1131 {
1132  kb_t kb = args->key;
1133  struct kb_item *res = NULL, *res_list;
1134 
1135  if (type != NULL && *type != KB_TYPE_INT)
1136  *type = -1;
1137 
1138  if (kb == NULL)
1139  return NULL;
1140 
1141  if (single && type != NULL && *type != KB_TYPE_INT)
1142  res = kb_item_get_single (kb, name, KB_TYPE_UNSPEC);
1143  else if (type != NULL && *type == KB_TYPE_INT)
1144  res = kb_item_get_single (kb, name, KB_TYPE_INT);
1145  else
1146  res = kb_item_get_all (kb, name);
1147 
1148  if (res == NULL)
1149  return NULL;
1150 
1151  if (!res->next) /* No fork - good */
1152  {
1153  void *ret;
1154  if (res->type == KB_TYPE_INT)
1155  {
1156  if (type != NULL)
1157  *type = KB_TYPE_INT;
1158  ret = g_memdup2 (&res->v_int, sizeof (res->v_int));
1159  }
1160  else
1161  {
1162  if (type != NULL)
1163  *type = KB_TYPE_STR;
1164  if (len)
1165  *len = res->len;
1166 
1167  ret = g_malloc0 (res->len + 1);
1168  memcpy (ret, res->v_str, res->len + 1);
1169  }
1170  kb_item_free (res);
1171  return ret;
1172  }
1173 
1174  /* More than one value - we will fork() then */
1175  sig_n (SIGCHLD, plug_get_key_sigchld);
1176  res_list = res;
1177  while (res)
1178  {
1179  int pret = plug_fork_child (kb);
1180 
1181  if (pret == 0)
1182  {
1183  /* Forked child. */
1184  void *ret;
1185 
1186  if (res->type == KB_TYPE_INT)
1187  {
1188  if (type != NULL)
1189  *type = KB_TYPE_INT;
1190  ret = g_memdup2 (&res->v_int, sizeof (res->v_int));
1191  }
1192  else
1193  {
1194  if (type != NULL)
1195  *type = KB_TYPE_STR;
1196  if (len)
1197  *len = res->len;
1198 
1199  ret = g_malloc0 (res->len + 1);
1200  memcpy (ret, res->v_str, res->len + 1);
1201  }
1202  kb_item_free (res_list);
1203  return ret;
1204  }
1205  else if (pret == -1)
1206  return NULL;
1207  res = res->next;
1208  }
1209  kb_item_free (res_list);
1210  _exit (0);
1211 }

References script_infos::key, len, name, plug_fork_child(), plug_get_key_sigchld(), and sig_n().

Referenced by banner_grab(), get_kb_item(), get_ssh_port(), nasl_open_sock_kdc(), and plugin_do_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_get_port_transport()

int plug_get_port_transport ( struct script_infos ,
int   
)

Definition at line 1288 of file plugutils.c.

1289 {
1290  char s[256];
1291  int trp;
1292 
1293  snprintf (s, sizeof (s), "Transports/TCP/%d", port);
1294  trp = kb_item_get_int (plug_get_kb (args), s);
1295  if (trp >= 0)
1296  return trp;
1297  else
1298  return OPENVAS_ENCAPS_IP; /* Change this to 0 for ultra smart SSL
1299  negotiation, at the expense of possibly
1300  breaking stuff */
1301 }

References OPENVAS_ENCAPS_IP, and plug_get_kb().

Referenced by get_port_transport(), and open_stream_auto_encaps_ext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_replace_key()

◆ plug_replace_key_len()

void plug_replace_key_len ( struct script_infos ,
char *  ,
int  ,
void *  ,
size_t   
)

Definition at line 1020 of file plugutils.c.

1022 {
1023  kb_t kb = plug_get_kb (args);
1024 
1025  if (name == NULL || value == NULL)
1026  return;
1027 
1028  if (type == ARG_STRING)
1029  kb_item_set_str (kb, name, value, len);
1030  else if (type == ARG_INT)
1031  kb_item_set_int (kb, name, GPOINTER_TO_SIZE (value));
1032  if (global_nasl_debug == 1)
1033  {
1034  if (type == ARG_STRING)
1035  g_message ("replace key %s -> %s", name, (char *) value);
1036  else if (type == ARG_INT)
1037  g_message ("replace key %s -> %d", name,
1038  (int) GPOINTER_TO_SIZE (value));
1039  }
1040 }

References ARG_INT, ARG_STRING, global_nasl_debug, len, name, and plug_get_kb().

Referenced by plug_replace_key(), and replace_kb_item().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_set_dep()

void plug_set_dep ( struct script_infos ,
const char *   
)

Definition at line 55 of file plugutils.c.

56 {
57  nvti_t *n = args->nvti;
58  gchar *old = nvti_dependencies (n);
59  gchar *new;
60 
61  if (!depname)
62  return;
63 
64  if (old)
65  {
66  new = g_strdup_printf ("%s, %s", old, depname);
67  nvti_set_dependencies (n, new);
68  g_free (new);
69  }
70  else
71  nvti_set_dependencies (n, depname);
72 }

References script_infos::nvti.

Referenced by script_dependencies().

Here is the caller graph for this function:

◆ plug_set_key()

void plug_set_key ( struct script_infos ,
char *  ,
int  ,
const void *   
)

Definition at line 962 of file plugutils.c.

964 {
965  plug_set_key_len (args, name, type, value, 0);
966 }

References name, and plug_set_key_len().

Referenced by banner_grab(), host_add_port_proto(), mark_unknown_svc(), mark_wrapped_svc(), plug_set_port_transport(), plug_set_ssl_item(), plugin_do_run(), plugin_run_openvas_tcp_scanner(), plugin_run_synscan(), register_service(), scan(), set_kb_item(), and simple_register_host_detail().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_set_key_len()

void plug_set_key_len ( struct script_infos ,
char *  ,
int  ,
const void *  ,
size_t   
)

Definition at line 939 of file plugutils.c.

941 {
942  kb_t kb = plug_get_kb (args);
943  int pos = 0; // Append the item on the right position of the list
944 
945  if (name == NULL || value == NULL)
946  return;
947 
948  if (type == ARG_STRING)
949  kb_item_add_str_unique (kb, name, value, len, pos);
950  else if (type == ARG_INT)
951  kb_item_add_int_unique (kb, name, GPOINTER_TO_SIZE (value));
952  if (global_nasl_debug == 1)
953  {
954  if (type == ARG_STRING)
955  g_message ("set key %s -> %s", name, (char *) value);
956  else if (type == ARG_INT)
957  g_message ("set key %s -> %d", name, (int) GPOINTER_TO_SIZE (value));
958  }
959 }

References ARG_INT, ARG_STRING, global_nasl_debug, len, name, and plug_get_kb().

Referenced by plug_set_key(), and set_kb_item().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_set_key_len_volatile()

void plug_set_key_len_volatile ( struct script_infos args,
char *  name,
int  type,
const void *  value,
int  expire,
size_t  len 
)

Set volatile key with expire.

Parameters
argsScript infos.
nameKey name.
typeKey type.
valueKey value.
expireKey expire in seconds.
lenLen of value.

Definition at line 979 of file plugutils.c.

981 {
982  kb_t kb = plug_get_kb (args);
983  int pos = 0; // Append the item on the right position of the list
984 
985  if (name == NULL || value == NULL || expire == -1)
986  return;
987 
988  if (type == ARG_STRING)
989  kb_add_str_unique_volatile (kb, name, value, expire, len, pos);
990  else if (type == ARG_INT)
991  kb_add_int_unique_volatile (kb, name, GPOINTER_TO_SIZE (value),
992  GPOINTER_TO_SIZE (expire));
993  if (global_nasl_debug == 1)
994  {
995  if (type == ARG_STRING)
996  g_message ("set volatile key %s -> %s", name, (char *) value);
997  else if (type == ARG_INT)
998  g_message ("set volatile key %s -> %d", name,
999  (int) GPOINTER_TO_SIZE (value));
1000  }
1001 }

References ARG_INT, ARG_STRING, global_nasl_debug, len, name, and plug_get_kb().

Referenced by plug_set_key_volatile(), and set_kb_item_volatile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_set_key_volatile()

void plug_set_key_volatile ( struct script_infos args,
char *  name,
int  type,
const void *  value,
int  expire 
)

Set volatile key with expire.

Parameters
argsScript infos.
nameKey name.
typeKey type.
valueKey value.
expireKey expire in seconds.

Definition at line 1013 of file plugutils.c.

1015 {
1016  plug_set_key_len_volatile (args, name, type, value, expire, 0);
1017 }

References name, and plug_set_key_len_volatile().

Referenced by set_kb_item_volatile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_set_port_transport()

void plug_set_port_transport ( struct script_infos args,
int  port,
int  tr 
)
Todo:
Those brain damaged functions should probably be in another file They are use to remember who speaks SSL or not

Definition at line 1275 of file plugutils.c.

1276 {
1277  char s[256];
1278 
1279  snprintf (s, sizeof (s), "Transports/TCP/%d", port);
1280  plug_set_key (args, s, ARG_INT, GSIZE_TO_POINTER (tr));
1281 }

References ARG_INT, and plug_set_key().

Referenced by open_stream_auto_encaps_ext(), and plugin_do_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_set_ssl_CA_file()

void plug_set_ssl_CA_file ( struct script_infos args,
char *  key 
)
Todo:
Also, all plug_set_ssl*-functions set values that are only accessed in network.c:open_stream_connection under specific conditions. Check whether these conditions can actually occur. Document the functions on the way.

Definition at line 1334 of file plugutils.c.

1335 {
1336  plug_set_ssl_item (args, "CA", key);
1337 }

References plug_set_ssl_item().

Referenced by plugin_run_find_service().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_set_ssl_cert()

void plug_set_ssl_cert ( struct script_infos ,
char *   
)

Definition at line 1312 of file plugutils.c.

1313 {
1314  plug_set_ssl_item (args, "cert", cert);
1315 }

References plug_set_ssl_item().

Referenced by plugin_run_find_service().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_set_ssl_key()

void plug_set_ssl_key ( struct script_infos ,
char *   
)

Definition at line 1318 of file plugutils.c.

1319 {
1320  plug_set_ssl_item (args, "key", key);
1321 }

References plug_set_ssl_item().

Referenced by plugin_run_find_service().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_set_ssl_pem_password()

void plug_set_ssl_pem_password ( struct script_infos ,
char *   
)

Definition at line 1324 of file plugutils.c.

1325 {
1326  plug_set_ssl_item (args, "password", key);
1327 }

References plug_set_ssl_item().

Referenced by plugin_run_find_service().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ post_alarm()

void post_alarm ( const char *  ,
struct script_infos ,
int  ,
const char *  ,
const char *   
)

Definition at line 680 of file plugutils.c.

682 {
683  proto_post_alarm (oid, desc, port, "tcp", action, uri);
684 }

References oid, and proto_post_alarm().

Referenced by mark_fssniffer(), mark_netbus_server(), mark_sub7_server(), mark_wild_shell(), and security_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ post_alarm_udp()

void post_alarm_udp ( struct script_infos ,
int  ,
const char *  ,
const char *   
)

◆ post_error()

void post_error ( const char *  ,
struct script_infos ,
int  ,
const char *  ,
const char *   
)

Definition at line 724 of file plugutils.c.

726 {
727  proto_post_error (oid, desc, port, "tcp", action, uri);
728 }

References oid, and proto_post_error().

Referenced by error_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ post_log()

void post_log ( const char *  ,
struct script_infos ,
int  ,
const char *   
)

Post a log message about a tcp port.

Definition at line 700 of file plugutils.c.

702 {
703  proto_post_log (oid, desc, port, "tcp", action, NULL);
704 }

References oid, and proto_post_log().

Referenced by mark_acap_server(), mark_adsgone(), mark_auth_server(), mark_avotus_mm_server(), mark_BitTorrent_server(), mark_chargen_server(), mark_citrix_server(), mark_cvslockserver(), mark_cvspserver(), mark_cvsupserver(), mark_dameware_server(), mark_dictd_server(), mark_direct_connect_hub(), mark_echo_server(), mark_eggdrop_server(), mark_ens_server(), mark_exchg_routing_server(), mark_finger_server(), mark_ftp_server(), mark_fw1(), mark_giop_server(), mark_gnocatan_server(), mark_gnome14_server(), mark_gnuserv(), mark_gopher_server(), mark_http_proxy(), mark_http_server(), mark_imap_server(), mark_interscan_viruswall(), mark_ircxpro_admin_server(), mark_iss_realsecure(), mark_jabber_server(), mark_linuxconf(), mark_LISa_server(), mark_listserv_server(), mark_locked_adsubtract_server(), mark_lpd_server(), mark_lyskom_server(), mark_mldonkey(), mark_mon_server(), mark_mongodb(), mark_msdtc_server(), mark_mysql(), mark_nagiosd_server(), mark_nntp_server(), mark_ofa_express_server(), mark_pblocald_server(), mark_pbmaster_server(), mark_ph_server(), mark_pnsclient(), mark_pop3pw_server(), mark_pop_server(), mark_postgresql(), mark_ppp_daemon(), mark_psybnc(), mark_quicktime_streaming_server(), mark_remote_nc_server(), mark_rmserver(), mark_rsync(), mark_shoutcast_server(), mark_smppd_server(), mark_smtp_server(), mark_smux_server(), mark_snpp_server(), mark_socks_proxy(), mark_spamd_server(), mark_sphinxql(), mark_ssh_server(), mark_stonegate_auth_server(), mark_tcpmux_server(), mark_teamspeak2_server(), mark_telnet_server(), mark_time_server(), mark_unknown_svc(), mark_upsmon_server(), mark_uucp_server(), mark_veritas_backup(), mark_vmware_auth(), mark_vtun_server(), mark_websm_server(), mark_whois_plus2_server(), mark_wrapped_svc(), mark_zebra_server(), and plugin_do_run().

Here is the call graph for this function:

◆ post_log_with_uri()

void post_log_with_uri ( const char *  ,
struct script_infos ,
int  ,
const char *  ,
const char *   
)

Post a log message about a tcp port with a uri.

Definition at line 710 of file plugutils.c.

712 {
713  proto_post_log (oid, desc, port, "tcp", action, uri);
714 }

References oid, and proto_post_log().

Referenced by log_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proto_post_alarm()

void proto_post_alarm ( const char *  ,
struct script_infos ,
int  ,
const char *  ,
const char *  ,
const char *   
)

Definition at line 673 of file plugutils.c.

675 {
676  proto_post_wrapped (oid, desc, port, proto, action, ALARM, uri);
677 }

References ALARM, oid, and proto_post_wrapped().

Referenced by post_alarm(), and security_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proto_post_error()

void proto_post_error ( const char *  ,
struct script_infos ,
int  ,
const char *  ,
const char *  ,
const char *   
)

Definition at line 717 of file plugutils.c.

719 {
720  proto_post_wrapped (oid, desc, port, proto, action, ERRMSG, uri);
721 }

References ERRMSG, oid, and proto_post_wrapped().

Referenced by error_message(), and post_error().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proto_post_log()

void proto_post_log ( const char *  ,
struct script_infos ,
int  ,
const char *  ,
const char *  ,
const char *   
)

Post a log message.

Definition at line 690 of file plugutils.c.

692 {
693  proto_post_wrapped (oid, desc, port, proto, action, LOG, uri);
694 }

References LOG, oid, and proto_post_wrapped().

Referenced by log_message(), post_log(), and post_log_with_uri().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scanner_add_port()

void scanner_add_port ( struct script_infos ,
int  ,
char *   
)

Definition at line 1049 of file plugutils.c.

1050 {
1051  host_add_port_proto (args, port, proto);
1052 }

References host_add_port_proto().

Referenced by banner_grab(), nasl_scanner_add_port(), sendpacket(), and v6_sendpacket().

Here is the call graph for this function:
Here is the caller graph for this function:
check_duplicated_vhost
static int check_duplicated_vhost(struct script_infos *args, const char *hostname)
Check for duplicated vhosts before inserting a new one.
Definition: plugutils.c:164
plug_set_key_len_volatile
void plug_set_key_len_volatile(struct script_infos *args, char *name, int type, const void *value, int expire, size_t len)
Set volatile key with expire.
Definition: plugutils.c:979
get_scan_id
const char * get_scan_id()
Definition: scan_id.c:22
OPENVAS_ENCAPS_IP
@ OPENVAS_ENCAPS_IP
Definition: network.h:31
plug_get_host_ip
struct in6_addr * plug_get_host_ip(struct script_infos *args)
Definition: plugutils.c:316
scan_globals::files_size_translation
GHashTable * files_size_translation
Definition: scanneraux.h:21
plug_get_kb
kb_t plug_get_kb(struct script_infos *args)
Definition: plugutils.c:1055
plug_fork_child
static int plug_fork_child(kb_t)
Spawns a new child process. Setups everything that is needed for a new process. Child must be handled...
Definition: plugutils.c:1089
script_infos::key
kb_t key
Definition: scanneraux.h:32
main_kb
kb_t main_kb
Definition: kb_cache.c:15
plug_get_host_fqdn
char * plug_get_host_fqdn(struct script_infos *args)
Definition: plugutils.c:242
HOST_START
@ HOST_START
Definition: plugutils.h:78
get_plugin_preference_file_content
char * get_plugin_preference_file_content(struct script_infos *desc, const char *identifier)
Get the file contents of a plugins preference that is of type "file".
Definition: plugutils.c:886
plug_replace_key_len
void plug_replace_key_len(struct script_infos *args, char *name, int type, void *value, size_t len)
Definition: plugutils.c:1020
host_add_port_proto
static void host_add_port_proto(struct script_infos *args, int portnum, char *proto)
Definition: plugutils.c:75
proto_post_wrapped
static void proto_post_wrapped(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action, msg_t msg_type, const char *uri)
Post a security message (e.g. LOG, NOTE, WARNING ...).
Definition: plugutils.c:620
name
const char * name
Definition: nasl_init.c:411
ERRMSG
@ ERRMSG
Definition: plugutils.h:77
LOG
@ LOG
Definition: plugutils.h:80
plug_set_key_len
void plug_set_key_len(struct script_infos *args, char *name, int type, const void *value, size_t len)
Definition: plugutils.c:939
scan_globals::files_translation
GHashTable * files_translation
Definition: scanneraux.h:20
sig_n
static void sig_n(int signo, void(*fnc)(int))
Definition: plugutils.c:1070
oid
const char * oid
Definition: nasl_builtin_find_service.c:51
proto_post_error
void proto_post_error(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action, const char *uri)
Definition: plugutils.c:717
script_infos::globals
struct scan_globals * globals
Definition: scanneraux.h:30
current_vhost
gvm_vhost_t * current_vhost
Definition: plugutils.c:43
host_get_port_state_proto
static int host_get_port_state_proto(struct script_infos *args, int portnum, char *proto)
Definition: plugutils.c:138
HOSTS_COUNT
@ HOSTS_COUNT
Definition: plugutils.h:84
plug_get_key_sigchld
static void plug_get_key_sigchld(int s)
Definition: plugutils.c:1061
len
uint8_t len
Definition: nasl_packet_forgery.c:1
HOST_END
@ HOST_END
Definition: plugutils.h:79
msg_t
msg_t
Definition: plugutils.h:76
prefix
static void prefix(int n, int i)
Definition: nasl_tree.c:222
scan_globals
Definition: scanneraux.h:19
unscanned_ports_as_closed
static int unscanned_ports_as_closed(port_protocol_t ptype)
Report state of preferences "unscanned_closed".
Definition: plugutils.c:88
HOST_DETAIL
@ HOST_DETAIL
Definition: plugutils.h:81
check_kb_inconsistency_log
static int check_kb_inconsistency_log(void)
calls check_kb_inconsistency and logs as debug when local scan_id is missing.
Definition: plugutils.c:426
proto_post_log
void proto_post_log(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action, const char *uri)
Post a log message.
Definition: plugutils.c:690
ARG_INT
#define ARG_INT
Definition: plugutils.h:20
DEADHOST
@ DEADHOST
Definition: plugutils.h:83
hostname
const char * hostname
Definition: pluginlaunch.c:68
ALARM
@ ALARM
Definition: plugutils.h:82
global_nasl_debug
int global_nasl_debug
Definition: plugutils.c:38
plug_set_key
void plug_set_key(struct script_infos *args, char *name, int type, const void *value)
Definition: plugutils.c:962
proto_post_alarm
void proto_post_alarm(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action, const char *uri)
Definition: plugutils.c:673
get_plugin_preference_file_size
long get_plugin_preference_file_size(struct script_infos *desc, const char *identifier)
Get the file size of a plugins preference that is of type "file".
Definition: plugutils.c:917
plug_set_ssl_item
static void plug_set_ssl_item(struct script_infos *args, char *item, char *itemfname)
Definition: plugutils.c:1304
ARG_STRING
#define ARG_STRING
Definition: plugutils.h:19
MAX_CANDIDATES
#define MAX_CANDIDATES