OpenVAS Libraries  8.0.3
Macros | Functions | Variables
plugutils.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <sys/wait.h>
#include <time.h>
#include <glib.h>
#include "arglists.h"
#include "kb.h"
#include "network.h"
#include "plugutils.h"
#include "internal_com.h"
#include "openvas_logging.h"
#include "prefs.h"
#include "../base/nvticache.h"

Macros

#define MAX_CANDIDATES   16
 

Functions

void plug_set_xref (struct arglist *desc, char *name, char *value)
 
void plug_set_tag (struct arglist *desc, char *name, char *value)
 
void plug_set_dep (struct arglist *desc, const char *depname)
 
void plug_set_launch (struct arglist *desc, int launch)
 
int plug_get_launch (struct arglist *desc)
 
void _add_plugin_preference (const char *p_name, const char *name, const char *type, const char *defaul)
 
struct arglistplug_create_from_nvti_and_prefs (const nvti_t *nvti)
 Returns a (plugin) arglist assembled from the nvti. More...
 
void host_add_port_proto (struct arglist *args, int portnum, int state, char *proto)
 
int kb_get_port_state_proto (kb_t kb, int portnum, char *proto)
 
int host_get_port_state_proto (struct arglist *plugdata, int portnum, char *proto)
 
int host_get_port_state (struct arglist *plugdata, int portnum)
 
int host_get_port_state_udp (struct arglist *plugdata, int portnum)
 
const char * plug_get_hostname (struct arglist *desc)
 
char * plug_get_host_fqdn (struct arglist *desc)
 
struct in6_addr * plug_get_host_ip (struct arglist *desc)
 
char * plug_get_host_ip_str (struct arglist *desc)
 
void proto_post_wrapped (const char *oid, struct arglist *desc, int port, const char *proto, const char *action, const char *what)
 Post a security message (e.g. LOG, NOTE, WARNING ...). More...
 
void proto_post_alarm (const char *oid, struct arglist *desc, int port, const char *proto, const char *action)
 
void post_alarm (const char *oid, struct arglist *desc, int port, const char *action)
 
void proto_post_log (const char *oid, struct arglist *desc, int port, const char *proto, const char *action)
 Post a log message. More...
 
void post_log (const char *oid, struct arglist *desc, int port, const char *action)
 Post a log message about a tcp port. More...
 
void proto_post_error (const char *oid, struct arglist *desc, int port, const char *proto, const char *action)
 
void post_error (const char *oid, struct arglist *desc, int port, const char *action)
 
void add_plugin_preference (struct arglist *desc, const char *name, const char *type, const char *defaul)
 
char * get_plugin_preference (const char *oid, const char *name)
 
const char * get_plugin_preference_fname (struct arglist *desc, const char *filename)
 Get the file name of a plugins preference that is of type "file". More...
 
char * get_plugin_preference_file_content (struct arglist *desc, const char *identifier)
 Get the file contents of a plugins preference that is of type "file". More...
 
const long get_plugin_preference_file_size (struct arglist *desc, const char *identifier)
 Get the file size of a plugins preference that is of type "file". More...
 
void plug_set_key (struct arglist *args, char *name, int type, void *value)
 
void plug_replace_key (struct arglist *args, char *name, int type, void *value)
 
void scanner_add_port (struct arglist *args, int port, char *proto)
 
kb_t plug_get_kb (struct arglist *args)
 
void * plug_get_key (struct arglist *args, char *name, int *type)
 
unsigned int plug_get_host_open_port (struct arglist *desc)
 
void plug_set_port_transport (struct arglist *args, int port, int tr)
 
int plug_get_port_transport (struct arglist *args, int port)
 
void plug_set_ssl_cert (struct arglist *args, char *cert)
 
void plug_set_ssl_key (struct arglist *args, char *key)
 
void plug_set_ssl_pem_password (struct arglist *args, char *key)
 
void plug_set_ssl_CA_file (struct arglist *args, char *key)
 
char * find_in_path (char *name, int safe)
 

Variables

int global_nasl_debug = 0
 

Macro Definition Documentation

#define MAX_CANDIDATES   16

Function Documentation

void _add_plugin_preference ( const char *  p_name,
const char *  name,
const char *  type,
const char *  defaul 
)
void add_plugin_preference ( struct arglist desc,
const char *  name,
const char *  type,
const char *  defaul 
)
char* find_in_path ( char *  name,
int  safe 
)
char* get_plugin_preference ( const char *  oid,
const char *  name 
)
char* get_plugin_preference_file_content ( struct arglist 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.
const long get_plugin_preference_file_size ( struct arglist 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.
const char* get_plugin_preference_fname ( struct arglist 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.
void host_add_port_proto ( struct arglist args,
int  portnum,
int  state,
char *  proto 
)
int host_get_port_state ( struct arglist plugdata,
int  portnum 
)
int host_get_port_state_proto ( struct arglist plugdata,
int  portnum,
char *  proto 
)
int host_get_port_state_udp ( struct arglist plugdata,
int  portnum 
)
int kb_get_port_state_proto ( kb_t  kb,
int  portnum,
char *  proto 
)
Parameters
protoProtocol (udp/tcp). If NULL, "tcp" will be used.
struct arglist* plug_create_from_nvti_and_prefs ( const nvti_t nvti)

Returns a (plugin) arglist assembled from the nvti.

Parameters
nvtiNVT Information to be used for the creation.
Returns
Pointer to plugin as arglist or NULL.
char* plug_get_host_fqdn ( struct arglist desc)
struct in6_addr* plug_get_host_ip ( struct arglist desc)
char* plug_get_host_ip_str ( struct arglist desc)
unsigned int plug_get_host_open_port ( struct arglist 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...

const char* plug_get_hostname ( struct arglist desc)
kb_t plug_get_kb ( struct arglist args)
void* plug_get_key ( struct arglist args,
char *  name,
int *  type 
)
int plug_get_launch ( struct arglist desc)
int plug_get_port_transport ( struct arglist args,
int  port 
)
void plug_replace_key ( struct arglist args,
char *  name,
int  type,
void *  value 
)
void plug_set_dep ( struct arglist desc,
const char *  depname 
)
void plug_set_key ( struct arglist args,
char *  name,
int  type,
void *  value 
)
void plug_set_launch ( struct arglist desc,
int  launch 
)
void plug_set_port_transport ( struct arglist 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
void plug_set_ssl_CA_file ( struct arglist 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.
void plug_set_ssl_cert ( struct arglist args,
char *  cert 
)
void plug_set_ssl_key ( struct arglist args,
char *  key 
)
void plug_set_ssl_pem_password ( struct arglist args,
char *  key 
)
void plug_set_tag ( struct arglist desc,
char *  name,
char *  value 
)
void plug_set_xref ( struct arglist desc,
char *  name,
char *  value 
)
void post_alarm ( const char *  oid,
struct arglist desc,
int  port,
const char *  action 
)
void post_error ( const char *  oid,
struct arglist desc,
int  port,
const char *  action 
)
void post_log ( const char *  oid,
struct arglist desc,
int  port,
const char *  action 
)

Post a log message about a tcp port.

void proto_post_alarm ( const char *  oid,
struct arglist desc,
int  port,
const char *  proto,
const char *  action 
)
void proto_post_error ( const char *  oid,
struct arglist desc,
int  port,
const char *  proto,
const char *  action 
)
void proto_post_log ( const char *  oid,
struct arglist desc,
int  port,
const char *  proto,
const char *  action 
)

Post a log message.

void proto_post_wrapped ( const char *  oid,
struct arglist desc,
int  port,
const char *  proto,
const char *  action,
const char *  what 
)

Post a security message (e.g. LOG, NOTE, WARNING ...).

Parameters
oidThe oid of the NVT
descThe arglist where to get the nvtichache from and some other settings and it is used to send the messages
portPort number related to the issue.
protoProtocol related to the issue (tcp or udp).
actionThe actual result text
whatThe type, like "LOG".
void scanner_add_port ( struct arglist args,
int  port,
char *  proto 
)

Variable Documentation

int global_nasl_debug = 0