37 #include "../base/kb.h" 38 #include "../misc/plugutils.h" 39 #include "../misc/network.h" 40 #include "../misc/vendorversion.h" 47 #include "../misc/openvas_logging.h" 52 #include "../base/nvticache.h" 54 #include "../misc/prefs.h" 63 isalldigit (
char *str,
int len)
67 for (i = 0; i < len; i++)
69 if (!isdigit (str[i]))
73 snprintf (buf,
sizeof (buf),
"%d", atoi (str));
74 if (strcmp (buf, str) != 0)
138 for (i = 0; cve != NULL; i++)
157 for (i = 0; bid != NULL; i++)
178 "script_xref() syntax error - should be" 179 " script_xref(name:<name>, value:<value>)\n");
213 nasl_perror (lexic,
"script_tag() syntax error - should be" 214 " script_tag(name:<name>, value:<value>)\n");
234 if (strchr (
value,
'|'))
262 nasl_perror (lexic,
"Argument error in function script_version()\n");
263 nasl_perror (lexic,
"Function usage is : script_version(<version>)\n");
264 nasl_perror (lexic,
"Where <version> is the version of this script\n");
296 nasl_perror (lexic,
"Argument error in function script_category()\n");
297 nasl_perror (lexic,
"Function usage is : script_category(<category>)\n");
321 nasl_perror (lexic,
"Argument error in function script_dependencies()\n");
322 nasl_perror (lexic,
"Function usage is : script_dependencies(<name>)\n");
323 nasl_perror (lexic,
"Where <name> is the name of another script\n");
328 for (i = 0; dep != NULL; i++)
347 nasl_perror (lexic,
"Argument error in function script_require_keys()\n");
348 nasl_perror (lexic,
"Function usage is : script_require_keys(<name>)\n");
349 nasl_perror (lexic,
"Where <name> is the name of a key\n");
353 for (i = 0; keys != NULL; i++)
372 "Argument error in function script_mandatory_keys()\n");
374 "Function usage is : script_mandatory_keys(<name>)\n");
375 nasl_perror (lexic,
"Where <name> is the name of a key\n");
381 splits = g_strsplit (re,
"=", 0);
383 if (!splits[0] || !splits[1] || !*splits[1] || splits[2])
389 for (i = 0; keys != NULL; i++)
393 if (splits && keys && !strcmp (keys, splits[0]))
418 nasl_perror (lexic,
"Argument error in function script_exclude_keys()\n");
419 nasl_perror (lexic,
"Function usage is : script_exclude_keys(<name>)\n");
420 nasl_perror (lexic,
"Where <name> is the name of a key\n");
424 for (i = 0; keys != NULL; i++)
482 "Argument error in the call to script_add_preference()\n");
500 "Argument error in the function script_get_preference()\n");
502 "Function usage is : pref = script_get_preference(<name>)\n");
541 "Argument error in the function script_get_preference()\n");
543 "Function usage is : pref = script_get_preference_file_content(<name>)\n");
555 if (contentsize <= 0)
557 nasl_perror (lexic,
"script_get_preference_file_content: could not get " 558 " size of file from preference %s\n", pref);
564 retc->
size = contentsize;
577 const char *
value, *local;
583 "script_get_preference_file_location: no preference name!\n");
591 "script_get_preference_file_location: could not get preference %s\n",
599 len = strlen (local);
602 retc->
x.
str_val = g_malloc0 (len + 1);
603 memcpy (retc->
x.
str_val, local, len + 1);
632 if (strcmp (
value,
"busy") == 0)
674 const char *
oid = lexic->
oid;
702 nasl_perror (lexic,
"get_kb_list() usage : get_kb_list(<NameOfItem>)\n");
713 top = res = kb_item_get_pattern (
kb, kb_mask);
718 bzero (&v,
sizeof (v));
758 if (kb_entry == NULL)
803 nasl_perror (lexic,
"Syntax error with replace_kb_item() [null name]\n",
813 GSIZE_TO_POINTER (
value));
816 "Syntax error with replace_kb_item(%s) [value=-1]\n",
825 "Syntax error with replace_kb_item(%s) [null value]\n",
844 nasl_perror (lexic,
"Syntax error with set_kb_item() [null name]\n",
856 "Syntax error with set_kb_item() [value=-1 for name '%s']\n",
865 "Syntax error with set_kb_item() [null value for name '%s']\n",
882 const char *,
const char *);
905 dup = g_memdup (data, len + 1);
906 for (i = 0; i < len; i++)
914 fprintf (stdout,
"%s\n", dup);
916 fprintf (stdout,
"Success\n");
928 post_func (lexic->
oid, script_infos, port, dup);
930 proto_post_func (lexic->
oid, script_infos, port, proto, dup);
937 post_func (lexic->
oid, script_infos, port, NULL);
939 proto_post_func (lexic->
oid, script_infos, port, proto, NULL);
1000 retc->
size = strlen (version);
1018 const char *prange =
prefs_get (
"port_range");
1020 static u_short *ports = NULL;
1027 nasl_perror (lexic,
"Argument error in scanner_get_port()\n");
1028 nasl_perror (lexic,
"Correct usage is : num = scanner_get_port(<num>)\n");
1030 "Where <num> should be 0 the first time you call it\n");
1036 ports = (u_short *)
getpts ((
char *)prange, &num);
1050 retc->
x.
i_val = ports[idx];
tree_cell * nasl_scanner_get_port(lex_ctxt *lexic)
tree_cell * script_get_preference_file_content(lex_ctxt *lexic)
int nvti_set_category(nvti_t *n, const gint category)
Set the category type of a NVT Info.
void proto_post_error(const char *oid, struct arglist *desc, int port, const char *proto, const char *action)
tree_cell * get_script_oid(lex_ctxt *lexic)
Return the OID of the current script.
void proto_post_alarm(const char *oid, struct arglist *desc, int port, const char *proto, const char *action)
tree_cell * script_exclude_keys(lex_ctxt *lexic)
tree_cell * script_oid(lex_ctxt *lexic)
void plug_replace_key(struct arglist *args, char *name, int type, void *value)
int nvti_set_copyright(nvti_t *n, const gchar *copyright)
Set the copyright of a NVT.
void kb_item_free(struct kb_item *)
Release a KB item (or a list).
void plug_set_dep(struct arglist *desc, const char *depname)
tree_cell * scan_phase(lex_ctxt *lexic)
void plug_set_tag(struct arglist *desc, char *name, char *value)
int nvti_set_family(nvti_t *n, const gchar *family)
Set the family of a NVT.
void post_error(const char *oid, struct arglist *desc, int port, const char *action)
void plug_set_key(struct arglist *args, char *name, int type, const void *value)
void * plug_get_key(struct arglist *args, char *name, int *type, int single)
The structure of a information record that corresponds to a NVT.
tree_cell * script_family(lex_ctxt *lexic)
tree_cell * script_require_ports(lex_ctxt *lexic)
Knowledge base item (defined by name, type (int/char*) and value). Implemented as a singly linked lis...
tree_cell * get_kb_item(lex_ctxt *lexic)
union st_a_nasl_var::@9 v
tree_cell * script_bugtraq_id(lex_ctxt *lexic)
int nvti_set_timeout(nvti_t *n, const gint timeout)
Set the timout of a NVT Info.
int nvti_add_required_udp_ports(nvti_t *n, const gchar *port)
Add a required udp port of a NVT.
void deref_cell(tree_cell *c)
tree_cell * nasl_scanner_status(lex_ctxt *lexic)
int nvti_add_cve(nvti_t *n, const gchar *cve_id)
Add a single CVE ID of a NVT.
tree_cell * script_version(lex_ctxt *lexic)
int add_var_to_array(nasl_array *a, char *name, const anon_nasl_var *v)
long int get_int_local_var_by_name(lex_ctxt *, const char *, int)
tree_cell * script_add_preference(lex_ctxt *lexic)
const gchar * prefs_get(const gchar *key)
Get a string preference value via a key.
tree_cell * script_cve_id(lex_ctxt *lexic)
int get_local_var_size_by_name(lex_ctxt *, const char *)
char * get_str_local_var_by_name(lex_ctxt *, const char *)
char * get_str_var_by_name(lex_ctxt *, const char *)
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".
tree_cell * log_message(lex_ctxt *lexic)
tree_cell * alloc_typed_cell(int typ)
tree_cell * nasl_scanner_add_port(lex_ctxt *lexic)
tree_cell * get_kb_list(lex_ctxt *lexic)
tree_cell * script_dependencies(lex_ctxt *lexic)
kb_t plug_get_kb(struct arglist *args)
void post_log(const char *oid, struct arglist *desc, int port, const char *action)
Post a log message about a tcp port.
unsigned short * getpts(char *origexpr, int *len)
Converts a string like "-100,200-1024,3000-4000,60000-" into an array.
tree_cell * set_kb_item(lex_ctxt *lexic)
tree_cell * script_timeout(lex_ctxt *lexic)
Top-level KB. This is to be inherited by KB implementations.
const gchar * vendor_version_get()
Get vendor version.
tree_cell * script_require_keys(lex_ctxt *lexic)
int nvti_set_oid(nvti_t *n, const gchar *oid)
Set the OID of a NVT Info.
int nvti_add_mandatory_keys(nvti_t *n, const gchar *key)
Add a mandatory key of a NVT.
int nvti_set_version(nvti_t *n, const gchar *version)
Set the version of a NVT.
tree_cell * script_tag(lex_ctxt *lexic)
int nvti_add_bid(nvti_t *n, const gchar *bid_id)
Add a single BID ID of a NVT.
int nvti_set_name(nvti_t *n, const gchar *name)
Set the name of a NVT.
void(* post_something_t)(const char *, struct arglist *, int, const char *)
tree_cell * safe_checks(lex_ctxt *lexic)
void(* proto_post_something_t)(const char *, struct arglist *, int, const char *, const char *)
void post_alarm(const char *oid, struct arglist *desc, int port, const char *action)
void plug_set_xref(struct arglist *desc, char *name, char *value)
tree_cell * script_id(lex_ctxt *lexic)
void scanner_add_port(struct arglist *args, int port, char *proto)
int get_local_var_type_by_name(lex_ctxt *, const char *)
tree_cell * script_name(lex_ctxt *lexic)
long int get_int_var_by_num(lex_ctxt *, int, int)
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".
void nasl_perror(lex_ctxt *lexic, char *msg,...)
tree_cell * script_get_preference_file_location(lex_ctxt *lexic)
char * get_str_var_by_num(lex_ctxt *, int)
int nvti_add_excluded_keys(nvti_t *n, const gchar *key)
Add a excluded key of a NVT.
tree_cell * script_mandatory_keys(lex_ctxt *lexic)
tree_cell * alloc_tree_cell(int lnb, char *s)
void add_plugin_preference(struct arglist *desc, const char *name, const char *type, const char *defaul)
tree_cell * nasl_get_preference(lex_ctxt *lexic)
tree_cell * replace_kb_item(lex_ctxt *lexic)
struct arglist * script_infos
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".
tree_cell * script_category(lex_ctxt *lexic)
void proto_post_log(const char *oid, struct arglist *desc, int port, const char *proto, const char *action)
Post a log message.
int nvti_add_required_ports(nvti_t *n, const gchar *port)
Add a required port of a NVT.
tree_cell * script_get_preference(lex_ctxt *lexic)
int nvti_add_required_keys(nvti_t *n, const gchar *key)
Add a required key of a NVT.
tree_cell * network_targets(lex_ctxt *lexic)
tree_cell * script_require_udp_ports(lex_ctxt *lexic)
tree_cell * error_message(lex_ctxt *lexic)
void * arg_get_value(struct arglist *args, const char *name)
tree_cell * nasl_vendor_version(lex_ctxt *lexic)
int prefs_get_bool(const gchar *key)
Get a boolean expression of a preference value via a key.
tree_cell * security_message(lex_ctxt *lexic)
Send a security message to the client.
tree_cell * script_copyright(lex_ctxt *lexic)
char * get_plugin_preference(const char *oid, const char *name)
tree_cell * script_summary(lex_ctxt *lexic)
tree_cell * script_xref(lex_ctxt *lexic)