Hello,
I created a small patch for the OpenVAS Client to allow entering of
virtual hosts in the format ip[vhost1,vhost2]. It should work both in
gui and cli mode.
The next part will be to group the report accordingly.
Please feel free to comment or commit it :-)
BR,
Christian
Index: openvas/prefs_dialog/prefs_help.h
===================================================================
--- openvas/prefs_dialog/prefs_help.h (revision 5826)
+++ openvas/prefs_dialog/prefs_help.h (working copy)
@@ -122,7 +122,9 @@
_("The first host(s) that will be attacked by OpenVAS Server. \
The options below allow you to extend the test to a larger set of \
computer. You may define several primary targets by separating \
-them with a comma (,). ie : \"host1,host2\".")
+them with a comma (,). ie : \"host1,host2\". Additionally it is possible \
+to define virtual hosts in square brackets ([]). ie : \"host1[vhost1,vhost2],\
+host2\".")
#define HLP_TARGET_READ_FROM_FILE \
_("A textfile can be specified that contains the list of targets. \
Index: openvas/read_target_file.c
===================================================================
--- openvas/read_target_file.c (revision 5826)
+++ openvas/read_target_file.c (working copy)
@@ -103,7 +103,39 @@
#endif /* USE_GTK */
+
/**
+ * @brief Convert target string with virtual hosts to comma separated string
+ *
+ * This function translates a string from the format IP[virtual_host1,virtual
host2, ...]
+ * to a string in the format IP,virtual_host1,virtual host2,...
+ * It has to be called from every function which reads targets in.
+ *
+ * @param targets Target string with possible virtual hosts in it
+ *
+ * @return New comma separated target string with virtual hosts as targets
+ */
+static char*
+translate_vhosts(const char* targets)
+{
+ gchar * temp = g_strdup(targets);
+ gchar ** v_wo_bracket = NULL;
+ gchar * s_wo_bracket = NULL;
+
+ // strip out '[' and replace it with a comma
+ g_strdelimit(temp, "[", ',');
+
+ // delete the character ']' entirely
+ v_wo_bracket = g_strsplit(temp, "]", -1);
+ s_wo_bracket = g_strjoinv(NULL, v_wo_bracket);
+
+ g_strfreev(v_wo_bracket);
+ return s_wo_bracket;
+}
+
+
+
+/**
* @brief Returns a string assembled out of the lines in file filename.
*
* The string will contain all the content of the file where newlines have been
@@ -166,6 +198,10 @@
ret[len-1]='\0';
len--;
}
+
+ // strip out the virtual hosts
+ ret = translate_vhosts(ret);
+
return(ret);
}
@@ -202,6 +238,9 @@
// Collapse the vector.
s_wo_white = g_strjoinv (NULL, v_wo_white);
+ // strip out the virtual hosts
+ s_wo_white = translate_vhosts( s_wo_white);
+
// Free and return
g_strfreev (v_wo_white);
return s_wo_white;
_______________________________________________
Openvas-devel mailing list
Openvas-devel@wald.intevation.org
http://lists.wald.intevation.org/mailman/listinfo/openvas-devel