OpenVAS Scanner  7.0.1~git
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
 

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 *)
 
void post_alarm (const char *, struct script_infos *, int, const char *)
 
void post_alarm_udp (struct script_infos *, int, const char *)
 
void proto_post_error (const char *, struct script_infos *, int, const char *, const char *)
 
void post_error (const char *, struct script_infos *, int, const char *)
 
void proto_post_log (const char *, struct script_infos *, int, 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...
 
int host_get_port_state (struct script_infos *, int)
 
int host_get_port_state_udp (struct script_infos *, int)
 
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_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...
 

Detailed Description

Header file for module plugutils.

Definition in file plugutils.h.

Macro Definition Documentation

◆ ARG_INT

◆ ARG_STRING

◆ post_alarm_tcp

#define post_alarm_tcp   post_alarm

Definition at line 99 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 115 of file plugutils.h.

Function Documentation

◆ 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 408 of file plugutils.c.

References name, oid, and prefix().

Referenced by _http_req(), add_scantype_arguments(), add_timing_arguments(), build_cmd_line(), nmap_create(), plugin_do_run(), plugin_run_find_service(), script_get_preference(), script_get_preference_file_content(), and script_get_preference_file_location().

409 {
410  GHashTable *prefs;
411  GHashTableIter iter;
412  char *cname = NULL, *retval = NULL;
413  void *itername, *itervalue;
414  char prefix[1024], suffix[1024];
415 
416  prefs = preferences_get ();
417  if (!prefs || !nvticache_initialized () || !oid || (!name && pref_id < 1))
418  return NULL;
419 
420  g_hash_table_iter_init (&iter, prefs);
421 
422  if (pref_id > 0)
423  {
424  snprintf (prefix, sizeof (prefix), "%s:%d:", oid, pref_id);
425  while (g_hash_table_iter_next (&iter, &itername, &itervalue))
426  {
427  if (g_str_has_prefix (itername, prefix))
428  {
429  retval = g_strdup (itervalue);
430  break;
431  }
432  }
433  }
434  else
435  {
436  cname = g_strdup (name);
437  g_strchomp (cname);
438  snprintf (prefix, sizeof (prefix), "%s:", oid);
439  snprintf (suffix, sizeof (suffix), ":%s", cname);
440  /* NVT preferences received in OID:PrefID:PrefType:PrefName form */
441  while (g_hash_table_iter_next (&iter, &itername, &itervalue))
442  {
443  if (g_str_has_prefix (itername, prefix)
444  && g_str_has_suffix (itername, suffix))
445  {
446  retval = g_strdup (itervalue);
447  break;
448  }
449  }
450  }
451 
452  /* If no value set by the user, get the default one. */
453  if (!retval)
454  {
455  GSList *nprefs, *tmp;
456 
457  tmp = nprefs = nvticache_get_prefs (oid);
458  while (tmp)
459  {
460  if ((cname && !strcmp (cname, nvtpref_name (tmp->data)))
461  || (pref_id >= 0 && pref_id == nvtpref_id (tmp->data)))
462  {
463  retval = g_strdup (nvtpref_default (tmp->data));
464  break;
465  }
466  tmp = tmp->next;
467  }
468  g_slist_free_full (nprefs, (void (*) (void *)) nvtpref_free);
469  }
470  if (cname)
471  g_free (cname);
472  return retval;
473 }
const char * oid
const char * name
Definition: nasl_init.c:377
static void prefix(int n, int i)
Definition: nasl_tree.c:233
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 541 of file plugutils.c.

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

Referenced by get_plugin_preference_fname(), and script_get_preference_file_content().

543 {
544  struct scan_globals *globals = desc->globals;
545  GHashTable *trans;
546 
547  if (!globals)
548  return NULL;
549 
550  trans = globals->files_translation;
551  if (!trans)
552  return NULL;
553 
554  return g_hash_table_lookup (trans, identifier);
555 }
struct scan_globals * globals
Definition: scanneraux.h:45
GHashTable * files_translation
Definition: scanneraux.h:36
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 572 of file plugutils.c.

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

Referenced by get_plugin_preference_fname(), and script_get_preference_file_content().

574 {
575  struct scan_globals *globals = desc->globals;
576  GHashTable *trans;
577  gchar *filesize_str;
578 
579  if (!globals)
580  return -1;
581 
582  trans = globals->files_size_translation;
583  if (!trans)
584  return -1;
585 
586  filesize_str = g_hash_table_lookup (trans, identifier);
587  if (filesize_str == NULL)
588  return -1;
589 
590  return atol (filesize_str);
591 }
struct scan_globals * globals
Definition: scanneraux.h:45
GHashTable * files_size_translation
Definition: scanneraux.h:37
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 486 of file plugutils.c.

References get_plugin_preference_file_content(), and get_plugin_preference_file_size().

Referenced by nmap_create(), plugin_run_find_service(), and script_get_preference_file_location().

487 {
488  const char *content;
489  long contentsize = 0;
490  gint tmpfile;
491  gchar *tmpfilename;
492  GError *error = NULL;
493 
494  content = get_plugin_preference_file_content (desc, filename);
495  if (content == NULL)
496  {
497  return NULL;
498  }
499  contentsize = get_plugin_preference_file_size (desc, filename);
500  if (contentsize <= 0)
501  return NULL;
502 
503  tmpfile =
504  g_file_open_tmp ("openvas-file-upload.XXXXXX", &tmpfilename, &error);
505  if (tmpfile == -1)
506  {
507  g_message ("get_plugin_preference_fname: Could not open temporary"
508  " file for %s: %s",
509  filename, error->message);
510  g_error_free (error);
511  return NULL;
512  }
513  close (tmpfile);
514 
515  if (!g_file_set_contents (tmpfilename, content, contentsize, &error))
516  {
517  g_message ("get_plugin_preference_fname: could set contents of"
518  " temporary file for %s: %s",
519  filename, error->message);
520  g_error_free (error);
521  return NULL;
522  }
523 
524  return tmpfilename;
525 }
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:541
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:572
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 154 of file plugutils.c.

References host_get_port_state_proto().

Referenced by get_port_state(), and open_sock_tcp().

155 {
156  return host_get_port_state_proto (plugdata, portnum, "tcp");
157 }
int host_get_port_state_proto(struct script_infos *args, int portnum, char *proto)
Definition: plugutils.c:148
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 160 of file plugutils.c.

References host_get_port_state_proto().

Referenced by get_udp_port_state().

161 {
162  return host_get_port_state_proto (plugdata, portnum, "udp");
163 }
int host_get_port_state_proto(struct script_infos *args, int portnum, char *proto)
Definition: plugutils.c:148
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 166 of file plugutils.c.

References hostname, and script_infos::vhosts.

Referenced by add_hostname().

168 {
169  gvm_vhost_t *vhost;
170  GSList *vhosts;
171  char **excluded;
172 
173  if (!prefs_get_bool ("expand_vhosts") || !hostname || !source)
174  return -1;
175 
176  /* Check for duplicate vhost value. */
177  vhosts = args->vhosts;
178  while (vhosts)
179  {
180  gvm_vhost_t *tmp = vhosts->data;
181 
182  if (!strcmp (tmp->value, hostname))
183  {
184  g_warning ("%s: Value '%s' exists already", __FUNCTION__, hostname);
185  return -1;
186  }
187  vhosts = vhosts->next;
188  }
189  /* Check for excluded vhost value. */
190  if (prefs_get ("exclude_hosts"))
191  {
192  char **tmp = excluded = g_strsplit (prefs_get ("exclude_hosts"), ",", 0);
193 
194  while (*tmp)
195  {
196  if (!strcmp (g_strstrip (*tmp), hostname))
197  {
198  g_strfreev (excluded);
199  return -1;
200  }
201  tmp++;
202  }
203  g_strfreev (excluded);
204  }
205  vhost = gvm_vhost_new (g_strdup (hostname), g_strdup (source));
206  args->vhosts = g_slist_prepend (args->vhosts, vhost);
207  return 0;
208 }
const char * hostname
Definition: pluginlaunch.c:76
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 57 of file plugutils.c.

References current_vhost.

Referenced by open_sock_tcp().

58 {
59  return current_vhost->value;
60 }
gvm_vhost_t * current_vhost
Definition: plugutils.c:53
Here is the caller graph for this function:

◆ plug_get_host_fqdn()

char* plug_get_host_fqdn ( struct script_infos )

Definition at line 211 of file plugutils.c.

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

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

212 {
213  GSList *vhosts = args->vhosts;
214 
215  if (!args->vhosts)
216  return addr6_as_str (args->ip);
217 
218  /* Workaround for rapid growth of forked processes ie. http_get() calls
219  * within foreach() loops. */
220  if (current_vhost)
221  return g_strdup (current_vhost->value);
222  while (vhosts)
223  {
224  pid_t pid = plug_fork_child (args->key);
225 
226  if (pid == 0)
227  {
228  current_vhost = vhosts->data;
229  return g_strdup (current_vhost->value);
230  }
231  else if (pid == -1)
232  return NULL;
233  vhosts = vhosts->next;
234  }
235  exit (0);
236 }
static pid_t pid
gvm_vhost_t * current_vhost
Definition: plugutils.c:53
static int plug_fork_child(kb_t)
Definition: plugutils.c:695
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 239 of file plugutils.c.

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

Referenced by get_hostnames().

240 {
241  GSList *results = NULL, *vhosts = args->vhosts;
242 
243  if (!args->vhosts)
244  results = g_slist_prepend (results, addr6_as_str (args->ip));
245 
246  while (vhosts)
247  {
248  gvm_vhost_t *vhost = vhosts->data;
249 
250  results = g_slist_prepend (results, g_strdup (vhost->value));
251  vhosts = vhosts->next;
252  }
253  return results;
254 }
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 291 of file plugutils.c.

References plug_get_host_ip().

Referenced by open_sock_tcp().

292 {
293  return addr6_as_str (plug_get_host_ip (desc));
294 }
struct in6_addr * plug_get_host_ip(struct script_infos *args)
Definition: plugutils.c:285
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 817 of file plugutils.c.

References MAX_CANDIDATES, and plug_get_kb().

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

818 {
819  kb_t kb = plug_get_kb (desc);
820  struct kb_item *res, *k;
821  int open21 = 0, open80 = 0;
822 #define MAX_CANDIDATES 16
823  u_short candidates[MAX_CANDIDATES];
824  int num_candidates = 0;
825 
826  k = res = kb_item_get_pattern (kb, "Ports/tcp/*");
827  if (res == NULL)
828  return 0;
829  else
830  {
831  int ret;
832  char *s;
833 
834  for (;;)
835  {
836  s = res->name + sizeof ("Ports/tcp/") - 1;
837  ret = atoi (s);
838  if (ret == 21)
839  open21 = 1;
840  else if (ret == 80)
841  open80 = 1;
842  else
843  {
844  candidates[num_candidates++] = ret;
845  if (num_candidates >= MAX_CANDIDATES)
846  break;
847  }
848  res = res->next;
849  if (res == NULL)
850  break;
851  }
852 
853  kb_item_free (k);
854  if (num_candidates != 0)
855  return candidates[lrand48 () % num_candidates];
856  else if (open21)
857  return 21;
858  else if (open80)
859  return 80;
860  }
861 
862  /* Not reachable */
863  return 0;
864 }
kb_t plug_get_kb(struct script_infos *args)
Definition: plugutils.c:658
#define MAX_CANDIDATES
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 257 of file plugutils.c.

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

Referenced by get_hostname_source().

258 {
259  if (!args->vhosts)
260  return g_strdup ("IP-address");
261 
262  if (hostname)
263  {
264  GSList *vhosts = args->vhosts;
265 
266  /* Search for source of specified hostname/vhost. */
267  while (vhosts)
268  {
269  gvm_vhost_t *vhost = vhosts->data;
270 
271  if (!strcmp (vhost->value, hostname))
272  return g_strdup (vhost->source);
273  vhosts = vhosts->next;
274  }
275  return NULL;
276  }
277  /* Call plug_get_host_fqdn() to set current_vhost (and fork, in case of
278  * multiple vhosts.) */
279  if (!current_vhost)
280  g_free (plug_get_host_fqdn (args));
281  return g_strdup (current_vhost->source);
282 }
char * plug_get_host_fqdn(struct script_infos *args)
Definition: plugutils.c:211
gvm_vhost_t * current_vhost
Definition: plugutils.c:53
const char * hostname
Definition: pluginlaunch.c:76
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 730 of file plugutils.c.

References script_infos::key, name, pid, plug_fork_child(), plug_get_key_sigchld(), and sig_chld().

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

732 {
733  kb_t kb = args->key;
734  struct kb_item *res = NULL, *res_list;
735 
736  if (type != NULL && *type != KB_TYPE_INT)
737  *type = -1;
738 
739  if (kb == NULL)
740  return NULL;
741 
742  if (single && *type != KB_TYPE_INT)
743  res = kb_item_get_single (kb, name, KB_TYPE_UNSPEC);
744  else if (*type == KB_TYPE_INT)
745  res = kb_item_get_single (kb, name, KB_TYPE_INT);
746  else
747  res = kb_item_get_all (kb, name);
748 
749  if (res == NULL)
750  return NULL;
751 
752  if (!res->next) /* No fork - good */
753  {
754  void *ret;
755  if (res->type == KB_TYPE_INT)
756  {
757  if (type != NULL)
758  *type = KB_TYPE_INT;
759  ret = g_memdup (&res->v_int, sizeof (res->v_int));
760  }
761  else
762  {
763  if (type != NULL)
764  *type = KB_TYPE_STR;
765  if (len)
766  *len = res->len;
767  ret = g_memdup (res->v_str, res->len + 1);
768  }
769  kb_item_free (res);
770  return ret;
771  }
772 
773  /* More than one value - we will fork() then */
775  res_list = res;
776  while (res)
777  {
778  pid_t pid = plug_fork_child (kb);
779 
780  if (pid == 0)
781  {
782  /* Forked child. */
783  void *ret;
784 
785  if (res->type == KB_TYPE_INT)
786  {
787  if (type != NULL)
788  *type = KB_TYPE_INT;
789  ret = g_memdup (&res->v_int, sizeof (res->v_int));
790  }
791  else
792  {
793  if (type != NULL)
794  *type = KB_TYPE_STR;
795  if (len)
796  *len = res->len;
797  ret = g_memdup (res->v_str, res->len + 1);
798  }
799  kb_item_free (res_list);
800  return ret;
801  }
802  else if (pid == -1)
803  return NULL;
804  res = res->next;
805  }
806  kb_item_free (res_list);
807  exit (0);
808 }
static pid_t pid
static void sig_chld(void(*fcn)())
Definition: plugutils.c:689
static void plug_get_key_sigchld()
Definition: plugutils.c:664
const char * name
Definition: nasl_init.c:377
static int plug_fork_child(kb_t)
Definition: plugutils.c:695
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 885 of file plugutils.c.

References OPENVAS_ENCAPS_IP, and plug_get_kb().

Referenced by get_port_transport(), and open_stream_auto_encaps_ext().

886 {
887  char s[256];
888  int trp;
889 
890  snprintf (s, sizeof (s), "Transports/TCP/%d", port);
891  trp = kb_item_get_int (plug_get_kb (args), s);
892  if (trp >= 0)
893  return trp;
894  else
895  return OPENVAS_ENCAPS_IP; /* Change this to 0 for ultra smart SSL
896  negotiation, at the expense of possibly
897  breaking stuff */
898 }
kb_t plug_get_kb(struct script_infos *args)
Definition: plugutils.c:658
Here is the call graph for this function:
Here is the caller graph for this function:

◆ plug_replace_key()

void plug_replace_key ( struct script_infos ,
char *  ,
int  ,
void *   
)

◆ plug_replace_key_len()

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

Definition at line 623 of file plugutils.c.

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

Referenced by plug_replace_key(), and replace_kb_item().

625 {
626  kb_t kb = plug_get_kb (args);
627 
628  if (name == NULL || value == NULL)
629  return;
630 
631  if (type == ARG_STRING)
632  kb_item_set_str (kb, name, value, len);
633  else if (type == ARG_INT)
634  kb_item_set_int (kb, name, GPOINTER_TO_SIZE (value));
635  if (global_nasl_debug == 1)
636  {
637  if (type == ARG_STRING)
638  g_message ("replace key %s -> %s", name, (char *) value);
639  else if (type == ARG_INT)
640  g_message ("replace key %s -> %d", name,
641  (int) GPOINTER_TO_SIZE (value));
642  }
643 }
kb_t plug_get_kb(struct script_infos *args)
Definition: plugutils.c:658
const char * name
Definition: nasl_init.c:377
#define ARG_INT
Definition: plugutils.h:34
int global_nasl_debug
Definition: plugutils.c:48
#define ARG_STRING
Definition: plugutils.h:33
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 65 of file plugutils.c.

References script_infos::nvti.

Referenced by script_dependencies().

66 {
67  nvti_t *n = args->nvti;
68  gchar *old = nvti_dependencies (n);
69  gchar *new;
70 
71  if (!depname)
72  return;
73 
74  if (old)
75  {
76  new = g_strdup_printf ("%s, %s", old, depname);
77  nvti_set_dependencies (n, new);
78  g_free (new);
79  }
80  else
81  nvti_set_dependencies (n, depname);
82 }
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 616 of file plugutils.c.

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(), save_detected_os(), save_host_state(), save_hostscripts(), save_ipidseq_details(), save_open_ports(), save_portscripts(), save_tcpseq_details(), save_traceroute_details(), scan(), set_kb_item(), and simple_register_host_detail().

618 {
619  plug_set_key_len (args, name, type, value, 0);
620 }
void plug_set_key_len(struct script_infos *args, char *name, int type, const void *value, size_t len)
Definition: plugutils.c:594
const char * name
Definition: nasl_init.c:377
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 594 of file plugutils.c.

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

Referenced by plug_set_key(), and set_kb_item().

596 {
597  kb_t kb = plug_get_kb (args);
598 
599  if (name == NULL || value == NULL)
600  return;
601 
602  if (type == ARG_STRING)
603  kb_item_add_str_unique (kb, name, value, len);
604  else if (type == ARG_INT)
605  kb_item_add_int_unique (kb, name, GPOINTER_TO_SIZE (value));
606  if (global_nasl_debug == 1)
607  {
608  if (type == ARG_STRING)
609  g_message ("set key %s -> %s", name, (char *) value);
610  else if (type == ARG_INT)
611  g_message ("set key %s -> %d", name, (int) GPOINTER_TO_SIZE (value));
612  }
613 }
kb_t plug_get_kb(struct script_infos *args)
Definition: plugutils.c:658
const char * name
Definition: nasl_init.c:377
#define ARG_INT
Definition: plugutils.h:34
int global_nasl_debug
Definition: plugutils.c:48
#define ARG_STRING
Definition: plugutils.h:33
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 872 of file plugutils.c.

References ARG_INT, and plug_set_key().

Referenced by open_stream_auto_encaps_ext(), and plugin_do_run().

873 {
874  char s[256];
875 
876  snprintf (s, sizeof (s), "Transports/TCP/%d", port);
877  plug_set_key (args, s, ARG_INT, GSIZE_TO_POINTER (tr));
878 }
void plug_set_key(struct script_infos *args, char *name, int type, const void *value)
Definition: plugutils.c:616
#define ARG_INT
Definition: plugutils.h:34
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 931 of file plugutils.c.

References plug_set_ssl_item().

Referenced by plugin_run_find_service().

932 {
933  plug_set_ssl_item (args, "CA", key);
934 }
static void plug_set_ssl_item(struct script_infos *args, char *item, char *itemfname)
Definition: plugutils.c:901
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 909 of file plugutils.c.

References plug_set_ssl_item().

Referenced by plugin_run_find_service().

910 {
911  plug_set_ssl_item (args, "cert", cert);
912 }
static void plug_set_ssl_item(struct script_infos *args, char *item, char *itemfname)
Definition: plugutils.c:901
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 915 of file plugutils.c.

References plug_set_ssl_item().

Referenced by plugin_run_find_service().

916 {
917  plug_set_ssl_item (args, "key", key);
918 }
static void plug_set_ssl_item(struct script_infos *args, char *item, char *itemfname)
Definition: plugutils.c:901
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 921 of file plugutils.c.

References plug_set_ssl_item().

Referenced by plugin_run_find_service().

922 {
923  plug_set_ssl_item (args, "password", key);
924 }
static void plug_set_ssl_item(struct script_infos *args, char *item, char *itemfname)
Definition: plugutils.c:901
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 *   
)

Definition at line 355 of file plugutils.c.

References oid, and proto_post_alarm().

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

357 {
358  proto_post_alarm (oid, desc, port, "tcp", action);
359 }
const char * oid
void proto_post_alarm(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action)
Definition: plugutils.c:348
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 *   
)

◆ post_error()

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

Definition at line 389 of file plugutils.c.

References oid, and proto_post_error().

Referenced by error_message().

391 {
392  proto_post_error (oid, desc, port, "tcp", action);
393 }
const char * oid
void proto_post_error(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action)
Definition: plugutils.c:382
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 375 of file plugutils.c.

References oid, and proto_post_log().

Referenced by log_message(), 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_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().

377 {
378  proto_post_log (oid, desc, port, "tcp", action);
379 }
const char * oid
void proto_post_log(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action)
Post a log message.
Definition: plugutils.c:365
Here is the call graph for this function:

◆ proto_post_alarm()

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

Definition at line 348 of file plugutils.c.

References oid, and proto_post_wrapped().

Referenced by post_alarm(), and security_message().

350 {
351  proto_post_wrapped (oid, desc, port, proto, action, "ALARM");
352 }
const char * oid
void proto_post_wrapped(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action, const char *what)
Post a security message (e.g. LOG, NOTE, WARNING ...).
Definition: plugutils.c:307
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 *   
)

Definition at line 382 of file plugutils.c.

References oid, and proto_post_wrapped().

Referenced by error_message(), and post_error().

384 {
385  proto_post_wrapped (oid, desc, port, proto, action, "ERRMSG");
386 }
const char * oid
void proto_post_wrapped(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action, const char *what)
Post a security message (e.g. LOG, NOTE, WARNING ...).
Definition: plugutils.c:307
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 *   
)

Post a log message.

Definition at line 365 of file plugutils.c.

References oid, and proto_post_wrapped().

Referenced by log_message(), and post_log().

367 {
368  proto_post_wrapped (oid, desc, port, proto, action, "LOG");
369 }
const char * oid
void proto_post_wrapped(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action, const char *what)
Post a security message (e.g. LOG, NOTE, WARNING ...).
Definition: plugutils.c:307
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 652 of file plugutils.c.

References host_add_port_proto().

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

653 {
654  host_add_port_proto (args, port, proto);
655 }
void host_add_port_proto(struct script_infos *args, int portnum, char *proto)
Definition: plugutils.c:85
Here is the call graph for this function:
Here is the caller graph for this function: