Update of /usr/local/cvs/nessus-core/nessus
In directory raccoon.nessus.org:/tmp/cvs-serv69892/nessus
Modified Files:
Makefile attack.c attack.h auth.c auth.h backend.c backend.h
cli.c comm.c comm.h data_mining.c detached_index.c
error_dialog.c error_dialog.h families.c families.h filter.c
globals.h gtk-compat.h html_graph_output.c html_output.c
latex_output.c monitor_dialog.c monitor_dialog.h nbe_output.c
nessus.c nessus.h nsr_output.c parser.c plugin_infos.c
preferences.c preferences.h read_target_file.c
read_target_file.h report.c report_save.c report_save.h
report_utils.c report_utils.h sighand.c text_output.c
xml_output.c xml_output_ng.c xstuff.c xstuff.h
Log Message:
Sync back to 2.2 as NessusClient is now on another branch
Index: Makefile
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/Makefile,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- Makefile 2 Sep 2005 09:25:13 -0000 1.71
+++ Makefile 17 Mar 2007 21:35:59 -0000 1.72
@@ -1,7 +1,7 @@
include ../nessus.tmpl
-GTKLIBS= $(GTKCONFIG_LIBS)
-INCLUDE = ${include} $(GTKCONFIG_CFLAGS) -Igdchart0.94b -Igdchart0.94b/gd1.3
+GTKLIBS= $(GTKCONFIG_LIBS) $(GLIBCONFIG_LIBS)
+INCLUDE = ${include} $(GTKCONFIG_CFLAGS) $(GLIBCONFIG_CFLAGS) -Igdchart0.94b -Igdchart0.94b/gd1.3
LIBS = `$(NESSUSCONFIG) --libs` $(X_LIBS) $(X_CFLAGS) $(GTKLIBS) \
$(RUN_LIBS) $(C_R_LIB) gdchart0.94b/gd1.3/libgd.a -lm
@@ -14,11 +14,11 @@
cli.o \
parser.o \
plugin_infos.o \
- context.o \
preferences.o \
families.o \
attack.o \
report.o \
+ report_ng.o \
report_save.o \
report_utils.o \
nsr_output.o \
@@ -35,14 +35,12 @@
backend.o \
data_mining.o \
prefs_dialog.o \
- prefs_scope_tree.o \
prefs_dialog_misc.o \
prefs_dialog_scan_opt.o \
prefs_dialog_user.o \
prefs_dialog_auth.o \
prefs_dialog_plugins_prefs.o \
prefs_plugins.o \
- prefs_plugins_tree.o \
prefs_target.o \
prefs_about.o \
prefs_kb.o \
@@ -58,9 +56,7 @@
dirutils.o \
sslui.o \
nessus.o
-
-GTK_OBJS = prefs_comment.o prefs_context.o prefs_options.o prefs_report.o \
- prefs_dialog_prefs.o prefs_scan_assistant.o pdf_output.o
+
all : cflags ${make_bindir}/nessus
@@ -71,207 +67,155 @@
cflags :
- @echo "$(NESSUS_CFLAGS) $(NESSUS_DEFS) -DPACKAGE=\"nessus\" $(INCLUDE)" | sed 's/\"/\\\"/g' > cflags.tmp
+ @echo "$(NESSUS_CFLAGS) $(NESSUS_DEFS) $(INCLUDE)" | sed 's/\"/\\\"/g' > cflags.tmp
@echo "echo \"`cat cflags.tmp`\"" > cflags
@rm cflags.tmp
@chmod +x cflags
-nessus : cflags $(OBJS) $(if $(USE_GTK),$(GTK_OBJS))
- $(CC) $(LDFLAGS) $(OBJS) $(if $(USE_GTK),$(GTK_OBJS)) -o nessus $(LIBS)
+nessus : cflags $(OBJS)
+ $(CC) $(LDFLAGS) $(OBJS) -o nessus $(LIBS)
detached_index.o : cflags detached_index.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c detached_index.c
-context.o : cflags context.c context.h error_dialog.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c context.c
-
-preferences.o : cflags preferences.c preferences.h error_dialog.h globals.h
+preferences.o : cflags preferences.c preferences.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c preferences.c
-prefs_dialog.o : cflags prefs_dialog/prefs_dialog.c prefs_dialog/prefs_dialog.h\
- prefs_dialog/prefs_help.h globals.h context.h prefs_dialog/prefs_context.h\
- error_dialog.h prefs_dialog/prefs_comment.h
+prefs_dialog.o : cflags prefs_dialog/prefs_dialog.c prefs_dialog/prefs_dialog.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog.c
-prefs_scope_tree.o : cflags prefs_dialog/prefs_scope_tree.c error_dialog.h \
- globals.h preferences.h context.h prefs_dialog/prefs_context.h \
- xpm/connected.xpm
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_scope_tree.c
-
-prefs_dialog_misc.o : cflags prefs_dialog/prefs_dialog_misc.c prefs_dialog/prefs_dialog_misc.h globals.h
+prefs_dialog_misc.o : cflags prefs_dialog/prefs_dialog_misc.c prefs_dialog/prefs_dialog_misc.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_misc.c
prefs_dialog_scan_opt.o : cflags prefs_dialog/prefs_dialog_scan_opt.c\
- prefs_dialog/prefs_dialog_scan_opt.h error_dialog.h globals.h
+ prefs_dialog/prefs_dialog_scan_opt.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_scan_opt.c
prefs_target.o : cflags prefs_dialog/prefs_target.c\
- prefs_dialog/prefs_target.h read_target_file.h
+ prefs_dialog/prefs_target.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_target.c
-prefs_dialog_user.o : cflags prefs_dialog/prefs_dialog_user.c globals.h
+prefs_dialog_user.o : cflags prefs_dialog/prefs_dialog_user.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_user.c
-prefs_dialog_auth.o : cflags prefs_dialog/prefs_dialog_auth.c \
- prefs_dialog/prefs_help.h globals.h context.h error_dialog.h
+prefs_dialog_auth.o : cflags prefs_dialog/prefs_dialog_auth.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_auth.c
-prefs_plugins.o : cflags prefs_dialog/prefs_plugins.c error_dialog.h\
- prefs_dialog/prefs_help.h prefs_dialog/prefs_plugins_tree.h\
- globals.h
+prefs_plugins.o : cflags prefs_dialog/prefs_plugins.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_plugins.c
-prefs_plugins_tree.o : cflags prefs_dialog/prefs_plugins_tree.c \
- prefs_dialog/prefs_plugins_tree.h filter.h \
- error_dialog.h prefs_dialog/prefs_help.h globals.h \
- plugin_infos.h families.h xpm/warning_small.xpm
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_plugins_tree.c
-
-prefs_dialog_plugins_prefs.o : cflags prefs_dialog/prefs_dialog_plugins_prefs.c context.h
+prefs_dialog_plugins_prefs.o : cflags prefs_dialog/prefs_dialog_plugins_prefs.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_plugins_prefs.c
-prefs_kb.o : cflags prefs_dialog/prefs_kb.c prefs_dialog/prefs_help.h \
- context.h
+prefs_kb.o : cflags prefs_dialog/prefs_kb.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_kb.c
-prefs_context.o : cflags prefs_dialog/prefs_context.c globals.h context.h \
- preferences.h error_dialog.h prefs_dialog/prefs_comment.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_context.c
-
-prefs_comment.o : cflags prefs_dialog/prefs_comment.c \
- prefs_dialog/prefs_comment.h globals.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_comment.c
-
-prefs_options.o : cflags prefs_dialog/prefs_options.c \
- prefs_dialog/prefs_options.h globals.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_options.c
-
-prefs_report.o : cflags prefs_dialog/prefs_report.c \
- prefs_dialog/prefs_report.h globals.h xpm/computer.xpm xpm/network.xpm \
- xpm/warning_small.xpm xpm/info_small.xpm xpm/error_small.xpm xpm/nothing.xpm
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_report.c
-
-prefs_dialog_prefs.o : cflags prefs_dialog/prefs_dialog_prefs.c \
- prefs_dialog/prefs_dialog_prefs.h globals.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_prefs.c
-
-prefs_scan_assistant.o : cflags prefs_dialog/prefs_scan_assistant.c \
- error_dialog.h context.h prefs_dialog/prefs_context.h \
- prefs_dialog/prefs_scope_tree.h prefs_dialog/prefs_dialog.h \
- prefs_dialog/prefs_dialog_auth.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_scan_assistant.c
-
-error_dialog.o : cflags error_dialog.c error_dialog.h globals.h
+error_dialog.o : cflags error_dialog.c error_dialog.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c error_dialog.c
-families.o : cflags families.c families.h globals.h
+families.o : cflags families.c families.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c families.c
-plugin_infos.o : cflags plugin_infos.c plugin_infos.h globals.h context.h
+plugin_infos.o : cflags plugin_infos.c plugin_infos.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c plugin_infos.c
main_window.o : cflags main_window.c main_window.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c main_window.c
-nsr_output.o : cflags nsr_output.c nsr_output.h error_dialog.h
+nsr_output.o : cflags nsr_output.c nsr_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c nsr_output.c
-nbe_output.o : cflags nbe_output.c nbe_output.h error_dialog.h
+nbe_output.o : cflags nbe_output.c nbe_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c nbe_output.c
-html_output.o : cflags html_output.c html_output.h error_dialog.h globals.h
+html_output.o : cflags html_output.c html_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c html_output.c
-text_output.o : cflags text_output.c text_output.h error_dialog.h globals.h
+text_output.o : cflags text_output.c text_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c text_output.c
-xml_output.o : cflags xml_output.c xml_output.h error_dialog.h globals.h
+xml_output.o : cflags xml_output.c xml_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c xml_output.c
-xml_output_ng.o : cflags xml_output_ng.c error_dialog.h globals.h context.h
+xml_output_ng.o : cflags xml_output_ng.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c xml_output_ng.c
-latex_output.o : cflags latex_output.c latex_output.h globals.h
+latex_output.o : cflags latex_output.c latex_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c latex_output.c
-html_graph_output.o : cflags html_graph_output.c html_graph_output.h error_dialog.h globals.h
+html_graph_output.o : cflags html_graph_output.c html_graph_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c html_graph_output.c
-pdf_output.o : cflags pdf_output.c pdf_output.h globals.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c pdf_output.c
-monitor_dialog.o : cflags monitor_dialog.c monitor_dialog.h globals.h \
- context.h report.h xpm/computer.xpm \
- prefs_dialog/prefs_context.h prefs_dialog/prefs_scope_tree.h
+monitor_dialog.o : cflags monitor_dialog.c monitor_dialog.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c monitor_dialog.c
-backend.o : cflags backend.c backend.h error_dialog.h
+backend.o : cflags backend.c backend.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c backend.c
data_mining.o : cflags data_mining.c data_mining.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c data_mining.c
-
+
+
report_utils.o : cflags report_utils.h report_utils.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c report_utils.c
-
-nessus.o : cflags nessus.c globals.h context.h preferences.h
+nessus.o : cflags nessus.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c nessus.c
-sighand.o : cflags sighand.c sighand.h error_dialog.h context.h backend.h auth.h
+sighand.o : cflags sighand.c sighand.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c sighand.c
-auth.o : cflags auth.c globals.h
+auth.o : cflags auth.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c auth.c
-comm.o : cflags comm.c error_dialog.h globals.h context.h
+comm.o : cflags comm.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c comm.c
-report.o : cflags report.c error_dialog.h globals.h context.h \
- prefs_dialog/prefs_scope_tree.h prefs_dialog/prefs_context.h
+report.o : cflags report.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c report.c
-report_save.o : cflags report_save.c preferences.h context.h error_dialog.h
+report_ng.o : cflags report_ng.c
+ $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c report_ng.c
+
+report_save.o : cflags report_save.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c report_save.c
-
-parser.o : cflags parser.c error_dialog.h globals.h
+
+
+parser.o : cflags parser.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c parser.c
-attack.o : cflags attack.c globals.h context.h
+attack.o : cflags attack.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c attack.c
-password_dialog.o : cflags password_dialog.c error_dialog.h globals.h
+password_dialog.o : cflags password_dialog.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c password_dialog.c
-
-xstuff.o : cflags xstuff.c globals.h
+xstuff.o : cflags xstuff.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c xstuff.c
-
-cli.o : cflags cli.c cli.h globals.h preferences.h
+cli.o : cflags cli.c cli.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c cli.c
-
-read_target_file.o : cflags read_target_file.c error_dialog.h globals.h
+read_target_file.o : cflags read_target_file.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c read_target_file.c
-prefs_about.o : cflags prefs_dialog/prefs_about.c globals.h \
- xpm/nessus.xpm xpm/logo_tenable.xpm xpm/logo_intevation.xpm xpm/logo_bsi.xpm \
- xpm/logo_bsi_de.xpm
+prefs_about.o : cflags prefs_dialog/prefs_about.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_about.c
-netmap.o : cflags netmap.c globals.h
+netmap.o : cflags netmap.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c netmap.c
regex.o : cflags regex.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c regex.c
-
-filter.o : cflags filter.c error_dialog.h
+
+filter.o : cflags filter.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c filter.c
-
+
+
dirutils.o : cflags dirutils.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c dirutils.c
-sslui.o : cflags sslui.c globals.h xpm/lock.xpm
+sslui.o : cflags sslui.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c sslui.c
-
+
gdchart0.94b/gdc.o : cflags
cd gdchart0.94b && $(MAKE)
Index: attack.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/attack.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- attack.c 21 Dec 2004 15:11:18 -0000 1.19
+++ attack.c 17 Mar 2007 21:35:59 -0000 1.20
@@ -31,7 +31,8 @@
#include "auth.h"
#include "parser.h"
#include "attack.h"
-#include "context.h"
+#include "globals.h"
+#include "error_dialog.h"
#include "preferences.h"
#ifdef ENABLE_CIPHER_LAYER
@@ -48,14 +49,13 @@
*/
#ifdef ENABLE_SAVE_TESTS
void
-restore_attack(session_name, context)
- char * session_name;
- struct context *context;
+restore_attack(session_name, preferences)
+ char * session_name;
+ struct arglist * preferences;
{
- struct arglist * preferences = context->prefs;
- char * plug_list, * old_plug_list;
- struct arglist * plugs = context->plugins;
- struct arglist * scans = context->scanners;
+ char * plug_list;
+ struct arglist * scans = Scanners;
+ struct arglist * plugs = Plugins;
struct arglist * serv_prefs;
int num_plug = 0;
int num_scanners = 0;
@@ -71,32 +71,33 @@
num_scanners++;
scans = scans->next;
}
-
- /*
+
+ plugs = Plugins;
+ scans = Scanners;
+
+
+ /*
* Set up the plugin list, according to the
* Nessus Transfer Protocol version 1.1
*/
- plug_list = emalloc(num_plug*50+1+num_scanners*50+1);
- setup_plug_list(context->plugins, context->scanners, plug_list);
- if(!strlen(plug_list))
- sprintf(plug_list, "0");
-
- /* Add plugin_set to server preferences so it gets sent to the server */
+ plug_list = emalloc(num_plug*20+1+num_scanners*20+1);
+ setup_plug_list(Plugins, Scanners, plug_list);
+ if(plug_list[0] == '\0' ) sprintf(plug_list, "0");
+
serv_prefs = arg_get_value(preferences, "SERVER_PREFS");
- if((old_plug_list = arg_get_value(serv_prefs, "plugin_set")))
+ if(arg_get_value(serv_prefs, "plugin_set"))
{
- efree(&old_plug_list);
arg_set_type(serv_prefs, "plugin_set", ARG_STRING);
arg_set_value(serv_prefs, "plugin_set", strlen(plug_list)+1, plug_list);
- }
+ }
else
arg_add_value(serv_prefs, "plugin_set", ARG_STRING, strlen(plug_list), plug_list);
- comm_send_preferences(context);
- comm_get_preferences_errors(context);
- preferences_save(context);
- comm_send_rules(context);
+ comm_send_preferences(preferences);
+ comm_get_preferences_errors(preferences);
+ preferences_save(Plugins);
+ comm_send_rules(preferences);
comm_restore_session(session_name);
- /* efree(&plug_list); it is stored as SERVER_PREFS[plugin_set] */
+/* efree(&plug_list); */
}
#endif
@@ -114,15 +115,14 @@
* recursive : unused
*
*/
-int
-attack_host(hostname, context)
- char * hostname;
- struct context *context;
+void
+attack_host(hostname, preferences)
+ char * hostname;
+ struct arglist * preferences;
{
- struct arglist * preferences = context->prefs;
- char * plug_list, * old_plug_list;
- struct arglist * plugs = context->plugins;
- struct arglist * scans = context->scanners;
+ char * plug_list;
+ struct arglist * scans = Scanners;
+ struct arglist * plugs = Plugins;
struct arglist * serv_prefs;
int num_plug = 0;
int num_scanners = 0;
@@ -138,33 +138,33 @@
num_scanners++;
scans = scans->next;
}
-
- /*
+
+ plugs = Plugins;
+ scans = Scanners;
+
+
+ /*
* Set up the plugin list, according to the
* Nessus Transfer Protocol version 1.1
*/
- plug_list = emalloc(num_plug*50+1+num_scanners*50+1);
- setup_plug_list(context->plugins, context->scanners, plug_list);
- if(!strlen(plug_list))
- sprintf(plug_list, "0");
-
- /* Add plugin_set to server preferences so it gets sent to the server */
+ plug_list = emalloc(num_plug*20+1+num_scanners*20+1);
+ setup_plug_list(Plugins, Scanners, plug_list);
+ if(plug_list[0] == '\0')sprintf(plug_list, "0");
+
serv_prefs = arg_get_value(preferences, "SERVER_PREFS");
- if((old_plug_list = arg_get_value(serv_prefs, "plugin_set")))
+ if(arg_get_value(serv_prefs, "plugin_set"))
{
- efree(&old_plug_list);
arg_set_type(serv_prefs, "plugin_set", ARG_STRING);
arg_set_value(serv_prefs, "plugin_set", strlen(plug_list)+1, plug_list);
- }
+ }
else
arg_add_value(serv_prefs, "plugin_set", ARG_STRING, strlen(plug_list), plug_list);
- comm_send_preferences(context);
- comm_get_preferences_errors(context);
- preferences_save(context);
- comm_send_rules(context);
+ comm_send_preferences(preferences);
+ comm_get_preferences_errors(preferences);
+ preferences_save(Plugins);
+ comm_send_rules(preferences);
network_printf("CLIENT <|> LONG_ATTACK <|>\n");
network_printf("%d\n", strlen(hostname));
- if(Context->socket > 0)
{
int len = strlen(hostname);
int n = 0;
@@ -177,23 +177,23 @@
{
int e;
if((len - m - n) < size)size = len-m-n;
- e = nsend(context->socket, &(hostname[n+m]), size, 0);
+ e = nsend(GlobalSocket, &(hostname[n+m]), size, 0);
if(e < 0)
{
perror("send ");
- return 0;
+ return;
}
m+=e;
}
n+=m;
}
- /* network_printf("<|> CLIENT\n"); */
- /* network_printf("CLIENT <|> NEW_ATTACK <|> %s <|> CLIENT\n", hostname); */
- /* efree(&plug_list); (stored in SERVER_PREFS arglist) */
- return 1;
- }
- else
- return 0;
+/* network_printf("<|> CLIENT\n"); */
+ /*
+ network_printf("CLIENT <|> NEW_ATTACK <|> %s <|> CLIENT\n",
+ hostname);
+ */
+ efree(&plug_list);
+ }
}
/*
@@ -210,25 +210,23 @@
{
struct arglist * w = NULL;
int i = 0;
+ char * s = plug_list;
for(i=0;i<2;i++)
{
- if(!w)w = plugs;
- else {
- w = scanners;
- }
+ if( w == NULL )w = plugs;
+ else w = scanners;
+
while(w && w->next)
{
- char * sp;
+ char sp[16];
if(plug_get_launch(w->value))
{
- sp = emalloc(9);
- sprintf(sp, "%d", (int)arg_get_value(w->value, "ID"));
- strcat(plug_list, sp);
- efree(&sp);
- strcat(plug_list, ";");
+ snprintf(sp, sizeof(sp), "%d;", (int)arg_get_value(w->value, "ID"));
+ memcpy(plug_list, sp, strlen(sp) + 1);
+ plug_list += strlen(sp);
}
w = w->next;
}
Index: attack.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/attack.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- attack.h 21 Dec 2004 15:11:18 -0000 1.6
+++ attack.h 17 Mar 2007 21:35:59 -0000 1.7
@@ -18,11 +18,11 @@
-int attack_host(char *, struct context *);
+void attack_host(char *, struct arglist *);
void attack_handler();
#ifdef ENABLE_SAVE_TESTS
-void restore_attack(char *, struct context *);
+void restore_attack(char *, struct arglist *);
#endif
Index: auth.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/auth.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- auth.c 26 Sep 2006 17:32:31 -0000 1.26
+++ auth.c 17 Mar 2007 21:35:59 -0000 1.27
@@ -35,6 +35,7 @@
#include "comm.h"
#include "auth.h"
#include "sighand.h"
+#include "globals.h"
#include "password_dialog.h"
/*
@@ -54,10 +55,12 @@
* Note : this function does NOT check if the login/password are
* valid.
*/
+
+extern char * stored_pwd;
-int auth_login(user, password)
- const char * user;
- const char * password;
+int auth_login(user,password)
+ char * user;
+ char * password;
{
char * buf = emalloc(255);
@@ -85,18 +88,16 @@
void network_printf(char * data, ...)
{
va_list param;
- int r, s = 16384;
+ int r, s = 65535;
char * buffer = emalloc(s);
int len, n = 0;
signal(SIGPIPE, sighand_pipe);
va_start(param, data);
- if(Context->socket <= 0)
- return;
for(;;)
{
- r = vsnprintf(buffer, s, data, param);
+ r = vsnprintf(buffer, s - 1, data, param);
if(r >= 0 && r < s)break;
s = r > s ? r + 2 : s * 2;
buffer = erealloc(buffer, s);
@@ -111,7 +112,7 @@
{
int e;
if((len - m - n) < size)size = len - m - n;
- e = nsend(Context->socket, &(buffer[n+m]), size, 0);
+ e = nsend(GlobalSocket, &(buffer[n+m]), size, 0);
if(e < 0) {
perror("send");
return;
@@ -137,15 +138,12 @@
size_t size;
{
int n;
-
- if(Context->socket <= 0)
- return 0;
/* We are assuming that recv_line() will block until it has
* recvieved a full line of data, encountered a hard error, or eof
* (socket close?)
* Also, recv_line will return 0 on error.
*/
- n = recv_line(Context->socket, s, size);
+ n = recv_line(GlobalSocket, s, size);
if (n > 0)
return n;
else
@@ -164,7 +162,7 @@
/* read up until no more data, or a line terminating character
'\0' or '\n' is found */
for (processed = 0; processed < (int)size; processed ++) {
- if ((n = nrecv (Context->socket, s + processed, 1, 0)) <= 0) {
+ if ((n = nrecv (GlobalSocket, s + processed, 1, 0)) <= 0) {
/* on error, the characers read so far might be garbage */
if (n < 0)
processed = 0 ;
Index: auth.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/auth.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- auth.h 3 Nov 2004 14:25:28 -0000 1.7
+++ auth.h 17 Mar 2007 21:35:59 -0000 1.8
@@ -30,7 +30,7 @@
#ifndef _NESSUSC_AUTH_H
#define _NESSUSC_AUTH_H
-int auth_login(const char * , const char * );
+int auth_login(char * , char * );
int network_gets(char * , size_t);
char * network_gets_raw(char * , size_t);
void network_printf(char * data, ...);
Index: backend.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/backend.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- backend.c 22 Sep 2006 20:28:40 -0000 1.28
+++ backend.c 17 Mar 2007 21:35:59 -0000 1.29
@@ -37,7 +37,6 @@
*/
#include <includes.h>
-#include "nessus_i18n.h"
#include "backend.h"
#include "nsr_output.h"
#include "nbe_output.h"
@@ -87,15 +86,13 @@
while((backends[i].fname) && (i<MAX_TMPFILES))i++;
if(backends[i].fname)
{
- show_error(_("No free tempfile!"));
+ show_error("No free tempfile !\n");
return -1;
}
if(!fname)
{
tmpdir = getenv("TMPDIR");
if(!tmpdir)tmpdir = getenv("TEMPDIR");
- if(!tmpdir)tmpdir = getenv("TMP");
- if(!tmpdir)tmpdir = getenv("TEMP");
if(!tmpdir)tmpdir = "/tmp";
tmpfile = emalloc(strlen(tmpdir) + strlen("/nessus-XXXXXX") + 1);
@@ -111,7 +108,7 @@
#endif
if(backends[i].fd < 0)
{
- show_error(_("Can't create file %s: %s"), tmpfile, strerror(errno));
+ show_error(strerror(errno));
efree(&tmpfile);
return -1;
}
@@ -121,7 +118,7 @@
{
if((backends[i].fd = open(fname,O_RDONLY)) < 0)
{
- show_error(_("Can't open file %s: %s"), fname, strerror(errno));
+ show_error(strerror(errno));
return -1;
}
tmpfile = estrdup(fname);
@@ -160,7 +157,7 @@
/*
- * backend_insert_scaninfo_timestamp
+ * backend_inset_scaninfo_timestamp
*/
int
backend_insert_timestamps(be, host, type, time)
@@ -431,12 +428,12 @@
else if(!strcmp(t, "Security Hole"))
buffer = estrdup("REPORT");
else buffer = NULL;
+
if ( buffer == NULL )
{
fprintf(stderr, "Error - line %d is malformed\n", line);
continue;
}
-
content = arg_get_value(port, buffer);
if(!content)
@@ -488,10 +485,7 @@
#ifdef HAVE_MMAP
if(backends[be].mmap)
{
- struct stat buf;
- int len;
- fstat(backends[be].fd, &buf);
- len = (int)buf.st_size;
+ int len = backends[be].mmap_size;
munmap(backends[be].mmap, len);
backends[be].mmap = NULL;
efree(&backends[be].lines);
@@ -615,7 +609,7 @@
{
return nbe_to_backend(fname); /* for now, we only pipe nbe files via stdin */
}
- show_error(_("Unknown report type - please set an extension to the filename"));
+ show_error("Unknown report type - please set an extension to the filename");
return -1;
}
@@ -629,6 +623,6 @@
return nbe_to_backend(fname);
}
- show_error(_("This file format can not be read back by the Nessus client"));
+ show_error("This file format can not be read back by the Nessus client");
return -1;
}
Index: backend.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/backend.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- backend.h 9 Mar 2003 14:33:26 -0000 1.6
+++ backend.h 17 Mar 2007 21:35:59 -0000 1.7
@@ -29,6 +29,7 @@
int disposable;
#ifdef HAVE_MMAP
char * mmap;
+ int mmap_size;
int mmap_attempts;
char ** lines;
char ** eols;
Index: cli.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/cli.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- cli.c 21 Dec 2004 15:12:45 -0000 1.45
+++ cli.c 17 Mar 2007 21:35:59 -0000 1.46
@@ -37,8 +37,6 @@
#include "globals.h"
#include "nessus.h"
-#include "context.h"
-#include "preferences.h"
#include "parser.h"
#include "cli.h"
@@ -122,14 +120,14 @@
for(i=0;i<num;i++)
{
- struct arglist * plugs = Context->plugins;
+ struct arglist * plugs = Plugins;
while(plugs && plugs->next &&
((int)(arg_get_value(plugs->value, "ID"))!=plugins_order_table_int[i]))
plugs = plugs->next;
if(!(plugs && plugs->next))
{
- plugs = Context->scanners;
+ plugs = Scanners;
while(plugs && plugs->next &&
((int)(arg_get_value(plugs->value, "ID"))!=plugins_order_table_int[i]))
plugs = plugs->next;
@@ -176,7 +174,7 @@
*/
if(network_gets(buf, sizeof(buf) - 1) < 0 || buf[0] == '\0')
{
- if(!is_server_present(Context->socket))
+ if(!is_server_present(GlobalSocket))
{
fprintf(stderr, "nessus: nessusd abruptly shut the communication down - the test may be incomplete\n");
finished = 1;
@@ -417,19 +415,21 @@
struct cli_args * cli;
{
/*ENABLE_CRYPTO_LAYER*/
+ char * pwd = cli->password;
char * err;
- prefs_set_string(Context, "nessusd_host", cli->server);
- prefs_set_int(Context, "nessusd_port", cli->port);
- prefs_set_string(Context, "nessusd_user", cli->login);
- Context->passwd = cli->password;
- err = connect_to_nessusd(Context);
-
+ err = connect_to_nessusd(cli->server,
+ cli->port,
+ cli->login,
+ pwd);
+
if(err)
{
fprintf(stderr, "nessus : %s\n", err);
return -1;
}
+ bzero(cli->login, strlen(cli->login));
+ bzero(cli->password, strlen(cli->password));
return 0;
}
@@ -445,13 +445,9 @@
return -1;
}
- if(attack_host(target_list, Context))
- {
- cli_test_monitor(cli);
- return 0;
- }
- else
- return -1;
+ attack_host(target_list, Prefs);
+ cli_test_monitor(cli);
+ return 0 ;
}
void
@@ -656,8 +652,8 @@
printf(" bugtraq_id varchar(255),\n");
printf(" xref blob,\n");
printf(" primary key (id));\n");
- _cli_sql_dump_plugins(Context->plugins);
- _cli_sql_dump_plugins(Context->scanners);
+ _cli_sql_dump_plugins(Plugins);
+ _cli_sql_dump_plugins(Scanners);
}
@@ -665,15 +661,15 @@
cli_dump_plugins(cli)
struct cli_args * cli;
{
- _cli_dump_plugins(Context->plugins);
- _cli_dump_plugins(Context->scanners);
+ _cli_dump_plugins(Plugins);
+ _cli_dump_plugins(Scanners);
}
static void
_cli_dump_pprefs()
{
- struct arglist * p = arg_get_value(Context->prefs, "PLUGINS_PREFS");
+ struct arglist * p = arg_get_value(Prefs, "PLUGINS_PREFS");
if(!p)
return;
@@ -706,7 +702,7 @@
cli_dump_prefs(cli)
struct cli_args * cli;
{
- struct arglist * p = arg_get_value(Context->prefs, "SERVER_PREFS");
+ struct arglist * p = arg_get_value(Prefs, "SERVER_PREFS");
if(!p)
return;
@@ -725,8 +721,8 @@
}
- if(Context->plugins)_cli_dump_pprefs(Context->plugins);
- if(Context->scanners)_cli_dump_pprefs(Context->scanners);
+ if(Plugins)_cli_dump_pprefs(Plugins);
+ if(Scanners)_cli_dump_pprefs(Scanners);
return;
}
@@ -734,7 +730,7 @@
cli_close_connection(cli)
struct cli_args * cli;
{
- return close_stream_connection(Context->socket);
+ return close_stream_connection(GlobalSocket);
}
#ifdef ENABLE_SAVE_TESTS
@@ -743,7 +739,7 @@
struct cli_args * cli;
char * session;
{
- restore_attack(session, Context);
+ restore_attack(session, Prefs);
cli_test_monitor(cli);
}
void
@@ -751,19 +747,19 @@
struct cli_args * cli;
{
hargwalk * hw;
- if(!comm_server_restores_sessions(Context))
+ if(!comm_server_restores_sessions(Prefs))
printf("** The remote nessusd server does not support session-saving\n");
else
{
char * key;
- hw = harg_walk_init(Context->sessions);
+ hw = harg_walk_init(Sessions);
printf("Remote sessions :\n");
printf("-----------------\n\n");
printf("Session ID | Targets\n");
printf("==========================\n");
while((key = (char*)harg_walk_next(hw)))
{
- printf("%s | %s\n", key, harg_get_string(Context->sessions, key));
+ printf("%s | %s\n", key, harg_get_string(Sessions, key));
}
}
}
Index: comm.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/comm.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- comm.c 22 Sep 2006 20:28:40 -0000 1.80
+++ comm.c 17 Mar 2007 21:36:00 -0000 1.81
@@ -28,18 +28,12 @@
*
* Nessus Communication Manager -- it manages the NTP Protocol, version 1.1
*
- */
-
+ */
+
#include <includes.h>
-#include "nessus_i18n.h"
-#ifdef USE_GTK
[...1890 lines suppressed...]
- s = NULL;
- }
- arg_add_value(context->dependencies, name, ARG_ARGLIST, -1, deps);
+ {
+ t[0] = '\0';
+ arg_add_value(deps, s, ARG_INT, (sizeof(int)), (void*)1);
+ s = t + 5;
}
- network_gets(buff, sizeof(buff) - 1);
+ else s = NULL;
+ }
+ arg_add_value(Dependencies, name, ARG_ARGLIST, -1, deps);
}
- }
- return 0;
+ network_gets(buff, sizeof(buff)-1);
+ }
+ }
+ return 0;
}
Index: comm.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/comm.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- comm.h 3 Nov 2004 14:25:28 -0000 1.13
+++ comm.h 17 Mar 2007 21:36:00 -0000 1.14
@@ -30,30 +30,30 @@
#ifndef _NESSUSC_COMM_H
#define _NESSUSC_COMM_H
-#include "context.h"
int comm_init(int,char*);
int comm_get_pluginlist();
-int comm_get_preferences(struct context *);
-int comm_get_rules(struct context *);
+int comm_get_preferences(struct arglist *);
+int cli_comm_get_preferences(struct arglist *);
+int comm_get_rules(struct arglist *);
-int comm_get_plugins(struct context *);
+int comm_get_plugins();
-int comm_send_preferences(struct context *);
-int comm_send_long_preferences(struct context *);
-int comm_send_rules(struct context *);
-void comm_get_preferences_errors(struct context*);
+int comm_send_preferences(struct arglist *);
+int comm_send_long_preferences(struct arglist*);
+int comm_send_rules(struct arglist *);
+void comm_get_preferences_errors(struct arglist *);
harglst * comm_get_sessions();
-int comm_server_restores_sessions(struct context *);
-int comm_server_detached_sessions(struct context *);
+int comm_server_restores_sessions(struct arglist *);
+int comm_server_detached_sessions(struct arglist *);
void comm_delete_session(char*);
void comm_restore_session(char*);
void comm_stop_detached_session( char *name);
int comm_plugin_upload(char*);
-int comm_get_dependencies(struct context*);
+int comm_get_dependencies();
#ifdef ENABLE_SAVE_TESTS
harglst * comm_get_detached_sessions(void);
Index: data_mining.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/data_mining.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- data_mining.c 21 Dec 2004 19:21:08 -0000 1.27
+++ data_mining.c 17 Mar 2007 21:36:00 -0000 1.28
@@ -178,13 +178,15 @@
char ** lines;
char ** eols;
char * sol, * eol;
+ char * eof = NULL;
lines = emalloc(num_allocated_lines*sizeof(*lines));
eols = emalloc(num_allocated_lines*sizeof(*eols));
sol = backends[be].mmap;
+ eof = sol + backends[be].mmap_size;
num_lines = 0;
- while(sol)
+ while(sol != NULL && sol != eof )
{
eol = strchr(sol, '\n');
lines[num_lines] = sol;
@@ -279,9 +281,9 @@
int len;
fstat(backends[be].fd, &buf);
len = (int)buf.st_size;
+ backends[be].mmap_size = len;
if((backends[be].mmap =
- mmap(NULL, len, PROT_READ, MAP_SHARED, backends[be].fd, 0))
- == MAP_FAILED)
+ mmap(NULL, len, PROT_READ, MAP_SHARED, backends[be].fd, 0)) == MAP_FAILED)
backends[be].mmap = NULL;
else
be_mk_index(be);
@@ -1188,7 +1190,14 @@
struct query * query;
{
struct subset * ret = NULL;
- static char buf[1048576];
+ static char *buf = NULL;
+ static int buf_sz = 0;
+
+ if ( buf == NULL ) {
+ buf_sz = 1024*1024;
+ buf = emalloc(buf_sz);
+ }
+
#ifdef HAVE_MMAP
if(backends[be].mmap) backends[be].cur_line = 0;
else
@@ -1219,7 +1228,6 @@
{
int j;
char * val = NULL;
- char buf[1048576];
char * table;
char * subnet;
char * hostname;
@@ -1227,7 +1235,7 @@
char * plugin_id;
char * severity;
char * data;
- mmap_read_line_n(be, buf, sizeof(buf), i);
+ mmap_read_line_n(be, buf, buf_sz, i);
__split_line(buf, &table, &subnet, &hostname, &port, &plugin_id, &severity, &data);
for(j=0;j<query->num;j++)
{
@@ -1268,7 +1276,7 @@
return ret;
}
#endif
- while(read_line(be,buf, sizeof(buf)) > 0)
+ while(read_line(be,buf, buf_sz ) > 0)
{
char * table;
char * subnet;
Index: detached_index.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/detached_index.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- detached_index.c 3 Nov 2004 14:25:29 -0000 1.10
+++ detached_index.c 17 Mar 2007 21:36:00 -0000 1.11
@@ -29,6 +29,7 @@
#include <includes.h>
#ifdef USE_GTK
+#include "gtk-compat.h"
#include <gtk/gtk.h>
#include "xstuff.h"
#ifdef ENABLE_SAVE_TESTS
@@ -96,7 +97,7 @@
struct arglist * ret = emalloc(sizeof(*ret));
char * titles[] = {"Session ID", "Targets"};
- window = gtk_window_new(GTK_WINDOW_POPUP);
+ window = gtk_window_new(WINDOW_DIALOG);
gtk_window_set_title(GTK_WINDOW(window), "Detached sessions");
gtk_widget_set_usize(GTK_WIDGET(window), 640, 480);
gtk_container_border_width(GTK_CONTAINER(window), 10);
@@ -122,7 +123,11 @@
gtk_widget_show(scrolled);
clist = gtk_clist_new_with_titles(2, titles);
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), clist);
+ #if GTK_VERSION < 11
+ gtk_container_add(GTK_CONTAINER(scrolled),clist);
+#else
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), clist);
+#endif
gtk_widget_show(clist);
arg_add_value(ret, "CLIST", ARG_PTR, -1, clist);
gtk_widget_show(clist);
@@ -182,11 +187,13 @@
i++;
}
harg_walk_stop(hw);
+#if GTK_VERSION > 10
gtk_clist_sort(GTK_CLIST(clist));
gtk_clist_set_column_width(GTK_CLIST(clist),
0,
gtk_clist_optimal_column_width(GTK_CLIST(clist), 0)
);
+#endif
gtk_clist_thaw(GTK_CLIST(clist));
Index: error_dialog.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/error_dialog.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- error_dialog.c 22 Nov 2004 10:49:53 -0000 1.27
+++ error_dialog.c 17 Mar 2007 21:36:00 -0000 1.28
@@ -1,278 +1,291 @@
-/* $Id$
+/* Nessus
+ * Copyright (C) 1998 - 2001 Renaud Deraison
*
- * Copyright (C) 2004 by Intevation GmbH
- * Author(s):
- * Thomas Arendsen Hein <thomas@intevation.de>
- * Jan-Oliver Wagner <jan@intevation.de>
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation
*
- * This program is free software under the GNU GPL (>=v2)
- * Read the file COPYING coming with the software for details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * In addition, as a special exception, Intevation GmbH gives
- * permission to link the code of this program with the OpenSSL
- * library (or with modified versions of OpenSSL that use the same
- * license as OpenSSL), and distribute linked combinations including
- * the two. You must obey the GNU General Public License in all
- * respects for all of the code used other than OpenSSL. If you
- * modify this file, you may extend this exception to your version
- * of the file, but you are not obligated to do so. If you do not
- * wish to do so, delete this exception statement from your version.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * In addition, as a special exception, Renaud Deraison
+ * gives permission to link the code of this program with any
+ * version of the OpenSSL library which is distributed under a
+ * license identical to that listed in the included COPYING.OpenSSL
+ * file, and distribute linked combinations including the two.
+ * You must obey the GNU General Public License in all respects
+ * for all of the code used other than OpenSSL. If you modify
+ * this file, you may extend this exception to your version of the
+ * file, but you are not obligated to do so. If you do not wish to
+ * do so, delete this exception statement from your version.
*/
-
+
#include <includes.h>
-#include <stdarg.h>
-
#include "globals.h"
-#include "error_dialog.h"
-#include "nessus_i18n.h"
-
-#ifdef USE_GTK
-#include <gtk/gtk.h>
-#endif
-
-#define DIALOG_TYPE_INFO 0
-#define DIALOG_TYPE_WARNING 1
-#define DIALOG_TYPE_ERROR 2
-
-#define DIALOG_NORMAL 0
-#define DIALOG_AND_WAIT 1
-
+#ifndef USE_GTK
-void
-show_dialog_std(type, wait, fmt, ap)
- int type;
- int wait;
- char *fmt;
- va_list ap;
+void
+show_dialog_and_wait
+ (char * error_text, int type)
{
- fprintf(stderr, "*** ");
- switch(type)
- {
- case DIALOG_TYPE_INFO:
- fprintf(stderr, _("Info: "));
- break;
- case DIALOG_TYPE_WARNING:
- fprintf(stderr, _("Warning: "));
- break;
- default: /* DIALOG_TYPE_ERROR or other */
- fprintf(stderr, _("Error: "));
- }
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- if(wait == DIALOG_AND_WAIT)
- {
- fprintf(stderr, _("Press <Enter> to continue ...\n"));
- getchar();
- }
+ fprintf(stderr, "*** %s\n", error_text);
+ fprintf(stderr, "press 'enter' to continue\n");
+ getchar();
}
-
-
-#ifdef USE_GTK
-void
-show_dialog_gtk_close(dialog, response_id, dialog_running)
- GtkDialog *dialog;
- gint response_id;
- gboolean *dialog_running;
+void
+show_dialog
+ (char * error_text, int type)
{
- gtk_widget_destroy(GTK_WIDGET(dialog));
- *dialog_running = FALSE;
+ fprintf (stderr, "*** %s\n", error_text);
}
+#else /* USE_GTK */
+#include "gtk-compat.h"
+#include <gtk/gtk.h>
+#include "xpm/error.xpm"
+#include "xpm/warning.xpm"
+#include "xpm/info.xpm"
+#include "xstuff.h"
+#include "error_dialog.h"
+#include "globals.h"
-void
-show_dialog_gtk_popup(type, wait, error_text)
- int type;
- int wait;
- char *error_text;
-{
- void *context_window = arg_get_value(MainDialog, "CONTEXT");
- GtkWindow *window;
- GtkWidget *dialog;
- int messagetype;
- static gboolean dialog_running = FALSE;
- while(dialog_running)
- gtk_main_iteration_do(TRUE);
- if(context_window)
- window = GTK_WINDOW(context_window);
+
+/*
+ * show_error
+ *
+ * This function draws a dialog showing an error
+ *
+ */
+
+
+void
+show_dialog(error_text, type)
+ char * error_text;
+ int type;
+{
+ if(F_quiet_mode)fprintf(stderr, "%s\n", error_text);
else
{
- window = NULL;
- wait = DIALOG_AND_WAIT;
- }
-
- /*
- * XXX
- * Always wait. This can be removed if other windows are created
- * using a common function which sets "dialog_running", too.
- */
- wait = DIALOG_AND_WAIT;
+ GtkWidget * dialog;
+ GtkWidget * button;
+ GtkWidget * vbox;
+ GtkWidget * hbox;
+ GtkWidget * label;
+ GtkStyle * style;
+ GtkWidget * pixmapwid;
+ GdkPixmap * pixmap;
+ GdkBitmap * mask;
+ GtkWidget * table;
+ char * name;
switch(type)
{
- case DIALOG_TYPE_INFO:
- messagetype = GTK_MESSAGE_INFO;
- break;
- case DIALOG_TYPE_WARNING:
- messagetype = GTK_MESSAGE_WARNING;
- break;
- default: /* DIALOG_TYPE_ERROR or other */
- messagetype = GTK_MESSAGE_ERROR;
+ case DIALOG_TYPE_INFO :
+ name = "Info";
+ break;
+ case DIALOG_TYPE_WARNING :
+ name = "Warning";
+ break;
+ case DIALOG_TYPE_ERROR :
+ default :
+ name = "Error";
+ break;
}
+
+ #if GTK_VERSION < 20
+ dialog = gtk_window_new(WINDOW_DIALOG);
+ #else
+ dialog = gtk_dialog_new();
+ #endif
+ gtk_window_set_title(GTK_WINDOW(dialog), name);
+ gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
+ GTK_SIGNAL_FUNC (delete_event), NULL);
+ gtk_window_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+ #if GTK_VERSION < 20
+ vbox = gtk_vbox_new(FALSE, 15);
+ gtk_container_border_width(GTK_CONTAINER(dialog), 10);
+ gtk_container_add(GTK_CONTAINER(dialog), vbox);
+ gtk_widget_show(vbox);
+ #else
+ vbox = GTK_DIALOG(dialog)->vbox;
+ #endif
+
+ hbox = gtk_hbox_new(FALSE,5);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE,0);
+ gtk_widget_show(hbox);
- /* create the user dialog */
- dialog = gtk_message_dialog_new(window, 0, messagetype,
- wait == DIALOG_AND_WAIT ? GTK_BUTTONS_OK : GTK_BUTTONS_CLOSE,
- "%s", error_text);
-
- if(wait == DIALOG_AND_WAIT)
+ label = gtk_label_new(error_text);
+ gtk_label_set_justify (GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 3);
+ gtk_widget_show(label);
+
+
+
+ button = gtk_button_new_with_label ("OK");
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (close_window), dialog);
+
+ table = gtk_table_new(1,3, TRUE);
+ gtk_box_pack_end(GTK_BOX(vbox), table, TRUE, TRUE, 0);
+ gtk_widget_show(table);
+
+
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 2,3,0,1);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default (button);
+ gtk_widget_show (button);
+ gtk_widget_realize(dialog);
+
+ style = gtk_widget_get_style(dialog);
+ if(F_show_pixmaps)
{
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
+ char** data;
+ switch(type)
+ {
+ case DIALOG_TYPE_INFO :
+ data = info_xpm;
+ break;
+ case DIALOG_TYPE_WARNING :
+ data = warning_xpm;
+ break;
+ case DIALOG_TYPE_ERROR :
+ default :
+ data = error_xpm;
+ break;
}
- else
- {
- dialog_running = TRUE;
- gtk_widget_show(dialog);
- g_signal_connect(dialog, "response",
- G_CALLBACK(show_dialog_gtk_close),
- &dialog_running);
+ pixmap = gdk_pixmap_create_from_xpm_d(dialog->window, &mask,
+ &style->bg[GTK_STATE_NORMAL],
+ (char **)data);
+ pixmapwid = gtk_pixmap_new(pixmap, mask);
+
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwid, FALSE, TRUE,3);
+ gtk_widget_show(pixmapwid);
}
-}
+ gtk_widget_show(dialog);
+ }
+}
-void
-show_dialog_gtk_log(type, error_text)
- int type;
- char *error_text;
-{
- GtkWidget *textview = arg_get_value(MainDialog, "MSGLOGTEXT");
- GtkWidget *scrolledwin = arg_get_value(MainDialog, "MSGLOGSCROLL");
- GtkTextBuffer *log;
- GtkTextIter iter;
- GtkAdjustment *vadjust;
- char *msgtype;
- if(!textview || !scrolledwin)
- return;
+static void show_dialog_and_wait_cb(gw, ok)
+ GtkWidget* gw;
+ int *ok;
+{
+ GtkWidget* dialog = gw->parent->parent->parent;
+ gtk_grab_remove(dialog);
+ close_window(NULL, dialog);
+ gtk_widget_destroy(dialog);
+ *ok = 1;
+ gtk_main_quit();
+}
+void show_dialog_and_wait_build(int * ok, char * error_text, int type)
+{
+ GtkWidget * dialog;
+ GtkWidget * button;
+ GtkWidget * vbox;
+ GtkWidget * hbox;
+ GtkWidget * label;
+ GtkStyle * style;
+ GtkWidget * pixmapwid;
+ GdkPixmap * pixmap;
+ GdkBitmap * mask;
+ GtkWidget * table;
+ char * name;
switch(type)
{
- case DIALOG_TYPE_INFO:
- msgtype = _("Info: ");
- break;
- case DIALOG_TYPE_WARNING:
- msgtype = _("Warning: ");
- break;
- default: /* DIALOG_TYPE_ERROR or other */
- msgtype = _("Error: ");
+ case DIALOG_TYPE_INFO :
+ name = "Info";
+ break;
+ case DIALOG_TYPE_WARNING :
+ name = "Warning";
+ break;
+ case DIALOG_TYPE_ERROR :
+ default :
+ name = "Error";
+ break;
}
+ dialog = gtk_window_new(WINDOW_DIALOG);
+ gtk_widget_realize(dialog);
+ gtk_window_set_title(GTK_WINDOW(dialog), name);
+ gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
+ GTK_SIGNAL_FUNC (show_dialog_and_wait_cb), ok);
+ gtk_window_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+ vbox = gtk_vbox_new(FALSE, 15);
+ gtk_container_border_width(GTK_CONTAINER(dialog), 10);
+ gtk_container_add(GTK_CONTAINER(dialog), vbox);
+ gtk_widget_show(vbox);
+
+ hbox = gtk_hbox_new(FALSE,5);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE,0);
+ gtk_widget_show(hbox);
- /* submit the message to the log */
- log = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
- gtk_text_buffer_get_end_iter(log, &iter);
- gtk_text_buffer_insert(log, &iter, msgtype, -1);
- gtk_text_buffer_get_end_iter(log, &iter);
- gtk_text_buffer_insert(log, &iter, error_text, -1);
- gtk_text_buffer_get_end_iter(log, &iter);
- gtk_text_buffer_insert(log, &iter, "\n", -1);
-
- vadjust = gtk_scrolled_window_get_vadjustment(
- GTK_SCROLLED_WINDOW(scrolledwin));
- gtk_adjustment_set_value(vadjust, vadjust->upper - 1);
+ label = gtk_label_new(error_text);
+ gtk_label_set_justify (GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 3);
+ gtk_widget_show(label);
+
+
+
+ button = gtk_button_new_with_label ("OK");
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (show_dialog_and_wait_cb), ok);
+
+ table = gtk_table_new(1,3, TRUE);
+ gtk_box_pack_end(GTK_BOX(vbox), table, TRUE, TRUE, 0);
+ gtk_widget_show(table);
+
+
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 2,3,0,1);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default (button);
+ gtk_widget_show (button);
+ gtk_widget_realize(dialog);
+
+ style = gtk_widget_get_style(dialog);
+ if(F_show_pixmaps)
+ {
+ char** data;
+ switch(type)
+ {
+ case DIALOG_TYPE_INFO :
+ data = info_xpm;
+ break;
+ case DIALOG_TYPE_WARNING :
+ data = warning_xpm;
+ break;
+ case DIALOG_TYPE_ERROR :
+ default :
+ data = error_xpm;
+ break;
+ }
+ pixmap = gdk_pixmap_create_from_xpm_d(dialog->window, &mask,
+ &style->bg[GTK_STATE_NORMAL],
+ (char **)data);
+ pixmapwid = gtk_pixmap_new(pixmap, mask);
+
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwid, FALSE, TRUE,3);
+ gtk_widget_show(pixmapwid);
+ }
+ gtk_widget_show(dialog);
+ gtk_grab_add(dialog);
}
-void
-show_dialog_gtk(type, wait, fmt, ap)
- int type;
- int wait;
- char *fmt;
- va_list ap;
+void show_dialog_and_wait(char * error, int type)
{
- char *error_text = g_strdup_vprintf(fmt, ap);
-
- show_dialog_gtk_log(type, error_text);
- show_dialog_gtk_popup(type, wait, error_text);
- g_free(error_text);
+ int ok = 0;
+ if(F_quiet_mode)fprintf(stderr, "%s\n", error);
+ else
+ {
+ show_dialog_and_wait_build(&ok, error, type);
+ gtk_main();
+ }
}
+
#endif
-
-
-void
-show_dialog(type, wait, fmt, ap)
- int type;
- int wait;
- char *fmt;
- va_list ap;
-{
-#ifdef USE_GTK
- if(!F_quiet_mode)
- show_dialog_gtk(type, wait, fmt, ap);
- else
-#endif /* USE_GTK */
- show_dialog_std(type, wait, fmt, ap);
-}
-
-/*
- * functions called by the application
- */
-
-void
-show_error(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- show_dialog(DIALOG_TYPE_ERROR, DIALOG_NORMAL, fmt, ap);
- va_end(ap);
-}
-
-void
-show_warning(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- show_dialog(DIALOG_TYPE_WARNING, DIALOG_NORMAL, fmt, ap);
- va_end(ap);
-}
-
-void
-show_info(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- show_dialog(DIALOG_TYPE_INFO, DIALOG_NORMAL, fmt, ap);
- va_end(ap);
-}
-
-
-void
-show_error_and_wait(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- show_dialog(DIALOG_TYPE_ERROR, DIALOG_AND_WAIT, fmt, ap);
- va_end(ap);
-}
-
-void
-show_warning_and_wait(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- show_dialog(DIALOG_TYPE_WARNING, DIALOG_AND_WAIT, fmt, ap);
- va_end(ap);
-}
-
-void
-show_info_and_wait(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- show_dialog(DIALOG_TYPE_INFO, DIALOG_AND_WAIT, fmt, ap);
- va_end(ap);
-}
Index: error_dialog.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/error_dialog.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- error_dialog.h 8 Nov 2004 19:21:21 -0000 1.8
+++ error_dialog.h 17 Mar 2007 21:36:00 -0000 1.9
@@ -1,32 +1,40 @@
-/* $Id$
+/* Nessuslib -- the Nessus Library
+ * Copyright (C) 1998 Renaud Deraison
*
- * Copyright (C) 2004 by Intevation GmbH
- * Author(s):
- * Thomas Arendsen Hein <thomas@intevation.de>
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
*
- * This program is free software under the GNU GPL (>=v2)
- * Read the file COPYING coming with the software for details.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
*
- * In addition, as a special exception, Intevation GmbH gives
- * permission to link the code of this program with the OpenSSL
- * library (or with modified versions of OpenSSL that use the same
- * license as OpenSSL), and distribute linked combinations including
- * the two. You must obey the GNU General Public License in all
- * respects for all of the code used other than OpenSSL. If you
- * modify this file, you may extend this exception to your version
- * of the file, but you are not obligated to do so. If you do not
- * wish to do so, delete this exception statement from your version.
- */
-
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
#ifndef _NESSUSC_ERROR_DIALOG_H
#define _NESSUSC_ERROR_DIALOG_H
-extern void show_error(char *, ...);
-extern void show_warning(char *, ...);
-extern void show_info(char *, ...);
+#define DIALOG_TYPE_INFO 0
+#define DIALOG_TYPE_WARNING 1
+#define DIALOG_TYPE_ERROR 2
-extern void show_error_and_wait(char *, ...);
-extern void show_warning_and_wait(char *, ...);
-extern void show_info_and_wait(char *, ...);
+
+#define show_error(x) show_dialog(x, DIALOG_TYPE_ERROR)
+#define show_warning(x) show_dialog(x, DIALOG_TYPE_WARNING)
+#define show_info(x) show_dialog(x, DIALOG_TYPE_INFO)
+
+#define show_error_and_wait(x) show_dialog_and_wait(x, DIALOG_TYPE_ERROR)
+#define show_warning_and_wait(x) show_dialog_and_wait(x, DIALOG_TYPE_WARNING)
+#define show_info_and_wait(x) show_dialog_and_wait(x, DIALOG_TYPE_INFO)
+
+
+extern void show_dialog(char * error_text, int type);
+extern void show_dialog_and_wait_build(int * ok, char * error_text, int type);
+extern void show_dialog_and_wait(char * error, int type);
#endif
Index: families.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/families.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- families.c 10 Dec 2004 08:04:37 -0000 1.17
+++ families.c 17 Mar 2007 21:36:00 -0000 1.18
@@ -103,6 +103,26 @@
case DISABLE_FAMILY :
plug_set_launch(plugins->value, 0);
break;
+ case ENABLE_FAMILY_BUT_DOS :
+ {
+ char* category = arg_get_value(plugins->value, "CATEGORY");
+ if(category && (
+ !strcmp(category, "denial") ||
+ !strcmp(category, "kill_host") ||
+ !strcmp(category, "flood") ||
+ !strcmp(category, "destructive_attack")
+ )
+ )
+ plug_set_launch(plugins->value, 0);
+ else
+ {
+ if(!filter_plugin(&Filter, plugins->value))
+ plug_set_launch(plugins->value, 1);
+ else
+ plug_set_launch(plugins->value, 0);
+ }
+ break;
+ }
case ENABLE_FAMILY :
if(!filter_plugin(&Filter, plugins->value))
plug_set_launch(plugins->value, 1);
Index: families.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/families.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- families.h 10 Dec 2004 08:04:37 -0000 1.6
+++ families.h 17 Mar 2007 21:36:00 -0000 1.7
@@ -21,6 +21,7 @@
#define ENABLE_FAMILY 1
#define DISABLE_FAMILY 0
+#define ENABLE_FAMILY_BUT_DOS 2
struct plugin_families {
char * name;
Index: filter.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/filter.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- filter.c 11 Nov 2004 17:23:39 -0000 1.15
+++ filter.c 17 Mar 2007 21:36:00 -0000 1.16
@@ -27,8 +27,6 @@
*/
#include <includes.h>
-#include "nessus_i18n.h"
-#include "globals.h"
#ifdef USE_GTK
#ifdef HAVE_REGEX_SUPPORT
#include <regex.h>
@@ -54,29 +52,56 @@
static int filter_on_xref = 0;
+static void
+ask_filter_callback(u1, ctrls)
+ GtkWidget * u1;
+ struct arglist * ctrls;
+{
+ GtkWidget * w = arg_get_value(ctrls, "WINDOW");
+ gtk_widget_hide(w);
+ if(arg_get_value(ctrls,"CANCEL") == u1)
+ {
+ arg_add_value(ctrls, "FILTER", ARG_STRING, 0, (void*)(-1));
+ return;
+ }
+ else {
+ char * filter = (char*)gtk_entry_get_text(GTK_ENTRY(arg_get_value(ctrls,"ENTRY")));
+ filter_on_name = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_NAME"))->active;
+ filter_on_description = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_DESCRIPTION"))->active;
+ filter_on_summary = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_SUMMARY"))->active;
+ filter_on_author = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_AUTHOR"))->active;
+ filter_on_id = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_ID"))->active;
+ filter_on_category = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_CATEGORY"))->active;
+ filter_on_bid = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_BID"))->active;
+ filter_on_cve = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_CVE"))->active;
+ filter_on_xref = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_XREF"))->active;
+ arg_add_value(ctrls, "FILTER", ARG_STRING,filter ? strlen(filter):0, filter);
+ }
+}
+
static struct arglist *
build_filter_dlog()
{
- GtkWindow * window = GTK_WINDOW(arg_get_value(MainDialog, "WINDOW"));
- GtkWidget * dialog;
- GtkWidget * label, *sep, * button, *entry;
+ GtkWidget * w, * label, *sep, * button, *entry;
GtkWidget * box, *hbox, *frame,*vbox;
struct arglist * ctrls = emalloc(sizeof(struct arglist));
+
+
+ w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(w), "Filter plugins...");
+
+ gtk_container_border_width(GTK_CONTAINER(w), 6);
+ arg_add_value(ctrls, "WINDOW", ARG_PTR, -1, w);
+ gtk_window_position(GTK_WINDOW(w), GTK_WIN_POS_CENTER);
+ gtk_widget_realize(w);
+
+ box = gtk_vbox_new(FALSE, 6);
+ gtk_container_add(GTK_CONTAINER(w), box);
+ gtk_widget_show(box);
- dialog = gtk_dialog_new_with_buttons(_("Filter plugins..."), window,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
- gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
- gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
-
- arg_add_value(ctrls, "WINDOW", ARG_PTR, -1, dialog);
-
- /* The overall vbox */
- box = GTK_DIALOG(dialog)->vbox;
-
- label = gtk_label_new(_("Filter plugins..."));
+
+
+ label = gtk_label_new("Filter plugins...");
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 1);
gtk_widget_show(label);
sep = gtk_hseparator_new();
@@ -88,7 +113,7 @@
hbox = gtk_hbox_new(FALSE, FALSE);
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 3);
- label = gtk_label_new(_("Pattern:"));
+ label = gtk_label_new("Pattern : ");
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 6);
gtk_widget_show(label);
@@ -98,7 +123,7 @@
gtk_widget_show(entry);
gtk_widget_show(hbox);
- frame = gtk_frame_new(_("Filter on:"));
+ frame = gtk_frame_new("Filter on : ");
gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 6);
vbox = gtk_vbox_new(FALSE, FALSE);
gtk_container_border_width(GTK_CONTAINER(frame), 6);
@@ -106,56 +131,56 @@
gtk_widget_show(vbox);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("Name"));
+ button = gtk_check_button_new_with_label("Name");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_NAME", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_name);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("Description"));
+ button = gtk_check_button_new_with_label("Description");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_DESCRIPTION", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_description);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("Summary"));
+ button = gtk_check_button_new_with_label("Summary");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_SUMMARY", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_summary);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("Author"));
+ button = gtk_check_button_new_with_label("Author");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_AUTHOR", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_author);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("ID number"));
+ button = gtk_check_button_new_with_label("ID number");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_ID", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_id);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("Category"));
+ button = gtk_check_button_new_with_label("Category");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_CATEGORY", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_category);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("CVE"));
+ button = gtk_check_button_new_with_label("CVE");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_CVE", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_cve);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("BID"));
+ button = gtk_check_button_new_with_label("BID");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_BID", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_bid);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("XREF"));
+ button = gtk_check_button_new_with_label("XREF");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_XREF", ARG_PTR, -1, button);
@@ -163,8 +188,32 @@
gtk_widget_show(frame);
-
- gtk_widget_show(dialog);
+
+ hbox = gtk_hbox_new(TRUE, 6);
+ gtk_box_pack_start(GTK_BOX(box), hbox,FALSE, FALSE, 6);
+ gtk_widget_show(hbox);
+
+ button = gtk_button_new_with_label("OK");
+ gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 6);
+ GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default(button);
+ gtk_widget_show(button);
+
+ gtk_signal_connect(GTK_OBJECT(button), "clicked",
+ (GtkSignalFunc)ask_filter_callback,
+ (void*)ctrls);
+
+
+ button = gtk_button_new_with_label("Cancel");
+ arg_add_value(ctrls, "CANCEL", ARG_PTR, -1, button);
+ gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 6);
+ gtk_signal_connect(GTK_OBJECT(button), "clicked",
+ (GtkSignalFunc)ask_filter_callback,
+ (void*)ctrls);
+ gtk_widget_show(button);;
+
+ gtk_widget_show(w);
+ gtk_grab_add(w);
return ctrls;
}
@@ -173,45 +222,19 @@
struct plugin_filter * filter;
{
struct arglist * ctrls = build_filter_dlog();
- GtkWidget * dialog;
- char * pattern = NULL;
-
- dialog = arg_get_value(ctrls,"WINDOW");
-
- switch (gtk_dialog_run(GTK_DIALOG(dialog)))
- {
- case GTK_RESPONSE_OK:
- pattern = (char*)gtk_entry_get_text(GTK_ENTRY(
- arg_get_value(ctrls,"ENTRY")));
- filter_on_name = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_NAME"))->active;
- filter_on_description = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_DESCRIPTION"))->active;
- filter_on_summary = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_SUMMARY"))->active;
- filter_on_author = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_AUTHOR"))->active;
- filter_on_id = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_ID"))->active;
- filter_on_category = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_CATEGORY"))->active;
- filter_on_bid = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_BID"))->active;
- filter_on_cve = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_CVE"))->active;
- filter_on_xref = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_XREF"))->active;
- break;
- default: /* pattern remains NULL */
- break;
- }
-
- if (!pattern)
- filter->pattern = NULL;
- else
- filter->pattern = estrdup(pattern);
+ char * ret;
+ while(!arg_get_value(ctrls, "FILTER"))
+ while(gtk_events_pending()){
+ gtk_main_iteration();
+#if !defined(WIN32) && !defined(_WIN32)
+ usleep(10000);
+#endif
+ }
- printf("P: %s\n", pattern);
+ ret = arg_get_value(ctrls, "FILTER");
+ if(ret == (void*)-1)filter->pattern = NULL;
+ else filter->pattern = estrdup(ret);
+
filter->filter_on_name = filter_on_name;
filter->filter_on_description = filter_on_description;
filter->filter_on_summary = filter_on_summary;
@@ -221,8 +244,8 @@
filter->filter_on_cve = filter_on_cve;
filter->filter_on_bid = filter_on_bid;
filter->filter_on_xref = filter_on_xref;
-
- gtk_widget_destroy(dialog);
+
+ gtk_widget_destroy(arg_get_value(ctrls, "WINDOW"));
arg_free(ctrls);
return 0;
}
@@ -235,7 +258,7 @@
ask_filter()
{
char * ret = emalloc(1024);
- printf(_("Enter a new filter : "));
+ printf("Enter a new filter : ");
fgets(ret, 1023, stdin);
return ret;
}
@@ -256,7 +279,7 @@
re_set_syntax(RE_SYNTAX_POSIX_EGREP);
if(regcomp(&re, pat, REG_EXTENDED|REG_ICASE))
{
- show_error(_("Invalid regular expression"));
+ show_error("Invalid regular expression");
bzero(pat, strlen(pat));
return -1;
}
Index: globals.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/globals.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- globals.h 25 Nov 2004 20:17:39 -0000 1.27
+++ globals.h 17 Mar 2007 21:36:00 -0000 1.28
@@ -1,23 +1,47 @@
#ifndef _NESSUSC_GLOBALS_H
#define _NESSUSC_GLOBALS_H
+
+extern struct arglist * Plugins;
+extern struct arglist * Scanners;
+extern struct arglist * Dependencies;
+#ifdef CLIENTSIDE_PLUGINS
+extern struct arglist * Upload;
+#endif
+extern harglst * NetMap;
+extern int PluginsNum;
+extern int ScannersNum;
+extern struct arglist * Prefs;
extern struct arglist * MainDialog;
+extern struct arglist * ArgSock;
extern char * Alt_rcfile;
+extern int GlobalSocket;
extern struct plugin_filter Filter;
+#ifdef ENABLE_SAVE_TESTS
+extern harglst * Sessions;
+extern int Sessions_saved;
+extern int Detached_sessions_saved;
+#endif
+
+#ifdef ENABLE_SAVE_KB
+extern int DetachedMode;
+#endif
extern int F_show_pixmaps;
extern int F_quiet_mode;
+extern int F_nessusd_running;
+extern int First_time;
extern int ListOnly;
#ifdef _WIN32
# include "globals.w32"
/* #define _NO_PIES */
#else /* _WIN32 */
-#ifndef NESSUS_ON_SSL
# define closesocket(x) close (x)
-#endif
#endif /* _WIN32 */
# define HANDLE int
+
+#define nulstr(x) (!(x) || ((x)[0] == '\0'))
#endif
Index: gtk-compat.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/gtk-compat.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gtk-compat.h 3 Nov 2004 14:25:29 -0000 1.3
+++ gtk-compat.h 17 Mar 2007 21:36:00 -0000 1.4
@@ -1,3 +1,8 @@
#define GTK_ENABLE_BROKEN 1
+#if GTK_VERSION >= 20
+#define WINDOW_DIALOG GTK_WINDOW_POPUP
+#else
+#define WINDOW_DIALOG GTK_WINDOW_DIALOG
+#endif
Index: html_graph_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/html_graph_output.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- html_graph_output.c 7 Sep 2005 09:54:26 -0000 1.58
+++ html_graph_output.c 17 Mar 2007 21:36:01 -0000 1.59
@@ -65,15 +65,14 @@
-------------------------------------------------------------------*/
#include <includes.h>
-#include "nessus_i18n.h"
#include "gdchart0.94b/gdc.h"
#include "gdchart0.94b/gdchart.h"
#include "gdchart0.94b/gdcpie.h"
#include "report.h"
#include "report_utils.h"
#include "error_dialog.h"
+#include "globals.h"
#include "nsr_output.h"
-#include "preferences.h"
static void insert_img(FILE *, char*);
@@ -488,71 +487,11 @@
Single host report
-----------------------------------------------------------------------------*/
-
-/*
- * print URL linking to CVE/BID/Nessus database to file.
- * '%s' in urlfmt (from preferences) will be replaced by
- * item IDs (or their parts split at minus characters).
- * '%%' will insert a percent character.
- * Everything else after '%' aborts parsing.
- * If urlfmt yields an empty string (e.g. it is only "%"),
- * only the item ID will be printed.
- */
-static void
-fprint_link(file, key, item)
- FILE *file;
- const char *key;
- const char *item;
-{
- char *itemparts = estrdup(item);
- char *itemsrc = itemparts;
- char *urlfmt = estrdup(prefs_get_string(Global, key));
- char *src = urlfmt;
- char *url = emalloc(strlen(urlfmt)+strlen(item)+1);
- char *dst = url;
- char *tmp;
-
- while((tmp = strchr(src, '%')))
- {
- *tmp = '\0';
- strcpy(dst, src);
- dst += strlen(src);
- src = tmp+1;
- switch(*src)
- {
- case 's':
- if((tmp = strchr(itemsrc, '-')))
- *tmp = '\0';
- strcpy(dst, itemsrc);
- dst += strlen(itemsrc);
- if(tmp)
- itemsrc = tmp+1;
- src++;
- break;
- case '%':
- strcpy(dst++, "%");
- src++;
- break;
- default:
- *src = '\0';
- }
- }
- strcpy(dst, src);
-
- efree(&itemparts);
- efree(&urlfmt);
- if(*url)
- fprintf(file, "<a href=\"%s\">%s</a>", url, item);
- else
- fprintf(file, "%s", item);
- efree(&url);
-}
-
/* All the cross references (CVE, BID) have the same format - XREF: <num>,...<br> */
static char *
-extract_xref(file, str, key)
+extract_xref(file, str, url)
FILE * file;
- char * str, * key;
+ char * str, * url;
{
while(str != NULL && strncmp(str, "<br>", 4) != 0)
{
@@ -567,7 +506,7 @@
tmp = e1[0];
e1[0] = '\0';
}
- fprint_link(file, key, str);
+ fprintf(file, "<a href=\"%s%s\">%s</a>", url, str, str);
str = e1;
if(e1 != NULL)
{
@@ -618,21 +557,19 @@
{
fprintf(file, "CVE : ");
str += 6;
- str = extract_xref(file, str, "url_cve");
+ str = extract_xref(file, str, "http://cgi.nessus.org/cve.php3?cve=");
}
else if(strncmp(str, "BID : ", 6) == 0)
{
fprintf(file, "BID : ");
str += 6;
- str = extract_xref(file, str, "url_bid");
+ str = extract_xref(file, str, "http://cgi.nessus.org/bid.php3?bid=");
}
else fputc(str[0], file);
- if(str != NULL)
- str++;
+ if ( str != NULL ) str++;
}
- fprintf(file, "Nessus ID : ");
- fprint_link(file, "url_nessus", plugin_id);
+ fprintf(file, "Nessus ID : <a href=\"http://cgi.nessus.org/nessus_id.php3?id=%s\">%s</a>", plugin_id, plugin_id);
}
static char * convert_cr_to_html(str)
@@ -1344,15 +1281,13 @@
if(mkdir(directory, 0750)<0)
{
- show_error(_("Directory %s couldn't be created: %s."),
- directory, strerror(errno));
+ show_error(strerror(errno));
return -1;
}
if(chdir(directory)<0)
{
- show_error(_("Can't change to directory %s: %s."),
- directory, strerror(errno));
+ show_error(strerror(errno));
return -1;
}
@@ -1362,7 +1297,7 @@
arglist_to_file(hosts, "report.nsr");
if(html_make_index(hosts)<0)
{
- show_error(_("Can't write index: %s"), strerror(errno));
+ show_error(strerror(errno));
return -1;
}
Index: html_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/html_output.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- html_output.c 22 Apr 2005 14:14:57 -0000 1.36
+++ html_output.c 17 Mar 2007 21:36:01 -0000 1.37
@@ -41,7 +41,7 @@
#include "report.h"
#include "report_utils.h"
#include "error_dialog.h"
-#include "preferences.h"
+#include "globals.h"
static char * convert_cr_to_html(char *);
@@ -52,71 +52,13 @@
/*
* Handy functions
*/
-
-/*
- * print URL linking to CVE/BID/Nessus database to file.
- * '%s' in urlfmt (from preferences) will be replaced by
- * item IDs (or their parts split at minus characters).
- * '%%' will insert a percent character.
- * Everything else after '%' aborts parsing.
- * If urlfmt yields an empty string (e.g. it is only "%"),
- * only the item ID will be printed.
- */
-static void
-fprint_link(file, key, item)
- FILE *file;
- const char *key;
- const char *item;
-{
- char *itemparts = estrdup(item);
- char *itemsrc = itemparts;
- char *urlfmt = estrdup(prefs_get_string(Global, key));
- char *src = urlfmt;
- char *url = emalloc(strlen(urlfmt)+strlen(item)+1);
- char *dst = url;
- char *tmp;
-
- while((tmp = strchr(src, '%')))
- {
- *tmp = '\0';
- strcpy(dst, src);
- dst += strlen(src);
- src = tmp+1;
- switch(*src)
- {
- case 's':
- if((tmp = strchr(itemsrc, '-')))
- *tmp = '\0';
- strcpy(dst, itemsrc);
- dst += strlen(itemsrc);
- if(tmp)
- itemsrc = tmp+1;
- src++;
- break;
- case '%':
- strcpy(dst++, "%");
- src++;
- break;
- default:
- *src = '\0';
- }
- }
- strcpy(dst, src);
-
- efree(&itemparts);
- efree(&urlfmt);
- if(*url)
- fprintf(file, "<a href=\"%s\">%s</a>", url, item);
- else
- fprintf(file, "%s", item);
- efree(&url);
-}
-
+
+
/* All the cross references (CVE, BID) have the same format - XREF: <num>,...<br> */
static char *
-extract_xref(file, str, key)
+extract_xref(file, str, url)
FILE * file;
- char * str, * key;
+ char * str, * url;
{
while(str != NULL && strncmp(str, "<br>", 4) != 0)
{
@@ -131,7 +73,7 @@
tmp = e1[0];
e1[0] = '\0';
}
- fprint_link(file, key, str);
+ fprintf(file, "<a href=\"%s%s\">%s</a>", url, str, str);
str = e1;
if(e1 != NULL)
{
@@ -182,21 +124,19 @@
{
fprintf(file, "CVE : ");
str += 6;
- str = extract_xref(file, str, "url_cve");
+ str = extract_xref(file, str, "http://cgi.nessus.org/cve.php3?cve=");
}
else if(strncmp(str, "BID : ", 6) == 0)
{
fprintf(file, "BID : ");
str += 6;
- str = extract_xref(file, str, "url_bid");
+ str = extract_xref(file, str, "http://cgi.nessus.org/bid.php3?bid=");
}
else fputc(str[0], file);
- if(str != NULL)
- str++;
+ if ( str != NULL ) str++;
}
- fprintf(file, "Nessus ID : ");
- fprint_link(file, "url_nessus", plugin_id);
+ fprintf(file, "Nessus ID : <a href=\"http://cgi.nessus.org/nessus_id.php3?id=%s\">%s</a>", plugin_id, plugin_id);
}
Index: latex_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/latex_output.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- latex_output.c 3 Nov 2004 14:25:29 -0000 1.18
+++ latex_output.c 17 Mar 2007 21:36:01 -0000 1.19
@@ -29,7 +29,7 @@
#include <includes.h>
#include "report.h"
#include "report_utils.h"
-#include "context.h"
+#include "globals.h"
#include "text_output.h"
#define CATEGORY_A 0
#define CATEGORY_B 1
@@ -146,7 +146,7 @@
if(num_of_hosts > 1)fprintf(f, "s");
fprintf(f," and none of the vulnerabilities tested were present on this ");
fprintf(f,"network ");
- if(Context->scanners && Context->plugins)
+ if(Scanners && Plugins)
{
fprintf(f, "(see Appendix A and B page \\pageref{appendix_a} and page \\pageref{appendix_b} for the exhaustive ");
fprintf(f,"list of what was tested).\\\\\n");
@@ -181,7 +181,7 @@
most->name);
fprintf(f, "the most affected by these warnings.\\\\\n");
}
- if(Context->scanners && Context->plugins)
+ if(Scanners && Plugins)
{
fprintf(f, "(see Appendix A and B page \\pageref{appendix_a} and page \\pageref{appendix_b} for the exhaustive ");
fprintf(f,"list of what was tested).\\\\\n");
@@ -219,7 +219,7 @@
fprintf(f, "the most affected by these warnings.\\\\\n");
}
- if(Context->scanners && Context->plugins)
+ if(Scanners && Plugins)
{
fprintf(f, "(see Appendix A and B page \\pageref{appendix_a} and page \\pageref{appendix_b} for the exhaustive ");
fprintf(f,"list of what was tested).\\\\\n");
@@ -253,7 +253,7 @@
fprintf(f, "that is the most likely to be the entry point of any cracker.\n");
}
- if(Context->scanners && Context->plugins)
+ if(Scanners && Plugins)
{
fprintf(f, "You should have a look at ");
fprintf(f, "(see Appendix A and B page \\pageref{appendix_a} and page \\pageref{appendix_b} for the exhaustive ");
@@ -287,7 +287,7 @@
most->name);
fprintf(f, "that is the most likely to be the entry point of any cracker.\n");
}
-if(Context->scanners && Context->plugins)
+if(Scanners && Plugins)
{
fprintf(f, "You should have a look at ");
fprintf(f, "(see Appendix A and B page \\pageref{appendix_a} and page \\pageref{appendix_b} for the exhaustive ");
@@ -485,19 +485,19 @@
}
void latex_appendix(FILE *f)
{
- if(Context->scanners || Context->plugins)
+ if(Scanners || Plugins)
{
fprintf(f, "\\newpage\n");
fprintf(f, "\\label{appendix_a}\n");
fprintf(f, "\\appendix\n");
fprintf(f, "\\section{List of port scanners used during this session}\n");
fprintf(f, "\\begin{itemize}\n");
- latex_appendix_plugins(f, Context->scanners);
+ latex_appendix_plugins(f, Scanners);
fprintf(f, "\\end{itemize}\n");
fprintf(f, "\\label{appendix_b}\n");
fprintf(f, "\\section{List of plugins used during this session}\n");
fprintf(f, "\\begin{itemize}\n");
- latex_appendix_plugins(f, Context->plugins);
+ latex_appendix_plugins(f, Plugins);
fprintf(f, "\\end{itemize}\n");
}
}
Index: monitor_dialog.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/monitor_dialog.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- monitor_dialog.c 24 Mar 2005 08:47:00 -0000 1.79
+++ monitor_dialog.c 17 Mar 2007 21:36:01 -0000 1.80
@@ -29,30 +29,26 @@
#include <includes.h>
-#ifdef USE_GTK
+#include "backend.h"
+#if USE_GTK
#include <gtk/gtk.h>
-#include "backend.h"
-#include "context.h"
-#include "preferences.h"
#include "attack.h"
#include "xstuff.h"
#include "comm.h"
#include "auth.h"
-#include "parser.h"
+#include "parser.h"
#include "report.h"
#include "globals.h"
#include "error_dialog.h"
#include "xpm/computer.xpm"
#include "monitor_dialog.h"
-#include "nessus_i18n.h"
-#include "prefs_dialog/prefs_context.h"
-#include "prefs_dialog/prefs_scope_tree.h"
+#include "report_ng.h"
/*static char ** plugins_order_table = NULL;*/
static harglst * plugins_order_table = NULL;
-static void monitor_input_callback(struct arglist *);
+static void monitor_input_callback(struct arglist *, int, int);
static void monitor_add_host(struct arglist *, char *, int);
static void monitor_stop_test(GtkWidget *, char *);
static void monitor_list_update(struct arglist *, char *, int);
@@ -60,6 +56,13 @@
static int monitor_stop_whole_test(GtkWidget * , struct arglist *);
static void build_plugins_order_table(char *);
+struct gui_host {
+ GtkWidget * gui;
+ struct arglist * ctrls;
+ struct gui_host * next;
+};
+
+
static int
is_server_present(soc)
@@ -71,7 +74,7 @@
if(fd < 0 || fd >= FD_SETSIZE)
{
- fprintf(stderr, _("is_server_present: fd(%d) out of range\n"), fd);
+ fprintf(stderr, "is_server_present: fd(%d) out of range\n", fd);
return 0;
}
FD_ZERO(&rd);
@@ -102,23 +105,29 @@
{
fd_set rd;
struct timeval tv = {0,100};
- int n, soc;
- if(Context->socket < 0)
+ int n, soc = -1;
+ if(GlobalSocket < 0)
{
- fprintf(stderr, "idle_socket: Context->socket=%d\n", Context->socket);
+ fprintf(stderr, "idle_socket: GlobalSocket=%d\n", GlobalSocket);
return FALSE;
}
- soc = nessus_get_socket_from_connection(Context->socket);
+
+ if ( stream_pending(GlobalSocket) > 0 )
+ {
+ monitor_input_callback(ctrls, soc /* ? Not used */, 0);
+ return TRUE;
+ }
+ soc = nessus_get_socket_from_connection(GlobalSocket);
if((soc < 0) || (soc >= FD_SETSIZE))
{
- fprintf(stderr, _("idle_server: soc(%d) out of range\n"), soc);
+ fprintf(stderr, "idle_server: soc(%d) out of range\n", soc);
return -1;
}
FD_ZERO(&rd);
FD_SET(soc, &rd);
n = select(soc+1, &rd, NULL, NULL, &tv);
if(FD_ISSET(soc, &rd)&& (n > 0))
- monitor_input_callback(ctrls);
+ monitor_input_callback(ctrls, soc /* ? Not used */, 0);
return TRUE;
}
@@ -129,43 +138,44 @@
* show the attack status
*/
void
-monitor_dialog_setup(victim)
+monitor_dialog_setup(victim, restore)
char * victim;
+ int restore;
{
struct arglist * ctrls = emalloc(sizeof(struct arglist));
- GtkWindow* parent = arg_get_value(MainDialog, "CONTEXT");
GtkWidget * scrolled_window;
GtkWidget * w, * box;
char* window_title;
- const char* host_name;
+ char* host_name;
int tag;
int backend = backend_init(NULL);
/* Could not create a backend */
if( backend < 0 )
+ {
+ gtk_widget_show(arg_get_value(MainDialog, "WINDOW"));
return;
+ }
+
arg_add_value(ctrls, "MONITOR_BACKEND", ARG_INT, -1, (void*)backend);
- arg_add_value(ctrls, "PARENT", ARG_PTR, -1, parent);
-
+
w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+#if GTK_VERSION > 10
gtk_window_set_default_size(GTK_WINDOW(w), 640,480);
-
- /* TODO make the window non-modal
- * This can be done when context is kept for all called functions */
- gtk_window_set_modal(GTK_WINDOW(w), TRUE);
- gtk_window_set_transient_for(GTK_WINDOW(w), parent);
- arg_set_value(MainDialog, "CONTEXT", -1, w);
+#else
+ gtk_widget_set_usize(GTK_WIDGET(w), 640, 480);
+#endif
gtk_widget_realize(w);
gtk_signal_connect(GTK_OBJECT(w), "delete_event",
(GtkSignalFunc)monitor_stop_whole_test_destroy,ctrls);
- host_name = prefs_get_string(Context, "nessusd_host");
+ host_name = arg_get_value(Prefs, "nessusd_host");
if(host_name)window_title = emalloc(strlen(host_name) + 255);
else window_title = emalloc(255);
- sprintf(window_title, _("Scanning network from %s"),
- host_name?host_name:_("some host"));
+ sprintf(window_title, "Scanning network from %s",
+ host_name?host_name:"some host");
gtk_window_set_title(GTK_WINDOW(w), window_title);
efree(&window_title);
gtk_container_border_width(GTK_CONTAINER(w), 10);
@@ -185,7 +195,11 @@
gtk_box_pack_start(GTK_BOX(box), scrolled_window, TRUE, TRUE, 0);
w = gtk_list_new();
+#if GTK_VERSION < 11
+ gtk_container_add(GTK_CONTAINER(scrolled_window), w);
+#else
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), w);
+#endif
gtk_widget_show(w);
gtk_widget_show (scrolled_window);
arg_add_value(ctrls, "LIST", ARG_PTR, -1, w);
@@ -195,20 +209,17 @@
tag = gtk_idle_add((GtkFunction)idle_socket, ctrls);
arg_add_value(ctrls, "TAG", ARG_INT, sizeof(int), (void*)tag);
- w = gtk_button_new_with_label(_("Stop the whole test"));
+ w = gtk_button_new_with_label("Stop the whole test");
gtk_signal_connect(GTK_OBJECT(w), "clicked",
(GtkSignalFunc)monitor_stop_whole_test,ctrls);
gtk_box_pack_start(GTK_BOX(box), w, FALSE, TRUE, 0);
gtk_widget_show(w);
- if(!attack_host(victim, Context))
- {
- gtk_widget_hide(arg_get_value(ctrls, "WINDOW"));
- gtk_idle_remove(tag);
- gtk_widget_destroy(arg_get_value(ctrls, "WINDOW"));
- arg_set_value(MainDialog, "CONTEXT", -1, parent);
- prefs_context_update(Context);
- scopetreeview_connected_update(Context);
- }
+#if ENABLE_SAVE_TESTS
+ if(restore)
+ restore_attack(victim, Prefs);
+ else
+#endif
+ attack_host(victim, Prefs);
}
/*
@@ -268,7 +279,7 @@
item = GTK_OBJECT(dlist->data);
list_hostname = gtk_object_get_data(item, "hostname");
if(!list_hostname){
- fprintf(stderr, _("Error ! Null hostname in the list\n"));
+ fprintf(stderr, "Error ! Null hostname in the list\n");
/*exit(1);*/
return;
}
@@ -284,9 +295,9 @@
gmax = max;
gcurrent = atoi(current);
- f = (gcurrent/gmax);
- if(f>=1.0)f=1.0;
- if(f<=0.0)f=0.0;
+ f = (gfloat)(gcurrent/gmax);
+ if(f >= 1.0)f = 0.99;
+ else if(f <= 0)f = 0;
gtk_progress_bar_update (GTK_PROGRESS_BAR(progress_bar), f);
flag = 1;
@@ -319,11 +330,17 @@
item = gtk_object_get_data(GTK_OBJECT(arg_get_value(ctrls, "LIST")),host);
if(!item){
+#ifndef ENABLE_SAVE_KB
/*
* If this happens, then it's very likely that the server
* thinks the communication has been cut between the client
* and itself. Which is not a good thing.
*/
+ fprintf(stderr, "warning. Could not find entry for %s\n", host);
+ fprintf(stderr, "This may be a bug - please check the nessusd logfile\n");
+ fprintf(stderr, "and if you see something about a lost connection,\n");
+ fprintf(stderr, "or any odd message, please report it to deraison@cvs.nessus.org\n");
+#endif
return;
}
@@ -409,11 +426,11 @@
gtk_widget_show(box);
gtk_box_pack_end(GTK_BOX(hbox), box, FALSE, FALSE, 0);
- label = gtk_label_new(_("Portscan:"));
+ label = gtk_label_new("Portscan : ");
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
gtk_widget_show(label);
- label = gtk_label_new(_("Checks:"));
+ label = gtk_label_new("Checks : ");
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
gtk_widget_show(label);
@@ -447,7 +464,7 @@
gtk_table_attach_defaults(GTK_TABLE(table), box, 2,3,0,2);
gtk_widget_show(box);
- button = gtk_button_new_with_label(_("Stop"));
+ button = gtk_button_new_with_label("Stop");
gtk_signal_connect(GTK_OBJECT(button), "clicked",
(GtkSignalFunc)monitor_stop_test, hostname);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
@@ -494,9 +511,8 @@
int type = 0, n;
char * msg;
char buf[32768];
- GtkWindow* parent = arg_get_value(ctrls, "PARENT");
-
network_printf( "CLIENT <|> STOP_WHOLE_TEST <|> CLIENT\n");
+ efree(&ArgSock);
gtk_idle_remove((int)arg_get_value(ctrls, "TAG"));
/*
@@ -515,9 +531,9 @@
efree(&msg);
}
+ F_nessusd_running = 0;
gtk_widget_hide(arg_get_value(ctrls, "WINDOW"));
- arg_set_value(MainDialog, "CONTEXT", -1, parent);
- report_save(Context, (int)arg_get_value(ctrls, "MONITOR_BACKEND"), NULL);
+ report_tests_ng((int)arg_get_value(ctrls, "MONITOR_BACKEND"), 0);
return(FALSE);
}
@@ -529,10 +545,11 @@
* data coming from the server.
*/
void
-monitor_input_callback(ctrls)
+monitor_input_callback(ctrls, fd, condition)
struct arglist * ctrls;
+ int fd;
+ int condition;
{
- GtkWindow* parent = arg_get_value(ctrls, "PARENT");
int finished = 0;
static char * buf = NULL;
static int bufsz = 0;
@@ -550,7 +567,7 @@
if ((n = strlen (buf)) && buf [n-1] == '\n') buf [n-1] = '\0';
if( buf[0] == '\0') {
- if(!is_server_present(Context->socket))
+ if(!is_server_present(GlobalSocket))
{
interrupted++;
goto scan_finished;
@@ -585,11 +602,11 @@
if(finished)
{
scan_finished :
+ F_nessusd_running = 0;
gtk_widget_hide(arg_get_value(ctrls, "WINDOW"));
gtk_idle_remove((int)arg_get_value(ctrls, "TAG"));
gtk_widget_destroy(arg_get_value(ctrls, "WINDOW"));
- arg_set_value(MainDialog, "CONTEXT", -1, parent);
- report_save(Context, (int)arg_get_value(ctrls, "MONITOR_BACKEND"), NULL);
+ report_tests_ng((int)arg_get_value(ctrls, "MONITOR_BACKEND"), interrupted);
}
}
@@ -641,14 +658,14 @@
for(i=0;i<num;i++)
{
- struct arglist * plugs = Context->plugins;
+ struct arglist * plugs = Plugins;
while(plugs && plugs->next &&
((int)(arg_get_value(plugs->value, "ID"))!=plugins_order_table_int[i]))
plugs = plugs->next;
if(!(plugs && plugs->next))
{
- plugs = Context->scanners;
+ plugs = Scanners;
while(plugs && plugs->next &&
((int)(arg_get_value(plugs->value, "ID"))!=plugins_order_table_int[i]))
plugs = plugs->next;
Index: monitor_dialog.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/monitor_dialog.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- monitor_dialog.h 13 Nov 2004 13:37:05 -0000 1.8
+++ monitor_dialog.h 17 Mar 2007 21:36:01 -0000 1.9
@@ -19,5 +19,5 @@
#ifndef _NESSUSC_MONITOR_DIALOG_H
#define _NESSUSC_MONITOR_DIALOG_H
-void monitor_dialog_setup(char *);
+void monitor_dialog_setup(char *, int);
#endif
Index: nbe_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/nbe_output.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- nbe_output.c 9 Dec 2004 18:50:21 -0000 1.12
+++ nbe_output.c 17 Mar 2007 21:36:01 -0000 1.13
@@ -97,9 +97,11 @@
if(fd < 0)
{
+ char err[1024];
int e = errno;
perror(filename);
- show_error("%s: %s", filename, strerror(e));
+ snprintf(err, sizeof(err), "%s: %s", filename, strerror(e));
+ show_error(err);
return -1;
}
Index: nessus.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/nessus.c,v
retrieving revision 1.194
retrieving revision 1.195
diff -u -d -r1.194 -r1.195
--- nessus.c 22 Sep 2006 20:28:40 -0000 1.194
+++ nessus.c 17 Mar 2007 21:36:01 -0000 1.195
@@ -1,5 +1,5 @@
/* Nessus
- * Copyright (C) 1998 - 2001 Renaud Deraison
+ * Copyright (C) 1998 - 2006 Tenable Network Security, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
@@ -28,18 +28,19 @@
*/
#include <includes.h>
-
-#include "nessus_i18n.h"
#include "password_dialog.h"
#ifdef USE_GTK
#include <gtk/gtk.h>
#include "xstuff.h"
+#include "error_dialog.h"
#include "prefs_dialog/prefs_dialog.h"
-#include "prefs_dialog/prefs_context.h"
+#include "prefs_dialog/prefs_dialog_plugins_prefs.h"
+#include "prefs_dialog/prefs_dialog_scan_opt.h"
+#include "prefs_dialog/prefs_target.h"
+#include "report_ng.h"
#endif
-#include "error_dialog.h"
#include "read_target_file.h"
#include "comm.h"
#include "auth.h"
@@ -48,11 +49,11 @@
#include "report.h"
#include "parser.h"
#include "sighand.h"
-#include "context.h"
#include "preferences.h"
#include "globals.h"
#include "corevers.h"
#include <getopt.h>
+#include "password_dialog.h"
#include "filter.h"
#include "backend.h"
@@ -65,12 +66,18 @@
#include "xml_output.h"
#include "xml_output_ng.h"
+
+
#include "cli.h"
#ifdef HAVE_SSL
#include <openssl/x509v3.h>
#endif
+#ifdef ENABLE_SAVE_TESTS
+#include "detached_index.h"
+#endif
+
#ifdef USE_AF_UNIX
#undef NESSUS_ON_SSL
#endif
@@ -87,12 +94,33 @@
#define inc_optind() (optind++)
#endif
+struct arglist * Plugins = NULL;
+struct arglist * Scanners = NULL;
+struct arglist * Dependencies = NULL;
+struct arglist * Upload = NULL;
+#ifdef ENABLE_SAVE_TESTS
+harglst * Sessions = NULL;
+int Sessions_saved = 0;
+int Detached_sessions_saved = 0;
+#endif
+#ifdef ENABLE_SAVE_KB
+int DetachedMode = 0;
+#endif
+
+int PluginsNum;
+int ScannersNum;
+struct arglist * Prefs;
struct arglist * MainDialog;
+struct arglist * ArgSock;
char * Alt_rcfile = NULL;
struct plugin_filter Filter;
+int GlobalSocket;
+char * stored_pwd = NULL;
int DontCheckServerCert = 0;
int F_show_pixmaps;
int F_quiet_mode;
+int F_nessusd_running;
+int First_time = 0;
int ListOnly = 0;
#ifndef USE_AF_INET
@@ -102,19 +130,6 @@
void init_globals();
-/*
- * Initialize I18N support, if possible
- */
-static void
-i18n_init(void)
-{
-#ifdef HAVE_GNU_GETTEXT
- setlocale (LC_ALL, "" );
- bindtextdomain (PACKAGE, LOCALEDIR);
- bind_textdomain_codeset (PACKAGE, "UTF-8");
- textdomain (PACKAGE);
-#endif
-}
#ifdef NESSUS_ON_SSL
@@ -175,7 +190,7 @@
int i, x;
- if ((fname = preferences_get_altname(Global, "cert")) == NULL)
+ if ((fname = preferences_get_altname("cert")) == NULL)
return -1;
fp = fopen(fname, "r");
@@ -234,7 +249,7 @@
int x;
int found;
- if ((fname = preferences_get_altname(Global, "cert")) == NULL)
+ if ((fname = preferences_get_altname("cert")) == NULL)
return -1;
if ((fp2 = tmpfile()) == NULL)
@@ -316,12 +331,12 @@
*
*/
char *
-connect_to_nessusd(context)
- struct context * context;
+connect_to_nessusd(hostname, port, login, pass)
+ char * hostname;
+ int port;
+ char * login;
+ char * pass; /* is a cipher in case of the crypto layer */
{
- const char * hostname;
- int port;
- const char * login;
#ifdef CLN_AUTH_SRV
int paranoia_level;
/*
@@ -335,11 +350,9 @@
static SSL_CTX *ssl_ctx = NULL;
static SSL_METHOD *ssl_mt = NULL;
SSL *ssl = NULL;
- const char *cert, *key, *client_ca, *trusted_ca, *ssl_ver;
- const char *ssl_cipher_list;
+ char *cert, *key, *client_ca, *trusted_ca, *ssl_ver;
+ char *ssl_cipher_list;
STACK_OF(X509_NAME) *cert_names;
- int use_client_cert = prefs_get_int(context, "use_client_cert");
- char *pem_pass = NULL;
#endif
int soc, soc2;
int opt;
@@ -347,21 +360,32 @@
struct sockaddr_un address;
char * name = AF_UNIX_PATH;
#endif
- const char *passwd;
- if(prefs_get_int(Global, "nessusd_autoconnect"))
- passwd = estrdup(context->passwd);
+ init_globals();
+ if(arg_get_type(Prefs, "nessusd_host")>=0)
+ arg_set_value(Prefs, "nessusd_host", strlen(hostname), strdup(hostname));
else
- {
- /* Don't cache the password */
- passwd = context->passwd;
- context->passwd = NULL;
- }
-
- hostname = prefs_get_string(context, "nessusd_host");
- port = prefs_get_int(context, "nessusd_port");
- login = prefs_get_string(context, "nessusd_user");
+ arg_add_value(Prefs, "nessusd_host", ARG_STRING, strlen(hostname),
+ strdup(hostname));
+
+ if(arg_get_type(Prefs, "nessusd_user")>=0)
+ arg_set_value(Prefs, "nessusd_user", strlen(login), strdup(login));
+ else
+ arg_add_value(Prefs, "nessusd_user", ARG_STRING, strlen(login),
+ strdup(login));
+#ifdef CLN_AUTH_SRV
+ paranoia_level = (int) arg_get_value(Prefs, "paranoia_level");
+ if(!paranoia_level && !DontCheckServerCert){
+ paranoia_level = sslui_ask_paranoia_level();
+ if(paranoia_level >= 1 && paranoia_level <= 3)
+ {
+ arg_add_value(Prefs, "paranoia_level", ARG_INT, sizeof(int),(void*)paranoia_level);
+ preferences_save(Plugins);
+ }
+ }
+#endif
+
#ifdef USE_AF_INET
soc = open_sock_tcp_hn(hostname, port);
@@ -371,10 +395,10 @@
static char err_msg[1024];
struct in_addr a = nn_resolve(hostname);
if(a.s_addr == INADDR_NONE)
- return _("Host not found!");
+ return("Host not found !");
else
{
- snprintf(err_msg, sizeof(err_msg), _("Could not open a connection to %s\n"), hostname);
+ snprintf(err_msg, sizeof(err_msg), "Could not open a connection to %s\n", hostname);
return err_msg;
}
}
@@ -393,37 +417,24 @@
if(connect(soc, (struct sockaddr*)&address, sizeof(address))==-1)
{
char * error = emalloc(255+strlen(name)+strlen(strerror(errno)));
- sprintf(error, _("Could not connect to %s - %s\n"), name, strerror(errno));
+ sprintf(error, "Could not connect to %s - %s\n", name, strerror(errno));
return error;
}
#endif
#ifdef NESSUS_ON_SSL
- if (prefs_get_int(context, "use_ssl"))
- {
- ssl_ver = prefs_get_string(context, "ssl_version");
- if (!strcasecmp(ssl_ver, "NONE"))
- ssl_ver = prefs_get_default(context, "ssl_version");
- }
- else
- ssl_ver = "NONE";
+#define SSL_VER_DEF_NAME "TLSv1"
+#define SSL_VER_DEF_METH TLSv1_client_method
+ ssl_ver = arg_get_value(Prefs, "ssl_version");
+ if (ssl_ver == NULL || *ssl_ver == '\0')
+ ssl_ver = SSL_VER_DEF_NAME;
if (strcasecmp(ssl_ver, "NONE") != 0)
{
-#ifdef CLN_AUTH_SRV
- paranoia_level = prefs_get_int(context, "paranoia_level");
- if(!paranoia_level && !DontCheckServerCert)
- {
- paranoia_level = sslui_ask_paranoia_level();
- if(paranoia_level >= 1 && paranoia_level <= 3)
- prefs_set_int(context, "paranoia_level", paranoia_level);
- }
-#endif
-
if(nessus_SSL_init(NULL) < 0)
{
- return(_("Could not initialize the OpenSSL library !\n\
-Please launch nessus-mkrand(1) first !"));
+ return("Could not initialize the OpenSSL library !\n\
+Please launch nessus-mkrand(1) first !");
}
if (ssl_mt == NULL)
{
@@ -437,9 +448,7 @@
ssl_mt = TLSv1_client_method();
else
{
- show_warning(
- _("Unknown SSL version \"%s\"\nUsing default: %s"),
- ssl_ver, SSL_VER_DEF_NAME);
+ fprintf(stderr, "Unknown SSL version \"%s\"\nSwitching to default " SSL_VER_DEF_NAME "\n", ssl_ver);
ssl_ver = SSL_VER_DEF_NAME;
ssl_mt = SSL_VER_DEF_METH();
}
@@ -466,7 +475,7 @@
#define NOEXP_CIPHER_LIST "EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:DES-CBC3-SHA:DES-CBC3-MD5:DHE-DSS-RC4-SHA:IDEA-CBC-SHA:RC4-SHA:RC4-MD5:IDEA-CBC-MD5:RC2-CBC-MD5:RC4-MD5:RC4-64-MD5:EDH-RSA-DES-CBC-SHA:EDH-DSS-DES-CBC-SHA:DES-CBC-SHA:DES-CBC-MD5"
#define STRONG_CIPHER_LIST "EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:DES-CBC3-SHA:DES-CBC3-MD5:DHE-DSS-RC4-SHA:IDEA-CBC-SHA:RC4-SHA:RC4-MD5:IDEA-CBC-MD5:RC2-CBC-MD5:RC4-MD5"
#define EDH_CIPHER_LIST "EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:DHE-DSS-RC4-SHA"
- ssl_cipher_list = prefs_get_string(context, "ssl_cipher_list");
+ ssl_cipher_list = arg_get_value(Prefs, "ssl_cipher_list");
if (ssl_cipher_list != NULL && *ssl_cipher_list != '\0' )
{
if (strcmp(ssl_cipher_list, "noexp") == 0)
@@ -485,19 +494,14 @@
sslerror("SSL_new");
return "SSL_error";
}
+ cert = arg_get_value(Prefs, "cert_file");
+ key = arg_get_value(Prefs, "key_file");
+ client_ca = arg_get_value(Prefs, "client_ca");
- if(use_client_cert)
- {
- cert = prefs_get_string(context, "cert_file");
- key = prefs_get_string(context, "key_file");
- client_ca = prefs_get_string(context, "client_ca");
-
- if(passwd && key)
+ if (pass != NULL && key != NULL)
{
- pem_pass = estrdup(passwd);
- nessus_install_passwd_cb(ssl_ctx, pem_pass);
- efree(&passwd);
- passwd = estrdup("*"); /* Do not send it over the network */
+ nessus_install_passwd_cb(ssl_ctx, pass);
+ /* pass = "*"; */ /* So that we do not send it over the network */
}
if (cert != NULL)
@@ -513,16 +517,14 @@
else
sslerror("SSL_load_client_CA_file");
}
- }
#ifdef CLN_AUTH_SRV
if (paranoia_level == 2 || paranoia_level == 3)
{
- trusted_ca = prefs_get_string(context, "trusted_ca");
+ trusted_ca = arg_get_value(Prefs, "trusted_ca");
if (trusted_ca == NULL)
{
- show_warning(
- _("paranoia_level=%d but \"trusted_ca\" not set"),
- paranoia_level);
+ fprintf(stderr, "paranoia_level=%d but \"trusted_ca\"not set\n",
+ paranoia_level);
paranoia_level = 1;
}
else
@@ -533,13 +535,7 @@
sslerror("SSL_CTX_set_default_verify_paths");
#endif
if (! SSL_CTX_load_verify_locations(ssl_ctx, trusted_ca, NULL))
- {
- sslerror("SSL_CTX_load_verify_locations");
- show_warning(
- _("Error while setting the trusted CA: %s\n"
- "SSL connections are likely to fail."),
- trusted_ca);
- }
+ sslerror("SSL_CTX_load_verify_locations");
}
}
#endif
@@ -547,8 +543,6 @@
if (! SSL_set_fd(ssl, soc))
{
sslerror("SSL_set_fd");
- efree(&passwd);
- efree(&pem_pass);
return "SSL error";
}
@@ -556,8 +550,6 @@
if (SSL_connect(ssl) <= 0)
{
sslerror("SSL_connect");
- efree(&passwd);
- efree(&pem_pass);
return "SSL error";
}
@@ -581,23 +573,16 @@
if(cert == NULL)
{
sslerror("SSL_get_peer_certificate");
- return _("SSL error: cannot get server certificate");
- efree(&passwd);
- efree(&pem_pass);
+ return "SSL error: cannot get server certificate";
}
X509_check_purpose(cert, -1, 0); /* Make sure hash is correct */
if (memcmp(cert->sha1_hash, stored_hash, SHA_DIGEST_LENGTH) != 0)
{
int x = sslui_check_cert(ssl);
- if(x < 0)
- {
- efree(&passwd);
- efree(&pem_pass);
- return _("Invalid server certificate");
- }
+ if(x < 0)return "Invalid server certificate";
if (set_server_cert_hash(hostname, cert->sha1_hash) < 0)
- perror(_("Could not save server certificate"));
+ perror("Could not save server certificate");
}
}
#endif
@@ -606,9 +591,7 @@
if ((soc2 = nessus_register_connection(soc, ssl)) <0)
{
shutdown(soc, 2);
- efree(&passwd);
- efree(&pem_pass);
- return _("Could not register the connection");
+ return "Could not register the connection";
}
stream_set_buffer(soc2, 1024 * 1024);
soc = soc2;
@@ -616,55 +599,96 @@
#else
if((soc2 = nessus_register_connection(soc, NULL)) < 0)
{
- efree(&passwd);
- return _("Could not register the connection");
+ return "Could not register the connection";
}
stream_set_buffer(soc2, 1024 * 1024);
soc = soc2;
#endif
- context->socket = soc;
+ GlobalSocket = soc;
+ ArgSock = emalloc(sizeof(struct arglist));
+ arg_add_value(ArgSock, "global_socket", ARG_INT, -1, (void *)GlobalSocket);
- if(comm_init(soc,PROTO_NAME) || (auth_login(login, passwd)))
+
+ if(comm_init(soc,PROTO_NAME) || (auth_login(login, pass)))
{
#ifdef NESSUS_ON_SSL
- close_stream_connection(context->socket);
- efree(&pem_pass);
+ close_stream_connection(GlobalSocket);
#else
- shutdown(context->socket, 2);
+ shutdown(soc, 2);
#endif
- context->socket = -1;
- efree(&passwd);
- return(_("Remote host is not using the good version of the Nessus communication protocol (1.2) or is tcpwrapped"));
+ return("Remote host is not using the good version of the Nessus communication protocol (1.2) or is tcpwrapped");
}
-
- if(comm_get_plugins(context))
+ if(comm_get_plugins())return("Login failed");
+ if(F_quiet_mode)
{
-#ifdef NESSUS_ON_SSL
- close_stream_connection(context->socket);
- efree(&pem_pass);
-#else
- shutdown(context->socket, 2);
-#endif
- context->socket = -1;
- efree(&passwd);
- return(_("Login failed"));
+ cli_comm_get_preferences(Prefs);
+ comm_get_rules(Prefs);
+ comm_get_dependencies();
+ }
+ else
+ {
+ if(!First_time){
+ comm_get_preferences(Prefs);
+ comm_get_rules(Prefs);
+ comm_get_dependencies();
+ }
+ else
+ {
+ /*
+ * Ignore the server preferences if we already logged in
+ */
+ struct arglist * devnull = emalloc(sizeof(*devnull));
+ comm_get_preferences(devnull);
+ comm_get_rules(devnull);
+ arg_free(devnull);
+ }
}
- comm_get_preferences(context);
- comm_get_rules(context);
- comm_get_dependencies(context);
+ if(comm_server_restores_sessions(Prefs))
+ {
+ Sessions = comm_get_sessions();
+#ifdef USE_GTK
+ prefs_dialog_target_fill_sessions(arg_get_value(MainDialog, "TARGET"),
+ Sessions);
+#endif
+ }
+
+
+
+ prefs_check_defaults(Prefs);
#ifdef ENABLE_SAVE_TESTS
- if(comm_server_restores_sessions(context))
- context->sessions = comm_get_sessions();
+#ifdef USE_GTK
+ if(comm_server_detached_sessions(Prefs))
+ detached_show_window(Prefs);
+#endif
#endif
- efree(&passwd);
-#ifdef NESSUS_ON_SSL
- efree(&pem_pass);
+
+#ifdef USE_GTK
+ prefs_plugins_reset(arg_get_value(MainDialog, "PLUGINS_PREFS"), Plugins,
+ Scanners);
#endif
+#ifdef USE_GTK
+ if(!F_quiet_mode)fill_scanner_list(arg_get_value(MainDialog, "SCAN_OPTIONS"));
+#endif
+
return(NULL);
}
+/*
+ * init_globals
+ *
+ * initializes two main global variables : plugins and
+ * scanners
+ *
+ */
+void
+init_globals()
+{
+ if(!Plugins)Plugins = emalloc(sizeof(struct arglist));
+ if(!Scanners)Scanners = emalloc(sizeof(struct arglist));
+}
+
void
display_help
@@ -673,39 +697,39 @@
printf("%s, version %s\n", pname, NESSUS_FULL_VERSION);
#ifdef USE_AF_INET
- printf(_("\nCommon options :\n %s [-vnh] [-c .rcfile] [-V] [-T <format>]"),pname);
- printf(_("\nBatch-mode scan:\n %s -q [-pPS] <host> <port> <user> <pass> <targets-file> <result-file>"),pname);
- printf(_("\nList sessions :\n %s -s -q <host> <port> <user> <pass> "),pname);
- printf(_("\nRestore session:\n %s -R <sessionid> -q <host> <port> <user> <pass> <result-file> "),pname);
+ printf("\nCommon options :\n %s [-vnh] [-c .rcfile] [-V] [-T <format>]",pname);
+ printf("\nBatch-mode scan:\n %s -q [-pPS] <host> <port> <user> <pass> <targets-file> <result-file>",pname);
+ printf("\nList sessions :\n %s -s -q <host> <port> <user> <pass> ",pname);
+ printf("\nRestore session:\n %s -R <sessionid> -q <host> <port> <user> <pass> <result-file> ",pname);
#else /* AF_UNIX */
- printf(_("\nBatch-mode scan:\n %s -q [-pPS] <user> <pass> <targets-file> <result-file>"),pname);
- printf(_("\nList sessions :\n %s -s -q <user> <pass> "),pname);
- printf(_("\nRestore session:\n %s -R <sessionid> -q <user> <pass> <result-file> "),pname);
+ printf("\nBatch-mode scan:\n %s -q [-pPS] <user> <pass> <targets-file> <result-file>",pname);
+ printf("\nList sessions :\n %s -s -q <user> <pass> ",pname);
+ printf("\nRestore session:\n %s -R <sessionid> -q <user> <pass> <result-file> ",pname);
#endif
- printf(_("\nReport conversion :\n %s -i in.[nsr|nbe] -o out.[html|xml|nsr|nbe]\n\n"), pname);
- printf(_("General options :\n"));
- printf(_("\t-v : shows version number\n"));
- printf(_("\t-h : shows this help\n"));
- printf(_("\t-n : No pixmaps\n"));
- printf(_("\t-T : Output format: 'nbe', 'html', 'html_graph', 'text', 'xml',\n"));
+ printf("\nReport conversion :\n %s -i in.[nsr|nbe] -o out.[html|xml|nsr|nbe]\n\n", pname);
+ printf("General options :\n");
+ printf("\t-v : shows version number\n");
+ printf("\t-h : shows this help\n");
+ printf("\t-n : No pixmaps\n");
+ printf("\t-T : Output format: 'nbe', 'html', 'html_graph', 'text', 'xml',\n");
printf("\t 'old-xml' 'tex' or 'nsr'\n");
- printf(_("\t-V : make the batch mode display status messages\n"
- "\t to the screen.\n"));
- printf(_("\t-x : override SSL \"paranoia\" question preventing nessus from\n"
- "\t checking certificates.\n\n"));
-
- printf(_("The batch mode (-q) arguments are :\n"));
+ printf("\t-V : make the batch mode display status messages\n");
+ printf("\t to the screen.\n");
+ printf("\t-x : override SSL \"paranoia\" question preventing nessus from\n");
+ printf("\t checking certificates.\n\n");
+
+ printf("The batch mode (-q) arguments are :\n");
#ifdef USE_AF_INET
- printf(_("\thost : nessusd host\n"));
- printf(_("\tport : nessusd host port\n"));
+ printf("\thost : nessusd host\n");
+ printf("\tport : nessusd host port\n");
#endif
- printf(_("\tuser : user name\n"));
- printf(_("\tpass : password\n"));
- printf(_("\ttargets : file containing the list of targets\n"));
- printf(_("\tresult : name of the file where \n\t\t nessus will store the results\n"));
- printf(_("\t-p : obtain list of plugins installed on the server.\n"));
- printf(_("\t-P : obtain list of server and plugin preferences.\n"));
- printf(_("\t-S : issue SQL output for -p and -P (experimental).\n"));
+ printf("\tuser : user name\n");
+ printf("\tpass : password\n");
+ printf("\ttargets : file containing the list of targets\n");
+ printf("\tresult : name of the file where \n\t\t nessus will store the results\n");
+ printf("\t-p : obtain list of plugins installed on the server.\n");
+ printf("\t-P : obtain list of server and plugin preferences.\n");
+ printf("\t-S : issue SQL output for -p and -P (experimental).\n");
/* TODO: The following options are not described yet: -m (jfs) */
}
@@ -776,28 +800,25 @@
int list_prefs = 0;
int sqlize_output = 0;
int restore_session = 0;
-#ifdef ENABLE_SAVE_TESTS
char * session_id = NULL;
-#endif
char * arg = NULL;
int opt_V= 0;
int opt_i= 0;
int opt_o= 0;
char * inf = NULL, *outf = NULL;
- /* Setup I18N. */
- i18n_init();
-
/*
* Version check
*/
+
+
if(version_check(NESSUS_VERSION, nessuslib_version())>0)
{
fprintf(stderr,
-_("Error : we are linked against nessus-libraries %s. \n\
+"Error : we are linked against nessus-libraries %s. \n\
Install nessus-libraries %s or make sure that\n\
-you have deleted older versions nessus libraries from your system\n"),
+you have deleted older versions nessus libraries from your system\n",
nessuslib_version(), NESSUS_VERSION);
}
@@ -812,7 +833,11 @@
else
myself ++ ;
- MainDialog = NULL;
+ PluginsNum = 0;
+ ScannersNum = 0;
+ Scanners = Plugins = MainDialog = NULL;
+ ArgSock = NULL;
+ GlobalSocket = -1;
#ifdef USE_GTK
F_quiet_mode = 0;
F_show_pixmaps = 1;
@@ -914,12 +939,12 @@
opt_V++;
break;
case 'v' :
- printf("nessus (%s) %s for %s\n\n(C) 1998 - 2003 Renaud Deraison <deraison@nessus.org>\n",
+ printf("nessus (%s) %s for %s\n\n(C) 1998 - 2006 Tenable Network Security, Inc.\n",
PROGNAME,NESSUS_VERSION, NESS_OS_NAME);
#ifdef NESSUS_ON_SSL
- printf(_("\tSSL used for client - server communication\n"));
+ printf("\tSSL used for client - server communication\n");
#else
- printf(_("\tclient - server communication is done in PLAIN TEXT\n"));
+ printf("\tclient - server communication is done in PLAIN TEXT\n");
#endif
printf ("\n");
exit(0);
@@ -963,14 +988,11 @@
exit (0);
}
}
-
- /* Initialize global context */
- context_init(&Global, NULL);
- Context = Global;
-
+
if(opt_i || opt_o)
{
int be;
+ preferences_init(&Prefs);
if(!(opt_i && opt_o))
{
display_help("nessus");
@@ -1010,7 +1032,7 @@
backend_to_xml_ng(be, outf);
else
{
- fprintf(stderr, _("Unsupported report type '%s'\n"), type);
+ fprintf(stderr, "Unsupported report type '%s'\n", type);
exit(1);
}
backend_close(be);
@@ -1018,7 +1040,7 @@
}
else
{
- fprintf(stderr, _("Could not import '%s' - is it a .nsr or .nbe file ?\n"),
+ fprintf(stderr, "Could not import '%s' - is it a .nsr or .nbe file ?\n",
inf);
}
exit(0);
@@ -1041,19 +1063,19 @@
#ifdef ENABLE_SAVE_TESTS
if(list_sessions && (argc<=optind) && !F_quiet_mode)
{
- fprintf(stderr, _("list-sessions requires %s\n"), BATCH_USAGE);
+ fprintf(stderr, "list-sessions requires %s\n", BATCH_USAGE);
exit(1);
}
if(restore_session && (argc<=optind) && !F_quiet_mode)
{
- fprintf(stderr, _("restore-session requires -q %s result\n"), BATCH_USAGE);
+ fprintf(stderr, "restore-session requires -q %s result\n", BATCH_USAGE);
exit(1);
}
if(restore_session && list_sessions)
{
- fprintf(stderr, _("--restore-session and --list-sessions are mutually exclusive\n"));
+ fprintf(stderr, "--restore-session and --list-sessions are mutually exclusive\n");
exit(1);
}
#endif
@@ -1073,24 +1095,20 @@
init_display (&argc, &argv);
}
#endif
-
+
/* system environment set up */
if(!opt_m)
{
- if (preferences_init(Global))
+ if (preferences_init(&Prefs))
exit (2);
- }
- else
- Global->prefs = emalloc(sizeof(struct arglist));
+ }
+ else
+ Prefs = emalloc(sizeof(struct arglist));
-#ifdef USE_GTK
- if(!F_quiet_mode)
- context_collect(Global);
-#endif /* USE_GTK */
if(opt_V && !F_quiet_mode)
{
- fprintf(stderr, _("Verbose mode can only be used in batch mode\n"));
+ fprintf(stderr, "Verbose mode can only be used in batch mode\n");
exit(1);
}
@@ -1124,14 +1142,14 @@
if(list_sessions || opt_m || list_plugins || list_prefs)
{
if (argc - optind != NUM_ARGS - 2) {
- fprintf(stderr, "%s" BATCH_USAGE "\n", _("list-sessions only requires "));
+ fprintf(stderr, "list-sessions only requires " BATCH_USAGE "\n");
exit(1);
}
}
else if(restore_session)
{
if (argc - optind != NUM_ARGS - 1) {
- fprintf(stderr, "%s" BATCH_USAGE " <result-file>\n", _("restore-session only requires "));
+ fprintf(stderr, "restore-session only requires " BATCH_USAGE " <result-file>\n");
exit(1);
}
}
@@ -1167,9 +1185,10 @@
if(list_prefs)
{
+ First_time = 0;
if(cli_connect_to_nessusd(cli) < 0)
{
- fprintf(stderr, _("Could not connect to nessusd\n"));
+ fprintf(stderr, "Could not connect to nessusd\n");
exit(1);
}
if(sqlize_output)
@@ -1181,9 +1200,10 @@
}
if(list_plugins)
{
+ First_time = 0;
if(cli_connect_to_nessusd(cli) < 0)
{
- fprintf(stderr, _("Could not connect to nessusd\n"));
+ fprintf(stderr, "Could not connect to nessusd\n");
exit(1);
}
if(sqlize_output)
@@ -1209,13 +1229,13 @@
char * t = argv[inc_optind()];
if(t)cli_args_target(cli, t);
else {
- fprintf(stderr, _("Missing parameter\n"));
+ fprintf(stderr, "Missing parameter\n");
display_help(myself);
}
t = argv[inc_optind()];
if(t) cli_args_results(cli, t);
else {
- fprintf(stderr, _("Missing parameter\n"));
+ fprintf(stderr, "Missing parameter\n");
display_help(myself);
}
}
@@ -1231,12 +1251,12 @@
if(list_sessions){
cli_list_sessions(cli);
#ifdef NESSUS_ON_SSL
- close_stream_connection(Context->socket);
+ close_stream_connection(GlobalSocket);
#else
- shutdown(Context->socket ,2);
- closesocket(Context->socket);
+ shutdown(GlobalSocket,2);
+ closesocket(GlobalSocket);
#endif
- Context->socket = -1;
+ GlobalSocket = -1;
nessus_exit(0);
}
else if(restore_session) {
@@ -1245,8 +1265,8 @@
else
#endif
if(opt_m){
- if(!preferences_generate_new_file(Global, NULL))
- printf(_("A new nessusrc file has been saved\n"));
+ if(!preferences_generate_new_file())
+ printf("A new nessusrc file has been saved\n");
}
else
{
@@ -1256,43 +1276,47 @@
/* end, exit */
nessus_exit(0);
}
-
+
+ F_nessusd_running = 0;
+
/*
* Set up the main window
*/
#if 0
- paranoia_level = prefs_get_int(context, "paranoia_level");
+ paranoia_level = arg_get_value(Prefs, "paranoia_level");
if (paranoia_level == 0)
{
paranoia_level = sslui_ask_paranoia_level();
if(paranoia_level > 0)
- prefs_set_int(context, "paranoia_level", paranoia_level);
+ arg_add_value(Prefs, "paranoia_level", ARG_INT, -1, (void*)paranoia_level);
}
#endif
#ifdef USE_GTK
- prefs_dialog_setup(Global);
- prefs_context_update(Global);
-
- gtk_main();
+ prefs_dialog_setup (NULL, Prefs);
+ /*
+ * all the options have been taken in account... Now, the user
+ * may want us to open a previously saved file
+ */
+ for (i = 1; i < xac; i ++) {
+ int be = backend_import_report(xav[i]);
+ if(be >= 0)
+ report_tests_ng (be, 0);
+ }
- /* XXX: Server preferences are not saved here */
- prefs_dialog_apply(Context, MainDialog);
- context_save_recurse(Global);
- /* FIXME: close all open connections
- close_stream_connection(Context->socket);
- Context->socket = -1;
- */
- nessus_exit(0);
- return 0; /* make the compiler happy */
+ gtk_main();
+ close_stream_connection(GlobalSocket);
+ close_display();
+ GlobalSocket = -1;
+ return(0);
#else
- printf(_("\nOoops ...\n\
+ printf("\nOoops ...\n\
This nessus version has no gui support. You need to give nessus the\n\
arguments SERVER PORT LOGIN TRG RESULT as explained in more detail\n\
- using the --help option.\n"));
+ using the --help option.\n");
exit (1);
#endif
}
Index: nessus.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/nessus.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- nessus.h 3 Nov 2004 14:25:29 -0000 1.25
+++ nessus.h 17 Mar 2007 21:36:01 -0000 1.26
@@ -29,10 +29,6 @@
#define DEFAULT_SERVER "localhost"
#define PROTO_NAME "< NTP/1.2 >< plugins_cve_id plugins_version plugins_bugtraq_id plugins_xrefs timestamps dependencies >\n"
-#ifdef NESSUS_ON_SSL
-# define SSL_VER_DEF_NAME "TLSv1"
-# define SSL_VER_DEF_METH TLSv1_client_method
-#endif /* NESSUS_ON_SSL */
#ifdef _CYGWIN_
extern char * NESSUS_RCFILE;
@@ -42,8 +38,6 @@
#endif
-#include "context.h"
-
-char * connect_to_nessusd(struct context *);
+char * connect_to_nessusd(char *, int, char *, char *);
#endif
Index: nsr_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/nsr_output.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- nsr_output.c 9 Dec 2004 18:50:21 -0000 1.31
+++ nsr_output.c 17 Mar 2007 21:36:01 -0000 1.32
@@ -169,9 +169,11 @@
if(fd < 0)
{
+ char err[1024];
int e = errno;
perror(filename);
- show_error("%s: %s", filename, strerror(e));
+ snprintf(err, sizeof(err), "%s: %s", filename, strerror(e));
+ show_error(err);
return -1;
}
Index: parser.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/parser.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- parser.c 9 Dec 2004 18:30:33 -0000 1.42
+++ parser.c 17 Mar 2007 21:36:02 -0000 1.43
@@ -27,8 +27,6 @@
*/
#include <includes.h>
-#include "nessus_i18n.h"
-
#include "parser.h"
#include "auth.h"
#include "error_dialog.h"
@@ -153,50 +151,6 @@
}
/*
- * parse_server_error
- *
- * Feed errors from the Nessus Server
- * to gettext and display them.
- */
-void
-parse_server_error(servmsg)
- char *servmsg;
-{
- char *msg = parse_separator(servmsg);
- char *msg1, *msg2;
-
- /*
- * msg2 contains the following lines of the server error.
- * Currently this can only be the list of rejected hosts,
- * so don't translate them.
- */
- if((msg2 = strchr(msg, ';')))
- {
- char *t;
-
- msg2[0] = '\0';
- msg2++;
- while((t = strchr(msg2, ';')))
- t[0]='\n';
- }
-
- /* * keep these in sync with the messages in ../nessusd/attack.c */
- if(!strncmp("E001 -", msg, 6))
- msg1 = _("Invalid port range");
- else if(!strncmp("E002 -", msg, 6))
- msg1 = _("These hosts could not be tested because you"
- " are not allowed to do so:");
- else
- msg1 = msg;
-
- if(msg2)
- show_error("%s\n%s", msg1, msg2);
- else
- show_error("%s", msg1);
- efree(&msg);
-}
-
-/*
* parse_server_message
*
* This function analyzes a message received
@@ -321,9 +275,20 @@
return(MSG_STAT2);
break;
case MSG_ERROR :
- parse_server_error(t);
- return(MSG_ERROR);
+ {
+ if(!F_quiet_mode)
+ {
+ char * msg = parse_separator(t);
+#ifdef USE_GTK
+ char * t;
+ while((t = strchr(msg, ';')))t[0]='\n';
+ show_error(msg);
+#endif
+ efree(&msg);
+ return(MSG_ERROR);
+ }
break;
+ }
case MSG_PORT :
parse_host_add_port(backend, t, humanmsg);
return(MSG_PORT);
@@ -622,7 +587,7 @@
char * ret;
s_1 = parse_symbol(str);
- if(!s_1 || s_1[0] == '\0')
+ if(nulstr(s_1))
return NULL;
s_2 = parse_symbol(s_1);
Index: plugin_infos.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/plugin_infos.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- plugin_infos.c 25 Nov 2004 16:33:46 -0000 1.28
+++ plugin_infos.c 17 Mar 2007 21:36:02 -0000 1.29
@@ -35,107 +35,100 @@
#include <gtk/gtk.h>
#include "xstuff.h"
-#include "context.h"
-
-#include "nessus_i18n.h"
#include "globals.h"
+
static void
show_deps(foo, name)
- GtkWidget * foo;
- char * name;
+ GtkWidget * foo;
+ char * name;
{
- GtkWindow * window = GTK_WINDOW(arg_get_value(MainDialog, "WINDOW"));
- GtkWidget * dialog;
- GtkWidget * vbox;
- GtkWidget * w;
- struct arglist * deps;
- char * lbl = emalloc(strlen(name) + 255);
- int label_size = 1024;
- char * label;
- sprintf(lbl, _("Dependencies of Plugin '%s'"), name);
-
- dialog = gtk_dialog_new_with_buttons(lbl, window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- NULL);
- gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
- gtk_widget_realize(dialog);
-
- /* The overall vbox */
- vbox = GTK_DIALOG(dialog)->vbox;
-
- /* The titel as label again */
- w = gtk_label_new(lbl);
- efree(&lbl);
- gtk_box_pack_start(GTK_BOX(vbox), w, TRUE, TRUE, 5);
- gtk_misc_set_alignment((GtkMisc *)w, 0, 1);
- gtk_widget_show(w);
-
- /* A horizontal separator */
- w = gtk_hseparator_new();
- gtk_box_pack_start(GTK_BOX(vbox), w, TRUE, TRUE, 5);
- gtk_widget_show(w);
-
- deps = arg_get_value(Context->dependencies, name);
+ GtkWidget * window;
+ GtkWidget * w;
+ GtkWidget * box;
+ struct arglist * deps;
+ char * lbl = emalloc(strlen(name) + 255);
+ int label_size = 1024;
+ char * label;
+ sprintf(lbl, "Dependencies of '%s'", name);
- label = emalloc(label_size);
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(window), lbl);
- /* In case we find no dependencies, create a hint on this */
- if (!deps || !deps->next)
- {
- strncpy(label, _("No dependencies found."), label_size);
- w = gtk_label_new(label);
- gtk_box_pack_start(GTK_BOX(vbox), w, TRUE, TRUE, 2);
- gtk_misc_set_alignment((GtkMisc *)w, 0, 1);
- gtk_widget_show(w);
- }
+
+ gtk_container_border_width(GTK_CONTAINER(window), 10);
+ gtk_signal_connect(GTK_OBJECT(window), "destroy",
+ GTK_SIGNAL_FUNC(close_window), window);
+
+ box = gtk_vbox_new(FALSE, 5);
+ gtk_container_add(GTK_CONTAINER(window), box);
+ gtk_widget_show(box);
+
+ w = gtk_label_new(lbl);
+ efree(&lbl);
+ gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 5);
+ gtk_widget_show(w);
+
+ w = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 5);
+ gtk_widget_show(w);
- while(deps && deps->next)
+
+ deps = arg_get_value(Dependencies, name);
+ if(!deps)
{
- struct arglist * p = arg_get_value(Context->plugins, deps->name);
-
- if(p == NULL)
- p = arg_get_value(Context->scanners, deps->name);
- if(p)
- {
- char * family = arg_get_value(p, "FAMILY");
- if(strlen(deps->name) + strlen(family) + 255 > label_size)
- {
- label_size *= 2;
- label = erealloc(label, label_size);
- }
- strncpy(label, deps->name, label_size);
- strncat(label, " (", label_size);
- strncat(label, family, label_size);
- strncat(label, _("), currently "), label_size);
- if (arg_get_value(p, "ENABLED"))
- strncat(label, _("enabled"), label_size);
- else
- strncat(label, _("disabled"), label_size);
- }
- else
- strncpy(label, deps->name, label_size);
- w = gtk_label_new(label);
- gtk_box_pack_start(GTK_BOX(vbox), w, TRUE, TRUE, 2);
- gtk_misc_set_alignment((GtkMisc *)w, 0, 1);
- gtk_widget_show(w);
- deps = deps->next;
+ return; /* XXX */
+ }
+ label = emalloc(label_size);
+
+ while(deps->next)
+ {
+ struct arglist * p = arg_get_value(Plugins, deps->name);
+
+ if(p == NULL)
+ p = arg_get_value(Scanners, deps->name);
+ if(p)
+ {
+ char * family = arg_get_value(p, "FAMILY");
+ if(strlen(deps->name) + strlen(family) + 255 > label_size)
+ {
+ label_size *= 2;
+ label = erealloc(label, label_size);
}
+ strncpy(label, deps->name, label_size);
+ strncat(label, " (", label_size);
+ strncat(label, family, label_size);
+ strncat(label, "), currently ", label_size);
+ if(arg_get_value(p, "ENABLED"))
+ strncat(label, "enabled", label_size);
+ else
+ strncat(label, "disabled", label_size);
+ }
+ else strncpy(label, deps->name, label_size);
+ w = gtk_label_new(label);
+ gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 2);
+ gtk_widget_show(w);
+ deps = deps->next;
+ }
+
+ efree(&label);
+ w = gtk_button_new_with_label("Close");
+ gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 3);
+ gtk_signal_connect(GTK_OBJECT(w), "clicked",GTK_SIGNAL_FUNC(close_window), window);
+ gtk_widget_show(w);
- efree(&label);
- /* execute and later remove the dialog */
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
+ gtk_widget_show(window);
}
static void
-do_set_timeout(ctrls)
+do_set_timeout(b, ctrls)
+ GtkWidget* b;
struct arglist * ctrls;
{
- struct arglist * serv_prefs = arg_get_value(Context->prefs, "SERVER_PREFS");
+ struct arglist * serv_prefs = arg_get_value(Prefs, "SERVER_PREFS");
GtkWidget * w = arg_get_value(ctrls, "ENTRY");
+ GtkWidget * window = arg_get_value(ctrls, "WINDOW");
char * to;
int id;
char * pref;
@@ -156,64 +149,75 @@
}
else
arg_add_value(serv_prefs, pref, ARG_STRING, sizeof(int), estrdup(to));
+
+ close_window(NULL, window);
}
-void
+static struct arglist *
set_timeout_build_window(id, cur_to, def_to)
- int id;
- char* cur_to;
- int def_to;
+ int id;
+ char* cur_to;
+ int def_to;
{
- GtkWindow * window = GTK_WINDOW(arg_get_value(MainDialog, "WINDOW"));
- GtkWidget * dialog;
- GtkWidget * vbox;
- GtkWidget * hbox;
- GtkWidget * w;
- struct arglist * ctrls = emalloc(sizeof(*ctrls));
-
- dialog = gtk_dialog_new_with_buttons(_("Set plugin timeout..."), window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
- gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
- gtk_widget_realize(dialog);
-
- /* The overall vbox */
- vbox = GTK_DIALOG(dialog)->vbox;
-
- /* A hbox that contains the label and entry field */
- hbox = gtk_hbox_new(FALSE, 5);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 10);
- gtk_widget_show(hbox);
+ GtkWidget * window;
+ GtkWidget * w;
+ GtkWidget * box, * hbox;
+ struct arglist * ctrls = emalloc(sizeof(*ctrls));
+
- /* The label for the entry field */
- w = gtk_label_new(_("Set plugin timeout:"));
- gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 10);
- gtk_misc_set_alignment((GtkMisc *)w, 0, 1);
- gtk_widget_show(w);
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(window), "Set plugin timeout...");
+ gtk_container_border_width(GTK_CONTAINER(window), 10);
+ gtk_signal_connect(GTK_OBJECT(window), "destroy",
+ GTK_SIGNAL_FUNC(close_window), window);
+
+ box = gtk_vbox_new(FALSE, 5);
+ gtk_container_add(GTK_CONTAINER(window), box);
+ gtk_widget_show(box);
+
+ w = gtk_label_new("Set plugin timeout : ");
+ gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 10);
+ gtk_widget_show(w);
+
+ w = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 10);
+ gtk_widget_show(w);
- /* Then entry field for the timeout */
- w = gtk_entry_new();
- gtk_box_pack_start(GTK_BOX(hbox),w, TRUE, TRUE, 10);
- gtk_widget_show(w);
- if(!def_to)
- gtk_entry_set_text(GTK_ENTRY(w), cur_to);
+
+
+ w = gtk_entry_new();
+ gtk_box_pack_start(GTK_BOX(box),w, TRUE, TRUE, 10);
+ gtk_widget_show(w);
+ if(!def_to){
+ gtk_entry_set_text(GTK_ENTRY(w), cur_to);
+ }
+
+ arg_add_value(ctrls, "WINDOW", ARG_PTR, -1, window);
+ arg_add_value(ctrls, "ENTRY", ARG_PTR, -1, w);
+ arg_add_value(ctrls, "ID", ARG_INT, sizeof(int), (void*)id);
+
+
+ hbox = gtk_hbox_new(FALSE, 5);
+ gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 10);
+ gtk_widget_show(hbox);
+
+ w = gtk_button_new_with_label("Cancel");
+ gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 3);
+ gtk_signal_connect(GTK_OBJECT(w), "clicked",GTK_SIGNAL_FUNC(close_window), window);
+ gtk_widget_show(w);
- arg_add_value(ctrls, "WINDOW", ARG_PTR, -1, window);
- arg_add_value(ctrls, "ENTRY", ARG_PTR, -1, w);
- arg_add_value(ctrls, "ID", ARG_INT, sizeof(int), (void*)id);
- /* execute and later remove the dialog */
- switch (gtk_dialog_run(GTK_DIALOG(dialog)))
- {
- case GTK_RESPONSE_OK:
- do_set_timeout(ctrls);
- break;
- }
- gtk_widget_destroy(dialog);
+ w = gtk_button_new_with_label("Set new timeout");
+ gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 3);
+ gtk_signal_connect(GTK_OBJECT(w), "clicked",GTK_SIGNAL_FUNC(do_set_timeout), ctrls);
+ gtk_widget_show(w);
+
+
+
+ gtk_widget_show(window);
+ return ctrls;
}
@@ -224,14 +228,14 @@
GtkWidget * w;
int id;
{
- struct arglist * serv_prefs = arg_get_value(Context->prefs, "SERVER_PREFS");
+ struct arglist * serv_prefs = arg_get_value(Prefs, "SERVER_PREFS");
char * name = emalloc(40);
int to_set = 1;
char* timeout = NULL;
sprintf(name, "timeout.%d", id);
if(arg_get_type(serv_prefs, name) == ARG_STRING)
- timeout = arg_get_value(serv_prefs, name);
+ timeout = arg_get_value(Prefs, name);
else
to_set = 0;
@@ -259,168 +263,187 @@
struct arglist* res;
char * pluginname;
{
- GtkWindow * window = GTK_WINDOW(arg_get_value(MainDialog, "WINDOW"));
- GtkWidget * dialog;
- GtkWidget * vbox;
- GtkWidget * hbox;
- GtkWidget * label;
- GtkWidget * scrolledwindow;
- GtkWidget * textview;
- GtkWidget * button;
- GtkWidget * separator;
-
- char buf[4096];
- struct arglist * plugin;
- char * txt;
+ GtkWidget * window;
+ GtkWidget * box;
+ GtkWidget * hbox;
+ GtkWidget * subbox;
+ GtkWidget * label;
+ GtkWidget * text;
+ GtkWidget * button;
+ GtkWidget * separator;
+ GtkAdjustment * vadj;
+ GtkWidget * vsb;
+ GtkWidget * table;
+
+
- plugin = arg_get_value(res, pluginname);
- if(!plugin)
- {
+ char * category;
+ char buf[4096];
+ struct arglist * plugin;
+ char * txt;
+
+
+ plugin = arg_get_value(res, pluginname);
+ if(!plugin)
+ {
#ifdef DEBUG
- fprintf(stderr, _("Error ! Plugin selected not found ?!\n"));
+ fprintf(stderr, "Error ! Plugin selected not found ?!\n");
#endif
- return;
- }
-
- dialog = gtk_dialog_new_with_buttons(pluginname, window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- NULL);
- gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
- gtk_window_set_default_size(GTK_WINDOW(dialog), 350, 450);
- gtk_widget_realize(dialog);
-
- /* The overall vbox */
- vbox = GTK_DIALOG(dialog)->vbox;
-
- /* The plugin name */
- label = gtk_label_new(pluginname);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* The copyright notice */
- label = gtk_label_new(arg_get_value(plugin, "COPYRIGHT"));
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE,FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* A separator */
- separator = gtk_hseparator_new();
- gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE,0);
- gtk_widget_show(separator);
-
- /* The Family */
- sprintf(buf, _("Family: %s"), (char*)arg_get_value(plugin, "FAMILY"));
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* The Category */
- sprintf(buf, _("Category: %s"), (char*)arg_get_value(plugin, "CATEGORY"));
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* The Plugin ID */
- sprintf(buf, _("Nessus Plugin ID: %d"), (int)arg_get_value(plugin, "ID"));
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* The CVE ID (in case the plugin provides one) */
- txt = arg_get_value(plugin, "CVE_ID");
- if( txt != NULL && txt[0] != '\0' )
- {
- snprintf(buf, sizeof(buf), _("CVE: %s"), txt);
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
- }
-
- /* The Bugtraq ID (in case the plugin provides one) */
- txt = arg_get_value(plugin, "BUGTRAQ_ID");
- if( txt != NULL && txt[0] != '\0' )
- {
- snprintf(buf, sizeof(buf), _("Bugtraq ID: %s"), txt);
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
- }
-
- /* The other cross references (in case the plugin provides one) */
- txt = arg_get_value(plugin, "XREFS");
- if( txt != NULL && txt[0] != '\0' )
- {
- snprintf(buf, sizeof(buf), _("Other references: %s"), txt);
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
- }
-
- /* The Version */
- label = gtk_label_new(arg_get_value(plugin, "VERSION"));
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE,FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* A separator */
- separator = gtk_hseparator_new();
- gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE,0);
- gtk_widget_show(separator);
-
- /* The titel for the scrolled text */
- label = gtk_label_new(_("What is shown if the attack is successful:"));
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* The scrolled window */
- scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
- gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 5);
- gtk_widget_show(scrolledwindow);
-
- /* The textview with the plugin description */
- textview = gtk_text_view_new();
- gtk_container_add(GTK_CONTAINER(scrolledwindow), textview);
- gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_WORD);
- if (arg_get_value(plugin, "DESCRIPTION"))
- gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)),
- arg_get_value(plugin, "DESCRIPTION"), -1);
- gtk_widget_show (textview);
-
- /* A hbox for the buttons */
- hbox = gtk_hbox_new(FALSE,10);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE,FALSE,10);
- gtk_widget_show(hbox);
-
- /* The button for setting the plugin timeout */
- button = gtk_button_new_with_label(_("Set plugin timeout..."));
- gtk_signal_connect(GTK_OBJECT(button), "clicked",GTK_SIGNAL_FUNC(set_timeout),
- arg_get_value(plugin, "ID"));
- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
- gtk_widget_show(button);
-
- /* The button for displaying the dependencies */
- button = gtk_button_new_with_label(_("Show dependencies"));
- gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(show_deps),
- arg_get_value(plugin, "NAME"));
- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
- gtk_widget_show(button);
- if(!arg_get_value(Context->dependencies, pluginname))
- gtk_widget_set_sensitive(button,FALSE);
+ return;
+ }
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+#if GTK_VERSION > 10
+ gtk_window_set_default_size(GTK_WINDOW(window), 400,500);
+#else
+ gtk_widget_set_usize(GTK_WIDGET(window), 400, 500);
+#endif
+ gtk_container_border_width(GTK_CONTAINER(window),10);
+ gtk_window_set_title(GTK_WINDOW(window), pluginname);
+
+ box = gtk_vbox_new(FALSE,3);
+ gtk_container_add(GTK_CONTAINER(window), box);
+
+
+ hbox = gtk_hbox_new(FALSE,10);
+ gtk_box_pack_start(GTK_BOX(box), hbox, FALSE,FALSE,0);
+ gtk_widget_show(hbox);
+
+
+
+ separator = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(box), separator, FALSE, FALSE,0);
+ gtk_widget_show(separator);
+
+
+ sprintf(buf, "Family : %s", (char*)arg_get_value(plugin, "FAMILY"));
+ label = gtk_label_new(buf);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+
+ sprintf(buf, "Category : %s", (char*)arg_get_value(plugin, "CATEGORY"));
+ label = gtk_label_new(buf);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+
+ sprintf(buf, "Nessus Plugin ID : %d", (int)arg_get_value(plugin, "ID"));
+ label = gtk_label_new(buf);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+
+ txt = arg_get_value(plugin, "CVE_ID");
+ if( txt != NULL && txt[0] != '\0' )
+ {
+ snprintf(buf, sizeof(buf), "CVE : %s", txt);
+ label = gtk_label_new(buf);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+ }
+
+ txt = arg_get_value(plugin, "BUGTRAQ_ID");
+ if( txt != NULL && txt[0] != '\0' )
+ {
+ snprintf(buf, sizeof(buf), "Bugtraq ID : %s", txt);
+ label = gtk_label_new(buf);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+ }
+
+
+ txt = arg_get_value(plugin, "XREFS");
+ if( txt != NULL && txt[0] != '\0' )
+ {
+ snprintf(buf, sizeof(buf), "Other references : %s", txt);
+ label = gtk_label_new(buf);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+ }
+
+
+
+
+ label = gtk_label_new(arg_get_value(plugin, "VERSION"));
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE,FALSE,0);
+ gtk_widget_show(label);
+
+
+
+
+ separator = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(box), separator, FALSE, FALSE,0);
+ gtk_widget_show(separator);
+
+ label = gtk_label_new("What is shown if the attack is successful : ");
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+
+
+ vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+ vsb = gtk_vscrollbar_new (vadj);
+ table = gtk_table_new(1,2,FALSE);
+ gtk_box_pack_start(GTK_BOX(box), table, TRUE,TRUE,0);
+ gtk_widget_show(table);
+
+ text = gtk_text_new(NULL,vadj);
+ gtk_table_attach (GTK_TABLE (table), vsb, 1, 2, 0, 1,
+ 0, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
+ gtk_container_border_width (GTK_CONTAINER (table), 2);
+ gtk_widget_show(vsb);
+
+ gtk_widget_realize (text);
+ gtk_text_set_editable(GTK_TEXT(text), FALSE);
+ gtk_text_set_word_wrap(GTK_TEXT(text), TRUE);
+ if(arg_get_value(plugin, "DESCRIPTION"))
+ gtk_text_insert(GTK_TEXT(text), NULL,NULL,NULL, arg_get_value(plugin, "DESCRIPTION"),
+ -1);
+ gtk_widget_show(text);
+
+ separator = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(box), separator, FALSE, FALSE,0);
+ gtk_widget_show(separator);
+
+ button = gtk_button_new_with_label("Set plugin timeout...");
+ gtk_signal_connect(GTK_OBJECT(button), "clicked",GTK_SIGNAL_FUNC(set_timeout), arg_get_value(plugin, "ID"));
+ gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 5);
+ gtk_widget_show(button);
+
+ button = gtk_button_new_with_label("Show dependencies");
+ gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(show_deps), arg_get_value(plugin, "NAME"));
+ gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 5);
+ gtk_widget_show(button);
+ if(!arg_get_value(Dependencies, pluginname))
+ {
+ gtk_widget_set_sensitive(button,FALSE);
+ }
+
+ button = gtk_button_new_with_label("Close");
+ gtk_signal_connect(GTK_OBJECT(button), "clicked",GTK_SIGNAL_FUNC(close_window), window);
+ gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE,5);
+ gtk_widget_show(button);
+
+ gtk_widget_realize(window);
+ category = arg_get_value(plugin, "CATEGORY");
- /* execute and later remove the dialog */
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
+
+
+ subbox = gtk_vbox_new(FALSE,3);
+ gtk_box_pack_start(GTK_BOX(hbox), subbox, FALSE,FALSE,0);
+ gtk_widget_show(subbox);
+
+ label = gtk_label_new(pluginname);
+ gtk_box_pack_start(GTK_BOX(subbox), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+
+ label = gtk_label_new(arg_get_value(plugin, "COPYRIGHT"));
+ gtk_box_pack_start(GTK_BOX(subbox), label, FALSE,FALSE,0);
+ gtk_widget_show(label);
+
+
+ gtk_widget_show(box);
+ gtk_widget_show(window);
+
}
#endif
Index: preferences.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/preferences.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- preferences.c 23 Apr 2005 16:37:36 -0000 1.79
+++ preferences.c 17 Mar 2007 21:36:02 -0000 1.80
@@ -1,6 +1,5 @@
/* Nessus
* Copyright (C) 1998 - 2001 Renaud Deraison
- * Copyright (C) 2004 Intevation GmbH
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
@@ -26,67 +25,59 @@
* file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
- * Preferences -- maps the content of the nessusrc file to memory
[...1255 lines suppressed...]
+void prefs_check_defaults(prefs)
+ struct arglist * prefs;
+{
+}
- pwd = getpwuid(getuid());
- if(pwd && pwd->pw_dir)
- return pwd->pw_dir;
- return "";
+int
+preferences_generate_new_file()
+{
+ preferences_new();
+ preferences_init(&Prefs);
+ pluginset_reload(Plugins, Scanners);
+ preferences_save(Prefs);
+ return 0;
}
+
Index: preferences.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/preferences.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- preferences.h 29 Nov 2004 17:35:47 -0000 1.19
+++ preferences.h 17 Mar 2007 21:36:02 -0000 1.20
@@ -1,6 +1,5 @@
/* Nessus
* Copyright (C) 1998 Renaud Deraison
- * Copyright (C) 2004 Intevation GmbH
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,24 +30,17 @@
#ifndef _NESSUSC_PREFERENCES_H
#define _NESSUSC_PREFERENCES_H
-#include "context.h"
-
-int preferences_init(struct context *);
-void preferences_save(struct context *);
-void preferences_save_as(struct context *, char *);
-struct arglist *prefs_get_pluginset(struct context *, char *, struct arglist *);
-int preferences_process_filename(struct context *, char *);
-int preferences_generate_new_file(struct context *, const char *);
-char * plugin_asc_id(struct arglist *);
-char * preferences_get_altname(struct context *, const char *);
-void * prefs_get_default(struct context *, const char *);
-void * prefs_get_value(struct context *, const char *);
-#define prefs_get_int(context, name) ((int)prefs_get_value(context, name))
-#define prefs_get_string(context, name) ((const char *)prefs_get_value(context, name))
-void prefs_set_value(struct context *, const char *, void *, int);
-void prefs_set_int(struct context *, const char *, int);
-void prefs_set_string(struct context *, const char *, const char *);
-int prefs_has_options(struct context *);
+int preferences_init(struct arglist **);
+void preferences_save(struct arglist *);
+void preferences_save_fname(char*, struct arglist*);
+int pluginset_apply(struct arglist *, char *);
+void pluginset_reload(struct arglist *, struct arglist *);
+void prefs_check_defaults(struct arglist *);
+int preferences_process(char *, struct arglist *);
+int preferences_generate_new_file();
+char * plugin_asc_id(struct arglist*);
+char * preferences_get_filename();
+char * preferences_get_altname(const char*);
#ifdef _WIN32
/* applies to some windows misunderstanding */
Index: read_target_file.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/read_target_file.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- read_target_file.c 9 Dec 2004 18:50:21 -0000 1.16
+++ read_target_file.c 17 Mar 2007 21:36:02 -0000 1.17
@@ -1,8 +1,6 @@
#include <includes.h>
#include <errno.h>
-#include "nessus_i18n.h"
-
#ifdef USE_GTK
#include <gtk/gtk.h>
#include "read_target_file.h"
@@ -39,7 +37,7 @@
void target_file_select()
{
GtkWidget * file;
- file = gtk_file_selection_new (_("Load file"));
+ file = gtk_file_selection_new ("Load file");
gtk_file_selection_set_filename (GTK_FILE_SELECTION(file), "");
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file)->ok_button),
"clicked", (GtkSignalFunc) read_target_file,(void *) file );
@@ -66,9 +64,8 @@
#endif
-char *
-target_file_to_list(filename)
- const char * filename;
+char * target_file_to_list(filename)
+ char * filename;
{
HANDLE fd = open(filename, O_RDONLY);
char * ret,*t;
@@ -77,14 +74,25 @@
int n, i, offs, left ;
if(fd < 0)
- {
- show_error(_("Could not open %s\nopen(%s): %s"),
- filename, filename, strerror(errno));
- return(NULL);
- }
-
+ {
+ char * text = emalloc(strlen(filename)+300);
+ sprintf(text,"Could not open %s\nopen(%s) : %s\n", filename, filename, strerror(errno));
+ if(F_quiet_mode)fprintf(stderr, "%s", text);
+#ifdef USE_GTK
+ else show_error(text);
+#endif
+ efree(&text);
+ return(NULL);
+ }
+
if (lstat (filename, &sb) != 0) {
- show_error(_("Cannot stat %s (%s)\n"), filename, strerror(errno));
+ char * text = emalloc(strlen(filename)+300);
+ sprintf(text, "Cannot stat %s (%s)\n", filename, strerror(errno));
+ if (F_quiet_mode) fprintf (stderr, "%s", text);
+# ifdef USE_GTK
+ else show_error(text);
+# endif
+ efree (&text);
return 0;
}
len = (int)sb.st_size;
@@ -94,11 +102,17 @@
do {
if ((n = read (fd, ret + offs, left)) < 0) {
+ char * text = emalloc(strlen(filename)+300);
efree(&ret);
if (n == 0)
- show_error(_("file mapping failed: unexpected end-of-file\n"));
+ sprintf(text, "file mapping failed: unexpected end-of-file\n");
else
- show_error(_("file mapping failed: %s\n"), strerror(errno));
+ sprintf(text, "file mapping failed: %s\n", strerror(errno));
+ if(F_quiet_mode)fprintf(stderr, "%s", text);
+# ifdef USE_GTK
+ else show_error(text);
+# endif
+ efree (&text);
return 0;
}
} while (offs += n, (left -= n) > 0) ;
@@ -125,9 +139,8 @@
#ifdef USE_GTK
-char *
-target_translate(target)
- const char * target;
+char * target_translate(target)
+ char * target;
{
if(!strncmp(target, "file:", 5))
return target_file_to_list(target+strlen("file:"));
@@ -149,7 +162,7 @@
GtkWidget * bidon;
GtkWidget * gtkw;
{
- const char * filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(gtkw));
+ char * filename = (char*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(gtkw));
char * ret = target_file_name(filename);
target_file_apply(ret);
efree(&ret);
Index: read_target_file.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/read_target_file.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- read_target_file.h 3 Nov 2004 14:25:30 -0000 1.6
+++ read_target_file.h 17 Mar 2007 21:36:02 -0000 1.7
@@ -4,7 +4,7 @@
#ifdef USE_GTK
void read_target_file(GtkWidget *, GtkWidget*);
#endif
-char *target_file_to_list(const char *);
-char *target_translate(const char *);
+char * target_file_to_list(char *);
+char* target_translate(char*);
#endif
Index: report.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/report.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- report.c 29 Nov 2004 16:47:46 -0000 1.70
+++ report.c 17 Mar 2007 21:36:02 -0000 1.71
@@ -1,12 +1,18 @@
-/* $Id$
- *
+/* Nessus
* Copyright (C) 1998, 1999, 2000 Renaud Deraison
- * Copyright (C) 2004 by Intevation GmbH
- * Author(s):
- * Thomas Arendsen Hein <thomas@intevation.de>
*
- * This program is free software under the GNU GPL (>=v2)
- * Read the file COPYING coming with the software for details.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* In addition, as a special exception, Renaud Deraison
* gives permission to link the code of this program with any
@@ -18,39 +24,707 @@
* this file, you may extend this exception to your version of the
* file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
+ */
+
+/* Pluto 26.6.00:
+ *
+ * changed infos_and_holes_to into findings_to
*/
#include <includes.h>
-#include "nessus_i18n.h"
-#include "context.h"
-#include "error_dialog.h"
-
+#include "globals.h"
#ifdef USE_GTK
+
+#define MAX_ITEMS_IN_LIST 500 /* only show the 500 first entries */
+#define MAX_ITEMS_IN_LIST_ASC "500"
+#define TOO_MANY_ITEMS "Only the first "MAX_ITEMS_IN_LIST_ASC" entries will be shown.\nExport the report to another format for a complete version"
+
+
+#include "gtk-compat.h"
#include <gtk/gtk.h>
-#include "prefs_dialog/prefs_scope_tree.h"
-#include "prefs_dialog/prefs_context.h"
+#include "xstuff.h"
+#include "xpm/yellow.xpm"
+#include "xpm/orange.xpm"
+#include "xpm/red.xpm"
+#include "xpm/white.xpm"
+#include "report_ng.h"
#endif
#include "report.h"
+#include "families.h"
+#include "nsr_output.h"
+#include "html_output.h"
+#include "html_graph_output.h"
+#include "report_utils.h"
+#include "error_dialog.h"
+#include "latex_output.h"
+#include "text_output.h"
+#include "xml_output.h"
+#include "globals.h"
+#include "comm.h"
#include "backend.h"
-#include "nbe_output.h"
+#include "prefs_dialog/prefs_target.h"
-/* returns filename of report (must be freed) or NULL */
-char *
-report_get_filename(context)
- struct context *context;
+#define SAVE_NSR 0
+#define SAVE_HTML 1
+#define SAVE_TEXT 2
+#define SAVE_LATEX 3
+#define SAVE_HTML_GRAPH 4
+#define SAVE_XML 5
+#define SAVE_MAX SAVE_XML
+
+#ifdef USE_GTK
+
+static void save_report_ask(GtkWidget *, GtkWidget *);
+static void save_report(GtkWidget *, GtkWidget *);
+GtkWidget * report_to_tree(struct arglist *, GtkWidget *);
+static void do_create_report_window(struct arglist *, int, int);
+#endif
+
+
+
+#ifdef USE_GTK
+
+static void
+report_click(GtkWidget * list, GtkWidget * data)
{
- char *report = NULL;
+ GtkWidget * window = gtk_object_get_data(GTK_OBJECT(list), "window");
+ GtkWidget * box = gtk_object_get_data(GTK_OBJECT(list), "box");
+ GList * dlist = GTK_LIST(list)->selection;
+ GtkObject * item;
+ struct arglist * report;
+ GtkWidget * tree = NULL;
+ GtkWidget * old_tree = NULL;
+ int new_tree = 0;
+ if(!dlist)
+ return;
+
+ item = GTK_OBJECT(dlist->data);
+ report = gtk_object_get_data(item, "results");
+
+ if(report){
+ tree = gtk_object_get_data(item, "tree");
+ if(!tree)
+ {
+ tree = report_to_tree(report->value, window);
+ gtk_object_set_data(item, "tree", tree);
+ new_tree++;
+ }
+ }
+
+
+ if(tree)
+ {
+ old_tree = gtk_object_get_data(GTK_OBJECT(box), "tree");
+ if(old_tree){
+ GtkAdjustment * adj;
+ gtk_widget_hide(old_tree);
+ adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(window));
+ gtk_adjustment_set_value(adj, 0);
+ }
+ if(new_tree)
+ {
+ gtk_box_pack_start(GTK_BOX(box), tree, TRUE, TRUE, 0);
+ }
+ gtk_widget_show(tree);
+#if GTK_VERSION > 10
+ gtk_widget_map(tree);
+#endif
+
+ gtk_widget_realize(tree);
+ gtk_object_set_data(GTK_OBJECT(box), "tree", tree);
+ }
+}
- if(context->type == CONTEXT_REPORT && context->dir)
+
+
+
+static
+GtkWidget * summary_host_label(name, window, severity)
+ char * name;
+ GtkWidget * window;
+ int severity;
+{
+ GtkWidget * label;
+ GtkWidget * hbox;
+ char ** pixdata = NULL;
+ GtkStyle * style;
+ GtkWidget * pixmapwid;
+ switch(severity)
+ {
+ case HOLE_PRESENT :
+ pixdata = red_dot_xpm;
+ break;
+ case WARNING_PRESENT :
+ pixdata = orange_dot_xpm;
+ break;
+ case NOTE_PRESENT :
+ pixdata = yellow_dot_xpm;
+ break;
+ default :
+ pixdata = white_dot_xpm;
+ break;
+ }
+ style = gtk_widget_get_style(window);
+ pixmapwid = make_pixmap(window, &style->bg[GTK_STATE_NORMAL], pixdata);
+ hbox = gtk_hbox_new(FALSE,FALSE);
+
+ label = gtk_label_new(name);
+ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwid, FALSE, FALSE, 0);
+ gtk_widget_show(pixmapwid);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+ gtk_widget_show(label);
+ return hbox;
+}
+static void
+fill_summary_box(box, scrolled, results, sorted)
+ GtkWidget * box, * scrolled;
+ struct arglist * results;
+ int sorted;
+{
+ GtkWidget * label = gtk_label_new("Summary");
+ GtkWidget * sep = gtk_hseparator_new();
+ char * data = emalloc(4096);
+ GtkWidget * window;
+ GtkWidget * list;
+ GtkWidget * hbox;
+
+ int count;
+
+ GList * dlist = NULL;
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+
+ gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 0);
+ gtk_widget_show(sep);
+
+ if (sorted) sprintf(data, "Number of ports found : %d", arglist_length(results));
+ else sprintf(data, "Number of hosts tested : %d", arglist_length(results));
+ label = gtk_label_new(data);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+ sprintf(data, "Found %d security holes", number_of_holes(results));
+
+ label = gtk_label_new(data);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+
+ sprintf(data, "Found %d security warnings", number_of_warnings(results));
+ label = gtk_label_new(data);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+
+ sprintf(data, "Found %d security notes", number_of_notes(results));
+ label = gtk_label_new(data);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+
+ sep = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 0);
+ gtk_widget_show(sep);
+
+ window = gtk_scrolled_window_new(NULL,NULL);
+
+ gtk_box_pack_start(GTK_BOX(box), window, TRUE, TRUE, 0);
+
+
+ list = gtk_list_new();
+#if GTK_VERSION < 11
+ gtk_container_add(GTK_CONTAINER(window),list);
+#else
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(window), list);
+#endif
+ gtk_widget_show(list);
+ gtk_object_set_data(GTK_OBJECT(list), "window", scrolled);
+ hbox = gtk_hbox_new(FALSE, FALSE);
+#if GTK_VERSION < 11
+ gtk_container_add(GTK_CONTAINER(scrolled),hbox);
+#else
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), hbox);
+#endif
+ gtk_object_set_data(GTK_OBJECT(list), "box", hbox);
+ gtk_widget_show(hbox);
+ gtk_widget_realize(scrolled);
+ gtk_signal_connect(GTK_OBJECT(list),
+ "selection_changed",
+ GTK_SIGNAL_FUNC(report_click),
+ NULL);
+
+ if (arglist_length(results) > MAX_ITEMS_IN_LIST)
+ show_warning(TOO_MANY_ITEMS);
+ count = MAX_ITEMS_IN_LIST ;
+ while(results && results->next && --count)
+ {
+ GtkWidget * item;
+ int severity;
+
+
+ item = gtk_list_item_new();
+ gtk_object_set_data(GTK_OBJECT(item), "results", results->value);
+
+ if (number_of_holes_by_host(results->value)) severity = HOLE_PRESENT;
+ else if (number_of_warnings_by_host(results->value)) severity = WARNING_PRESENT;
+ else if (number_of_notes_by_host(results->value)) severity = NOTE_PRESENT;
+ else severity = 0;
+
+ label = summary_host_label(results->name, scrolled, severity);
+ gtk_container_add(GTK_CONTAINER(item), label);
+ gtk_widget_show(label);
+ dlist = g_list_append(dlist, item);
+ gtk_widget_show(item);
+ results = results->next;
+ }
+ gtk_list_append_items(GTK_LIST(list), dlist);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ gtk_widget_show(window);
+ gtk_widget_realize(window);
+ free(data);
+}
+
+static void create_report_window(args, interrupted_test)
+ struct arglist * args;
+ int interrupted_test;
+{
+
+ do_create_report_window(args, interrupted_test, 0);
+}
+static void create_report_window_by_port(nul, reportw)
+ GtkWidget * nul;
+ GtkWidget * reportw;
+{
+ struct arglist * hosts = gtk_object_get_data(GTK_OBJECT(reportw), "hosts");
+ hosts = sort_by_port(hosts);
+ hosts = sort_dangerous_hosts(hosts);
+ do_create_report_window(hosts, 0, 1);
+
+}
+
+/*
+ * Creation of the reporting window
+ */
+static void do_create_report_window(args, interrupted_test, sorted_by_port)
+ struct arglist * args;
+ int interrupted_test;
+ int sorted_by_port;
+{
+
+ GtkWidget * window;
+ GtkWidget * widget;
+ GtkWidget * vbox;
+ GtkWidget * hbox;
+ GtkWidget * paned;
+
+ GtkWidget * button;
+ GtkWidget * by_port;
+ GtkWidget * optionmenu;
+ GtkWidget * type;
+ GtkWidget * menu;
+ GtkWidget * summary_box;
+ struct arglist * report = args;
+ struct arglist * hosts;
+
+ if(!args || !args->next){
+ if(!interrupted_test)
+ {
+#ifdef ENABLE_SAVE_KB
+ if(DetachedMode)
+ {
+ struct arglist * arg;
+ show_info("nessusd is now scanning the remote network \n\
+in detached mode");
+ /*
+ * Restore the login button
+ */
+ arg = arg_get_value(MainDialog, "AUTH");
+ gtk_widget_hide(arg_get_value(arg, "CONNECTED"));
+ gtk_widget_hide(arg_get_value(arg, "BUTTON_LOG_OUT"));
+ gtk_widget_show(arg_get_value(arg, "BUTTON_LOG_IN"));
+ GlobalSocket = -1;
+ }
+ else
+#endif
+ show_info("No problem has been found, or none of the \
+hosts tested was alive");
+ }
+ else
+ {
+ show_warning("nessusd abruptly shut the communication down.\n\
+No problem has been found at this stage of the test");
+ }
+ return;
+ }
+ else if(interrupted_test)
{
- report = emalloc(strlen(context->dir) + strlen("/report.nbe") + 1);
- sprintf(report, "%s/report.nbe", context->dir);
+ show_warning("nessusd closed the communication before the end of the test !");
}
- return report;
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+#if GTK_VERSION > 10
+ gtk_window_set_default_size(GTK_WINDOW(window), 640,480);
+#else
+ gtk_widget_set_usize(GTK_WIDGET(window), 640, 480);
+#endif
+ gtk_widget_realize(window);
+ gtk_signal_connect(GTK_OBJECT(window), "destroy",
+ GTK_SIGNAL_FUNC(close_window), window);
+ gtk_signal_connect(GTK_OBJECT(window), "delete_event",
+ GTK_SIGNAL_FUNC(delete_event), window);
+
+ if (sorted_by_port) gtk_window_set_title(GTK_WINDOW(window), "Nessus Report by port");
+ else gtk_window_set_title(GTK_WINDOW(window), "Nessus Report");
+
+ gtk_container_border_width(GTK_CONTAINER(window), 10);
+
+ paned = gtk_hpaned_new();
+#if GTK_VERSION <= 11
+ gtk_paned_gutter_size(GTK_PANED(paned), 15);
+#else
+ gtk_paned_set_gutter_size(GTK_PANED(paned), 15);
+#endif
+ gtk_container_add(GTK_CONTAINER(window), paned);
+ gtk_widget_show(paned);
+
+ vbox = gtk_vbox_new(FALSE, 0);
+
+ summary_box = gtk_vbox_new(FALSE, 5);
+
+ gtk_paned_add1(GTK_PANED(paned), summary_box);
+ gtk_paned_add2(GTK_PANED(paned), vbox);
+
+
+
+
+ widget = gtk_scrolled_window_new(NULL,NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 5);
+ gtk_widget_show(widget);
+
+ fill_summary_box(summary_box, widget, args, sorted_by_port);
+ gtk_widget_show(summary_box);
+
+
+ hosts = emalloc(sizeof(struct arglist));
+
+ gtk_widget_realize(widget);
+
+ hbox = gtk_hbox_new(TRUE,10);
+
+ if (!sorted_by_port) {
+ by_port = gtk_button_new_with_label("Sort by port");
+ gtk_signal_connect(GTK_OBJECT(by_port),"clicked",
+ GTK_SIGNAL_FUNC(create_report_window_by_port),by_port);
+
+ gtk_box_pack_start(GTK_BOX(hbox), by_port, TRUE, TRUE, 0);
+ gtk_widget_show(by_port);
+
+ gtk_object_set_data(GTK_OBJECT(by_port), "hosts", report);
+
+ button = gtk_button_new_with_label("Save as...");
+
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
+
+ optionmenu = gtk_option_menu_new();
+ menu = gtk_menu_new();
+ gtk_option_menu_set_menu(GTK_OPTION_MENU(optionmenu), menu);
+ gtk_widget_show(menu);
+
+ gtk_object_set_data(GTK_OBJECT(menu), "hosts", report);
+
+ type = gtk_menu_item_new_with_label("Save as NSR");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_NSR);
+ gtk_menu_append(GTK_MENU(menu), type);
+ gtk_widget_show(type);
+
+ type = gtk_menu_item_new_with_label("Save as HTML");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_HTML);
+ gtk_menu_append(GTK_MENU(menu), type);
+ gtk_widget_show(type);
+
+ type = gtk_menu_item_new_with_label("Save as LaTeX");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_LATEX);
+ gtk_menu_append(GTK_MENU(menu), type);
+ gtk_widget_show(type);
+
+ type = gtk_menu_item_new_with_label("Save as ASCII text");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_TEXT);
+ gtk_menu_append(GTK_MENU(menu), type);
+ gtk_widget_show(type);
+
+#ifndef _NO_PIES
+ type = gtk_menu_item_new_with_label("Save as HTML with Pies and Graphs");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_HTML_GRAPH);
+ gtk_menu_append(GTK_MENU(menu), type);
+ gtk_widget_show(type);
+#endif
+
+ type = gtk_menu_item_new_with_label ("Save as XML (experimental)");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_XML);
+ gtk_menu_append(GTK_MENU(menu), type);
+ gtk_widget_show(type);
+
+ gtk_signal_connect(GTK_OBJECT(button),"clicked",
+ GTK_SIGNAL_FUNC(save_report_ask),menu);
+ gtk_box_pack_start(GTK_BOX(hbox), optionmenu, TRUE, TRUE, 0);
+ gtk_widget_show(optionmenu);
+ gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu), 0);
+ }
+ button = gtk_button_new_with_label("Close");
+ gtk_signal_connect(GTK_OBJECT(button),"clicked",
+ GTK_SIGNAL_FUNC(close_window),(void *) window);
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
+
+ gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
+
+ gtk_widget_show(hbox);
+ gtk_widget_show(vbox);
+ gtk_widget_show(window);
+}
+
+
+
+static
+GtkWidget * data_to_tree_build_label(name)
+ char * name;
+{
+ GtkWidget * label;
+ GtkWidget * hbox;
+
+ hbox = gtk_hbox_new(FALSE,FALSE);
+
+ label = gtk_label_new(name);
+ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 15);
+ gtk_widget_show(label);
+ return hbox;
+}
+
+static
+GtkWidget * data_to_tree(arglist)
+ struct arglist * arglist;
+{
+ GtkWidget * tree;
+ int count = MAX_ITEMS_IN_LIST;
+
+ if(!(arglist && arglist->next))
+ return NULL;
+
+ tree = gtk_tree_new();
+
+ if(arglist_length(arglist) > count)
+ show_warning(TOO_MANY_ITEMS);
+
+ while(arglist && arglist->next && count--)
+ {
+ GtkWidget * tree_item;
+ GtkWidget * report_data = data_to_tree_build_label(arglist->value);
+
+ tree_item = gtk_tree_item_new();
+
+ gtk_container_add(GTK_CONTAINER(tree_item), report_data);
+ gtk_widget_show(report_data);
+
+ gtk_tree_append(GTK_TREE(tree), tree_item);
+ gtk_tree_item_expand(GTK_TREE_ITEM(tree_item));
+ gtk_tree_item_collapse(GTK_TREE_ITEM(tree_item));
+
+ gtk_widget_show(tree_item);
+ arglist = arglist->next;
+ }
+
+ return tree;
+}
+
+
+static
+GtkWidget * findings_to_tree_build_label(name, severity)
+ char * name;
+ int severity;
+{
+ GtkWidget * label;
+ GtkWidget * hbox;
+
+ hbox = gtk_hbox_new(FALSE,FALSE);
+
+ label = gtk_label_new(name);
+ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 15);
+ gtk_widget_show(label);
+ return hbox;
+}
+
+
+
+static
+GtkWidget * findings_to_tree(arglist, window)
+ struct arglist * arglist;
+ GtkWidget * window;
+{
+ int level = is_there_any_hole(arglist);
+ GtkWidget * tree;
+ GtkWidget * tree_item;
+ GtkWidget * label;
+ if(!level)
+ return NULL;
+ tree = gtk_tree_new();
+ if(arg_get_value(arglist, "NOTE"))
+ {
+ GtkWidget * subtree;
+
+ tree_item = gtk_tree_item_new();
+ label = findings_to_tree_build_label("Security note", 1);
+ gtk_container_add(GTK_CONTAINER(tree_item), label);
+ gtk_widget_show(label);
+ gtk_tree_append(GTK_TREE(tree), tree_item);
+ subtree = data_to_tree(arg_get_value(arglist, "NOTE"));
+ if(subtree)
+ {
+ gtk_tree_item_set_subtree(GTK_TREE_ITEM(tree_item), subtree);
+ gtk_widget_show(subtree);
+ }
+ gtk_tree_item_expand(GTK_TREE_ITEM(tree_item));
+ gtk_tree_item_collapse(GTK_TREE_ITEM(tree_item));
+
+ gtk_widget_show(tree_item);
+ }
+
+ if(arg_get_value(arglist, "INFO"))
+ {
+ GtkWidget * subtree;
+ tree_item = gtk_tree_item_new();
+ label = findings_to_tree_build_label("Security warnings", 1);
+ gtk_container_add(GTK_CONTAINER(tree_item), label);
+ gtk_widget_show(label);
+ gtk_tree_append(GTK_TREE(tree), tree_item);
+ subtree = data_to_tree(arg_get_value(arglist, "INFO"));
+ if(subtree)
+ {
+ gtk_tree_item_set_subtree(GTK_TREE_ITEM(tree_item), subtree);
+ gtk_widget_show(subtree);
+ }
+ gtk_tree_item_expand(GTK_TREE_ITEM(tree_item));
+ gtk_tree_item_collapse(GTK_TREE_ITEM(tree_item));
+
+ gtk_widget_show(tree_item);
+ }
+
+ if(arg_get_value(arglist, "REPORT"))
+ {
+ GtkWidget * subtree;
+ tree_item = gtk_tree_item_new();
+ label = findings_to_tree_build_label("Security holes", 2);
+ gtk_container_add(GTK_CONTAINER(tree_item), label);
+ gtk_widget_show(label);
+ gtk_tree_append(GTK_TREE(tree), tree_item);
+ subtree = data_to_tree(arg_get_value(arglist, "REPORT"));
+ if(subtree)
+ {
+ gtk_tree_item_set_subtree(GTK_TREE_ITEM(tree_item), subtree);
+ gtk_widget_show(subtree);
+ }
+ gtk_tree_item_expand(GTK_TREE_ITEM(tree_item));
+ gtk_tree_item_collapse(GTK_TREE_ITEM(tree_item));
+ gtk_widget_show(tree_item);
+ }
+
+ return tree;
}
+static
+GtkWidget * report_build_label(name, window, severity)
+ char * name;
+ GtkWidget * window;
+ int severity;
+{
+ GtkWidget * label;
+ GtkWidget * hbox;
+ char ** pixdata = NULL;
+ GdkPixmap * pixmap;
+ GtkStyle * style;
+ GdkBitmap * mask;
+ GtkWidget * pixmapwid;
+ switch(severity)
+ {
+ case HOLE_PRESENT :
+ pixdata = red_dot_xpm;
+ break;
+ case WARNING_PRESENT :
+ pixdata = orange_dot_xpm;
+ break;
+ case NOTE_PRESENT :
+ pixdata = yellow_dot_xpm;
+ break;
+ default :
+ pixdata = white_dot_xpm;
+ break;
+ }
+ style = gtk_widget_get_style(window);
+ pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask,
+ &style->bg[GTK_STATE_NORMAL],(gchar **)pixdata);
+
+ pixmapwid = gtk_pixmap_new(pixmap, mask);
+ hbox = gtk_hbox_new(FALSE,FALSE);
+
+ label = gtk_label_new(name);
+ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwid, FALSE, FALSE, 0);
+ gtk_widget_show(pixmapwid);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+ gtk_widget_show(label);
+ return hbox;
+}
+
+
+GtkWidget * report_to_tree(arglist, window)
+ struct arglist * arglist;
+ GtkWidget * window;
+{
+ GtkWidget * tree;
+ int count = MAX_ITEMS_IN_LIST;
+ tree = gtk_tree_new();
+
+
+ if(arglist_length(arglist) > count)
+ show_warning(TOO_MANY_ITEMS);
+
+ while(arglist && arglist->next && count--)
+ {
+ GtkWidget * tree_item;
+ GtkWidget * label;
+ GtkWidget * subtree;
+
+
+ tree_item = gtk_tree_item_new();
+
+ /*
+ * Make label here
+ */
+
+ label = report_build_label(arglist->name, window, is_there_any_hole(arglist->value));
+ gtk_container_add(GTK_CONTAINER(tree_item), label);
+ gtk_widget_show(label);
+ gtk_tree_append(GTK_TREE(tree), tree_item);
+
+ if((subtree = findings_to_tree(arglist->value, window)))
+ {
+ gtk_tree_item_set_subtree(GTK_TREE_ITEM(tree_item), subtree);
+ gtk_widget_show(subtree);
+ }
+ gtk_tree_item_expand(GTK_TREE_ITEM(tree_item));
+ gtk_tree_item_collapse(GTK_TREE_ITEM(tree_item));
+
+ gtk_widget_show(tree_item);
+ arglist = arglist->next;
+ }
+ return(tree);
+}
+#endif
/* reports back the highest number */
int is_there_any_hole(arglist)
@@ -83,77 +757,38 @@
#ifdef USE_GTK
-void
-report_save(context, backend, name)
- struct context *context;
- int backend;
- const char *name;
-{
- struct context *report_context;
- char *report_filename;
- char *report_name;
- int report_len = strlen("Report YYYYMMDD-HHMMSS") + 1;
- time_t t;
- int error;
-
- context = context_by_type(context, CONTEXT_SCOPE);
- if(!context)
- {
- show_error(_("report_save() called with illegal type"));
- return;
- }
-
- if(name)
- report_context = scopetree_new(CONTEXT_REPORT, name, "");
- else
- {
- report_name = emalloc(report_len);
- t = time(NULL);
- strftime(report_name, report_len, "Report %Y%m%d-%H%M%S", localtime(&t));
- report_context = scopetree_new(CONTEXT_REPORT, report_name, NULL);
- efree(&report_name);
- }
- if(!report_context)
- {
- show_error(_("report_save() coudn't create context"));
- return;
- }
- report_filename = report_get_filename(report_context);
- if(!report_filename)
- {
- show_error(_("report_save() coudn't find a report filename"));
- return;
- }
+/*
+ * Main function of the holes reporter
+ */
+void
+report_tests(hosts, interrupted_test)
+ struct arglist * hosts;
+ int interrupted_test;
+{
- error = backend_to_nbe(backend, report_filename);
- efree(&report_filename);
- if(error)
- {
- show_error(_("report_save() coudn't save the report"));
- return;
- }
- prefs_context_update(report_context);
+ gtk_widget_show(arg_get_value(MainDialog, "WINDOW"));
+#ifdef ENABLE_SAVE_TESTS
+ if(comm_server_restores_sessions(Prefs))
+ {
+ harglst * oldSessions = Sessions;
+ Sessions = comm_get_sessions();
+ prefs_dialog_target_fill_sessions(arg_get_value(MainDialog, "TARGET"),
+ Sessions);
+ if(oldSessions)harg_close_all(oldSessions);
+ }
+#endif
+ hosts = sort_dangerous_hosts(hosts);
+ create_report_window(hosts, interrupted_test);
}
-
/*
* Opens the report
*/
-void
-open_report(GtkWidget * dontcare, GtkWidget *nsr)
+void open_report(GtkWidget * dontcare, GtkWidget *nsr)
{
- const char *filename =
- gtk_file_selection_get_filename(GTK_FILE_SELECTION(nsr));
- int be = backend_import_report((char *)filename);
-
- if(be >= 0)
- {
- char *report_name = g_path_get_basename(filename);
-
- report_save(Context, be, report_name);
- g_free(report_name);
- }
+int be = backend_import_report((char*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(nsr)));
+if(be >= 0)report_tests_ng(be, 0);
}
/*
@@ -162,11 +797,11 @@
void open_report_selectfile()
{
GtkWidget * nsr;
- nsr = gtk_file_selection_new (_("Load file"));
+ nsr = gtk_file_selection_new ("Load file");
/*
* CWD
*/
- gtk_file_selection_set_filename (GTK_FILE_SELECTION(nsr), "");
+ gtk_file_selection_set_filename (GTK_FILE_SELECTION(nsr), ".");
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (nsr)->ok_button),
"clicked", (GtkSignalFunc) open_report,(void *) nsr );
@@ -179,5 +814,105 @@
(gpointer) nsr);
gtk_widget_show(nsr);
+}
+
+/*
+ * Saves the report
+ */
+static void
+save_report_ask(nul,menu)
+ GtkWidget * nul;
+ GtkWidget * menu;
+{
+ GtkWidget * active;
+ GtkWidget * filew;
+ char * filename;
+ char * tmp;
+ char * hostname;
+ int value;
+ char * suffixes[] = {".nsr", ".html", ".txt", ".tex", "", ".xml"};
+ struct arglist * hosts;
+
+ active = gtk_menu_get_active(GTK_MENU(menu));
+ value = (int)gtk_object_get_data(GTK_OBJECT(active), "type");
+ hosts = gtk_object_get_data(GTK_OBJECT(menu), "hosts");
+ if(!hosts)
+ {
+ fprintf(stderr, "Error - NULL hosts in save_report_ask()\n");
+ return ;
+ }
+ if(value < 0)value = 0;
+ if(value > SAVE_MAX)value = SAVE_MAX;
+
+
+ hostname = emalloc(strlen(hosts->name)+1);
+ strncpy(hostname, hosts->name, strlen(hosts->name));
+
+ while((tmp = strchr(hostname, '.')))tmp[0]='_';
+
+ filename = emalloc(strlen(hosts->name)+7);
+ sprintf(filename, "%s%s", hostname, suffixes[value]);
+ efree(&hostname);
+
+ filew = gtk_file_selection_new ("Save file");
+ gtk_object_set_data(GTK_OBJECT(filew), "type", (void*)value);
+ gtk_object_set_data(GTK_OBJECT(filew), "hosts", hosts);
+ gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button),
+ "clicked", (GtkSignalFunc) save_report, filew );
+
+ gtk_signal_connect /*_object*/ (GTK_OBJECT (GTK_FILE_SELECTION
+ (filew)->cancel_button),
+ "clicked", (GtkSignalFunc)close_window, (void *)filew);
+ gtk_file_selection_set_filename (GTK_FILE_SELECTION(filew), filename);
+
+ gtk_widget_show(filew);
+}
+
+/*
+ * save_report
+ *
+ * this function is called when the user
+ * clicks on the 'save' item of the file
+ * menu...
+ */
+static void
+save_report(nul,filew)
+ GtkWidget * nul;
+
+ GtkWidget * filew;
+{
+ char * fname = (char*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(filew));
+ int type = (int)gtk_object_get_data(GTK_OBJECT(filew), "type");
+ struct arglist * hosts = gtk_object_get_data(GTK_OBJECT(filew), "hosts");
+
+ gtk_widget_hide(filew);
+ hosts = sort_dangerous_hosts(hosts);
+ switch(type)
+ {
+ case SAVE_HTML :
+ arglist_to_html(hosts, fname);
+ break;
+ case SAVE_XML :
+ arglist_to_xml(hosts, fname);
+ break;
+
+ case SAVE_LATEX :
+ arglist_to_latex(hosts, fname);
+ break;
+ case SAVE_TEXT :
+ arglist_to_text(hosts, fname);
+ break;
+#ifndef _NO_PIES
+ case SAVE_HTML_GRAPH :
+ arglist_to_html_graph(hosts, fname);
+ break;
+#endif /* _NO_PIES */
+ case SAVE_NSR:
+ default :
+ arglist_to_file(hosts, fname);
+ break;
+ }
+ arg_free(hosts);
+ gtk_widget_destroy(filew);
}
#endif
Index: report_save.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/report_save.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- report_save.c 22 Apr 2005 13:51:31 -0000 1.23
+++ report_save.c 17 Mar 2007 21:36:02 -0000 1.24
@@ -26,17 +26,16 @@
* do so, delete this exception statement from your version.
*
* This code deals with the 'save report' dialog.
- */
-
-
+ */
+
+
#include <includes.h>
#ifdef USE_GTK
#include <gtk/gtk.h>
+#include "gtk-compat.h"
#include "xstuff.h"
+#include "xpm/warning.xpm"
-#include "preferences.h"
-#include "context.h"
-#include "error_dialog.h"
#include "backend.h"
#include "nsr_output.h"
#include "html_output.h"
@@ -48,11 +47,9 @@
#include "xml_output_ng.h"
#include "html_graph_output.h"
#include "nbe_output.h"
-#include "pdf_output.h"
-#include "nessus_i18n.h"
+#include "report_ng.h"
-#include "globals.h"
#define SAVE_NBE 0
#define SAVE_NSR 1
@@ -60,268 +57,393 @@
#define SAVE_TEXT 3
#define SAVE_LATEX 4
#define SAVE_HTML_GRAPH 5
-#define SAVE_PDF 6
-#define SAVE_XML 7
-#define SAVE_XML_NG 8
+#define SAVE_XML 6
+#define SAVE_XML_NG 7
#define SAVE_MAX SAVE_XML_NG
/*------------------------------------------------------------------------*/
-static int
-file_save_ok_callback(widget, filedialog)
- GtkWidget *widget;
- GtkWidget *filedialog;
+static int file_dialog_hide(filedialog)
+ GtkWidget * filedialog;
{
- const char *filename =
- gtk_file_selection_get_filename(GTK_FILE_SELECTION(filedialog));
- char *basename = g_path_get_basename(filename);
- char *ext = strrchr(basename, '.');
- char *fname;
- struct arglist *hosts = NULL;
- GtkWidget *menu = gtk_object_get_data(GTK_OBJECT(filedialog), "menu");
- GtkWidget *active = gtk_menu_get_active(GTK_MENU(menu));
- int type = (int)gtk_object_get_data(GTK_OBJECT(active), "type");
- char *suffixes[] =
- { ".nbe", ".nsr", ".html", ".txt", ".tex", ".pdf", "", ".xml", ".xml" };
-#define MAX_SUFFIX_LEN 5 /* .html */
- char *suffix = suffixes[type];
- int be = (int)arg_get_value(arg_get_value(MainDialog, "REPORT"), "BE");
-
- gtk_widget_hide(filedialog);
+ gtk_widget_hide(filedialog);
+ gtk_widget_destroy(filedialog);
+ return 0;
+}
- if(check_is_dir(filename))
- fname = g_build_filename(filename, basename, NULL);
- else
- fname = g_strdup(filename);
+static int file_save_ok_callback(widget, filedialog)
+ GtkWidget * widget;
+ GtkWidget * filedialog;
+{
+ char * fname = (char*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(filedialog));
+ int type;
+ struct arglist * hosts = NULL;
+ GtkWidget * menu = gtk_object_get_data(GTK_OBJECT(filedialog), "menu");
+ GtkWidget * window = gtk_object_get_data(GTK_OBJECT(filedialog), "window");
+ GtkWidget * active;
+ char * suffixes[] = {".nbe", ".nsr", ".html", ".txt", ".tex", "", ".xml", ".xml"};
+#define MAX_SUFFIX_LEN 5 /* .html */
+ int be = (int)gtk_object_get_data(GTK_OBJECT(filedialog), "be");
+
+ gtk_object_set_data(GTK_OBJECT(window), "report_saved", (void*)1);
+ gtk_widget_hide(filedialog);
- /*
- * Add a default extension
- */
- if(suffix && (!ext || strcmp(ext, suffix)))
- {
- char *tmpname = g_strdup_printf("%s%s", fname, suffix);
+
+
+ active = gtk_menu_get_active(GTK_MENU(menu));
+ type = (int)gtk_object_get_data(GTK_OBJECT(active), "type");
- g_free(fname);
- fname = tmpname;
- }
+
+
+ /*
+ * Add a default extension
+ */
+ if(strrchr(fname, '.'))
+ fname = estrdup(fname);
+ else
+ {
+ char * s;
+ s = emalloc(strlen(fname) + MAX_SUFFIX_LEN + 1);
+ strcat(s, fname);
+ strcat(s, suffixes[type]);
+ fname = s;
+ }
+
+
+
+
- switch (type)
- {
- case SAVE_HTML:
- hosts = backend_convert(be);
- arglist_to_html(hosts, fname);
- break;
- case SAVE_XML:
- hosts = backend_convert(be);
- arglist_to_xml(hosts, fname);
- break;
- case SAVE_XML_NG:
- backend_to_xml_ng(be, fname);
- break;
- case SAVE_LATEX:
- hosts = backend_convert(be);
- arglist_to_latex(hosts, fname);
- break;
- case SAVE_TEXT:
- hosts = backend_convert(be);
- arglist_to_text(hosts, fname);
- break;
+ switch(type)
+ {
+ case SAVE_HTML :
+ hosts = backend_convert(be);
+ arglist_to_html(hosts, fname);
+ break;
+ case SAVE_XML :
+ hosts = backend_convert(be);
+ arglist_to_xml(hosts, fname);
+ break;
+ case SAVE_XML_NG :
+ backend_to_xml_ng(be, fname);
+ break;
+ case SAVE_LATEX :
+ hosts = backend_convert(be);
+ arglist_to_latex(hosts, fname);
+ break;
+ case SAVE_TEXT:
+ hosts = backend_convert(be);
+ arglist_to_text(hosts, fname);
+ break;
#ifndef _NOPIE
- case SAVE_HTML_GRAPH:
- hosts = backend_convert(be);
- arglist_to_html_graph(hosts, fname);
- break;
+ case SAVE_HTML_GRAPH:
+ hosts = backend_convert(be);
+ arglist_to_html_graph(hosts,fname);
+ break;
#endif
- case SAVE_PDF:
- arglist_to_pdf(be, fname);
- break;
- case SAVE_NSR:
- backend_to_nsr(be, fname);
- break;
- case SAVE_NBE:
- default:
- backend_to_nbe(be, fname);
- break;
+ case SAVE_NSR:
+ backend_to_nsr(be, fname);
+ break;
+ case SAVE_NBE:
+ default:
+ backend_to_nbe(be, fname);
+ break;
}
- g_free(basename);
- g_free(fname);
- if(hosts)
- arg_free_all(hosts);
- gtk_widget_destroy(filedialog);
- return 0;
+ efree(&fname);
+ if(hosts)arg_free_all(hosts);
+ gtk_widget_destroy(filedialog);
+ if(gtk_object_get_data(GTK_OBJECT(window), "dont_close"))
+ gtk_object_remove_data(GTK_OBJECT(window), "dont_close");
+ else
+ report_delete_window(window, NULL);
+ return 0;
}
/*
* "inspired" from the Gimp 1.2.2
* See gimp/app/fileops.c for a cleaner function
*/
-void
-report_save_cb(window)
- GtkWidget *window;
+static void
+file_dialog_setup(window)
+ GtkWidget * window;
{
- GtkWidget *filesave;
- GtkWidget *frame;
- GtkWidget *hbox;
- GtkWidget *label;
- GtkWidget *option_menu;
- GtkWidget *menu;
- GtkWidget *save_options;
- GtkWidget *type;
-
- filesave = gtk_file_selection_new(_("Export Report"));
-
- gtk_window_set_position(GTK_WINDOW(filesave), GTK_WIN_POS_MOUSE);
-
- gtk_container_border_width(GTK_CONTAINER(filesave), 2);
- gtk_container_border_width(GTK_CONTAINER(GTK_FILE_SELECTION(filesave)->
- button_area), 2);
-
- g_signal_connect(GTK_FILE_SELECTION(filesave)->ok_button,
- "clicked", G_CALLBACK(file_save_ok_callback), filesave);
-
- g_signal_connect_swapped(GTK_FILE_SELECTION(filesave)->cancel_button,
- "clicked", G_CALLBACK(gtk_widget_destroy), filesave);
-
- save_options = gtk_hbox_new(TRUE, 1);
+ GtkWidget *filesave;
+ GtkWidget *frame;
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtkWidget *option_menu;
+ GtkWidget *menu;
+ GtkWidget *save_options;
+ GtkWidget *type;
+
+ filesave = gtk_file_selection_new("Save Report");
+ gtk_object_set_data(GTK_OBJECT(filesave), "window", window);
+ gtk_object_set_data(GTK_OBJECT(filesave), "be",
+ gtk_object_get_data(GTK_OBJECT(window), "be"));
+
+ gtk_window_set_wmclass(GTK_WINDOW(filesave), "save_report", "Nessus");
+#if GTK_VERSION > 10
+ gtk_window_set_position(GTK_WINDOW(filesave), GTK_WIN_POS_MOUSE);
+#endif
+ gtk_object_set_data(GTK_OBJECT(filesave), "be",
+ gtk_object_get_data(GTK_OBJECT(window), "be"));
+
+ gtk_container_border_width(GTK_CONTAINER(filesave), 2);
+ gtk_container_border_width(GTK_CONTAINER(
+ GTK_FILE_SELECTION(filesave)->button_area), 2);
- frame = gtk_frame_new(_("Export Options"));
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
- gtk_box_pack_start(GTK_BOX(save_options), frame, TRUE, TRUE, 4);
+ gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filesave)->cancel_button),
+ "clicked",
+ GTK_SIGNAL_FUNC (file_dialog_hide),
+ GTK_OBJECT (filesave));
+ gtk_signal_connect (GTK_OBJECT (filesave), "delete_event",
+ GTK_SIGNAL_FUNC (file_dialog_hide),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filesave)->ok_button),
+ "clicked",
+ GTK_SIGNAL_FUNC (file_save_ok_callback),
+ filesave);
+ gtk_quit_add_destroy (1, GTK_OBJECT (filesave));
+
+
+ save_options = gtk_hbox_new (TRUE, 1);
- hbox = gtk_hbox_new(FALSE, 4);
- gtk_container_border_width(GTK_CONTAINER(hbox), 4);
- gtk_container_add(GTK_CONTAINER(frame), hbox);
- gtk_widget_show(hbox);
+ frame = gtk_frame_new ("Save Options");
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
+ gtk_box_pack_start (GTK_BOX (save_options), frame, TRUE, TRUE, 4);
- label = gtk_label_new(_("Report file format : "));
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- gtk_widget_show(label);
+ hbox = gtk_hbox_new (FALSE, 4);
+ gtk_container_border_width (GTK_CONTAINER (hbox), 4);
+ gtk_container_add (GTK_CONTAINER (frame), hbox);
+ gtk_widget_show (hbox);
- option_menu = gtk_option_menu_new();
- gtk_box_pack_start(GTK_BOX(hbox), option_menu, TRUE, TRUE, 0);
- gtk_widget_show(option_menu);
+ label = gtk_label_new ("Report file format : ");
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+ option_menu = gtk_option_menu_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), option_menu, TRUE, TRUE, 0);
+ gtk_widget_show (option_menu);
+
+
+
+
/*---------------------------------------------------------------*
- * We fill the dialog with the various export formats
+ * We fill the dialog with the various export formats
* we know about
*---------------------------------------------------------------*/
- menu = gtk_menu_new();
+ menu = gtk_menu_new();
gtk_object_set_data(GTK_OBJECT(filesave), "menu", menu);
-
+
type = gtk_menu_item_new_with_label("NBE");
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_NBE);
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_NBE);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-
-
- type = gtk_menu_item_new_with_label(_("NSR (deprecated)"));
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_NSR);
+
+
+
+ type = gtk_menu_item_new_with_label("NSR (deprecated)");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_NSR);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-
- type = gtk_menu_item_new_with_label("XML");
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_XML_NG);
+
+ type = gtk_menu_item_new_with_label ("XML");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_XML_NG);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-
- type = gtk_menu_item_new_with_label(_("XML (old style - deprecated)"));
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_XML);
+
+
+ type = gtk_menu_item_new_with_label ("XML (old style - deprecated)");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_XML);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-
-
+
+
+
type = gtk_menu_item_new_with_label("HTML");
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_HTML);
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_HTML);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-
+
type = gtk_menu_item_new_with_label("LaTeX");
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_LATEX);
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_LATEX);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-
- type = gtk_menu_item_new_with_label(_("ASCII text"));
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_TEXT);
+
+ type = gtk_menu_item_new_with_label("ASCII text");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_TEXT);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
#ifndef _NO_PIES
- type = gtk_menu_item_new_with_label(_("HTML with Pies and Graphs"));
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_HTML_GRAPH);
+ type = gtk_menu_item_new_with_label("HTML with Pies and Graphs");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_HTML_GRAPH);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-#endif
+#endif
+
- type = gtk_menu_item_new_with_label("PDF");
- gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_PDF);
- gtk_menu_append(GTK_MENU(menu), type);
- gtk_widget_show(type);
+
+
+ /*----------------------------------------------------------------*/
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
+ gtk_widget_show(menu);
+ gtk_widget_show (frame);
- /*----------------------------------------------------------------*/
- gtk_option_menu_set_menu(GTK_OPTION_MENU(option_menu), menu);
- gtk_widget_show(menu);
- gtk_widget_show(frame);
+ /* pack the containing save_options hbox into the save-dialog */
+ gtk_box_pack_end (GTK_BOX (GTK_FILE_SELECTION (filesave)->main_vbox),
+ save_options, FALSE, FALSE, 0);
+ gtk_widget_show(save_options);
+ gtk_widget_show(filesave);
+
+}
- /* pack the containing save_options hbox into the save-dialog */
- gtk_box_pack_end(GTK_BOX(GTK_FILE_SELECTION(filesave)->main_vbox),
- save_options, FALSE, FALSE, 0);
- gtk_widget_show(save_options);
- gtk_widget_show(filesave);
+
+/*------------------------------------------------------------------------*/
+static int
+dialog_close_do_save(a, dialog)
+ GtkWidget * a, * dialog;
+{
+ GtkWidget * window = gtk_object_get_data(GTK_OBJECT(dialog), "report");
+ gtk_widget_hide(dialog);
+ file_dialog_setup(window);
+ return 0;
}
-/*
- * Open a pdf file with the configured pdf viewer.
- * XXX: This function eventually should be moved into a more
- * suitable module.
- */
+static int
+dialog_close_dont_save(a, dialog)
+ GtkWidget * a, * dialog;
+{
+ GtkWidget * window = gtk_object_get_data(GTK_OBJECT(dialog), "report");
+ gtk_widget_hide(dialog);
+ gtk_object_set_data(GTK_OBJECT(window), "report_saved", (void*)1);
+ report_delete_window(window, NULL);
+ return 0;
+}
+
+static int
+dialog_close_cancel(a, dialog)
+ GtkWidget * a, * dialog;
+{
+ gtk_widget_hide(dialog);
+ return 0;
+}
+
+
+
+
+
void
-show_pdf(filename)
- char * filename;
+dialog_close_setup(window)
+ GtkWidget * window;
{
- const gchar *pdfviewer = prefs_get_string(Global, "pdfviewer");
+ GtkWidget * dialog;
+ GtkWidget * button;
+ GtkWidget * vbox;
+ GtkWidget * hbox;
+ GtkWidget * label;
+ GtkStyle * style;
+ GtkWidget * pixmapwid;
+ GdkPixmap * pixmap;
+ GdkBitmap * mask;
+ GtkWidget * table;
+ char * name = "Save report";
+ char * error_text =
+ "This report was not saved.\nDo you want to save it ?";
+
+
+ dialog = gtk_object_get_data(GTK_OBJECT(window),
+ "save_dialog");
- if (!check_is_file(filename))
+ if(dialog)
{
- show_warning(_("PDF file %s not found."), filename);
- return;
- }
+ gtk_widget_show(dialog);
+ return;
+ }
+
+ dialog = gtk_window_new(WINDOW_DIALOG);
+ gtk_object_set_data(GTK_OBJECT(dialog), "report", window);
+ gtk_object_set_data(GTK_OBJECT(window), "save_dialog", dialog);
+
+ gtk_window_set_title(GTK_WINDOW(dialog), name);
+ gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
+ GTK_SIGNAL_FUNC (delete_event), NULL);
+ gtk_window_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+ vbox = gtk_vbox_new(FALSE, 15);
+ gtk_container_border_width(GTK_CONTAINER(dialog), 10);
+ gtk_container_add(GTK_CONTAINER(dialog), vbox);
+ gtk_widget_show(vbox);
+
+ hbox = gtk_hbox_new(FALSE,5);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE,0);
+ gtk_widget_show(hbox);
- if (!pdfviewer)
- {
- show_warning(_("You haven't configured a PDF viewer."
- "\nThe report was saved as %s so you can manually open it."),
- filename);
- return;
- }
+ label = gtk_label_new(error_text);
+ gtk_label_set_justify (GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 3);
+ gtk_widget_show(label);
+
+
+
+ button = gtk_button_new_with_label ("Yes");
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_close_do_save), dialog);
+
+ table = gtk_table_new(1,3, TRUE);
+ gtk_box_pack_end(GTK_BOX(vbox), table, TRUE, TRUE, 0);
+ gtk_widget_show(table);
+
+
+
+
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 0,1,0,1);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default (button);
+ gtk_widget_show (button);
+ gtk_widget_realize(dialog);
+
+
+ button = gtk_button_new_with_label ("No");
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_close_dont_save), dialog);
+
+
+
+
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 1,2,0,1);
+ gtk_widget_show (button);
+ gtk_widget_realize(dialog);
- {
- gchar *cmd = g_strdup_printf("'%s' '%s'", pdfviewer, filename);
- /* start PDF viewer */
- if(!g_spawn_command_line_async(cmd, NULL))
- show_error(_("Can't launch PDF viewer: %s"), pdfviewer);
- g_free(cmd);
- }
+ button = gtk_button_new_with_label ("Cancel");
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_close_cancel), dialog);
+
+
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 2,3,0,1);
+ gtk_widget_show (button);
+ gtk_widget_realize(dialog);
+
+
+
+ style = gtk_widget_get_style(dialog);
+ pixmap = gdk_pixmap_create_from_xpm_d(dialog->window, &mask,
+ &style->bg[GTK_STATE_NORMAL],
+ (char **)warning_xpm);
+ pixmapwid = gtk_pixmap_new(pixmap, mask);
+
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwid, FALSE, TRUE,3);
+ gtk_widget_show(pixmapwid);
+ gtk_widget_show(dialog);
}
void
-report_open_pdf(menuitem, ctrls)
- GtkWidget *menuitem;
- gpointer ctrls;
+report_save_cb(w, window)
+ GtkWidget * w, * window;
{
- int be = (int)arg_get_value(arg_get_value(ctrls, "REPORT"), "BE");
- char *basename = g_path_get_basename(Context->dir);
- char *fname = g_strdup_printf("%s.pdf", basename);
- char *filename = g_build_filename(Context->dir, fname, NULL);
-
- g_free(basename);
- g_free(fname);
- arglist_to_pdf(be, filename);
-
- show_pdf(filename);
- g_free(filename);
+ gtk_object_set_data(GTK_OBJECT(window), "dont_close", (void*)1);
+ file_dialog_setup(window);
}
#endif
Index: report_save.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/report_save.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- report_save.h 9 Dec 2004 11:07:30 -0000 1.6
+++ report_save.h 17 Mar 2007 21:36:02 -0000 1.7
@@ -1,8 +1,8 @@
#ifndef NESSUS_REPORT_SAVE_H_
#define NESSUS_REPORT_SAVE_H_
-void report_save_cb(GtkWidget *);
-void report_open_pdf(GtkWidget *, gpointer);
-void show_pdf(char *);
+void report_save_cb(GtkWidget*, GtkWidget*);
+void dialog_close_setup(GtkWidget*);
+
#endif
Index: report_utils.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/report_utils.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- report_utils.c 3 Nov 2004 14:25:33 -0000 1.10
+++ report_utils.c 17 Mar 2007 21:36:02 -0000 1.11
@@ -55,6 +55,111 @@
return arg->next ? 1 + arglist_length(arg->next):0;
}
+struct arglist * sort_by_port(hosts)
+ struct arglist * hosts;
+{
+ struct arglist * by_port;
+ struct arglist * sub_port;
+ struct arglist * hosts_port;
+ struct arglist * sub_arg;
+ struct arglist * tmp_port;
+ char * comm;
+ by_port = emalloc(sizeof(struct arglist));
+
+ if (!hosts || !hosts->next) {
+ return by_port;
+ }
+
+ while (hosts && hosts->next)
+ {
+ struct arglist * ports = arg_get_value(hosts->value, "PORTS");
+ while(ports && ports->next)
+ {
+ struct arglist * reports = arg_get_value(ports->value, "REPORT");
+ struct arglist * infos = arg_get_value(ports->value, "INFO");
+ struct arglist * notes = arg_get_value(ports->value, "NOTE");
+
+ tmp_port = arg_get_value(by_port, ports->name);
+ if(!tmp_port)
+ {
+ tmp_port = emalloc(sizeof(struct arglist));
+ arg_add_value(by_port, ports->name, ARG_ARGLIST, -1, tmp_port);
+ }
+
+ hosts_port = arg_get_value(tmp_port,"HOSTS");
+ if (!hosts_port){
+ hosts_port = emalloc(sizeof(struct arglist));
+ arg_add_value(tmp_port, "HOSTS", ARG_ARGLIST, -1, hosts_port);
+ }
+
+ sub_port = arg_get_value(hosts_port,hosts->name);
+ if (!sub_port){
+ sub_port = emalloc(sizeof(struct arglist));
+ arg_add_value(hosts_port, hosts->name, ARG_ARGLIST, -1, sub_port);
+ /*arg_add_value(sub_port, "STATE", ARG_INT, sizeof(int),(void *)1);*/
+ }
+ if ( reports || infos || notes){
+ if (reports) {
+ sub_arg = arg_get_value(sub_port, "REPORT");
+ if (!sub_arg) {
+ sub_arg = emalloc(sizeof(struct arglist));
+
+ }
+ while (sub_arg && sub_arg->next)sub_arg = sub_arg->next;
+
+ while (reports && reports->next) {
+ comm = emalloc(strlen(reports->value)+1);
+ strncpy(comm, reports->value, strlen(reports->value));
+ /* arg_add_value(tmp_port, hosts->name, ARG_STRING, strlen(comm),comm); */
+ arg_add_value(sub_arg, "REPORT", ARG_STRING, strlen(comm),comm);
+ reports = reports->next;
+ }
+ arg_add_value(sub_port, "REPORT", ARG_ARGLIST, -1, sub_arg);
+ }
+
+ if (notes) {
+ sub_arg = arg_get_value(sub_port, "NOTE");
+ if (!sub_arg) {
+ sub_arg = emalloc(sizeof(struct arglist));
+ arg_add_value(sub_port, "NOTE", ARG_ARGLIST, -1, sub_arg);
+ }
+ while (sub_arg && sub_arg->next)sub_arg = sub_arg->next;
+
+ while (notes && notes->next) {
+ comm = emalloc(strlen(notes->value)+1);
+ strncpy(comm, notes->value, strlen(notes->value));
+ /* arg_add_value(tmp_port, hosts->name, ARG_STRING, strlen(comm),comm); */
+ arg_add_value(sub_arg, "NOTE", ARG_STRING, strlen(comm),comm);
+ notes = notes->next;
+ }
+ }
+
+ if (infos) {
+ sub_arg = arg_get_value(sub_port, "INFO");
+ if (!sub_arg) {
+ sub_arg = emalloc(sizeof(struct arglist));
+ arg_add_value(sub_port, "INFO", ARG_ARGLIST, -1, sub_arg);
+ }
+ while (sub_arg && sub_arg->next)sub_arg = sub_arg->next;
+
+ while (infos && infos->next) {
+ comm = emalloc(strlen(infos->value)+1);
+ strncpy(comm, infos->value, strlen(infos->value));
+ /* arg_add_value(tmp_port, hosts->name, ARG_STRING, strlen(comm),comm); */
+ arg_add_value(sub_arg, "INFO", ARG_STRING, strlen(comm),comm);
+ infos = infos->next;
+ }
+ }
+ }
+ ports = ports->next;
+ }
+ hosts = hosts->next;
+ }
+
+ return by_port;
+}
+
+
/*
* Auxilliary functions
@@ -189,3 +294,68 @@
else return sub_most_dangerous_host_notes(hosts, NULL, 0);
}
+/************************************************************************
+ *
+ * Insertion sort
+ *
+ ************************************************************************/
+
+
+struct arglist * arglist_insert(struct arglist*e, struct arglist** l)
+{
+ int greater = 0;
+ int danger_e = 0;
+ int danger_l = 0;
+
+ danger_e = number_of_holes_by_host(e->value);
+ danger_l = number_of_holes_by_host((*l)->value);
+ if(danger_e > danger_l)greater++;
+
+ if(!(danger_e || danger_l))
+ {
+ danger_e = number_of_warnings_by_host(e->value);
+ danger_l = number_of_warnings_by_host((*l)->value);
+ if(danger_e > danger_l)greater++;
+ }
+ if(!(danger_e || danger_l))
+ {
+ danger_e = number_of_notes_by_host(e->value);
+ danger_l = number_of_notes_by_host((*l)->value);
+ if(danger_e > danger_l)greater++;
+ }
+
+ if(!((*l)->next) || greater)
+ {
+ e->next = *l;
+ *l = e;
+ return *l;
+ }
+ else
+ {
+ arglist_insert(e, &((*l)->next));
+ return *l;
+ }
+}
+
+struct arglist * arglist_insert_sort(struct arglist * l)
+{
+ if(!l->next)
+ return l;
+ else
+ {
+ struct arglist * result_insert;
+
+ result_insert = arglist_insert_sort(l->next);
+ return arglist_insert(l, &result_insert);
+ }
+}
+
+
+
+
+struct arglist * sort_dangerous_hosts(struct arglist * hosts)
+{
+ struct arglist * ret = emalloc(sizeof(struct arglist));
+ arg_dup(ret, hosts);
+ return arglist_insert_sort(ret);
+}
Index: report_utils.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/report_utils.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- report_utils.h 3 Nov 2004 14:25:33 -0000 1.7
+++ report_utils.h 17 Mar 2007 21:36:02 -0000 1.8
@@ -1,6 +1,8 @@
#ifndef NESSUSC_REPORT_UTILS_H__
#define NESSUSC_REPORT_UTILS_H__
+struct arglist * sort_by_port(struct arglist *);
+
int arglist_length(struct arglist *);
int number_of_notes_by_port(struct arglist *);
@@ -17,6 +19,7 @@
int number_of_holes(struct arglist * );
struct arglist *most_dangerous_host(struct arglist *);
+struct arglist * sort_dangerous_hosts(struct arglist *);
int safe_strcmp(char*, char*);
#endif
Index: sighand.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/sighand.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- sighand.c 21 Dec 2004 15:08:17 -0000 1.20
+++ sighand.c 17 Mar 2007 21:36:03 -0000 1.21
@@ -1,6 +1,5 @@
/* Nessus
* Copyright (C) 1998 - 2001 Renaud Deraison
- * Copyright (C) 2004 Intevation GmbH
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
@@ -30,48 +29,54 @@
*/
#include <includes.h>
-#include "nessus_i18n.h"
+#include "nsr_output.h"
#include "error_dialog.h"
-#include "context.h"
+#include "globals.h"
#include "backend.h"
#include "auth.h"
-#include "globals.h" /* for closesocket() */
void
nessus_exit(code)
- int code;
+ int code;
{
- backend_clear_all();
- exit(code);
+ backend_clear_all();
+ exit(code);
}
-
-void
+void
sighand_pipe()
{
- Context->socket = -1;
- show_error(_("Connection closed by the server (SIGPIPE caught)"));
+#ifdef USE_GTK
+ if(!F_quiet_mode)
+ show_error_and_wait("Connection closed by the server (SIGPIPE caught)");
+ else
+#endif
+ fprintf(stderr, "Connection closed by the server (SIGPIPE caught)\n");
}
+
void
sighand_alarm()
{
- show_error(_("Connection timed out"));
+#ifdef USE_GTK
+ if(!F_quiet_mode)show_error_and_wait("Connection timed out");
+ else
+#endif
+ fprintf(stderr, "Connection timed out\n");
}
-
+
void sighand_exit()
{
- /* FIXME: close all open connections */
- if(Context->socket > 0)
- {
- network_printf( "CLIENT <|> STOP_WHOLE_TEST <|> CLIENT\n");
+ if(GlobalSocket > 0)
+ {
+ network_printf( "CLIENT <|> STOP_WHOLE_TEST <|> CLIENT\n");
#ifdef NESSUS_ON_SSL
- close_stream_connection(Context->socket);
-#else
- shutdown(Context->socket, 2);
- closesocket(Context->socket);
-#endif
- Context->socket = -1;
- }
- nessus_exit(1);
+ close_stream_connection(GlobalSocket);
+#else
+ shutdown(GlobalSocket, 2);
+ closesocket(GlobalSocket);
+#endif
+ GlobalSocket = -1;
+ }
+ nessus_exit (1);
}
Index: text_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/text_output.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- text_output.c 3 Nov 2004 14:25:35 -0000 1.10
+++ text_output.c 17 Mar 2007 21:36:03 -0000 1.11
@@ -30,6 +30,7 @@
#include "report.h"
#include "report_utils.h"
#include "error_dialog.h"
+#include "globals.h"
static int line_length(char * text)
@@ -70,7 +71,8 @@
{
/* go to the end and rewind until we find a space */
char * t = text + width - pl;
- while((t[0]!=' ') && (t[0]!='\n'))
+ if ( t >= (text + length) ) t = NULL;
+ while(t != NULL && (t[0]!=' ') && (t[0]!='\n'))
{
t--;
if(t == text)
Index: xml_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/xml_output.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- xml_output.c 3 Nov 2004 14:25:35 -0000 1.11
+++ xml_output.c 17 Mar 2007 21:36:03 -0000 1.12
@@ -30,6 +30,7 @@
#include "report.h"
#include "report_utils.h"
#include "error_dialog.h"
+#include "globals.h"
#include "xml_output.h"
static char *parse_portname ( char *name, int howto );
Index: xml_output_ng.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/xml_output_ng.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- xml_output_ng.c 6 Jul 2005 14:53:28 -0000 1.34
+++ xml_output_ng.c 17 Mar 2007 21:36:03 -0000 1.35
@@ -41,7 +41,6 @@
#include <includes.h>
-#include "nessus_i18n.h"
#include <stdarg.h>
#include "report.h"
@@ -49,8 +48,6 @@
#include "backend.h"
#include "data_mining.h"
#include "globals.h"
-#include "context.h"
-#include "preferences.h"
#include "report_utils.h"
int backend_to_xml_ng (int, char *);
@@ -187,12 +184,21 @@
static void
xml_info_host (int be, FILE* fd, int indent, struct arglist * t)
{
- const char *host = prefs_get_string(Context, "nessusd_host");
-
xml_fprintf (fd, indent, "<host>\n");
- xml_fprintf_element(fd, indent+1, "name", (char*)host);
+ if (First_time)
+ {
+ t = Prefs;
+ if (t)
+ {
+ xml_fprintf_element (
+ fd, indent+1, "name", (char *) arg_get_value (t, "nessusd_host"));
+ }
+ }
+ else
+ xml_fprintf (fd, indent+1,
+ "<error txt=\"No server name information (not connected ?).\"/>\n");
- t = arg_get_value(Context->prefs, "SERVER_INFO");
+ t = arg_get_value(Prefs, "SERVER_INFO");
if (t)
{
xml_fprintf_element (fd, indent+1, "osname", (char *) arg_get_value (t, "server_info_os"));
@@ -253,19 +259,20 @@
xml_info (int be, FILE* fd, int indent)
{
struct arglist * t;
- t = arg_get_value(Context->prefs, "SERVER_INFO");
+ t = arg_get_value(Prefs, "SERVER_INFO");
if (t)
{
- xml_fprintf (fd, 2, "<info>\n");
+ xml_fprintf (fd, indent, "<info>\n");
xml_info_nessusd(be, fd, indent+1, t);
xml_info_host(be, fd, indent+1, t);
xml_info_date(be, fd, indent+1, t);
- xml_fprintf (fd, 2, "</info>\n\n");
+ xml_fprintf (fd, indent, "</info>\n");
} else {
- xml_fprintf (fd, 2, "<info>\n");
+ fprintf (stderr, "xml_output: No SERVER_INFO found.\n");
+ xml_fprintf (fd, indent, "<info>\n");
xml_fprintf (fd, indent+1, "<!-- no version information found -->");
- xml_fprintf (fd, 2, "</info>\n\n");
+ xml_fprintf (fd, indent, "</info>\n");
}
} /* xml_info */
@@ -280,7 +287,7 @@
efree(&esc_name);
t = t->next;
}
- xml_fprintf (fd, indent, "</scanners>\n\n");
+ xml_fprintf (fd, indent, "</scanners>\n");
} /* xml_config_scanners */
static void
@@ -288,7 +295,7 @@
{
char* esc_name = escape_string(name);
char* esc_value = escape_string(value);
- xml_fprintf (fd, indent+1,
+ xml_fprintf (fd, indent,
"<pref name=\"%s\" value=\"%s\" />\n", esc_name, esc_value);
efree(&esc_name);
efree(&esc_value);
@@ -297,8 +304,8 @@
static void
xml_config_global (FILE* fd, int indent, struct arglist* t)
{
- xml_fprintf (fd, indent, "<global> ");
- while(t && t->next)
+ xml_fprintf (fd, indent, "<global>\n");
+ while( t->next != NULL )
{
if (t->type == ARG_STRING) {
xml_config_global_pref(fd, indent+1, t->name, t->value);
@@ -307,7 +314,7 @@
}
t = t->next;
} /* while */
- fprintf (fd, "</global>\n");
+ xml_fprintf (fd, indent, "</global>\n");
} /* xml_config_global */
static void
@@ -333,7 +340,7 @@
xml_setting (fd, indent+1, t->name, (t->value?"yes":"no"));
t = t->next;
}
- xml_fprintf (fd, indent, "</plugins>\n\n");
+ xml_fprintf (fd, indent, "</plugins>\n");
} /* xml_config_server */
static void
@@ -351,7 +358,7 @@
}
t = t->next;
}
- xml_fprintf (fd, indent, "</server>\n\n");
+ xml_fprintf (fd, indent, "</server>\n");
} /* xml_config_server */
static void
@@ -361,27 +368,31 @@
xml_fprintf (fd, indent, "<config>\n");
- xml_config_global (fd, indent+1, Context->prefs);
+ t = Prefs;
+ if (t)
+ {
+ xml_config_global (fd, indent+1, t);
+ }
- t = arg_get_value(Context->prefs, "SCANNER_SET");
+ t = arg_get_value(Prefs, "SCANNER_SET");
if (t)
{
xml_config_scanners(fd, indent+1, t);
}
- t = arg_get_value(Context->prefs, "SERVER_PREFS");
+ t = arg_get_value(Prefs, "SERVER_PREFS");
if (t)
{
xml_config_server(fd, indent+1, t);
}
- t = arg_get_value(Context->prefs, "PLUGINS_PREFS");
+ t = arg_get_value(Prefs, "PLUGINS_PREFS");
if (t)
{
xml_config_plugins(fd, indent+1, t);
}
- xml_fprintf (fd, indent, "</config>\n\n");
+ xml_fprintf (fd, indent, "</config>\n");
}
static void
@@ -398,7 +409,7 @@
xml_fprintf_element (fd, indent+1, "risk", getrisk((char*)arg_get_value (u, "DESCRIPTION")));
xml_fprintf_element (fd, indent+1, "summary", arg_get_value (u, "SUMMARY"));
xml_fprintf_element (fd, indent+1, "copyright", (char *) arg_get_value (u, "COPYRIGHT"));
- xml_fprintf (fd, indent, "</plugin>\n\n");
+ xml_fprintf (fd, indent, "</plugin>\n");
} /* xml_plugins_plugin */
static void
@@ -408,7 +419,7 @@
xml_fprintf (fd, indent, "<plugins>\n");
- t = Context->scanners;
+ t = Scanners;
if (t && t->type == ARG_ARGLIST)
{
while (t->next)
@@ -425,7 +436,7 @@
else
xml_fprintf (fd, indent+1, "<error txt=\"No scanners list.\"/>\n");
- t = Context->plugins;
+ t = Plugins;
if (t && t->type == ARG_ARGLIST)
{
while (t->next)
@@ -442,8 +453,7 @@
else
xml_fprintf (fd, indent+1, "<error txt=\"No plugins list.\"/>\n");
-
- xml_fprintf (fd, indent, "</plugins>\n\n");
+ xml_fprintf (fd, indent, "</plugins>\n");
}
@@ -698,7 +708,7 @@
q = subset_next(q);
}
- xml_fprintf (fd, indent, "</results>\n\n");
+ xml_fprintf (fd, indent, "</results>\n");
subset_free(sq);
} /* xml_results */
@@ -710,7 +720,7 @@
if(!fd)
{
- show_error(_("Can't open %s for writing: %s."), strerror(errno));
+ show_error(strerror(errno));
return -1;
}
Index: xstuff.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/xstuff.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- xstuff.c 4 Nov 2004 19:31:18 -0000 1.13
+++ xstuff.c 17 Mar 2007 21:36:03 -0000 1.14
@@ -33,8 +33,8 @@
#include "nessus.h"
#include "xstuff.h"
+#include "globals.h"
#include "sighand.h"
-#include "context.h"
int init_display(int *argc, char *** argv)
{
@@ -51,6 +51,11 @@
int delete_event(GtkWidget * nul, void * data)
{
return(FALSE);
+}
+void close_display()
+{
+ gtk_main_quit();
+ nessus_exit(0);
}
struct pixmap_and_mask
Index: xstuff.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/xstuff.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- xstuff.h 4 Nov 2004 19:31:18 -0000 1.6
+++ xstuff.h 17 Mar 2007 21:36:03 -0000 1.7
@@ -20,6 +20,7 @@
#define _NESSUSC_XSTUFF_H
int init_display(int *argc, char *** argv);
+void close_display();
int close_window(GtkWidget * , GtkWidget * );
int delete_event(GtkWidget * nul, void * data);
GtkWidget *make_pixmap(GtkWidget *, GdkColor *, char **);
_______________________________________________
Nessus-cvs mailing list
Nessus-cvs@list.nessus.org
http://mail.nessus.org/mailman/listinfo/nessus-cvs
In directory raccoon.nessus.org:/tmp/cvs-serv69892/nessus
Modified Files:
Makefile attack.c attack.h auth.c auth.h backend.c backend.h
cli.c comm.c comm.h data_mining.c detached_index.c
error_dialog.c error_dialog.h families.c families.h filter.c
globals.h gtk-compat.h html_graph_output.c html_output.c
latex_output.c monitor_dialog.c monitor_dialog.h nbe_output.c
nessus.c nessus.h nsr_output.c parser.c plugin_infos.c
preferences.c preferences.h read_target_file.c
read_target_file.h report.c report_save.c report_save.h
report_utils.c report_utils.h sighand.c text_output.c
xml_output.c xml_output_ng.c xstuff.c xstuff.h
Log Message:
Sync back to 2.2 as NessusClient is now on another branch
Index: Makefile
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/Makefile,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- Makefile 2 Sep 2005 09:25:13 -0000 1.71
+++ Makefile 17 Mar 2007 21:35:59 -0000 1.72
@@ -1,7 +1,7 @@
include ../nessus.tmpl
-GTKLIBS= $(GTKCONFIG_LIBS)
-INCLUDE = ${include} $(GTKCONFIG_CFLAGS) -Igdchart0.94b -Igdchart0.94b/gd1.3
+GTKLIBS= $(GTKCONFIG_LIBS) $(GLIBCONFIG_LIBS)
+INCLUDE = ${include} $(GTKCONFIG_CFLAGS) $(GLIBCONFIG_CFLAGS) -Igdchart0.94b -Igdchart0.94b/gd1.3
LIBS = `$(NESSUSCONFIG) --libs` $(X_LIBS) $(X_CFLAGS) $(GTKLIBS) \
$(RUN_LIBS) $(C_R_LIB) gdchart0.94b/gd1.3/libgd.a -lm
@@ -14,11 +14,11 @@
cli.o \
parser.o \
plugin_infos.o \
- context.o \
preferences.o \
families.o \
attack.o \
report.o \
+ report_ng.o \
report_save.o \
report_utils.o \
nsr_output.o \
@@ -35,14 +35,12 @@
backend.o \
data_mining.o \
prefs_dialog.o \
- prefs_scope_tree.o \
prefs_dialog_misc.o \
prefs_dialog_scan_opt.o \
prefs_dialog_user.o \
prefs_dialog_auth.o \
prefs_dialog_plugins_prefs.o \
prefs_plugins.o \
- prefs_plugins_tree.o \
prefs_target.o \
prefs_about.o \
prefs_kb.o \
@@ -58,9 +56,7 @@
dirutils.o \
sslui.o \
nessus.o
-
-GTK_OBJS = prefs_comment.o prefs_context.o prefs_options.o prefs_report.o \
- prefs_dialog_prefs.o prefs_scan_assistant.o pdf_output.o
+
all : cflags ${make_bindir}/nessus
@@ -71,207 +67,155 @@
cflags :
- @echo "$(NESSUS_CFLAGS) $(NESSUS_DEFS) -DPACKAGE=\"nessus\" $(INCLUDE)" | sed 's/\"/\\\"/g' > cflags.tmp
+ @echo "$(NESSUS_CFLAGS) $(NESSUS_DEFS) $(INCLUDE)" | sed 's/\"/\\\"/g' > cflags.tmp
@echo "echo \"`cat cflags.tmp`\"" > cflags
@rm cflags.tmp
@chmod +x cflags
-nessus : cflags $(OBJS) $(if $(USE_GTK),$(GTK_OBJS))
- $(CC) $(LDFLAGS) $(OBJS) $(if $(USE_GTK),$(GTK_OBJS)) -o nessus $(LIBS)
+nessus : cflags $(OBJS)
+ $(CC) $(LDFLAGS) $(OBJS) -o nessus $(LIBS)
detached_index.o : cflags detached_index.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c detached_index.c
-context.o : cflags context.c context.h error_dialog.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c context.c
-
-preferences.o : cflags preferences.c preferences.h error_dialog.h globals.h
+preferences.o : cflags preferences.c preferences.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c preferences.c
-prefs_dialog.o : cflags prefs_dialog/prefs_dialog.c prefs_dialog/prefs_dialog.h\
- prefs_dialog/prefs_help.h globals.h context.h prefs_dialog/prefs_context.h\
- error_dialog.h prefs_dialog/prefs_comment.h
+prefs_dialog.o : cflags prefs_dialog/prefs_dialog.c prefs_dialog/prefs_dialog.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog.c
-prefs_scope_tree.o : cflags prefs_dialog/prefs_scope_tree.c error_dialog.h \
- globals.h preferences.h context.h prefs_dialog/prefs_context.h \
- xpm/connected.xpm
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_scope_tree.c
-
-prefs_dialog_misc.o : cflags prefs_dialog/prefs_dialog_misc.c prefs_dialog/prefs_dialog_misc.h globals.h
+prefs_dialog_misc.o : cflags prefs_dialog/prefs_dialog_misc.c prefs_dialog/prefs_dialog_misc.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_misc.c
prefs_dialog_scan_opt.o : cflags prefs_dialog/prefs_dialog_scan_opt.c\
- prefs_dialog/prefs_dialog_scan_opt.h error_dialog.h globals.h
+ prefs_dialog/prefs_dialog_scan_opt.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_scan_opt.c
prefs_target.o : cflags prefs_dialog/prefs_target.c\
- prefs_dialog/prefs_target.h read_target_file.h
+ prefs_dialog/prefs_target.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_target.c
-prefs_dialog_user.o : cflags prefs_dialog/prefs_dialog_user.c globals.h
+prefs_dialog_user.o : cflags prefs_dialog/prefs_dialog_user.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_user.c
-prefs_dialog_auth.o : cflags prefs_dialog/prefs_dialog_auth.c \
- prefs_dialog/prefs_help.h globals.h context.h error_dialog.h
+prefs_dialog_auth.o : cflags prefs_dialog/prefs_dialog_auth.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_auth.c
-prefs_plugins.o : cflags prefs_dialog/prefs_plugins.c error_dialog.h\
- prefs_dialog/prefs_help.h prefs_dialog/prefs_plugins_tree.h\
- globals.h
+prefs_plugins.o : cflags prefs_dialog/prefs_plugins.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_plugins.c
-prefs_plugins_tree.o : cflags prefs_dialog/prefs_plugins_tree.c \
- prefs_dialog/prefs_plugins_tree.h filter.h \
- error_dialog.h prefs_dialog/prefs_help.h globals.h \
- plugin_infos.h families.h xpm/warning_small.xpm
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_plugins_tree.c
-
-prefs_dialog_plugins_prefs.o : cflags prefs_dialog/prefs_dialog_plugins_prefs.c context.h
+prefs_dialog_plugins_prefs.o : cflags prefs_dialog/prefs_dialog_plugins_prefs.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_plugins_prefs.c
-prefs_kb.o : cflags prefs_dialog/prefs_kb.c prefs_dialog/prefs_help.h \
- context.h
+prefs_kb.o : cflags prefs_dialog/prefs_kb.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_kb.c
-prefs_context.o : cflags prefs_dialog/prefs_context.c globals.h context.h \
- preferences.h error_dialog.h prefs_dialog/prefs_comment.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_context.c
-
-prefs_comment.o : cflags prefs_dialog/prefs_comment.c \
- prefs_dialog/prefs_comment.h globals.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_comment.c
-
-prefs_options.o : cflags prefs_dialog/prefs_options.c \
- prefs_dialog/prefs_options.h globals.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_options.c
-
-prefs_report.o : cflags prefs_dialog/prefs_report.c \
- prefs_dialog/prefs_report.h globals.h xpm/computer.xpm xpm/network.xpm \
- xpm/warning_small.xpm xpm/info_small.xpm xpm/error_small.xpm xpm/nothing.xpm
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_report.c
-
-prefs_dialog_prefs.o : cflags prefs_dialog/prefs_dialog_prefs.c \
- prefs_dialog/prefs_dialog_prefs.h globals.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_prefs.c
-
-prefs_scan_assistant.o : cflags prefs_dialog/prefs_scan_assistant.c \
- error_dialog.h context.h prefs_dialog/prefs_context.h \
- prefs_dialog/prefs_scope_tree.h prefs_dialog/prefs_dialog.h \
- prefs_dialog/prefs_dialog_auth.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_scan_assistant.c
-
-error_dialog.o : cflags error_dialog.c error_dialog.h globals.h
+error_dialog.o : cflags error_dialog.c error_dialog.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c error_dialog.c
-families.o : cflags families.c families.h globals.h
+families.o : cflags families.c families.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c families.c
-plugin_infos.o : cflags plugin_infos.c plugin_infos.h globals.h context.h
+plugin_infos.o : cflags plugin_infos.c plugin_infos.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c plugin_infos.c
main_window.o : cflags main_window.c main_window.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c main_window.c
-nsr_output.o : cflags nsr_output.c nsr_output.h error_dialog.h
+nsr_output.o : cflags nsr_output.c nsr_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c nsr_output.c
-nbe_output.o : cflags nbe_output.c nbe_output.h error_dialog.h
+nbe_output.o : cflags nbe_output.c nbe_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c nbe_output.c
-html_output.o : cflags html_output.c html_output.h error_dialog.h globals.h
+html_output.o : cflags html_output.c html_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c html_output.c
-text_output.o : cflags text_output.c text_output.h error_dialog.h globals.h
+text_output.o : cflags text_output.c text_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c text_output.c
-xml_output.o : cflags xml_output.c xml_output.h error_dialog.h globals.h
+xml_output.o : cflags xml_output.c xml_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c xml_output.c
-xml_output_ng.o : cflags xml_output_ng.c error_dialog.h globals.h context.h
+xml_output_ng.o : cflags xml_output_ng.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c xml_output_ng.c
-latex_output.o : cflags latex_output.c latex_output.h globals.h
+latex_output.o : cflags latex_output.c latex_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c latex_output.c
-html_graph_output.o : cflags html_graph_output.c html_graph_output.h error_dialog.h globals.h
+html_graph_output.o : cflags html_graph_output.c html_graph_output.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c html_graph_output.c
-pdf_output.o : cflags pdf_output.c pdf_output.h globals.h
- $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c pdf_output.c
-monitor_dialog.o : cflags monitor_dialog.c monitor_dialog.h globals.h \
- context.h report.h xpm/computer.xpm \
- prefs_dialog/prefs_context.h prefs_dialog/prefs_scope_tree.h
+monitor_dialog.o : cflags monitor_dialog.c monitor_dialog.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c monitor_dialog.c
-backend.o : cflags backend.c backend.h error_dialog.h
+backend.o : cflags backend.c backend.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c backend.c
data_mining.o : cflags data_mining.c data_mining.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c data_mining.c
-
+
+
report_utils.o : cflags report_utils.h report_utils.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c report_utils.c
-
-nessus.o : cflags nessus.c globals.h context.h preferences.h
+nessus.o : cflags nessus.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c nessus.c
-sighand.o : cflags sighand.c sighand.h error_dialog.h context.h backend.h auth.h
+sighand.o : cflags sighand.c sighand.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c sighand.c
-auth.o : cflags auth.c globals.h
+auth.o : cflags auth.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c auth.c
-comm.o : cflags comm.c error_dialog.h globals.h context.h
+comm.o : cflags comm.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c comm.c
-report.o : cflags report.c error_dialog.h globals.h context.h \
- prefs_dialog/prefs_scope_tree.h prefs_dialog/prefs_context.h
+report.o : cflags report.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c report.c
-report_save.o : cflags report_save.c preferences.h context.h error_dialog.h
+report_ng.o : cflags report_ng.c
+ $(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c report_ng.c
+
+report_save.o : cflags report_save.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c report_save.c
-
-parser.o : cflags parser.c error_dialog.h globals.h
+
+
+parser.o : cflags parser.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c parser.c
-attack.o : cflags attack.c globals.h context.h
+attack.o : cflags attack.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c attack.c
-password_dialog.o : cflags password_dialog.c error_dialog.h globals.h
+password_dialog.o : cflags password_dialog.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c password_dialog.c
-
-xstuff.o : cflags xstuff.c globals.h
+xstuff.o : cflags xstuff.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c xstuff.c
-
-cli.o : cflags cli.c cli.h globals.h preferences.h
+cli.o : cflags cli.c cli.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c cli.c
-
-read_target_file.o : cflags read_target_file.c error_dialog.h globals.h
+read_target_file.o : cflags read_target_file.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c read_target_file.c
-prefs_about.o : cflags prefs_dialog/prefs_about.c globals.h \
- xpm/nessus.xpm xpm/logo_tenable.xpm xpm/logo_intevation.xpm xpm/logo_bsi.xpm \
- xpm/logo_bsi_de.xpm
+prefs_about.o : cflags prefs_dialog/prefs_about.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_about.c
-netmap.o : cflags netmap.c globals.h
+netmap.o : cflags netmap.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c netmap.c
regex.o : cflags regex.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c regex.c
-
-filter.o : cflags filter.c error_dialog.h
+
+filter.o : cflags filter.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c filter.c
-
+
+
dirutils.o : cflags dirutils.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c dirutils.c
-sslui.o : cflags sslui.c globals.h xpm/lock.xpm
+sslui.o : cflags sslui.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c sslui.c
-
+
gdchart0.94b/gdc.o : cflags
cd gdchart0.94b && $(MAKE)
Index: attack.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/attack.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- attack.c 21 Dec 2004 15:11:18 -0000 1.19
+++ attack.c 17 Mar 2007 21:35:59 -0000 1.20
@@ -31,7 +31,8 @@
#include "auth.h"
#include "parser.h"
#include "attack.h"
-#include "context.h"
+#include "globals.h"
+#include "error_dialog.h"
#include "preferences.h"
#ifdef ENABLE_CIPHER_LAYER
@@ -48,14 +49,13 @@
*/
#ifdef ENABLE_SAVE_TESTS
void
-restore_attack(session_name, context)
- char * session_name;
- struct context *context;
+restore_attack(session_name, preferences)
+ char * session_name;
+ struct arglist * preferences;
{
- struct arglist * preferences = context->prefs;
- char * plug_list, * old_plug_list;
- struct arglist * plugs = context->plugins;
- struct arglist * scans = context->scanners;
+ char * plug_list;
+ struct arglist * scans = Scanners;
+ struct arglist * plugs = Plugins;
struct arglist * serv_prefs;
int num_plug = 0;
int num_scanners = 0;
@@ -71,32 +71,33 @@
num_scanners++;
scans = scans->next;
}
-
- /*
+
+ plugs = Plugins;
+ scans = Scanners;
+
+
+ /*
* Set up the plugin list, according to the
* Nessus Transfer Protocol version 1.1
*/
- plug_list = emalloc(num_plug*50+1+num_scanners*50+1);
- setup_plug_list(context->plugins, context->scanners, plug_list);
- if(!strlen(plug_list))
- sprintf(plug_list, "0");
-
- /* Add plugin_set to server preferences so it gets sent to the server */
+ plug_list = emalloc(num_plug*20+1+num_scanners*20+1);
+ setup_plug_list(Plugins, Scanners, plug_list);
+ if(plug_list[0] == '\0' ) sprintf(plug_list, "0");
+
serv_prefs = arg_get_value(preferences, "SERVER_PREFS");
- if((old_plug_list = arg_get_value(serv_prefs, "plugin_set")))
+ if(arg_get_value(serv_prefs, "plugin_set"))
{
- efree(&old_plug_list);
arg_set_type(serv_prefs, "plugin_set", ARG_STRING);
arg_set_value(serv_prefs, "plugin_set", strlen(plug_list)+1, plug_list);
- }
+ }
else
arg_add_value(serv_prefs, "plugin_set", ARG_STRING, strlen(plug_list), plug_list);
- comm_send_preferences(context);
- comm_get_preferences_errors(context);
- preferences_save(context);
- comm_send_rules(context);
+ comm_send_preferences(preferences);
+ comm_get_preferences_errors(preferences);
+ preferences_save(Plugins);
+ comm_send_rules(preferences);
comm_restore_session(session_name);
- /* efree(&plug_list); it is stored as SERVER_PREFS[plugin_set] */
+/* efree(&plug_list); */
}
#endif
@@ -114,15 +115,14 @@
* recursive : unused
*
*/
-int
-attack_host(hostname, context)
- char * hostname;
- struct context *context;
+void
+attack_host(hostname, preferences)
+ char * hostname;
+ struct arglist * preferences;
{
- struct arglist * preferences = context->prefs;
- char * plug_list, * old_plug_list;
- struct arglist * plugs = context->plugins;
- struct arglist * scans = context->scanners;
+ char * plug_list;
+ struct arglist * scans = Scanners;
+ struct arglist * plugs = Plugins;
struct arglist * serv_prefs;
int num_plug = 0;
int num_scanners = 0;
@@ -138,33 +138,33 @@
num_scanners++;
scans = scans->next;
}
-
- /*
+
+ plugs = Plugins;
+ scans = Scanners;
+
+
+ /*
* Set up the plugin list, according to the
* Nessus Transfer Protocol version 1.1
*/
- plug_list = emalloc(num_plug*50+1+num_scanners*50+1);
- setup_plug_list(context->plugins, context->scanners, plug_list);
- if(!strlen(plug_list))
- sprintf(plug_list, "0");
-
- /* Add plugin_set to server preferences so it gets sent to the server */
+ plug_list = emalloc(num_plug*20+1+num_scanners*20+1);
+ setup_plug_list(Plugins, Scanners, plug_list);
+ if(plug_list[0] == '\0')sprintf(plug_list, "0");
+
serv_prefs = arg_get_value(preferences, "SERVER_PREFS");
- if((old_plug_list = arg_get_value(serv_prefs, "plugin_set")))
+ if(arg_get_value(serv_prefs, "plugin_set"))
{
- efree(&old_plug_list);
arg_set_type(serv_prefs, "plugin_set", ARG_STRING);
arg_set_value(serv_prefs, "plugin_set", strlen(plug_list)+1, plug_list);
- }
+ }
else
arg_add_value(serv_prefs, "plugin_set", ARG_STRING, strlen(plug_list), plug_list);
- comm_send_preferences(context);
- comm_get_preferences_errors(context);
- preferences_save(context);
- comm_send_rules(context);
+ comm_send_preferences(preferences);
+ comm_get_preferences_errors(preferences);
+ preferences_save(Plugins);
+ comm_send_rules(preferences);
network_printf("CLIENT <|> LONG_ATTACK <|>\n");
network_printf("%d\n", strlen(hostname));
- if(Context->socket > 0)
{
int len = strlen(hostname);
int n = 0;
@@ -177,23 +177,23 @@
{
int e;
if((len - m - n) < size)size = len-m-n;
- e = nsend(context->socket, &(hostname[n+m]), size, 0);
+ e = nsend(GlobalSocket, &(hostname[n+m]), size, 0);
if(e < 0)
{
perror("send ");
- return 0;
+ return;
}
m+=e;
}
n+=m;
}
- /* network_printf("<|> CLIENT\n"); */
- /* network_printf("CLIENT <|> NEW_ATTACK <|> %s <|> CLIENT\n", hostname); */
- /* efree(&plug_list); (stored in SERVER_PREFS arglist) */
- return 1;
- }
- else
- return 0;
+/* network_printf("<|> CLIENT\n"); */
+ /*
+ network_printf("CLIENT <|> NEW_ATTACK <|> %s <|> CLIENT\n",
+ hostname);
+ */
+ efree(&plug_list);
+ }
}
/*
@@ -210,25 +210,23 @@
{
struct arglist * w = NULL;
int i = 0;
+ char * s = plug_list;
for(i=0;i<2;i++)
{
- if(!w)w = plugs;
- else {
- w = scanners;
- }
+ if( w == NULL )w = plugs;
+ else w = scanners;
+
while(w && w->next)
{
- char * sp;
+ char sp[16];
if(plug_get_launch(w->value))
{
- sp = emalloc(9);
- sprintf(sp, "%d", (int)arg_get_value(w->value, "ID"));
- strcat(plug_list, sp);
- efree(&sp);
- strcat(plug_list, ";");
+ snprintf(sp, sizeof(sp), "%d;", (int)arg_get_value(w->value, "ID"));
+ memcpy(plug_list, sp, strlen(sp) + 1);
+ plug_list += strlen(sp);
}
w = w->next;
}
Index: attack.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/attack.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- attack.h 21 Dec 2004 15:11:18 -0000 1.6
+++ attack.h 17 Mar 2007 21:35:59 -0000 1.7
@@ -18,11 +18,11 @@
-int attack_host(char *, struct context *);
+void attack_host(char *, struct arglist *);
void attack_handler();
#ifdef ENABLE_SAVE_TESTS
-void restore_attack(char *, struct context *);
+void restore_attack(char *, struct arglist *);
#endif
Index: auth.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/auth.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- auth.c 26 Sep 2006 17:32:31 -0000 1.26
+++ auth.c 17 Mar 2007 21:35:59 -0000 1.27
@@ -35,6 +35,7 @@
#include "comm.h"
#include "auth.h"
#include "sighand.h"
+#include "globals.h"
#include "password_dialog.h"
/*
@@ -54,10 +55,12 @@
* Note : this function does NOT check if the login/password are
* valid.
*/
+
+extern char * stored_pwd;
-int auth_login(user, password)
- const char * user;
- const char * password;
+int auth_login(user,password)
+ char * user;
+ char * password;
{
char * buf = emalloc(255);
@@ -85,18 +88,16 @@
void network_printf(char * data, ...)
{
va_list param;
- int r, s = 16384;
+ int r, s = 65535;
char * buffer = emalloc(s);
int len, n = 0;
signal(SIGPIPE, sighand_pipe);
va_start(param, data);
- if(Context->socket <= 0)
- return;
for(;;)
{
- r = vsnprintf(buffer, s, data, param);
+ r = vsnprintf(buffer, s - 1, data, param);
if(r >= 0 && r < s)break;
s = r > s ? r + 2 : s * 2;
buffer = erealloc(buffer, s);
@@ -111,7 +112,7 @@
{
int e;
if((len - m - n) < size)size = len - m - n;
- e = nsend(Context->socket, &(buffer[n+m]), size, 0);
+ e = nsend(GlobalSocket, &(buffer[n+m]), size, 0);
if(e < 0) {
perror("send");
return;
@@ -137,15 +138,12 @@
size_t size;
{
int n;
-
- if(Context->socket <= 0)
- return 0;
/* We are assuming that recv_line() will block until it has
* recvieved a full line of data, encountered a hard error, or eof
* (socket close?)
* Also, recv_line will return 0 on error.
*/
- n = recv_line(Context->socket, s, size);
+ n = recv_line(GlobalSocket, s, size);
if (n > 0)
return n;
else
@@ -164,7 +162,7 @@
/* read up until no more data, or a line terminating character
'\0' or '\n' is found */
for (processed = 0; processed < (int)size; processed ++) {
- if ((n = nrecv (Context->socket, s + processed, 1, 0)) <= 0) {
+ if ((n = nrecv (GlobalSocket, s + processed, 1, 0)) <= 0) {
/* on error, the characers read so far might be garbage */
if (n < 0)
processed = 0 ;
Index: auth.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/auth.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- auth.h 3 Nov 2004 14:25:28 -0000 1.7
+++ auth.h 17 Mar 2007 21:35:59 -0000 1.8
@@ -30,7 +30,7 @@
#ifndef _NESSUSC_AUTH_H
#define _NESSUSC_AUTH_H
-int auth_login(const char * , const char * );
+int auth_login(char * , char * );
int network_gets(char * , size_t);
char * network_gets_raw(char * , size_t);
void network_printf(char * data, ...);
Index: backend.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/backend.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- backend.c 22 Sep 2006 20:28:40 -0000 1.28
+++ backend.c 17 Mar 2007 21:35:59 -0000 1.29
@@ -37,7 +37,6 @@
*/
#include <includes.h>
-#include "nessus_i18n.h"
#include "backend.h"
#include "nsr_output.h"
#include "nbe_output.h"
@@ -87,15 +86,13 @@
while((backends[i].fname) && (i<MAX_TMPFILES))i++;
if(backends[i].fname)
{
- show_error(_("No free tempfile!"));
+ show_error("No free tempfile !\n");
return -1;
}
if(!fname)
{
tmpdir = getenv("TMPDIR");
if(!tmpdir)tmpdir = getenv("TEMPDIR");
- if(!tmpdir)tmpdir = getenv("TMP");
- if(!tmpdir)tmpdir = getenv("TEMP");
if(!tmpdir)tmpdir = "/tmp";
tmpfile = emalloc(strlen(tmpdir) + strlen("/nessus-XXXXXX") + 1);
@@ -111,7 +108,7 @@
#endif
if(backends[i].fd < 0)
{
- show_error(_("Can't create file %s: %s"), tmpfile, strerror(errno));
+ show_error(strerror(errno));
efree(&tmpfile);
return -1;
}
@@ -121,7 +118,7 @@
{
if((backends[i].fd = open(fname,O_RDONLY)) < 0)
{
- show_error(_("Can't open file %s: %s"), fname, strerror(errno));
+ show_error(strerror(errno));
return -1;
}
tmpfile = estrdup(fname);
@@ -160,7 +157,7 @@
/*
- * backend_insert_scaninfo_timestamp
+ * backend_inset_scaninfo_timestamp
*/
int
backend_insert_timestamps(be, host, type, time)
@@ -431,12 +428,12 @@
else if(!strcmp(t, "Security Hole"))
buffer = estrdup("REPORT");
else buffer = NULL;
+
if ( buffer == NULL )
{
fprintf(stderr, "Error - line %d is malformed\n", line);
continue;
}
-
content = arg_get_value(port, buffer);
if(!content)
@@ -488,10 +485,7 @@
#ifdef HAVE_MMAP
if(backends[be].mmap)
{
- struct stat buf;
- int len;
- fstat(backends[be].fd, &buf);
- len = (int)buf.st_size;
+ int len = backends[be].mmap_size;
munmap(backends[be].mmap, len);
backends[be].mmap = NULL;
efree(&backends[be].lines);
@@ -615,7 +609,7 @@
{
return nbe_to_backend(fname); /* for now, we only pipe nbe files via stdin */
}
- show_error(_("Unknown report type - please set an extension to the filename"));
+ show_error("Unknown report type - please set an extension to the filename");
return -1;
}
@@ -629,6 +623,6 @@
return nbe_to_backend(fname);
}
- show_error(_("This file format can not be read back by the Nessus client"));
+ show_error("This file format can not be read back by the Nessus client");
return -1;
}
Index: backend.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/backend.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- backend.h 9 Mar 2003 14:33:26 -0000 1.6
+++ backend.h 17 Mar 2007 21:35:59 -0000 1.7
@@ -29,6 +29,7 @@
int disposable;
#ifdef HAVE_MMAP
char * mmap;
+ int mmap_size;
int mmap_attempts;
char ** lines;
char ** eols;
Index: cli.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/cli.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- cli.c 21 Dec 2004 15:12:45 -0000 1.45
+++ cli.c 17 Mar 2007 21:35:59 -0000 1.46
@@ -37,8 +37,6 @@
#include "globals.h"
#include "nessus.h"
-#include "context.h"
-#include "preferences.h"
#include "parser.h"
#include "cli.h"
@@ -122,14 +120,14 @@
for(i=0;i<num;i++)
{
- struct arglist * plugs = Context->plugins;
+ struct arglist * plugs = Plugins;
while(plugs && plugs->next &&
((int)(arg_get_value(plugs->value, "ID"))!=plugins_order_table_int[i]))
plugs = plugs->next;
if(!(plugs && plugs->next))
{
- plugs = Context->scanners;
+ plugs = Scanners;
while(plugs && plugs->next &&
((int)(arg_get_value(plugs->value, "ID"))!=plugins_order_table_int[i]))
plugs = plugs->next;
@@ -176,7 +174,7 @@
*/
if(network_gets(buf, sizeof(buf) - 1) < 0 || buf[0] == '\0')
{
- if(!is_server_present(Context->socket))
+ if(!is_server_present(GlobalSocket))
{
fprintf(stderr, "nessus: nessusd abruptly shut the communication down - the test may be incomplete\n");
finished = 1;
@@ -417,19 +415,21 @@
struct cli_args * cli;
{
/*ENABLE_CRYPTO_LAYER*/
+ char * pwd = cli->password;
char * err;
- prefs_set_string(Context, "nessusd_host", cli->server);
- prefs_set_int(Context, "nessusd_port", cli->port);
- prefs_set_string(Context, "nessusd_user", cli->login);
- Context->passwd = cli->password;
- err = connect_to_nessusd(Context);
-
+ err = connect_to_nessusd(cli->server,
+ cli->port,
+ cli->login,
+ pwd);
+
if(err)
{
fprintf(stderr, "nessus : %s\n", err);
return -1;
}
+ bzero(cli->login, strlen(cli->login));
+ bzero(cli->password, strlen(cli->password));
return 0;
}
@@ -445,13 +445,9 @@
return -1;
}
- if(attack_host(target_list, Context))
- {
- cli_test_monitor(cli);
- return 0;
- }
- else
- return -1;
+ attack_host(target_list, Prefs);
+ cli_test_monitor(cli);
+ return 0 ;
}
void
@@ -656,8 +652,8 @@
printf(" bugtraq_id varchar(255),\n");
printf(" xref blob,\n");
printf(" primary key (id));\n");
- _cli_sql_dump_plugins(Context->plugins);
- _cli_sql_dump_plugins(Context->scanners);
+ _cli_sql_dump_plugins(Plugins);
+ _cli_sql_dump_plugins(Scanners);
}
@@ -665,15 +661,15 @@
cli_dump_plugins(cli)
struct cli_args * cli;
{
- _cli_dump_plugins(Context->plugins);
- _cli_dump_plugins(Context->scanners);
+ _cli_dump_plugins(Plugins);
+ _cli_dump_plugins(Scanners);
}
static void
_cli_dump_pprefs()
{
- struct arglist * p = arg_get_value(Context->prefs, "PLUGINS_PREFS");
+ struct arglist * p = arg_get_value(Prefs, "PLUGINS_PREFS");
if(!p)
return;
@@ -706,7 +702,7 @@
cli_dump_prefs(cli)
struct cli_args * cli;
{
- struct arglist * p = arg_get_value(Context->prefs, "SERVER_PREFS");
+ struct arglist * p = arg_get_value(Prefs, "SERVER_PREFS");
if(!p)
return;
@@ -725,8 +721,8 @@
}
- if(Context->plugins)_cli_dump_pprefs(Context->plugins);
- if(Context->scanners)_cli_dump_pprefs(Context->scanners);
+ if(Plugins)_cli_dump_pprefs(Plugins);
+ if(Scanners)_cli_dump_pprefs(Scanners);
return;
}
@@ -734,7 +730,7 @@
cli_close_connection(cli)
struct cli_args * cli;
{
- return close_stream_connection(Context->socket);
+ return close_stream_connection(GlobalSocket);
}
#ifdef ENABLE_SAVE_TESTS
@@ -743,7 +739,7 @@
struct cli_args * cli;
char * session;
{
- restore_attack(session, Context);
+ restore_attack(session, Prefs);
cli_test_monitor(cli);
}
void
@@ -751,19 +747,19 @@
struct cli_args * cli;
{
hargwalk * hw;
- if(!comm_server_restores_sessions(Context))
+ if(!comm_server_restores_sessions(Prefs))
printf("** The remote nessusd server does not support session-saving\n");
else
{
char * key;
- hw = harg_walk_init(Context->sessions);
+ hw = harg_walk_init(Sessions);
printf("Remote sessions :\n");
printf("-----------------\n\n");
printf("Session ID | Targets\n");
printf("==========================\n");
while((key = (char*)harg_walk_next(hw)))
{
- printf("%s | %s\n", key, harg_get_string(Context->sessions, key));
+ printf("%s | %s\n", key, harg_get_string(Sessions, key));
}
}
}
Index: comm.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/comm.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- comm.c 22 Sep 2006 20:28:40 -0000 1.80
+++ comm.c 17 Mar 2007 21:36:00 -0000 1.81
@@ -28,18 +28,12 @@
*
* Nessus Communication Manager -- it manages the NTP Protocol, version 1.1
*
- */
-
+ */
+
#include <includes.h>
-#include "nessus_i18n.h"
-#ifdef USE_GTK
[...1890 lines suppressed...]
- s = NULL;
- }
- arg_add_value(context->dependencies, name, ARG_ARGLIST, -1, deps);
+ {
+ t[0] = '\0';
+ arg_add_value(deps, s, ARG_INT, (sizeof(int)), (void*)1);
+ s = t + 5;
}
- network_gets(buff, sizeof(buff) - 1);
+ else s = NULL;
+ }
+ arg_add_value(Dependencies, name, ARG_ARGLIST, -1, deps);
}
- }
- return 0;
+ network_gets(buff, sizeof(buff)-1);
+ }
+ }
+ return 0;
}
Index: comm.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/comm.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- comm.h 3 Nov 2004 14:25:28 -0000 1.13
+++ comm.h 17 Mar 2007 21:36:00 -0000 1.14
@@ -30,30 +30,30 @@
#ifndef _NESSUSC_COMM_H
#define _NESSUSC_COMM_H
-#include "context.h"
int comm_init(int,char*);
int comm_get_pluginlist();
-int comm_get_preferences(struct context *);
-int comm_get_rules(struct context *);
+int comm_get_preferences(struct arglist *);
+int cli_comm_get_preferences(struct arglist *);
+int comm_get_rules(struct arglist *);
-int comm_get_plugins(struct context *);
+int comm_get_plugins();
-int comm_send_preferences(struct context *);
-int comm_send_long_preferences(struct context *);
-int comm_send_rules(struct context *);
-void comm_get_preferences_errors(struct context*);
+int comm_send_preferences(struct arglist *);
+int comm_send_long_preferences(struct arglist*);
+int comm_send_rules(struct arglist *);
+void comm_get_preferences_errors(struct arglist *);
harglst * comm_get_sessions();
-int comm_server_restores_sessions(struct context *);
-int comm_server_detached_sessions(struct context *);
+int comm_server_restores_sessions(struct arglist *);
+int comm_server_detached_sessions(struct arglist *);
void comm_delete_session(char*);
void comm_restore_session(char*);
void comm_stop_detached_session( char *name);
int comm_plugin_upload(char*);
-int comm_get_dependencies(struct context*);
+int comm_get_dependencies();
#ifdef ENABLE_SAVE_TESTS
harglst * comm_get_detached_sessions(void);
Index: data_mining.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/data_mining.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- data_mining.c 21 Dec 2004 19:21:08 -0000 1.27
+++ data_mining.c 17 Mar 2007 21:36:00 -0000 1.28
@@ -178,13 +178,15 @@
char ** lines;
char ** eols;
char * sol, * eol;
+ char * eof = NULL;
lines = emalloc(num_allocated_lines*sizeof(*lines));
eols = emalloc(num_allocated_lines*sizeof(*eols));
sol = backends[be].mmap;
+ eof = sol + backends[be].mmap_size;
num_lines = 0;
- while(sol)
+ while(sol != NULL && sol != eof )
{
eol = strchr(sol, '\n');
lines[num_lines] = sol;
@@ -279,9 +281,9 @@
int len;
fstat(backends[be].fd, &buf);
len = (int)buf.st_size;
+ backends[be].mmap_size = len;
if((backends[be].mmap =
- mmap(NULL, len, PROT_READ, MAP_SHARED, backends[be].fd, 0))
- == MAP_FAILED)
+ mmap(NULL, len, PROT_READ, MAP_SHARED, backends[be].fd, 0)) == MAP_FAILED)
backends[be].mmap = NULL;
else
be_mk_index(be);
@@ -1188,7 +1190,14 @@
struct query * query;
{
struct subset * ret = NULL;
- static char buf[1048576];
+ static char *buf = NULL;
+ static int buf_sz = 0;
+
+ if ( buf == NULL ) {
+ buf_sz = 1024*1024;
+ buf = emalloc(buf_sz);
+ }
+
#ifdef HAVE_MMAP
if(backends[be].mmap) backends[be].cur_line = 0;
else
@@ -1219,7 +1228,6 @@
{
int j;
char * val = NULL;
- char buf[1048576];
char * table;
char * subnet;
char * hostname;
@@ -1227,7 +1235,7 @@
char * plugin_id;
char * severity;
char * data;
- mmap_read_line_n(be, buf, sizeof(buf), i);
+ mmap_read_line_n(be, buf, buf_sz, i);
__split_line(buf, &table, &subnet, &hostname, &port, &plugin_id, &severity, &data);
for(j=0;j<query->num;j++)
{
@@ -1268,7 +1276,7 @@
return ret;
}
#endif
- while(read_line(be,buf, sizeof(buf)) > 0)
+ while(read_line(be,buf, buf_sz ) > 0)
{
char * table;
char * subnet;
Index: detached_index.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/detached_index.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- detached_index.c 3 Nov 2004 14:25:29 -0000 1.10
+++ detached_index.c 17 Mar 2007 21:36:00 -0000 1.11
@@ -29,6 +29,7 @@
#include <includes.h>
#ifdef USE_GTK
+#include "gtk-compat.h"
#include <gtk/gtk.h>
#include "xstuff.h"
#ifdef ENABLE_SAVE_TESTS
@@ -96,7 +97,7 @@
struct arglist * ret = emalloc(sizeof(*ret));
char * titles[] = {"Session ID", "Targets"};
- window = gtk_window_new(GTK_WINDOW_POPUP);
+ window = gtk_window_new(WINDOW_DIALOG);
gtk_window_set_title(GTK_WINDOW(window), "Detached sessions");
gtk_widget_set_usize(GTK_WIDGET(window), 640, 480);
gtk_container_border_width(GTK_CONTAINER(window), 10);
@@ -122,7 +123,11 @@
gtk_widget_show(scrolled);
clist = gtk_clist_new_with_titles(2, titles);
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), clist);
+ #if GTK_VERSION < 11
+ gtk_container_add(GTK_CONTAINER(scrolled),clist);
+#else
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), clist);
+#endif
gtk_widget_show(clist);
arg_add_value(ret, "CLIST", ARG_PTR, -1, clist);
gtk_widget_show(clist);
@@ -182,11 +187,13 @@
i++;
}
harg_walk_stop(hw);
+#if GTK_VERSION > 10
gtk_clist_sort(GTK_CLIST(clist));
gtk_clist_set_column_width(GTK_CLIST(clist),
0,
gtk_clist_optimal_column_width(GTK_CLIST(clist), 0)
);
+#endif
gtk_clist_thaw(GTK_CLIST(clist));
Index: error_dialog.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/error_dialog.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- error_dialog.c 22 Nov 2004 10:49:53 -0000 1.27
+++ error_dialog.c 17 Mar 2007 21:36:00 -0000 1.28
@@ -1,278 +1,291 @@
-/* $Id$
+/* Nessus
+ * Copyright (C) 1998 - 2001 Renaud Deraison
*
- * Copyright (C) 2004 by Intevation GmbH
- * Author(s):
- * Thomas Arendsen Hein <thomas@intevation.de>
- * Jan-Oliver Wagner <jan@intevation.de>
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation
*
- * This program is free software under the GNU GPL (>=v2)
- * Read the file COPYING coming with the software for details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * In addition, as a special exception, Intevation GmbH gives
- * permission to link the code of this program with the OpenSSL
- * library (or with modified versions of OpenSSL that use the same
- * license as OpenSSL), and distribute linked combinations including
- * the two. You must obey the GNU General Public License in all
- * respects for all of the code used other than OpenSSL. If you
- * modify this file, you may extend this exception to your version
- * of the file, but you are not obligated to do so. If you do not
- * wish to do so, delete this exception statement from your version.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * In addition, as a special exception, Renaud Deraison
+ * gives permission to link the code of this program with any
+ * version of the OpenSSL library which is distributed under a
+ * license identical to that listed in the included COPYING.OpenSSL
+ * file, and distribute linked combinations including the two.
+ * You must obey the GNU General Public License in all respects
+ * for all of the code used other than OpenSSL. If you modify
+ * this file, you may extend this exception to your version of the
+ * file, but you are not obligated to do so. If you do not wish to
+ * do so, delete this exception statement from your version.
*/
-
+
#include <includes.h>
-#include <stdarg.h>
-
#include "globals.h"
-#include "error_dialog.h"
-#include "nessus_i18n.h"
-
-#ifdef USE_GTK
-#include <gtk/gtk.h>
-#endif
-
-#define DIALOG_TYPE_INFO 0
-#define DIALOG_TYPE_WARNING 1
-#define DIALOG_TYPE_ERROR 2
-
-#define DIALOG_NORMAL 0
-#define DIALOG_AND_WAIT 1
-
+#ifndef USE_GTK
-void
-show_dialog_std(type, wait, fmt, ap)
- int type;
- int wait;
- char *fmt;
- va_list ap;
+void
+show_dialog_and_wait
+ (char * error_text, int type)
{
- fprintf(stderr, "*** ");
- switch(type)
- {
- case DIALOG_TYPE_INFO:
- fprintf(stderr, _("Info: "));
- break;
- case DIALOG_TYPE_WARNING:
- fprintf(stderr, _("Warning: "));
- break;
- default: /* DIALOG_TYPE_ERROR or other */
- fprintf(stderr, _("Error: "));
- }
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- if(wait == DIALOG_AND_WAIT)
- {
- fprintf(stderr, _("Press <Enter> to continue ...\n"));
- getchar();
- }
+ fprintf(stderr, "*** %s\n", error_text);
+ fprintf(stderr, "press 'enter' to continue\n");
+ getchar();
}
-
-
-#ifdef USE_GTK
-void
-show_dialog_gtk_close(dialog, response_id, dialog_running)
- GtkDialog *dialog;
- gint response_id;
- gboolean *dialog_running;
+void
+show_dialog
+ (char * error_text, int type)
{
- gtk_widget_destroy(GTK_WIDGET(dialog));
- *dialog_running = FALSE;
+ fprintf (stderr, "*** %s\n", error_text);
}
+#else /* USE_GTK */
+#include "gtk-compat.h"
+#include <gtk/gtk.h>
+#include "xpm/error.xpm"
+#include "xpm/warning.xpm"
+#include "xpm/info.xpm"
+#include "xstuff.h"
+#include "error_dialog.h"
+#include "globals.h"
-void
-show_dialog_gtk_popup(type, wait, error_text)
- int type;
- int wait;
- char *error_text;
-{
- void *context_window = arg_get_value(MainDialog, "CONTEXT");
- GtkWindow *window;
- GtkWidget *dialog;
- int messagetype;
- static gboolean dialog_running = FALSE;
- while(dialog_running)
- gtk_main_iteration_do(TRUE);
- if(context_window)
- window = GTK_WINDOW(context_window);
+
+/*
+ * show_error
+ *
+ * This function draws a dialog showing an error
+ *
+ */
+
+
+void
+show_dialog(error_text, type)
+ char * error_text;
+ int type;
+{
+ if(F_quiet_mode)fprintf(stderr, "%s\n", error_text);
else
{
- window = NULL;
- wait = DIALOG_AND_WAIT;
- }
-
- /*
- * XXX
- * Always wait. This can be removed if other windows are created
- * using a common function which sets "dialog_running", too.
- */
- wait = DIALOG_AND_WAIT;
+ GtkWidget * dialog;
+ GtkWidget * button;
+ GtkWidget * vbox;
+ GtkWidget * hbox;
+ GtkWidget * label;
+ GtkStyle * style;
+ GtkWidget * pixmapwid;
+ GdkPixmap * pixmap;
+ GdkBitmap * mask;
+ GtkWidget * table;
+ char * name;
switch(type)
{
- case DIALOG_TYPE_INFO:
- messagetype = GTK_MESSAGE_INFO;
- break;
- case DIALOG_TYPE_WARNING:
- messagetype = GTK_MESSAGE_WARNING;
- break;
- default: /* DIALOG_TYPE_ERROR or other */
- messagetype = GTK_MESSAGE_ERROR;
+ case DIALOG_TYPE_INFO :
+ name = "Info";
+ break;
+ case DIALOG_TYPE_WARNING :
+ name = "Warning";
+ break;
+ case DIALOG_TYPE_ERROR :
+ default :
+ name = "Error";
+ break;
}
+
+ #if GTK_VERSION < 20
+ dialog = gtk_window_new(WINDOW_DIALOG);
+ #else
+ dialog = gtk_dialog_new();
+ #endif
+ gtk_window_set_title(GTK_WINDOW(dialog), name);
+ gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
+ GTK_SIGNAL_FUNC (delete_event), NULL);
+ gtk_window_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+ #if GTK_VERSION < 20
+ vbox = gtk_vbox_new(FALSE, 15);
+ gtk_container_border_width(GTK_CONTAINER(dialog), 10);
+ gtk_container_add(GTK_CONTAINER(dialog), vbox);
+ gtk_widget_show(vbox);
+ #else
+ vbox = GTK_DIALOG(dialog)->vbox;
+ #endif
+
+ hbox = gtk_hbox_new(FALSE,5);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE,0);
+ gtk_widget_show(hbox);
- /* create the user dialog */
- dialog = gtk_message_dialog_new(window, 0, messagetype,
- wait == DIALOG_AND_WAIT ? GTK_BUTTONS_OK : GTK_BUTTONS_CLOSE,
- "%s", error_text);
-
- if(wait == DIALOG_AND_WAIT)
+ label = gtk_label_new(error_text);
+ gtk_label_set_justify (GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 3);
+ gtk_widget_show(label);
+
+
+
+ button = gtk_button_new_with_label ("OK");
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (close_window), dialog);
+
+ table = gtk_table_new(1,3, TRUE);
+ gtk_box_pack_end(GTK_BOX(vbox), table, TRUE, TRUE, 0);
+ gtk_widget_show(table);
+
+
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 2,3,0,1);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default (button);
+ gtk_widget_show (button);
+ gtk_widget_realize(dialog);
+
+ style = gtk_widget_get_style(dialog);
+ if(F_show_pixmaps)
{
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
+ char** data;
+ switch(type)
+ {
+ case DIALOG_TYPE_INFO :
+ data = info_xpm;
+ break;
+ case DIALOG_TYPE_WARNING :
+ data = warning_xpm;
+ break;
+ case DIALOG_TYPE_ERROR :
+ default :
+ data = error_xpm;
+ break;
}
- else
- {
- dialog_running = TRUE;
- gtk_widget_show(dialog);
- g_signal_connect(dialog, "response",
- G_CALLBACK(show_dialog_gtk_close),
- &dialog_running);
+ pixmap = gdk_pixmap_create_from_xpm_d(dialog->window, &mask,
+ &style->bg[GTK_STATE_NORMAL],
+ (char **)data);
+ pixmapwid = gtk_pixmap_new(pixmap, mask);
+
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwid, FALSE, TRUE,3);
+ gtk_widget_show(pixmapwid);
}
-}
+ gtk_widget_show(dialog);
+ }
+}
-void
-show_dialog_gtk_log(type, error_text)
- int type;
- char *error_text;
-{
- GtkWidget *textview = arg_get_value(MainDialog, "MSGLOGTEXT");
- GtkWidget *scrolledwin = arg_get_value(MainDialog, "MSGLOGSCROLL");
- GtkTextBuffer *log;
- GtkTextIter iter;
- GtkAdjustment *vadjust;
- char *msgtype;
- if(!textview || !scrolledwin)
- return;
+static void show_dialog_and_wait_cb(gw, ok)
+ GtkWidget* gw;
+ int *ok;
+{
+ GtkWidget* dialog = gw->parent->parent->parent;
+ gtk_grab_remove(dialog);
+ close_window(NULL, dialog);
+ gtk_widget_destroy(dialog);
+ *ok = 1;
+ gtk_main_quit();
+}
+void show_dialog_and_wait_build(int * ok, char * error_text, int type)
+{
+ GtkWidget * dialog;
+ GtkWidget * button;
+ GtkWidget * vbox;
+ GtkWidget * hbox;
+ GtkWidget * label;
+ GtkStyle * style;
+ GtkWidget * pixmapwid;
+ GdkPixmap * pixmap;
+ GdkBitmap * mask;
+ GtkWidget * table;
+ char * name;
switch(type)
{
- case DIALOG_TYPE_INFO:
- msgtype = _("Info: ");
- break;
- case DIALOG_TYPE_WARNING:
- msgtype = _("Warning: ");
- break;
- default: /* DIALOG_TYPE_ERROR or other */
- msgtype = _("Error: ");
+ case DIALOG_TYPE_INFO :
+ name = "Info";
+ break;
+ case DIALOG_TYPE_WARNING :
+ name = "Warning";
+ break;
+ case DIALOG_TYPE_ERROR :
+ default :
+ name = "Error";
+ break;
}
+ dialog = gtk_window_new(WINDOW_DIALOG);
+ gtk_widget_realize(dialog);
+ gtk_window_set_title(GTK_WINDOW(dialog), name);
+ gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
+ GTK_SIGNAL_FUNC (show_dialog_and_wait_cb), ok);
+ gtk_window_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+ vbox = gtk_vbox_new(FALSE, 15);
+ gtk_container_border_width(GTK_CONTAINER(dialog), 10);
+ gtk_container_add(GTK_CONTAINER(dialog), vbox);
+ gtk_widget_show(vbox);
+
+ hbox = gtk_hbox_new(FALSE,5);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE,0);
+ gtk_widget_show(hbox);
- /* submit the message to the log */
- log = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
- gtk_text_buffer_get_end_iter(log, &iter);
- gtk_text_buffer_insert(log, &iter, msgtype, -1);
- gtk_text_buffer_get_end_iter(log, &iter);
- gtk_text_buffer_insert(log, &iter, error_text, -1);
- gtk_text_buffer_get_end_iter(log, &iter);
- gtk_text_buffer_insert(log, &iter, "\n", -1);
-
- vadjust = gtk_scrolled_window_get_vadjustment(
- GTK_SCROLLED_WINDOW(scrolledwin));
- gtk_adjustment_set_value(vadjust, vadjust->upper - 1);
+ label = gtk_label_new(error_text);
+ gtk_label_set_justify (GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 3);
+ gtk_widget_show(label);
+
+
+
+ button = gtk_button_new_with_label ("OK");
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (show_dialog_and_wait_cb), ok);
+
+ table = gtk_table_new(1,3, TRUE);
+ gtk_box_pack_end(GTK_BOX(vbox), table, TRUE, TRUE, 0);
+ gtk_widget_show(table);
+
+
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 2,3,0,1);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default (button);
+ gtk_widget_show (button);
+ gtk_widget_realize(dialog);
+
+ style = gtk_widget_get_style(dialog);
+ if(F_show_pixmaps)
+ {
+ char** data;
+ switch(type)
+ {
+ case DIALOG_TYPE_INFO :
+ data = info_xpm;
+ break;
+ case DIALOG_TYPE_WARNING :
+ data = warning_xpm;
+ break;
+ case DIALOG_TYPE_ERROR :
+ default :
+ data = error_xpm;
+ break;
+ }
+ pixmap = gdk_pixmap_create_from_xpm_d(dialog->window, &mask,
+ &style->bg[GTK_STATE_NORMAL],
+ (char **)data);
+ pixmapwid = gtk_pixmap_new(pixmap, mask);
+
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwid, FALSE, TRUE,3);
+ gtk_widget_show(pixmapwid);
+ }
+ gtk_widget_show(dialog);
+ gtk_grab_add(dialog);
}
-void
-show_dialog_gtk(type, wait, fmt, ap)
- int type;
- int wait;
- char *fmt;
- va_list ap;
+void show_dialog_and_wait(char * error, int type)
{
- char *error_text = g_strdup_vprintf(fmt, ap);
-
- show_dialog_gtk_log(type, error_text);
- show_dialog_gtk_popup(type, wait, error_text);
- g_free(error_text);
+ int ok = 0;
+ if(F_quiet_mode)fprintf(stderr, "%s\n", error);
+ else
+ {
+ show_dialog_and_wait_build(&ok, error, type);
+ gtk_main();
+ }
}
+
#endif
-
-
-void
-show_dialog(type, wait, fmt, ap)
- int type;
- int wait;
- char *fmt;
- va_list ap;
-{
-#ifdef USE_GTK
- if(!F_quiet_mode)
- show_dialog_gtk(type, wait, fmt, ap);
- else
-#endif /* USE_GTK */
- show_dialog_std(type, wait, fmt, ap);
-}
-
-/*
- * functions called by the application
- */
-
-void
-show_error(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- show_dialog(DIALOG_TYPE_ERROR, DIALOG_NORMAL, fmt, ap);
- va_end(ap);
-}
-
-void
-show_warning(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- show_dialog(DIALOG_TYPE_WARNING, DIALOG_NORMAL, fmt, ap);
- va_end(ap);
-}
-
-void
-show_info(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- show_dialog(DIALOG_TYPE_INFO, DIALOG_NORMAL, fmt, ap);
- va_end(ap);
-}
-
-
-void
-show_error_and_wait(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- show_dialog(DIALOG_TYPE_ERROR, DIALOG_AND_WAIT, fmt, ap);
- va_end(ap);
-}
-
-void
-show_warning_and_wait(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- show_dialog(DIALOG_TYPE_WARNING, DIALOG_AND_WAIT, fmt, ap);
- va_end(ap);
-}
-
-void
-show_info_and_wait(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- show_dialog(DIALOG_TYPE_INFO, DIALOG_AND_WAIT, fmt, ap);
- va_end(ap);
-}
Index: error_dialog.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/error_dialog.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- error_dialog.h 8 Nov 2004 19:21:21 -0000 1.8
+++ error_dialog.h 17 Mar 2007 21:36:00 -0000 1.9
@@ -1,32 +1,40 @@
-/* $Id$
+/* Nessuslib -- the Nessus Library
+ * Copyright (C) 1998 Renaud Deraison
*
- * Copyright (C) 2004 by Intevation GmbH
- * Author(s):
- * Thomas Arendsen Hein <thomas@intevation.de>
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
*
- * This program is free software under the GNU GPL (>=v2)
- * Read the file COPYING coming with the software for details.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
*
- * In addition, as a special exception, Intevation GmbH gives
- * permission to link the code of this program with the OpenSSL
- * library (or with modified versions of OpenSSL that use the same
- * license as OpenSSL), and distribute linked combinations including
- * the two. You must obey the GNU General Public License in all
- * respects for all of the code used other than OpenSSL. If you
- * modify this file, you may extend this exception to your version
- * of the file, but you are not obligated to do so. If you do not
- * wish to do so, delete this exception statement from your version.
- */
-
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
#ifndef _NESSUSC_ERROR_DIALOG_H
#define _NESSUSC_ERROR_DIALOG_H
-extern void show_error(char *, ...);
-extern void show_warning(char *, ...);
-extern void show_info(char *, ...);
+#define DIALOG_TYPE_INFO 0
+#define DIALOG_TYPE_WARNING 1
+#define DIALOG_TYPE_ERROR 2
-extern void show_error_and_wait(char *, ...);
-extern void show_warning_and_wait(char *, ...);
-extern void show_info_and_wait(char *, ...);
+
+#define show_error(x) show_dialog(x, DIALOG_TYPE_ERROR)
+#define show_warning(x) show_dialog(x, DIALOG_TYPE_WARNING)
+#define show_info(x) show_dialog(x, DIALOG_TYPE_INFO)
+
+#define show_error_and_wait(x) show_dialog_and_wait(x, DIALOG_TYPE_ERROR)
+#define show_warning_and_wait(x) show_dialog_and_wait(x, DIALOG_TYPE_WARNING)
+#define show_info_and_wait(x) show_dialog_and_wait(x, DIALOG_TYPE_INFO)
+
+
+extern void show_dialog(char * error_text, int type);
+extern void show_dialog_and_wait_build(int * ok, char * error_text, int type);
+extern void show_dialog_and_wait(char * error, int type);
#endif
Index: families.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/families.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- families.c 10 Dec 2004 08:04:37 -0000 1.17
+++ families.c 17 Mar 2007 21:36:00 -0000 1.18
@@ -103,6 +103,26 @@
case DISABLE_FAMILY :
plug_set_launch(plugins->value, 0);
break;
+ case ENABLE_FAMILY_BUT_DOS :
+ {
+ char* category = arg_get_value(plugins->value, "CATEGORY");
+ if(category && (
+ !strcmp(category, "denial") ||
+ !strcmp(category, "kill_host") ||
+ !strcmp(category, "flood") ||
+ !strcmp(category, "destructive_attack")
+ )
+ )
+ plug_set_launch(plugins->value, 0);
+ else
+ {
+ if(!filter_plugin(&Filter, plugins->value))
+ plug_set_launch(plugins->value, 1);
+ else
+ plug_set_launch(plugins->value, 0);
+ }
+ break;
+ }
case ENABLE_FAMILY :
if(!filter_plugin(&Filter, plugins->value))
plug_set_launch(plugins->value, 1);
Index: families.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/families.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- families.h 10 Dec 2004 08:04:37 -0000 1.6
+++ families.h 17 Mar 2007 21:36:00 -0000 1.7
@@ -21,6 +21,7 @@
#define ENABLE_FAMILY 1
#define DISABLE_FAMILY 0
+#define ENABLE_FAMILY_BUT_DOS 2
struct plugin_families {
char * name;
Index: filter.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/filter.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- filter.c 11 Nov 2004 17:23:39 -0000 1.15
+++ filter.c 17 Mar 2007 21:36:00 -0000 1.16
@@ -27,8 +27,6 @@
*/
#include <includes.h>
-#include "nessus_i18n.h"
-#include "globals.h"
#ifdef USE_GTK
#ifdef HAVE_REGEX_SUPPORT
#include <regex.h>
@@ -54,29 +52,56 @@
static int filter_on_xref = 0;
+static void
+ask_filter_callback(u1, ctrls)
+ GtkWidget * u1;
+ struct arglist * ctrls;
+{
+ GtkWidget * w = arg_get_value(ctrls, "WINDOW");
+ gtk_widget_hide(w);
+ if(arg_get_value(ctrls,"CANCEL") == u1)
+ {
+ arg_add_value(ctrls, "FILTER", ARG_STRING, 0, (void*)(-1));
+ return;
+ }
+ else {
+ char * filter = (char*)gtk_entry_get_text(GTK_ENTRY(arg_get_value(ctrls,"ENTRY")));
+ filter_on_name = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_NAME"))->active;
+ filter_on_description = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_DESCRIPTION"))->active;
+ filter_on_summary = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_SUMMARY"))->active;
+ filter_on_author = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_AUTHOR"))->active;
+ filter_on_id = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_ID"))->active;
+ filter_on_category = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_CATEGORY"))->active;
+ filter_on_bid = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_BID"))->active;
+ filter_on_cve = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_CVE"))->active;
+ filter_on_xref = GTK_TOGGLE_BUTTON(arg_get_value(ctrls, "FILTER_XREF"))->active;
+ arg_add_value(ctrls, "FILTER", ARG_STRING,filter ? strlen(filter):0, filter);
+ }
+}
+
static struct arglist *
build_filter_dlog()
{
- GtkWindow * window = GTK_WINDOW(arg_get_value(MainDialog, "WINDOW"));
- GtkWidget * dialog;
- GtkWidget * label, *sep, * button, *entry;
+ GtkWidget * w, * label, *sep, * button, *entry;
GtkWidget * box, *hbox, *frame,*vbox;
struct arglist * ctrls = emalloc(sizeof(struct arglist));
+
+
+ w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(w), "Filter plugins...");
+
+ gtk_container_border_width(GTK_CONTAINER(w), 6);
+ arg_add_value(ctrls, "WINDOW", ARG_PTR, -1, w);
+ gtk_window_position(GTK_WINDOW(w), GTK_WIN_POS_CENTER);
+ gtk_widget_realize(w);
+
+ box = gtk_vbox_new(FALSE, 6);
+ gtk_container_add(GTK_CONTAINER(w), box);
+ gtk_widget_show(box);
- dialog = gtk_dialog_new_with_buttons(_("Filter plugins..."), window,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
- gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
- gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
-
- arg_add_value(ctrls, "WINDOW", ARG_PTR, -1, dialog);
-
- /* The overall vbox */
- box = GTK_DIALOG(dialog)->vbox;
-
- label = gtk_label_new(_("Filter plugins..."));
+
+
+ label = gtk_label_new("Filter plugins...");
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 1);
gtk_widget_show(label);
sep = gtk_hseparator_new();
@@ -88,7 +113,7 @@
hbox = gtk_hbox_new(FALSE, FALSE);
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 3);
- label = gtk_label_new(_("Pattern:"));
+ label = gtk_label_new("Pattern : ");
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 6);
gtk_widget_show(label);
@@ -98,7 +123,7 @@
gtk_widget_show(entry);
gtk_widget_show(hbox);
- frame = gtk_frame_new(_("Filter on:"));
+ frame = gtk_frame_new("Filter on : ");
gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 6);
vbox = gtk_vbox_new(FALSE, FALSE);
gtk_container_border_width(GTK_CONTAINER(frame), 6);
@@ -106,56 +131,56 @@
gtk_widget_show(vbox);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("Name"));
+ button = gtk_check_button_new_with_label("Name");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_NAME", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_name);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("Description"));
+ button = gtk_check_button_new_with_label("Description");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_DESCRIPTION", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_description);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("Summary"));
+ button = gtk_check_button_new_with_label("Summary");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_SUMMARY", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_summary);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("Author"));
+ button = gtk_check_button_new_with_label("Author");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_AUTHOR", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_author);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("ID number"));
+ button = gtk_check_button_new_with_label("ID number");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_ID", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_id);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("Category"));
+ button = gtk_check_button_new_with_label("Category");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_CATEGORY", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_category);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("CVE"));
+ button = gtk_check_button_new_with_label("CVE");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_CVE", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_cve);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("BID"));
+ button = gtk_check_button_new_with_label("BID");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_BID", ARG_PTR, -1, button);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), filter_on_bid);
/*--------------------------------------------*/
- button = gtk_check_button_new_with_label(_("XREF"));
+ button = gtk_check_button_new_with_label("XREF");
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_XREF", ARG_PTR, -1, button);
@@ -163,8 +188,32 @@
gtk_widget_show(frame);
-
- gtk_widget_show(dialog);
+
+ hbox = gtk_hbox_new(TRUE, 6);
+ gtk_box_pack_start(GTK_BOX(box), hbox,FALSE, FALSE, 6);
+ gtk_widget_show(hbox);
+
+ button = gtk_button_new_with_label("OK");
+ gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 6);
+ GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default(button);
+ gtk_widget_show(button);
+
+ gtk_signal_connect(GTK_OBJECT(button), "clicked",
+ (GtkSignalFunc)ask_filter_callback,
+ (void*)ctrls);
+
+
+ button = gtk_button_new_with_label("Cancel");
+ arg_add_value(ctrls, "CANCEL", ARG_PTR, -1, button);
+ gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 6);
+ gtk_signal_connect(GTK_OBJECT(button), "clicked",
+ (GtkSignalFunc)ask_filter_callback,
+ (void*)ctrls);
+ gtk_widget_show(button);;
+
+ gtk_widget_show(w);
+ gtk_grab_add(w);
return ctrls;
}
@@ -173,45 +222,19 @@
struct plugin_filter * filter;
{
struct arglist * ctrls = build_filter_dlog();
- GtkWidget * dialog;
- char * pattern = NULL;
-
- dialog = arg_get_value(ctrls,"WINDOW");
-
- switch (gtk_dialog_run(GTK_DIALOG(dialog)))
- {
- case GTK_RESPONSE_OK:
- pattern = (char*)gtk_entry_get_text(GTK_ENTRY(
- arg_get_value(ctrls,"ENTRY")));
- filter_on_name = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_NAME"))->active;
- filter_on_description = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_DESCRIPTION"))->active;
- filter_on_summary = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_SUMMARY"))->active;
- filter_on_author = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_AUTHOR"))->active;
- filter_on_id = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_ID"))->active;
- filter_on_category = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_CATEGORY"))->active;
- filter_on_bid = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_BID"))->active;
- filter_on_cve = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_CVE"))->active;
- filter_on_xref = GTK_TOGGLE_BUTTON(
- arg_get_value(ctrls, "FILTER_XREF"))->active;
- break;
- default: /* pattern remains NULL */
- break;
- }
-
- if (!pattern)
- filter->pattern = NULL;
- else
- filter->pattern = estrdup(pattern);
+ char * ret;
+ while(!arg_get_value(ctrls, "FILTER"))
+ while(gtk_events_pending()){
+ gtk_main_iteration();
+#if !defined(WIN32) && !defined(_WIN32)
+ usleep(10000);
+#endif
+ }
- printf("P: %s\n", pattern);
+ ret = arg_get_value(ctrls, "FILTER");
+ if(ret == (void*)-1)filter->pattern = NULL;
+ else filter->pattern = estrdup(ret);
+
filter->filter_on_name = filter_on_name;
filter->filter_on_description = filter_on_description;
filter->filter_on_summary = filter_on_summary;
@@ -221,8 +244,8 @@
filter->filter_on_cve = filter_on_cve;
filter->filter_on_bid = filter_on_bid;
filter->filter_on_xref = filter_on_xref;
-
- gtk_widget_destroy(dialog);
+
+ gtk_widget_destroy(arg_get_value(ctrls, "WINDOW"));
arg_free(ctrls);
return 0;
}
@@ -235,7 +258,7 @@
ask_filter()
{
char * ret = emalloc(1024);
- printf(_("Enter a new filter : "));
+ printf("Enter a new filter : ");
fgets(ret, 1023, stdin);
return ret;
}
@@ -256,7 +279,7 @@
re_set_syntax(RE_SYNTAX_POSIX_EGREP);
if(regcomp(&re, pat, REG_EXTENDED|REG_ICASE))
{
- show_error(_("Invalid regular expression"));
+ show_error("Invalid regular expression");
bzero(pat, strlen(pat));
return -1;
}
Index: globals.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/globals.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- globals.h 25 Nov 2004 20:17:39 -0000 1.27
+++ globals.h 17 Mar 2007 21:36:00 -0000 1.28
@@ -1,23 +1,47 @@
#ifndef _NESSUSC_GLOBALS_H
#define _NESSUSC_GLOBALS_H
+
+extern struct arglist * Plugins;
+extern struct arglist * Scanners;
+extern struct arglist * Dependencies;
+#ifdef CLIENTSIDE_PLUGINS
+extern struct arglist * Upload;
+#endif
+extern harglst * NetMap;
+extern int PluginsNum;
+extern int ScannersNum;
+extern struct arglist * Prefs;
extern struct arglist * MainDialog;
+extern struct arglist * ArgSock;
extern char * Alt_rcfile;
+extern int GlobalSocket;
extern struct plugin_filter Filter;
+#ifdef ENABLE_SAVE_TESTS
+extern harglst * Sessions;
+extern int Sessions_saved;
+extern int Detached_sessions_saved;
+#endif
+
+#ifdef ENABLE_SAVE_KB
+extern int DetachedMode;
+#endif
extern int F_show_pixmaps;
extern int F_quiet_mode;
+extern int F_nessusd_running;
+extern int First_time;
extern int ListOnly;
#ifdef _WIN32
# include "globals.w32"
/* #define _NO_PIES */
#else /* _WIN32 */
-#ifndef NESSUS_ON_SSL
# define closesocket(x) close (x)
-#endif
#endif /* _WIN32 */
# define HANDLE int
+
+#define nulstr(x) (!(x) || ((x)[0] == '\0'))
#endif
Index: gtk-compat.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/gtk-compat.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gtk-compat.h 3 Nov 2004 14:25:29 -0000 1.3
+++ gtk-compat.h 17 Mar 2007 21:36:00 -0000 1.4
@@ -1,3 +1,8 @@
#define GTK_ENABLE_BROKEN 1
+#if GTK_VERSION >= 20
+#define WINDOW_DIALOG GTK_WINDOW_POPUP
+#else
+#define WINDOW_DIALOG GTK_WINDOW_DIALOG
+#endif
Index: html_graph_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/html_graph_output.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- html_graph_output.c 7 Sep 2005 09:54:26 -0000 1.58
+++ html_graph_output.c 17 Mar 2007 21:36:01 -0000 1.59
@@ -65,15 +65,14 @@
-------------------------------------------------------------------*/
#include <includes.h>
-#include "nessus_i18n.h"
#include "gdchart0.94b/gdc.h"
#include "gdchart0.94b/gdchart.h"
#include "gdchart0.94b/gdcpie.h"
#include "report.h"
#include "report_utils.h"
#include "error_dialog.h"
+#include "globals.h"
#include "nsr_output.h"
-#include "preferences.h"
static void insert_img(FILE *, char*);
@@ -488,71 +487,11 @@
Single host report
-----------------------------------------------------------------------------*/
-
-/*
- * print URL linking to CVE/BID/Nessus database to file.
- * '%s' in urlfmt (from preferences) will be replaced by
- * item IDs (or their parts split at minus characters).
- * '%%' will insert a percent character.
- * Everything else after '%' aborts parsing.
- * If urlfmt yields an empty string (e.g. it is only "%"),
- * only the item ID will be printed.
- */
-static void
-fprint_link(file, key, item)
- FILE *file;
- const char *key;
- const char *item;
-{
- char *itemparts = estrdup(item);
- char *itemsrc = itemparts;
- char *urlfmt = estrdup(prefs_get_string(Global, key));
- char *src = urlfmt;
- char *url = emalloc(strlen(urlfmt)+strlen(item)+1);
- char *dst = url;
- char *tmp;
-
- while((tmp = strchr(src, '%')))
- {
- *tmp = '\0';
- strcpy(dst, src);
- dst += strlen(src);
- src = tmp+1;
- switch(*src)
- {
- case 's':
- if((tmp = strchr(itemsrc, '-')))
- *tmp = '\0';
- strcpy(dst, itemsrc);
- dst += strlen(itemsrc);
- if(tmp)
- itemsrc = tmp+1;
- src++;
- break;
- case '%':
- strcpy(dst++, "%");
- src++;
- break;
- default:
- *src = '\0';
- }
- }
- strcpy(dst, src);
-
- efree(&itemparts);
- efree(&urlfmt);
- if(*url)
- fprintf(file, "<a href=\"%s\">%s</a>", url, item);
- else
- fprintf(file, "%s", item);
- efree(&url);
-}
-
/* All the cross references (CVE, BID) have the same format - XREF: <num>,...<br> */
static char *
-extract_xref(file, str, key)
+extract_xref(file, str, url)
FILE * file;
- char * str, * key;
+ char * str, * url;
{
while(str != NULL && strncmp(str, "<br>", 4) != 0)
{
@@ -567,7 +506,7 @@
tmp = e1[0];
e1[0] = '\0';
}
- fprint_link(file, key, str);
+ fprintf(file, "<a href=\"%s%s\">%s</a>", url, str, str);
str = e1;
if(e1 != NULL)
{
@@ -618,21 +557,19 @@
{
fprintf(file, "CVE : ");
str += 6;
- str = extract_xref(file, str, "url_cve");
+ str = extract_xref(file, str, "http://cgi.nessus.org/cve.php3?cve=");
}
else if(strncmp(str, "BID : ", 6) == 0)
{
fprintf(file, "BID : ");
str += 6;
- str = extract_xref(file, str, "url_bid");
+ str = extract_xref(file, str, "http://cgi.nessus.org/bid.php3?bid=");
}
else fputc(str[0], file);
- if(str != NULL)
- str++;
+ if ( str != NULL ) str++;
}
- fprintf(file, "Nessus ID : ");
- fprint_link(file, "url_nessus", plugin_id);
+ fprintf(file, "Nessus ID : <a href=\"http://cgi.nessus.org/nessus_id.php3?id=%s\">%s</a>", plugin_id, plugin_id);
}
static char * convert_cr_to_html(str)
@@ -1344,15 +1281,13 @@
if(mkdir(directory, 0750)<0)
{
- show_error(_("Directory %s couldn't be created: %s."),
- directory, strerror(errno));
+ show_error(strerror(errno));
return -1;
}
if(chdir(directory)<0)
{
- show_error(_("Can't change to directory %s: %s."),
- directory, strerror(errno));
+ show_error(strerror(errno));
return -1;
}
@@ -1362,7 +1297,7 @@
arglist_to_file(hosts, "report.nsr");
if(html_make_index(hosts)<0)
{
- show_error(_("Can't write index: %s"), strerror(errno));
+ show_error(strerror(errno));
return -1;
}
Index: html_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/html_output.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- html_output.c 22 Apr 2005 14:14:57 -0000 1.36
+++ html_output.c 17 Mar 2007 21:36:01 -0000 1.37
@@ -41,7 +41,7 @@
#include "report.h"
#include "report_utils.h"
#include "error_dialog.h"
-#include "preferences.h"
+#include "globals.h"
static char * convert_cr_to_html(char *);
@@ -52,71 +52,13 @@
/*
* Handy functions
*/
-
-/*
- * print URL linking to CVE/BID/Nessus database to file.
- * '%s' in urlfmt (from preferences) will be replaced by
- * item IDs (or their parts split at minus characters).
- * '%%' will insert a percent character.
- * Everything else after '%' aborts parsing.
- * If urlfmt yields an empty string (e.g. it is only "%"),
- * only the item ID will be printed.
- */
-static void
-fprint_link(file, key, item)
- FILE *file;
- const char *key;
- const char *item;
-{
- char *itemparts = estrdup(item);
- char *itemsrc = itemparts;
- char *urlfmt = estrdup(prefs_get_string(Global, key));
- char *src = urlfmt;
- char *url = emalloc(strlen(urlfmt)+strlen(item)+1);
- char *dst = url;
- char *tmp;
-
- while((tmp = strchr(src, '%')))
- {
- *tmp = '\0';
- strcpy(dst, src);
- dst += strlen(src);
- src = tmp+1;
- switch(*src)
- {
- case 's':
- if((tmp = strchr(itemsrc, '-')))
- *tmp = '\0';
- strcpy(dst, itemsrc);
- dst += strlen(itemsrc);
- if(tmp)
- itemsrc = tmp+1;
- src++;
- break;
- case '%':
- strcpy(dst++, "%");
- src++;
- break;
- default:
- *src = '\0';
- }
- }
- strcpy(dst, src);
-
- efree(&itemparts);
- efree(&urlfmt);
- if(*url)
- fprintf(file, "<a href=\"%s\">%s</a>", url, item);
- else
- fprintf(file, "%s", item);
- efree(&url);
-}
-
+
+
/* All the cross references (CVE, BID) have the same format - XREF: <num>,...<br> */
static char *
-extract_xref(file, str, key)
+extract_xref(file, str, url)
FILE * file;
- char * str, * key;
+ char * str, * url;
{
while(str != NULL && strncmp(str, "<br>", 4) != 0)
{
@@ -131,7 +73,7 @@
tmp = e1[0];
e1[0] = '\0';
}
- fprint_link(file, key, str);
+ fprintf(file, "<a href=\"%s%s\">%s</a>", url, str, str);
str = e1;
if(e1 != NULL)
{
@@ -182,21 +124,19 @@
{
fprintf(file, "CVE : ");
str += 6;
- str = extract_xref(file, str, "url_cve");
+ str = extract_xref(file, str, "http://cgi.nessus.org/cve.php3?cve=");
}
else if(strncmp(str, "BID : ", 6) == 0)
{
fprintf(file, "BID : ");
str += 6;
- str = extract_xref(file, str, "url_bid");
+ str = extract_xref(file, str, "http://cgi.nessus.org/bid.php3?bid=");
}
else fputc(str[0], file);
- if(str != NULL)
- str++;
+ if ( str != NULL ) str++;
}
- fprintf(file, "Nessus ID : ");
- fprint_link(file, "url_nessus", plugin_id);
+ fprintf(file, "Nessus ID : <a href=\"http://cgi.nessus.org/nessus_id.php3?id=%s\">%s</a>", plugin_id, plugin_id);
}
Index: latex_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/latex_output.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- latex_output.c 3 Nov 2004 14:25:29 -0000 1.18
+++ latex_output.c 17 Mar 2007 21:36:01 -0000 1.19
@@ -29,7 +29,7 @@
#include <includes.h>
#include "report.h"
#include "report_utils.h"
-#include "context.h"
+#include "globals.h"
#include "text_output.h"
#define CATEGORY_A 0
#define CATEGORY_B 1
@@ -146,7 +146,7 @@
if(num_of_hosts > 1)fprintf(f, "s");
fprintf(f," and none of the vulnerabilities tested were present on this ");
fprintf(f,"network ");
- if(Context->scanners && Context->plugins)
+ if(Scanners && Plugins)
{
fprintf(f, "(see Appendix A and B page \\pageref{appendix_a} and page \\pageref{appendix_b} for the exhaustive ");
fprintf(f,"list of what was tested).\\\\\n");
@@ -181,7 +181,7 @@
most->name);
fprintf(f, "the most affected by these warnings.\\\\\n");
}
- if(Context->scanners && Context->plugins)
+ if(Scanners && Plugins)
{
fprintf(f, "(see Appendix A and B page \\pageref{appendix_a} and page \\pageref{appendix_b} for the exhaustive ");
fprintf(f,"list of what was tested).\\\\\n");
@@ -219,7 +219,7 @@
fprintf(f, "the most affected by these warnings.\\\\\n");
}
- if(Context->scanners && Context->plugins)
+ if(Scanners && Plugins)
{
fprintf(f, "(see Appendix A and B page \\pageref{appendix_a} and page \\pageref{appendix_b} for the exhaustive ");
fprintf(f,"list of what was tested).\\\\\n");
@@ -253,7 +253,7 @@
fprintf(f, "that is the most likely to be the entry point of any cracker.\n");
}
- if(Context->scanners && Context->plugins)
+ if(Scanners && Plugins)
{
fprintf(f, "You should have a look at ");
fprintf(f, "(see Appendix A and B page \\pageref{appendix_a} and page \\pageref{appendix_b} for the exhaustive ");
@@ -287,7 +287,7 @@
most->name);
fprintf(f, "that is the most likely to be the entry point of any cracker.\n");
}
-if(Context->scanners && Context->plugins)
+if(Scanners && Plugins)
{
fprintf(f, "You should have a look at ");
fprintf(f, "(see Appendix A and B page \\pageref{appendix_a} and page \\pageref{appendix_b} for the exhaustive ");
@@ -485,19 +485,19 @@
}
void latex_appendix(FILE *f)
{
- if(Context->scanners || Context->plugins)
+ if(Scanners || Plugins)
{
fprintf(f, "\\newpage\n");
fprintf(f, "\\label{appendix_a}\n");
fprintf(f, "\\appendix\n");
fprintf(f, "\\section{List of port scanners used during this session}\n");
fprintf(f, "\\begin{itemize}\n");
- latex_appendix_plugins(f, Context->scanners);
+ latex_appendix_plugins(f, Scanners);
fprintf(f, "\\end{itemize}\n");
fprintf(f, "\\label{appendix_b}\n");
fprintf(f, "\\section{List of plugins used during this session}\n");
fprintf(f, "\\begin{itemize}\n");
- latex_appendix_plugins(f, Context->plugins);
+ latex_appendix_plugins(f, Plugins);
fprintf(f, "\\end{itemize}\n");
}
}
Index: monitor_dialog.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/monitor_dialog.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- monitor_dialog.c 24 Mar 2005 08:47:00 -0000 1.79
+++ monitor_dialog.c 17 Mar 2007 21:36:01 -0000 1.80
@@ -29,30 +29,26 @@
#include <includes.h>
-#ifdef USE_GTK
+#include "backend.h"
+#if USE_GTK
#include <gtk/gtk.h>
-#include "backend.h"
-#include "context.h"
-#include "preferences.h"
#include "attack.h"
#include "xstuff.h"
#include "comm.h"
#include "auth.h"
-#include "parser.h"
+#include "parser.h"
#include "report.h"
#include "globals.h"
#include "error_dialog.h"
#include "xpm/computer.xpm"
#include "monitor_dialog.h"
-#include "nessus_i18n.h"
-#include "prefs_dialog/prefs_context.h"
-#include "prefs_dialog/prefs_scope_tree.h"
+#include "report_ng.h"
/*static char ** plugins_order_table = NULL;*/
static harglst * plugins_order_table = NULL;
-static void monitor_input_callback(struct arglist *);
+static void monitor_input_callback(struct arglist *, int, int);
static void monitor_add_host(struct arglist *, char *, int);
static void monitor_stop_test(GtkWidget *, char *);
static void monitor_list_update(struct arglist *, char *, int);
@@ -60,6 +56,13 @@
static int monitor_stop_whole_test(GtkWidget * , struct arglist *);
static void build_plugins_order_table(char *);
+struct gui_host {
+ GtkWidget * gui;
+ struct arglist * ctrls;
+ struct gui_host * next;
+};
+
+
static int
is_server_present(soc)
@@ -71,7 +74,7 @@
if(fd < 0 || fd >= FD_SETSIZE)
{
- fprintf(stderr, _("is_server_present: fd(%d) out of range\n"), fd);
+ fprintf(stderr, "is_server_present: fd(%d) out of range\n", fd);
return 0;
}
FD_ZERO(&rd);
@@ -102,23 +105,29 @@
{
fd_set rd;
struct timeval tv = {0,100};
- int n, soc;
- if(Context->socket < 0)
+ int n, soc = -1;
+ if(GlobalSocket < 0)
{
- fprintf(stderr, "idle_socket: Context->socket=%d\n", Context->socket);
+ fprintf(stderr, "idle_socket: GlobalSocket=%d\n", GlobalSocket);
return FALSE;
}
- soc = nessus_get_socket_from_connection(Context->socket);
+
+ if ( stream_pending(GlobalSocket) > 0 )
+ {
+ monitor_input_callback(ctrls, soc /* ? Not used */, 0);
+ return TRUE;
+ }
+ soc = nessus_get_socket_from_connection(GlobalSocket);
if((soc < 0) || (soc >= FD_SETSIZE))
{
- fprintf(stderr, _("idle_server: soc(%d) out of range\n"), soc);
+ fprintf(stderr, "idle_server: soc(%d) out of range\n", soc);
return -1;
}
FD_ZERO(&rd);
FD_SET(soc, &rd);
n = select(soc+1, &rd, NULL, NULL, &tv);
if(FD_ISSET(soc, &rd)&& (n > 0))
- monitor_input_callback(ctrls);
+ monitor_input_callback(ctrls, soc /* ? Not used */, 0);
return TRUE;
}
@@ -129,43 +138,44 @@
* show the attack status
*/
void
-monitor_dialog_setup(victim)
+monitor_dialog_setup(victim, restore)
char * victim;
+ int restore;
{
struct arglist * ctrls = emalloc(sizeof(struct arglist));
- GtkWindow* parent = arg_get_value(MainDialog, "CONTEXT");
GtkWidget * scrolled_window;
GtkWidget * w, * box;
char* window_title;
- const char* host_name;
+ char* host_name;
int tag;
int backend = backend_init(NULL);
/* Could not create a backend */
if( backend < 0 )
+ {
+ gtk_widget_show(arg_get_value(MainDialog, "WINDOW"));
return;
+ }
+
arg_add_value(ctrls, "MONITOR_BACKEND", ARG_INT, -1, (void*)backend);
- arg_add_value(ctrls, "PARENT", ARG_PTR, -1, parent);
-
+
w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+#if GTK_VERSION > 10
gtk_window_set_default_size(GTK_WINDOW(w), 640,480);
-
- /* TODO make the window non-modal
- * This can be done when context is kept for all called functions */
- gtk_window_set_modal(GTK_WINDOW(w), TRUE);
- gtk_window_set_transient_for(GTK_WINDOW(w), parent);
- arg_set_value(MainDialog, "CONTEXT", -1, w);
+#else
+ gtk_widget_set_usize(GTK_WIDGET(w), 640, 480);
+#endif
gtk_widget_realize(w);
gtk_signal_connect(GTK_OBJECT(w), "delete_event",
(GtkSignalFunc)monitor_stop_whole_test_destroy,ctrls);
- host_name = prefs_get_string(Context, "nessusd_host");
+ host_name = arg_get_value(Prefs, "nessusd_host");
if(host_name)window_title = emalloc(strlen(host_name) + 255);
else window_title = emalloc(255);
- sprintf(window_title, _("Scanning network from %s"),
- host_name?host_name:_("some host"));
+ sprintf(window_title, "Scanning network from %s",
+ host_name?host_name:"some host");
gtk_window_set_title(GTK_WINDOW(w), window_title);
efree(&window_title);
gtk_container_border_width(GTK_CONTAINER(w), 10);
@@ -185,7 +195,11 @@
gtk_box_pack_start(GTK_BOX(box), scrolled_window, TRUE, TRUE, 0);
w = gtk_list_new();
+#if GTK_VERSION < 11
+ gtk_container_add(GTK_CONTAINER(scrolled_window), w);
+#else
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), w);
+#endif
gtk_widget_show(w);
gtk_widget_show (scrolled_window);
arg_add_value(ctrls, "LIST", ARG_PTR, -1, w);
@@ -195,20 +209,17 @@
tag = gtk_idle_add((GtkFunction)idle_socket, ctrls);
arg_add_value(ctrls, "TAG", ARG_INT, sizeof(int), (void*)tag);
- w = gtk_button_new_with_label(_("Stop the whole test"));
+ w = gtk_button_new_with_label("Stop the whole test");
gtk_signal_connect(GTK_OBJECT(w), "clicked",
(GtkSignalFunc)monitor_stop_whole_test,ctrls);
gtk_box_pack_start(GTK_BOX(box), w, FALSE, TRUE, 0);
gtk_widget_show(w);
- if(!attack_host(victim, Context))
- {
- gtk_widget_hide(arg_get_value(ctrls, "WINDOW"));
- gtk_idle_remove(tag);
- gtk_widget_destroy(arg_get_value(ctrls, "WINDOW"));
- arg_set_value(MainDialog, "CONTEXT", -1, parent);
- prefs_context_update(Context);
- scopetreeview_connected_update(Context);
- }
+#if ENABLE_SAVE_TESTS
+ if(restore)
+ restore_attack(victim, Prefs);
+ else
+#endif
+ attack_host(victim, Prefs);
}
/*
@@ -268,7 +279,7 @@
item = GTK_OBJECT(dlist->data);
list_hostname = gtk_object_get_data(item, "hostname");
if(!list_hostname){
- fprintf(stderr, _("Error ! Null hostname in the list\n"));
+ fprintf(stderr, "Error ! Null hostname in the list\n");
/*exit(1);*/
return;
}
@@ -284,9 +295,9 @@
gmax = max;
gcurrent = atoi(current);
- f = (gcurrent/gmax);
- if(f>=1.0)f=1.0;
- if(f<=0.0)f=0.0;
+ f = (gfloat)(gcurrent/gmax);
+ if(f >= 1.0)f = 0.99;
+ else if(f <= 0)f = 0;
gtk_progress_bar_update (GTK_PROGRESS_BAR(progress_bar), f);
flag = 1;
@@ -319,11 +330,17 @@
item = gtk_object_get_data(GTK_OBJECT(arg_get_value(ctrls, "LIST")),host);
if(!item){
+#ifndef ENABLE_SAVE_KB
/*
* If this happens, then it's very likely that the server
* thinks the communication has been cut between the client
* and itself. Which is not a good thing.
*/
+ fprintf(stderr, "warning. Could not find entry for %s\n", host);
+ fprintf(stderr, "This may be a bug - please check the nessusd logfile\n");
+ fprintf(stderr, "and if you see something about a lost connection,\n");
+ fprintf(stderr, "or any odd message, please report it to deraison@cvs.nessus.org\n");
+#endif
return;
}
@@ -409,11 +426,11 @@
gtk_widget_show(box);
gtk_box_pack_end(GTK_BOX(hbox), box, FALSE, FALSE, 0);
- label = gtk_label_new(_("Portscan:"));
+ label = gtk_label_new("Portscan : ");
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
gtk_widget_show(label);
- label = gtk_label_new(_("Checks:"));
+ label = gtk_label_new("Checks : ");
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
gtk_widget_show(label);
@@ -447,7 +464,7 @@
gtk_table_attach_defaults(GTK_TABLE(table), box, 2,3,0,2);
gtk_widget_show(box);
- button = gtk_button_new_with_label(_("Stop"));
+ button = gtk_button_new_with_label("Stop");
gtk_signal_connect(GTK_OBJECT(button), "clicked",
(GtkSignalFunc)monitor_stop_test, hostname);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
@@ -494,9 +511,8 @@
int type = 0, n;
char * msg;
char buf[32768];
- GtkWindow* parent = arg_get_value(ctrls, "PARENT");
-
network_printf( "CLIENT <|> STOP_WHOLE_TEST <|> CLIENT\n");
+ efree(&ArgSock);
gtk_idle_remove((int)arg_get_value(ctrls, "TAG"));
/*
@@ -515,9 +531,9 @@
efree(&msg);
}
+ F_nessusd_running = 0;
gtk_widget_hide(arg_get_value(ctrls, "WINDOW"));
- arg_set_value(MainDialog, "CONTEXT", -1, parent);
- report_save(Context, (int)arg_get_value(ctrls, "MONITOR_BACKEND"), NULL);
+ report_tests_ng((int)arg_get_value(ctrls, "MONITOR_BACKEND"), 0);
return(FALSE);
}
@@ -529,10 +545,11 @@
* data coming from the server.
*/
void
-monitor_input_callback(ctrls)
+monitor_input_callback(ctrls, fd, condition)
struct arglist * ctrls;
+ int fd;
+ int condition;
{
- GtkWindow* parent = arg_get_value(ctrls, "PARENT");
int finished = 0;
static char * buf = NULL;
static int bufsz = 0;
@@ -550,7 +567,7 @@
if ((n = strlen (buf)) && buf [n-1] == '\n') buf [n-1] = '\0';
if( buf[0] == '\0') {
- if(!is_server_present(Context->socket))
+ if(!is_server_present(GlobalSocket))
{
interrupted++;
goto scan_finished;
@@ -585,11 +602,11 @@
if(finished)
{
scan_finished :
+ F_nessusd_running = 0;
gtk_widget_hide(arg_get_value(ctrls, "WINDOW"));
gtk_idle_remove((int)arg_get_value(ctrls, "TAG"));
gtk_widget_destroy(arg_get_value(ctrls, "WINDOW"));
- arg_set_value(MainDialog, "CONTEXT", -1, parent);
- report_save(Context, (int)arg_get_value(ctrls, "MONITOR_BACKEND"), NULL);
+ report_tests_ng((int)arg_get_value(ctrls, "MONITOR_BACKEND"), interrupted);
}
}
@@ -641,14 +658,14 @@
for(i=0;i<num;i++)
{
- struct arglist * plugs = Context->plugins;
+ struct arglist * plugs = Plugins;
while(plugs && plugs->next &&
((int)(arg_get_value(plugs->value, "ID"))!=plugins_order_table_int[i]))
plugs = plugs->next;
if(!(plugs && plugs->next))
{
- plugs = Context->scanners;
+ plugs = Scanners;
while(plugs && plugs->next &&
((int)(arg_get_value(plugs->value, "ID"))!=plugins_order_table_int[i]))
plugs = plugs->next;
Index: monitor_dialog.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/monitor_dialog.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- monitor_dialog.h 13 Nov 2004 13:37:05 -0000 1.8
+++ monitor_dialog.h 17 Mar 2007 21:36:01 -0000 1.9
@@ -19,5 +19,5 @@
#ifndef _NESSUSC_MONITOR_DIALOG_H
#define _NESSUSC_MONITOR_DIALOG_H
-void monitor_dialog_setup(char *);
+void monitor_dialog_setup(char *, int);
#endif
Index: nbe_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/nbe_output.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- nbe_output.c 9 Dec 2004 18:50:21 -0000 1.12
+++ nbe_output.c 17 Mar 2007 21:36:01 -0000 1.13
@@ -97,9 +97,11 @@
if(fd < 0)
{
+ char err[1024];
int e = errno;
perror(filename);
- show_error("%s: %s", filename, strerror(e));
+ snprintf(err, sizeof(err), "%s: %s", filename, strerror(e));
+ show_error(err);
return -1;
}
Index: nessus.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/nessus.c,v
retrieving revision 1.194
retrieving revision 1.195
diff -u -d -r1.194 -r1.195
--- nessus.c 22 Sep 2006 20:28:40 -0000 1.194
+++ nessus.c 17 Mar 2007 21:36:01 -0000 1.195
@@ -1,5 +1,5 @@
/* Nessus
- * Copyright (C) 1998 - 2001 Renaud Deraison
+ * Copyright (C) 1998 - 2006 Tenable Network Security, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
@@ -28,18 +28,19 @@
*/
#include <includes.h>
-
-#include "nessus_i18n.h"
#include "password_dialog.h"
#ifdef USE_GTK
#include <gtk/gtk.h>
#include "xstuff.h"
+#include "error_dialog.h"
#include "prefs_dialog/prefs_dialog.h"
-#include "prefs_dialog/prefs_context.h"
+#include "prefs_dialog/prefs_dialog_plugins_prefs.h"
+#include "prefs_dialog/prefs_dialog_scan_opt.h"
+#include "prefs_dialog/prefs_target.h"
+#include "report_ng.h"
#endif
-#include "error_dialog.h"
#include "read_target_file.h"
#include "comm.h"
#include "auth.h"
@@ -48,11 +49,11 @@
#include "report.h"
#include "parser.h"
#include "sighand.h"
-#include "context.h"
#include "preferences.h"
#include "globals.h"
#include "corevers.h"
#include <getopt.h>
+#include "password_dialog.h"
#include "filter.h"
#include "backend.h"
@@ -65,12 +66,18 @@
#include "xml_output.h"
#include "xml_output_ng.h"
+
+
#include "cli.h"
#ifdef HAVE_SSL
#include <openssl/x509v3.h>
#endif
+#ifdef ENABLE_SAVE_TESTS
+#include "detached_index.h"
+#endif
+
#ifdef USE_AF_UNIX
#undef NESSUS_ON_SSL
#endif
@@ -87,12 +94,33 @@
#define inc_optind() (optind++)
#endif
+struct arglist * Plugins = NULL;
+struct arglist * Scanners = NULL;
+struct arglist * Dependencies = NULL;
+struct arglist * Upload = NULL;
+#ifdef ENABLE_SAVE_TESTS
+harglst * Sessions = NULL;
+int Sessions_saved = 0;
+int Detached_sessions_saved = 0;
+#endif
+#ifdef ENABLE_SAVE_KB
+int DetachedMode = 0;
+#endif
+
+int PluginsNum;
+int ScannersNum;
+struct arglist * Prefs;
struct arglist * MainDialog;
+struct arglist * ArgSock;
char * Alt_rcfile = NULL;
struct plugin_filter Filter;
+int GlobalSocket;
+char * stored_pwd = NULL;
int DontCheckServerCert = 0;
int F_show_pixmaps;
int F_quiet_mode;
+int F_nessusd_running;
+int First_time = 0;
int ListOnly = 0;
#ifndef USE_AF_INET
@@ -102,19 +130,6 @@
void init_globals();
-/*
- * Initialize I18N support, if possible
- */
-static void
-i18n_init(void)
-{
-#ifdef HAVE_GNU_GETTEXT
- setlocale (LC_ALL, "" );
- bindtextdomain (PACKAGE, LOCALEDIR);
- bind_textdomain_codeset (PACKAGE, "UTF-8");
- textdomain (PACKAGE);
-#endif
-}
#ifdef NESSUS_ON_SSL
@@ -175,7 +190,7 @@
int i, x;
- if ((fname = preferences_get_altname(Global, "cert")) == NULL)
+ if ((fname = preferences_get_altname("cert")) == NULL)
return -1;
fp = fopen(fname, "r");
@@ -234,7 +249,7 @@
int x;
int found;
- if ((fname = preferences_get_altname(Global, "cert")) == NULL)
+ if ((fname = preferences_get_altname("cert")) == NULL)
return -1;
if ((fp2 = tmpfile()) == NULL)
@@ -316,12 +331,12 @@
*
*/
char *
-connect_to_nessusd(context)
- struct context * context;
+connect_to_nessusd(hostname, port, login, pass)
+ char * hostname;
+ int port;
+ char * login;
+ char * pass; /* is a cipher in case of the crypto layer */
{
- const char * hostname;
- int port;
- const char * login;
#ifdef CLN_AUTH_SRV
int paranoia_level;
/*
@@ -335,11 +350,9 @@
static SSL_CTX *ssl_ctx = NULL;
static SSL_METHOD *ssl_mt = NULL;
SSL *ssl = NULL;
- const char *cert, *key, *client_ca, *trusted_ca, *ssl_ver;
- const char *ssl_cipher_list;
+ char *cert, *key, *client_ca, *trusted_ca, *ssl_ver;
+ char *ssl_cipher_list;
STACK_OF(X509_NAME) *cert_names;
- int use_client_cert = prefs_get_int(context, "use_client_cert");
- char *pem_pass = NULL;
#endif
int soc, soc2;
int opt;
@@ -347,21 +360,32 @@
struct sockaddr_un address;
char * name = AF_UNIX_PATH;
#endif
- const char *passwd;
- if(prefs_get_int(Global, "nessusd_autoconnect"))
- passwd = estrdup(context->passwd);
+ init_globals();
+ if(arg_get_type(Prefs, "nessusd_host")>=0)
+ arg_set_value(Prefs, "nessusd_host", strlen(hostname), strdup(hostname));
else
- {
- /* Don't cache the password */
- passwd = context->passwd;
- context->passwd = NULL;
- }
-
- hostname = prefs_get_string(context, "nessusd_host");
- port = prefs_get_int(context, "nessusd_port");
- login = prefs_get_string(context, "nessusd_user");
+ arg_add_value(Prefs, "nessusd_host", ARG_STRING, strlen(hostname),
+ strdup(hostname));
+
+ if(arg_get_type(Prefs, "nessusd_user")>=0)
+ arg_set_value(Prefs, "nessusd_user", strlen(login), strdup(login));
+ else
+ arg_add_value(Prefs, "nessusd_user", ARG_STRING, strlen(login),
+ strdup(login));
+#ifdef CLN_AUTH_SRV
+ paranoia_level = (int) arg_get_value(Prefs, "paranoia_level");
+ if(!paranoia_level && !DontCheckServerCert){
+ paranoia_level = sslui_ask_paranoia_level();
+ if(paranoia_level >= 1 && paranoia_level <= 3)
+ {
+ arg_add_value(Prefs, "paranoia_level", ARG_INT, sizeof(int),(void*)paranoia_level);
+ preferences_save(Plugins);
+ }
+ }
+#endif
+
#ifdef USE_AF_INET
soc = open_sock_tcp_hn(hostname, port);
@@ -371,10 +395,10 @@
static char err_msg[1024];
struct in_addr a = nn_resolve(hostname);
if(a.s_addr == INADDR_NONE)
- return _("Host not found!");
+ return("Host not found !");
else
{
- snprintf(err_msg, sizeof(err_msg), _("Could not open a connection to %s\n"), hostname);
+ snprintf(err_msg, sizeof(err_msg), "Could not open a connection to %s\n", hostname);
return err_msg;
}
}
@@ -393,37 +417,24 @@
if(connect(soc, (struct sockaddr*)&address, sizeof(address))==-1)
{
char * error = emalloc(255+strlen(name)+strlen(strerror(errno)));
- sprintf(error, _("Could not connect to %s - %s\n"), name, strerror(errno));
+ sprintf(error, "Could not connect to %s - %s\n", name, strerror(errno));
return error;
}
#endif
#ifdef NESSUS_ON_SSL
- if (prefs_get_int(context, "use_ssl"))
- {
- ssl_ver = prefs_get_string(context, "ssl_version");
- if (!strcasecmp(ssl_ver, "NONE"))
- ssl_ver = prefs_get_default(context, "ssl_version");
- }
- else
- ssl_ver = "NONE";
+#define SSL_VER_DEF_NAME "TLSv1"
+#define SSL_VER_DEF_METH TLSv1_client_method
+ ssl_ver = arg_get_value(Prefs, "ssl_version");
+ if (ssl_ver == NULL || *ssl_ver == '\0')
+ ssl_ver = SSL_VER_DEF_NAME;
if (strcasecmp(ssl_ver, "NONE") != 0)
{
-#ifdef CLN_AUTH_SRV
- paranoia_level = prefs_get_int(context, "paranoia_level");
- if(!paranoia_level && !DontCheckServerCert)
- {
- paranoia_level = sslui_ask_paranoia_level();
- if(paranoia_level >= 1 && paranoia_level <= 3)
- prefs_set_int(context, "paranoia_level", paranoia_level);
- }
-#endif
-
if(nessus_SSL_init(NULL) < 0)
{
- return(_("Could not initialize the OpenSSL library !\n\
-Please launch nessus-mkrand(1) first !"));
+ return("Could not initialize the OpenSSL library !\n\
+Please launch nessus-mkrand(1) first !");
}
if (ssl_mt == NULL)
{
@@ -437,9 +448,7 @@
ssl_mt = TLSv1_client_method();
else
{
- show_warning(
- _("Unknown SSL version \"%s\"\nUsing default: %s"),
- ssl_ver, SSL_VER_DEF_NAME);
+ fprintf(stderr, "Unknown SSL version \"%s\"\nSwitching to default " SSL_VER_DEF_NAME "\n", ssl_ver);
ssl_ver = SSL_VER_DEF_NAME;
ssl_mt = SSL_VER_DEF_METH();
}
@@ -466,7 +475,7 @@
#define NOEXP_CIPHER_LIST "EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:DES-CBC3-SHA:DES-CBC3-MD5:DHE-DSS-RC4-SHA:IDEA-CBC-SHA:RC4-SHA:RC4-MD5:IDEA-CBC-MD5:RC2-CBC-MD5:RC4-MD5:RC4-64-MD5:EDH-RSA-DES-CBC-SHA:EDH-DSS-DES-CBC-SHA:DES-CBC-SHA:DES-CBC-MD5"
#define STRONG_CIPHER_LIST "EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:DES-CBC3-SHA:DES-CBC3-MD5:DHE-DSS-RC4-SHA:IDEA-CBC-SHA:RC4-SHA:RC4-MD5:IDEA-CBC-MD5:RC2-CBC-MD5:RC4-MD5"
#define EDH_CIPHER_LIST "EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:DHE-DSS-RC4-SHA"
- ssl_cipher_list = prefs_get_string(context, "ssl_cipher_list");
+ ssl_cipher_list = arg_get_value(Prefs, "ssl_cipher_list");
if (ssl_cipher_list != NULL && *ssl_cipher_list != '\0' )
{
if (strcmp(ssl_cipher_list, "noexp") == 0)
@@ -485,19 +494,14 @@
sslerror("SSL_new");
return "SSL_error";
}
+ cert = arg_get_value(Prefs, "cert_file");
+ key = arg_get_value(Prefs, "key_file");
+ client_ca = arg_get_value(Prefs, "client_ca");
- if(use_client_cert)
- {
- cert = prefs_get_string(context, "cert_file");
- key = prefs_get_string(context, "key_file");
- client_ca = prefs_get_string(context, "client_ca");
-
- if(passwd && key)
+ if (pass != NULL && key != NULL)
{
- pem_pass = estrdup(passwd);
- nessus_install_passwd_cb(ssl_ctx, pem_pass);
- efree(&passwd);
- passwd = estrdup("*"); /* Do not send it over the network */
+ nessus_install_passwd_cb(ssl_ctx, pass);
+ /* pass = "*"; */ /* So that we do not send it over the network */
}
if (cert != NULL)
@@ -513,16 +517,14 @@
else
sslerror("SSL_load_client_CA_file");
}
- }
#ifdef CLN_AUTH_SRV
if (paranoia_level == 2 || paranoia_level == 3)
{
- trusted_ca = prefs_get_string(context, "trusted_ca");
+ trusted_ca = arg_get_value(Prefs, "trusted_ca");
if (trusted_ca == NULL)
{
- show_warning(
- _("paranoia_level=%d but \"trusted_ca\" not set"),
- paranoia_level);
+ fprintf(stderr, "paranoia_level=%d but \"trusted_ca\"not set\n",
+ paranoia_level);
paranoia_level = 1;
}
else
@@ -533,13 +535,7 @@
sslerror("SSL_CTX_set_default_verify_paths");
#endif
if (! SSL_CTX_load_verify_locations(ssl_ctx, trusted_ca, NULL))
- {
- sslerror("SSL_CTX_load_verify_locations");
- show_warning(
- _("Error while setting the trusted CA: %s\n"
- "SSL connections are likely to fail."),
- trusted_ca);
- }
+ sslerror("SSL_CTX_load_verify_locations");
}
}
#endif
@@ -547,8 +543,6 @@
if (! SSL_set_fd(ssl, soc))
{
sslerror("SSL_set_fd");
- efree(&passwd);
- efree(&pem_pass);
return "SSL error";
}
@@ -556,8 +550,6 @@
if (SSL_connect(ssl) <= 0)
{
sslerror("SSL_connect");
- efree(&passwd);
- efree(&pem_pass);
return "SSL error";
}
@@ -581,23 +573,16 @@
if(cert == NULL)
{
sslerror("SSL_get_peer_certificate");
- return _("SSL error: cannot get server certificate");
- efree(&passwd);
- efree(&pem_pass);
+ return "SSL error: cannot get server certificate";
}
X509_check_purpose(cert, -1, 0); /* Make sure hash is correct */
if (memcmp(cert->sha1_hash, stored_hash, SHA_DIGEST_LENGTH) != 0)
{
int x = sslui_check_cert(ssl);
- if(x < 0)
- {
- efree(&passwd);
- efree(&pem_pass);
- return _("Invalid server certificate");
- }
+ if(x < 0)return "Invalid server certificate";
if (set_server_cert_hash(hostname, cert->sha1_hash) < 0)
- perror(_("Could not save server certificate"));
+ perror("Could not save server certificate");
}
}
#endif
@@ -606,9 +591,7 @@
if ((soc2 = nessus_register_connection(soc, ssl)) <0)
{
shutdown(soc, 2);
- efree(&passwd);
- efree(&pem_pass);
- return _("Could not register the connection");
+ return "Could not register the connection";
}
stream_set_buffer(soc2, 1024 * 1024);
soc = soc2;
@@ -616,55 +599,96 @@
#else
if((soc2 = nessus_register_connection(soc, NULL)) < 0)
{
- efree(&passwd);
- return _("Could not register the connection");
+ return "Could not register the connection";
}
stream_set_buffer(soc2, 1024 * 1024);
soc = soc2;
#endif
- context->socket = soc;
+ GlobalSocket = soc;
+ ArgSock = emalloc(sizeof(struct arglist));
+ arg_add_value(ArgSock, "global_socket", ARG_INT, -1, (void *)GlobalSocket);
- if(comm_init(soc,PROTO_NAME) || (auth_login(login, passwd)))
+
+ if(comm_init(soc,PROTO_NAME) || (auth_login(login, pass)))
{
#ifdef NESSUS_ON_SSL
- close_stream_connection(context->socket);
- efree(&pem_pass);
+ close_stream_connection(GlobalSocket);
#else
- shutdown(context->socket, 2);
+ shutdown(soc, 2);
#endif
- context->socket = -1;
- efree(&passwd);
- return(_("Remote host is not using the good version of the Nessus communication protocol (1.2) or is tcpwrapped"));
+ return("Remote host is not using the good version of the Nessus communication protocol (1.2) or is tcpwrapped");
}
-
- if(comm_get_plugins(context))
+ if(comm_get_plugins())return("Login failed");
+ if(F_quiet_mode)
{
-#ifdef NESSUS_ON_SSL
- close_stream_connection(context->socket);
- efree(&pem_pass);
-#else
- shutdown(context->socket, 2);
-#endif
- context->socket = -1;
- efree(&passwd);
- return(_("Login failed"));
+ cli_comm_get_preferences(Prefs);
+ comm_get_rules(Prefs);
+ comm_get_dependencies();
+ }
+ else
+ {
+ if(!First_time){
+ comm_get_preferences(Prefs);
+ comm_get_rules(Prefs);
+ comm_get_dependencies();
+ }
+ else
+ {
+ /*
+ * Ignore the server preferences if we already logged in
+ */
+ struct arglist * devnull = emalloc(sizeof(*devnull));
+ comm_get_preferences(devnull);
+ comm_get_rules(devnull);
+ arg_free(devnull);
+ }
}
- comm_get_preferences(context);
- comm_get_rules(context);
- comm_get_dependencies(context);
+ if(comm_server_restores_sessions(Prefs))
+ {
+ Sessions = comm_get_sessions();
+#ifdef USE_GTK
+ prefs_dialog_target_fill_sessions(arg_get_value(MainDialog, "TARGET"),
+ Sessions);
+#endif
+ }
+
+
+
+ prefs_check_defaults(Prefs);
#ifdef ENABLE_SAVE_TESTS
- if(comm_server_restores_sessions(context))
- context->sessions = comm_get_sessions();
+#ifdef USE_GTK
+ if(comm_server_detached_sessions(Prefs))
+ detached_show_window(Prefs);
+#endif
#endif
- efree(&passwd);
-#ifdef NESSUS_ON_SSL
- efree(&pem_pass);
+
+#ifdef USE_GTK
+ prefs_plugins_reset(arg_get_value(MainDialog, "PLUGINS_PREFS"), Plugins,
+ Scanners);
#endif
+#ifdef USE_GTK
+ if(!F_quiet_mode)fill_scanner_list(arg_get_value(MainDialog, "SCAN_OPTIONS"));
+#endif
+
return(NULL);
}
+/*
+ * init_globals
+ *
+ * initializes two main global variables : plugins and
+ * scanners
+ *
+ */
+void
+init_globals()
+{
+ if(!Plugins)Plugins = emalloc(sizeof(struct arglist));
+ if(!Scanners)Scanners = emalloc(sizeof(struct arglist));
+}
+
void
display_help
@@ -673,39 +697,39 @@
printf("%s, version %s\n", pname, NESSUS_FULL_VERSION);
#ifdef USE_AF_INET
- printf(_("\nCommon options :\n %s [-vnh] [-c .rcfile] [-V] [-T <format>]"),pname);
- printf(_("\nBatch-mode scan:\n %s -q [-pPS] <host> <port> <user> <pass> <targets-file> <result-file>"),pname);
- printf(_("\nList sessions :\n %s -s -q <host> <port> <user> <pass> "),pname);
- printf(_("\nRestore session:\n %s -R <sessionid> -q <host> <port> <user> <pass> <result-file> "),pname);
+ printf("\nCommon options :\n %s [-vnh] [-c .rcfile] [-V] [-T <format>]",pname);
+ printf("\nBatch-mode scan:\n %s -q [-pPS] <host> <port> <user> <pass> <targets-file> <result-file>",pname);
+ printf("\nList sessions :\n %s -s -q <host> <port> <user> <pass> ",pname);
+ printf("\nRestore session:\n %s -R <sessionid> -q <host> <port> <user> <pass> <result-file> ",pname);
#else /* AF_UNIX */
- printf(_("\nBatch-mode scan:\n %s -q [-pPS] <user> <pass> <targets-file> <result-file>"),pname);
- printf(_("\nList sessions :\n %s -s -q <user> <pass> "),pname);
- printf(_("\nRestore session:\n %s -R <sessionid> -q <user> <pass> <result-file> "),pname);
+ printf("\nBatch-mode scan:\n %s -q [-pPS] <user> <pass> <targets-file> <result-file>",pname);
+ printf("\nList sessions :\n %s -s -q <user> <pass> ",pname);
+ printf("\nRestore session:\n %s -R <sessionid> -q <user> <pass> <result-file> ",pname);
#endif
- printf(_("\nReport conversion :\n %s -i in.[nsr|nbe] -o out.[html|xml|nsr|nbe]\n\n"), pname);
- printf(_("General options :\n"));
- printf(_("\t-v : shows version number\n"));
- printf(_("\t-h : shows this help\n"));
- printf(_("\t-n : No pixmaps\n"));
- printf(_("\t-T : Output format: 'nbe', 'html', 'html_graph', 'text', 'xml',\n"));
+ printf("\nReport conversion :\n %s -i in.[nsr|nbe] -o out.[html|xml|nsr|nbe]\n\n", pname);
+ printf("General options :\n");
+ printf("\t-v : shows version number\n");
+ printf("\t-h : shows this help\n");
+ printf("\t-n : No pixmaps\n");
+ printf("\t-T : Output format: 'nbe', 'html', 'html_graph', 'text', 'xml',\n");
printf("\t 'old-xml' 'tex' or 'nsr'\n");
- printf(_("\t-V : make the batch mode display status messages\n"
- "\t to the screen.\n"));
- printf(_("\t-x : override SSL \"paranoia\" question preventing nessus from\n"
- "\t checking certificates.\n\n"));
-
- printf(_("The batch mode (-q) arguments are :\n"));
+ printf("\t-V : make the batch mode display status messages\n");
+ printf("\t to the screen.\n");
+ printf("\t-x : override SSL \"paranoia\" question preventing nessus from\n");
+ printf("\t checking certificates.\n\n");
+
+ printf("The batch mode (-q) arguments are :\n");
#ifdef USE_AF_INET
- printf(_("\thost : nessusd host\n"));
- printf(_("\tport : nessusd host port\n"));
+ printf("\thost : nessusd host\n");
+ printf("\tport : nessusd host port\n");
#endif
- printf(_("\tuser : user name\n"));
- printf(_("\tpass : password\n"));
- printf(_("\ttargets : file containing the list of targets\n"));
- printf(_("\tresult : name of the file where \n\t\t nessus will store the results\n"));
- printf(_("\t-p : obtain list of plugins installed on the server.\n"));
- printf(_("\t-P : obtain list of server and plugin preferences.\n"));
- printf(_("\t-S : issue SQL output for -p and -P (experimental).\n"));
+ printf("\tuser : user name\n");
+ printf("\tpass : password\n");
+ printf("\ttargets : file containing the list of targets\n");
+ printf("\tresult : name of the file where \n\t\t nessus will store the results\n");
+ printf("\t-p : obtain list of plugins installed on the server.\n");
+ printf("\t-P : obtain list of server and plugin preferences.\n");
+ printf("\t-S : issue SQL output for -p and -P (experimental).\n");
/* TODO: The following options are not described yet: -m (jfs) */
}
@@ -776,28 +800,25 @@
int list_prefs = 0;
int sqlize_output = 0;
int restore_session = 0;
-#ifdef ENABLE_SAVE_TESTS
char * session_id = NULL;
-#endif
char * arg = NULL;
int opt_V= 0;
int opt_i= 0;
int opt_o= 0;
char * inf = NULL, *outf = NULL;
- /* Setup I18N. */
- i18n_init();
-
/*
* Version check
*/
+
+
if(version_check(NESSUS_VERSION, nessuslib_version())>0)
{
fprintf(stderr,
-_("Error : we are linked against nessus-libraries %s. \n\
+"Error : we are linked against nessus-libraries %s. \n\
Install nessus-libraries %s or make sure that\n\
-you have deleted older versions nessus libraries from your system\n"),
+you have deleted older versions nessus libraries from your system\n",
nessuslib_version(), NESSUS_VERSION);
}
@@ -812,7 +833,11 @@
else
myself ++ ;
- MainDialog = NULL;
+ PluginsNum = 0;
+ ScannersNum = 0;
+ Scanners = Plugins = MainDialog = NULL;
+ ArgSock = NULL;
+ GlobalSocket = -1;
#ifdef USE_GTK
F_quiet_mode = 0;
F_show_pixmaps = 1;
@@ -914,12 +939,12 @@
opt_V++;
break;
case 'v' :
- printf("nessus (%s) %s for %s\n\n(C) 1998 - 2003 Renaud Deraison <deraison@nessus.org>\n",
+ printf("nessus (%s) %s for %s\n\n(C) 1998 - 2006 Tenable Network Security, Inc.\n",
PROGNAME,NESSUS_VERSION, NESS_OS_NAME);
#ifdef NESSUS_ON_SSL
- printf(_("\tSSL used for client - server communication\n"));
+ printf("\tSSL used for client - server communication\n");
#else
- printf(_("\tclient - server communication is done in PLAIN TEXT\n"));
+ printf("\tclient - server communication is done in PLAIN TEXT\n");
#endif
printf ("\n");
exit(0);
@@ -963,14 +988,11 @@
exit (0);
}
}
-
- /* Initialize global context */
- context_init(&Global, NULL);
- Context = Global;
-
+
if(opt_i || opt_o)
{
int be;
+ preferences_init(&Prefs);
if(!(opt_i && opt_o))
{
display_help("nessus");
@@ -1010,7 +1032,7 @@
backend_to_xml_ng(be, outf);
else
{
- fprintf(stderr, _("Unsupported report type '%s'\n"), type);
+ fprintf(stderr, "Unsupported report type '%s'\n", type);
exit(1);
}
backend_close(be);
@@ -1018,7 +1040,7 @@
}
else
{
- fprintf(stderr, _("Could not import '%s' - is it a .nsr or .nbe file ?\n"),
+ fprintf(stderr, "Could not import '%s' - is it a .nsr or .nbe file ?\n",
inf);
}
exit(0);
@@ -1041,19 +1063,19 @@
#ifdef ENABLE_SAVE_TESTS
if(list_sessions && (argc<=optind) && !F_quiet_mode)
{
- fprintf(stderr, _("list-sessions requires %s\n"), BATCH_USAGE);
+ fprintf(stderr, "list-sessions requires %s\n", BATCH_USAGE);
exit(1);
}
if(restore_session && (argc<=optind) && !F_quiet_mode)
{
- fprintf(stderr, _("restore-session requires -q %s result\n"), BATCH_USAGE);
+ fprintf(stderr, "restore-session requires -q %s result\n", BATCH_USAGE);
exit(1);
}
if(restore_session && list_sessions)
{
- fprintf(stderr, _("--restore-session and --list-sessions are mutually exclusive\n"));
+ fprintf(stderr, "--restore-session and --list-sessions are mutually exclusive\n");
exit(1);
}
#endif
@@ -1073,24 +1095,20 @@
init_display (&argc, &argv);
}
#endif
-
+
/* system environment set up */
if(!opt_m)
{
- if (preferences_init(Global))
+ if (preferences_init(&Prefs))
exit (2);
- }
- else
- Global->prefs = emalloc(sizeof(struct arglist));
+ }
+ else
+ Prefs = emalloc(sizeof(struct arglist));
-#ifdef USE_GTK
- if(!F_quiet_mode)
- context_collect(Global);
-#endif /* USE_GTK */
if(opt_V && !F_quiet_mode)
{
- fprintf(stderr, _("Verbose mode can only be used in batch mode\n"));
+ fprintf(stderr, "Verbose mode can only be used in batch mode\n");
exit(1);
}
@@ -1124,14 +1142,14 @@
if(list_sessions || opt_m || list_plugins || list_prefs)
{
if (argc - optind != NUM_ARGS - 2) {
- fprintf(stderr, "%s" BATCH_USAGE "\n", _("list-sessions only requires "));
+ fprintf(stderr, "list-sessions only requires " BATCH_USAGE "\n");
exit(1);
}
}
else if(restore_session)
{
if (argc - optind != NUM_ARGS - 1) {
- fprintf(stderr, "%s" BATCH_USAGE " <result-file>\n", _("restore-session only requires "));
+ fprintf(stderr, "restore-session only requires " BATCH_USAGE " <result-file>\n");
exit(1);
}
}
@@ -1167,9 +1185,10 @@
if(list_prefs)
{
+ First_time = 0;
if(cli_connect_to_nessusd(cli) < 0)
{
- fprintf(stderr, _("Could not connect to nessusd\n"));
+ fprintf(stderr, "Could not connect to nessusd\n");
exit(1);
}
if(sqlize_output)
@@ -1181,9 +1200,10 @@
}
if(list_plugins)
{
+ First_time = 0;
if(cli_connect_to_nessusd(cli) < 0)
{
- fprintf(stderr, _("Could not connect to nessusd\n"));
+ fprintf(stderr, "Could not connect to nessusd\n");
exit(1);
}
if(sqlize_output)
@@ -1209,13 +1229,13 @@
char * t = argv[inc_optind()];
if(t)cli_args_target(cli, t);
else {
- fprintf(stderr, _("Missing parameter\n"));
+ fprintf(stderr, "Missing parameter\n");
display_help(myself);
}
t = argv[inc_optind()];
if(t) cli_args_results(cli, t);
else {
- fprintf(stderr, _("Missing parameter\n"));
+ fprintf(stderr, "Missing parameter\n");
display_help(myself);
}
}
@@ -1231,12 +1251,12 @@
if(list_sessions){
cli_list_sessions(cli);
#ifdef NESSUS_ON_SSL
- close_stream_connection(Context->socket);
+ close_stream_connection(GlobalSocket);
#else
- shutdown(Context->socket ,2);
- closesocket(Context->socket);
+ shutdown(GlobalSocket,2);
+ closesocket(GlobalSocket);
#endif
- Context->socket = -1;
+ GlobalSocket = -1;
nessus_exit(0);
}
else if(restore_session) {
@@ -1245,8 +1265,8 @@
else
#endif
if(opt_m){
- if(!preferences_generate_new_file(Global, NULL))
- printf(_("A new nessusrc file has been saved\n"));
+ if(!preferences_generate_new_file())
+ printf("A new nessusrc file has been saved\n");
}
else
{
@@ -1256,43 +1276,47 @@
/* end, exit */
nessus_exit(0);
}
-
+
+ F_nessusd_running = 0;
+
/*
* Set up the main window
*/
#if 0
- paranoia_level = prefs_get_int(context, "paranoia_level");
+ paranoia_level = arg_get_value(Prefs, "paranoia_level");
if (paranoia_level == 0)
{
paranoia_level = sslui_ask_paranoia_level();
if(paranoia_level > 0)
- prefs_set_int(context, "paranoia_level", paranoia_level);
+ arg_add_value(Prefs, "paranoia_level", ARG_INT, -1, (void*)paranoia_level);
}
#endif
#ifdef USE_GTK
- prefs_dialog_setup(Global);
- prefs_context_update(Global);
-
- gtk_main();
+ prefs_dialog_setup (NULL, Prefs);
+ /*
+ * all the options have been taken in account... Now, the user
+ * may want us to open a previously saved file
+ */
+ for (i = 1; i < xac; i ++) {
+ int be = backend_import_report(xav[i]);
+ if(be >= 0)
+ report_tests_ng (be, 0);
+ }
- /* XXX: Server preferences are not saved here */
- prefs_dialog_apply(Context, MainDialog);
- context_save_recurse(Global);
- /* FIXME: close all open connections
- close_stream_connection(Context->socket);
- Context->socket = -1;
- */
- nessus_exit(0);
- return 0; /* make the compiler happy */
+ gtk_main();
+ close_stream_connection(GlobalSocket);
+ close_display();
+ GlobalSocket = -1;
+ return(0);
#else
- printf(_("\nOoops ...\n\
+ printf("\nOoops ...\n\
This nessus version has no gui support. You need to give nessus the\n\
arguments SERVER PORT LOGIN TRG RESULT as explained in more detail\n\
- using the --help option.\n"));
+ using the --help option.\n");
exit (1);
#endif
}
Index: nessus.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/nessus.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- nessus.h 3 Nov 2004 14:25:29 -0000 1.25
+++ nessus.h 17 Mar 2007 21:36:01 -0000 1.26
@@ -29,10 +29,6 @@
#define DEFAULT_SERVER "localhost"
#define PROTO_NAME "< NTP/1.2 >< plugins_cve_id plugins_version plugins_bugtraq_id plugins_xrefs timestamps dependencies >\n"
-#ifdef NESSUS_ON_SSL
-# define SSL_VER_DEF_NAME "TLSv1"
-# define SSL_VER_DEF_METH TLSv1_client_method
-#endif /* NESSUS_ON_SSL */
#ifdef _CYGWIN_
extern char * NESSUS_RCFILE;
@@ -42,8 +38,6 @@
#endif
-#include "context.h"
-
-char * connect_to_nessusd(struct context *);
+char * connect_to_nessusd(char *, int, char *, char *);
#endif
Index: nsr_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/nsr_output.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- nsr_output.c 9 Dec 2004 18:50:21 -0000 1.31
+++ nsr_output.c 17 Mar 2007 21:36:01 -0000 1.32
@@ -169,9 +169,11 @@
if(fd < 0)
{
+ char err[1024];
int e = errno;
perror(filename);
- show_error("%s: %s", filename, strerror(e));
+ snprintf(err, sizeof(err), "%s: %s", filename, strerror(e));
+ show_error(err);
return -1;
}
Index: parser.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/parser.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- parser.c 9 Dec 2004 18:30:33 -0000 1.42
+++ parser.c 17 Mar 2007 21:36:02 -0000 1.43
@@ -27,8 +27,6 @@
*/
#include <includes.h>
-#include "nessus_i18n.h"
-
#include "parser.h"
#include "auth.h"
#include "error_dialog.h"
@@ -153,50 +151,6 @@
}
/*
- * parse_server_error
- *
- * Feed errors from the Nessus Server
- * to gettext and display them.
- */
-void
-parse_server_error(servmsg)
- char *servmsg;
-{
- char *msg = parse_separator(servmsg);
- char *msg1, *msg2;
-
- /*
- * msg2 contains the following lines of the server error.
- * Currently this can only be the list of rejected hosts,
- * so don't translate them.
- */
- if((msg2 = strchr(msg, ';')))
- {
- char *t;
-
- msg2[0] = '\0';
- msg2++;
- while((t = strchr(msg2, ';')))
- t[0]='\n';
- }
-
- /* * keep these in sync with the messages in ../nessusd/attack.c */
- if(!strncmp("E001 -", msg, 6))
- msg1 = _("Invalid port range");
- else if(!strncmp("E002 -", msg, 6))
- msg1 = _("These hosts could not be tested because you"
- " are not allowed to do so:");
- else
- msg1 = msg;
-
- if(msg2)
- show_error("%s\n%s", msg1, msg2);
- else
- show_error("%s", msg1);
- efree(&msg);
-}
-
-/*
* parse_server_message
*
* This function analyzes a message received
@@ -321,9 +275,20 @@
return(MSG_STAT2);
break;
case MSG_ERROR :
- parse_server_error(t);
- return(MSG_ERROR);
+ {
+ if(!F_quiet_mode)
+ {
+ char * msg = parse_separator(t);
+#ifdef USE_GTK
+ char * t;
+ while((t = strchr(msg, ';')))t[0]='\n';
+ show_error(msg);
+#endif
+ efree(&msg);
+ return(MSG_ERROR);
+ }
break;
+ }
case MSG_PORT :
parse_host_add_port(backend, t, humanmsg);
return(MSG_PORT);
@@ -622,7 +587,7 @@
char * ret;
s_1 = parse_symbol(str);
- if(!s_1 || s_1[0] == '\0')
+ if(nulstr(s_1))
return NULL;
s_2 = parse_symbol(s_1);
Index: plugin_infos.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/plugin_infos.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- plugin_infos.c 25 Nov 2004 16:33:46 -0000 1.28
+++ plugin_infos.c 17 Mar 2007 21:36:02 -0000 1.29
@@ -35,107 +35,100 @@
#include <gtk/gtk.h>
#include "xstuff.h"
-#include "context.h"
-
-#include "nessus_i18n.h"
#include "globals.h"
+
static void
show_deps(foo, name)
- GtkWidget * foo;
- char * name;
+ GtkWidget * foo;
+ char * name;
{
- GtkWindow * window = GTK_WINDOW(arg_get_value(MainDialog, "WINDOW"));
- GtkWidget * dialog;
- GtkWidget * vbox;
- GtkWidget * w;
- struct arglist * deps;
- char * lbl = emalloc(strlen(name) + 255);
- int label_size = 1024;
- char * label;
- sprintf(lbl, _("Dependencies of Plugin '%s'"), name);
-
- dialog = gtk_dialog_new_with_buttons(lbl, window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- NULL);
- gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
- gtk_widget_realize(dialog);
-
- /* The overall vbox */
- vbox = GTK_DIALOG(dialog)->vbox;
-
- /* The titel as label again */
- w = gtk_label_new(lbl);
- efree(&lbl);
- gtk_box_pack_start(GTK_BOX(vbox), w, TRUE, TRUE, 5);
- gtk_misc_set_alignment((GtkMisc *)w, 0, 1);
- gtk_widget_show(w);
-
- /* A horizontal separator */
- w = gtk_hseparator_new();
- gtk_box_pack_start(GTK_BOX(vbox), w, TRUE, TRUE, 5);
- gtk_widget_show(w);
-
- deps = arg_get_value(Context->dependencies, name);
+ GtkWidget * window;
+ GtkWidget * w;
+ GtkWidget * box;
+ struct arglist * deps;
+ char * lbl = emalloc(strlen(name) + 255);
+ int label_size = 1024;
+ char * label;
+ sprintf(lbl, "Dependencies of '%s'", name);
- label = emalloc(label_size);
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(window), lbl);
- /* In case we find no dependencies, create a hint on this */
- if (!deps || !deps->next)
- {
- strncpy(label, _("No dependencies found."), label_size);
- w = gtk_label_new(label);
- gtk_box_pack_start(GTK_BOX(vbox), w, TRUE, TRUE, 2);
- gtk_misc_set_alignment((GtkMisc *)w, 0, 1);
- gtk_widget_show(w);
- }
+
+ gtk_container_border_width(GTK_CONTAINER(window), 10);
+ gtk_signal_connect(GTK_OBJECT(window), "destroy",
+ GTK_SIGNAL_FUNC(close_window), window);
+
+ box = gtk_vbox_new(FALSE, 5);
+ gtk_container_add(GTK_CONTAINER(window), box);
+ gtk_widget_show(box);
+
+ w = gtk_label_new(lbl);
+ efree(&lbl);
+ gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 5);
+ gtk_widget_show(w);
+
+ w = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 5);
+ gtk_widget_show(w);
- while(deps && deps->next)
+
+ deps = arg_get_value(Dependencies, name);
+ if(!deps)
{
- struct arglist * p = arg_get_value(Context->plugins, deps->name);
-
- if(p == NULL)
- p = arg_get_value(Context->scanners, deps->name);
- if(p)
- {
- char * family = arg_get_value(p, "FAMILY");
- if(strlen(deps->name) + strlen(family) + 255 > label_size)
- {
- label_size *= 2;
- label = erealloc(label, label_size);
- }
- strncpy(label, deps->name, label_size);
- strncat(label, " (", label_size);
- strncat(label, family, label_size);
- strncat(label, _("), currently "), label_size);
- if (arg_get_value(p, "ENABLED"))
- strncat(label, _("enabled"), label_size);
- else
- strncat(label, _("disabled"), label_size);
- }
- else
- strncpy(label, deps->name, label_size);
- w = gtk_label_new(label);
- gtk_box_pack_start(GTK_BOX(vbox), w, TRUE, TRUE, 2);
- gtk_misc_set_alignment((GtkMisc *)w, 0, 1);
- gtk_widget_show(w);
- deps = deps->next;
+ return; /* XXX */
+ }
+ label = emalloc(label_size);
+
+ while(deps->next)
+ {
+ struct arglist * p = arg_get_value(Plugins, deps->name);
+
+ if(p == NULL)
+ p = arg_get_value(Scanners, deps->name);
+ if(p)
+ {
+ char * family = arg_get_value(p, "FAMILY");
+ if(strlen(deps->name) + strlen(family) + 255 > label_size)
+ {
+ label_size *= 2;
+ label = erealloc(label, label_size);
}
+ strncpy(label, deps->name, label_size);
+ strncat(label, " (", label_size);
+ strncat(label, family, label_size);
+ strncat(label, "), currently ", label_size);
+ if(arg_get_value(p, "ENABLED"))
+ strncat(label, "enabled", label_size);
+ else
+ strncat(label, "disabled", label_size);
+ }
+ else strncpy(label, deps->name, label_size);
+ w = gtk_label_new(label);
+ gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 2);
+ gtk_widget_show(w);
+ deps = deps->next;
+ }
+
+ efree(&label);
+ w = gtk_button_new_with_label("Close");
+ gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 3);
+ gtk_signal_connect(GTK_OBJECT(w), "clicked",GTK_SIGNAL_FUNC(close_window), window);
+ gtk_widget_show(w);
- efree(&label);
- /* execute and later remove the dialog */
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
+ gtk_widget_show(window);
}
static void
-do_set_timeout(ctrls)
+do_set_timeout(b, ctrls)
+ GtkWidget* b;
struct arglist * ctrls;
{
- struct arglist * serv_prefs = arg_get_value(Context->prefs, "SERVER_PREFS");
+ struct arglist * serv_prefs = arg_get_value(Prefs, "SERVER_PREFS");
GtkWidget * w = arg_get_value(ctrls, "ENTRY");
+ GtkWidget * window = arg_get_value(ctrls, "WINDOW");
char * to;
int id;
char * pref;
@@ -156,64 +149,75 @@
}
else
arg_add_value(serv_prefs, pref, ARG_STRING, sizeof(int), estrdup(to));
+
+ close_window(NULL, window);
}
-void
+static struct arglist *
set_timeout_build_window(id, cur_to, def_to)
- int id;
- char* cur_to;
- int def_to;
+ int id;
+ char* cur_to;
+ int def_to;
{
- GtkWindow * window = GTK_WINDOW(arg_get_value(MainDialog, "WINDOW"));
- GtkWidget * dialog;
- GtkWidget * vbox;
- GtkWidget * hbox;
- GtkWidget * w;
- struct arglist * ctrls = emalloc(sizeof(*ctrls));
-
- dialog = gtk_dialog_new_with_buttons(_("Set plugin timeout..."), window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
- gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
- gtk_widget_realize(dialog);
-
- /* The overall vbox */
- vbox = GTK_DIALOG(dialog)->vbox;
-
- /* A hbox that contains the label and entry field */
- hbox = gtk_hbox_new(FALSE, 5);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 10);
- gtk_widget_show(hbox);
+ GtkWidget * window;
+ GtkWidget * w;
+ GtkWidget * box, * hbox;
+ struct arglist * ctrls = emalloc(sizeof(*ctrls));
+
- /* The label for the entry field */
- w = gtk_label_new(_("Set plugin timeout:"));
- gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 10);
- gtk_misc_set_alignment((GtkMisc *)w, 0, 1);
- gtk_widget_show(w);
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(window), "Set plugin timeout...");
+ gtk_container_border_width(GTK_CONTAINER(window), 10);
+ gtk_signal_connect(GTK_OBJECT(window), "destroy",
+ GTK_SIGNAL_FUNC(close_window), window);
+
+ box = gtk_vbox_new(FALSE, 5);
+ gtk_container_add(GTK_CONTAINER(window), box);
+ gtk_widget_show(box);
+
+ w = gtk_label_new("Set plugin timeout : ");
+ gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 10);
+ gtk_widget_show(w);
+
+ w = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(box), w, TRUE, TRUE, 10);
+ gtk_widget_show(w);
- /* Then entry field for the timeout */
- w = gtk_entry_new();
- gtk_box_pack_start(GTK_BOX(hbox),w, TRUE, TRUE, 10);
- gtk_widget_show(w);
- if(!def_to)
- gtk_entry_set_text(GTK_ENTRY(w), cur_to);
+
+
+ w = gtk_entry_new();
+ gtk_box_pack_start(GTK_BOX(box),w, TRUE, TRUE, 10);
+ gtk_widget_show(w);
+ if(!def_to){
+ gtk_entry_set_text(GTK_ENTRY(w), cur_to);
+ }
+
+ arg_add_value(ctrls, "WINDOW", ARG_PTR, -1, window);
+ arg_add_value(ctrls, "ENTRY", ARG_PTR, -1, w);
+ arg_add_value(ctrls, "ID", ARG_INT, sizeof(int), (void*)id);
+
+
+ hbox = gtk_hbox_new(FALSE, 5);
+ gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 10);
+ gtk_widget_show(hbox);
+
+ w = gtk_button_new_with_label("Cancel");
+ gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 3);
+ gtk_signal_connect(GTK_OBJECT(w), "clicked",GTK_SIGNAL_FUNC(close_window), window);
+ gtk_widget_show(w);
- arg_add_value(ctrls, "WINDOW", ARG_PTR, -1, window);
- arg_add_value(ctrls, "ENTRY", ARG_PTR, -1, w);
- arg_add_value(ctrls, "ID", ARG_INT, sizeof(int), (void*)id);
- /* execute and later remove the dialog */
- switch (gtk_dialog_run(GTK_DIALOG(dialog)))
- {
- case GTK_RESPONSE_OK:
- do_set_timeout(ctrls);
- break;
- }
- gtk_widget_destroy(dialog);
+ w = gtk_button_new_with_label("Set new timeout");
+ gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 3);
+ gtk_signal_connect(GTK_OBJECT(w), "clicked",GTK_SIGNAL_FUNC(do_set_timeout), ctrls);
+ gtk_widget_show(w);
+
+
+
+ gtk_widget_show(window);
+ return ctrls;
}
@@ -224,14 +228,14 @@
GtkWidget * w;
int id;
{
- struct arglist * serv_prefs = arg_get_value(Context->prefs, "SERVER_PREFS");
+ struct arglist * serv_prefs = arg_get_value(Prefs, "SERVER_PREFS");
char * name = emalloc(40);
int to_set = 1;
char* timeout = NULL;
sprintf(name, "timeout.%d", id);
if(arg_get_type(serv_prefs, name) == ARG_STRING)
- timeout = arg_get_value(serv_prefs, name);
+ timeout = arg_get_value(Prefs, name);
else
to_set = 0;
@@ -259,168 +263,187 @@
struct arglist* res;
char * pluginname;
{
- GtkWindow * window = GTK_WINDOW(arg_get_value(MainDialog, "WINDOW"));
- GtkWidget * dialog;
- GtkWidget * vbox;
- GtkWidget * hbox;
- GtkWidget * label;
- GtkWidget * scrolledwindow;
- GtkWidget * textview;
- GtkWidget * button;
- GtkWidget * separator;
-
- char buf[4096];
- struct arglist * plugin;
- char * txt;
+ GtkWidget * window;
+ GtkWidget * box;
+ GtkWidget * hbox;
+ GtkWidget * subbox;
+ GtkWidget * label;
+ GtkWidget * text;
+ GtkWidget * button;
+ GtkWidget * separator;
+ GtkAdjustment * vadj;
+ GtkWidget * vsb;
+ GtkWidget * table;
+
+
- plugin = arg_get_value(res, pluginname);
- if(!plugin)
- {
+ char * category;
+ char buf[4096];
+ struct arglist * plugin;
+ char * txt;
+
+
+ plugin = arg_get_value(res, pluginname);
+ if(!plugin)
+ {
#ifdef DEBUG
- fprintf(stderr, _("Error ! Plugin selected not found ?!\n"));
+ fprintf(stderr, "Error ! Plugin selected not found ?!\n");
#endif
- return;
- }
-
- dialog = gtk_dialog_new_with_buttons(pluginname, window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- NULL);
- gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
- gtk_window_set_default_size(GTK_WINDOW(dialog), 350, 450);
- gtk_widget_realize(dialog);
-
- /* The overall vbox */
- vbox = GTK_DIALOG(dialog)->vbox;
-
- /* The plugin name */
- label = gtk_label_new(pluginname);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* The copyright notice */
- label = gtk_label_new(arg_get_value(plugin, "COPYRIGHT"));
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE,FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* A separator */
- separator = gtk_hseparator_new();
- gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE,0);
- gtk_widget_show(separator);
-
- /* The Family */
- sprintf(buf, _("Family: %s"), (char*)arg_get_value(plugin, "FAMILY"));
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* The Category */
- sprintf(buf, _("Category: %s"), (char*)arg_get_value(plugin, "CATEGORY"));
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* The Plugin ID */
- sprintf(buf, _("Nessus Plugin ID: %d"), (int)arg_get_value(plugin, "ID"));
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* The CVE ID (in case the plugin provides one) */
- txt = arg_get_value(plugin, "CVE_ID");
- if( txt != NULL && txt[0] != '\0' )
- {
- snprintf(buf, sizeof(buf), _("CVE: %s"), txt);
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
- }
-
- /* The Bugtraq ID (in case the plugin provides one) */
- txt = arg_get_value(plugin, "BUGTRAQ_ID");
- if( txt != NULL && txt[0] != '\0' )
- {
- snprintf(buf, sizeof(buf), _("Bugtraq ID: %s"), txt);
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
- }
-
- /* The other cross references (in case the plugin provides one) */
- txt = arg_get_value(plugin, "XREFS");
- if( txt != NULL && txt[0] != '\0' )
- {
- snprintf(buf, sizeof(buf), _("Other references: %s"), txt);
- label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
- }
-
- /* The Version */
- label = gtk_label_new(arg_get_value(plugin, "VERSION"));
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE,FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* A separator */
- separator = gtk_hseparator_new();
- gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE,0);
- gtk_widget_show(separator);
-
- /* The titel for the scrolled text */
- label = gtk_label_new(_("What is shown if the attack is successful:"));
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE,0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
- gtk_widget_show(label);
-
- /* The scrolled window */
- scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
- gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 5);
- gtk_widget_show(scrolledwindow);
-
- /* The textview with the plugin description */
- textview = gtk_text_view_new();
- gtk_container_add(GTK_CONTAINER(scrolledwindow), textview);
- gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_WORD);
- if (arg_get_value(plugin, "DESCRIPTION"))
- gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)),
- arg_get_value(plugin, "DESCRIPTION"), -1);
- gtk_widget_show (textview);
-
- /* A hbox for the buttons */
- hbox = gtk_hbox_new(FALSE,10);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE,FALSE,10);
- gtk_widget_show(hbox);
-
- /* The button for setting the plugin timeout */
- button = gtk_button_new_with_label(_("Set plugin timeout..."));
- gtk_signal_connect(GTK_OBJECT(button), "clicked",GTK_SIGNAL_FUNC(set_timeout),
- arg_get_value(plugin, "ID"));
- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
- gtk_widget_show(button);
-
- /* The button for displaying the dependencies */
- button = gtk_button_new_with_label(_("Show dependencies"));
- gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(show_deps),
- arg_get_value(plugin, "NAME"));
- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
- gtk_widget_show(button);
- if(!arg_get_value(Context->dependencies, pluginname))
- gtk_widget_set_sensitive(button,FALSE);
+ return;
+ }
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+#if GTK_VERSION > 10
+ gtk_window_set_default_size(GTK_WINDOW(window), 400,500);
+#else
+ gtk_widget_set_usize(GTK_WIDGET(window), 400, 500);
+#endif
+ gtk_container_border_width(GTK_CONTAINER(window),10);
+ gtk_window_set_title(GTK_WINDOW(window), pluginname);
+
+ box = gtk_vbox_new(FALSE,3);
+ gtk_container_add(GTK_CONTAINER(window), box);
+
+
+ hbox = gtk_hbox_new(FALSE,10);
+ gtk_box_pack_start(GTK_BOX(box), hbox, FALSE,FALSE,0);
+ gtk_widget_show(hbox);
+
+
+
+ separator = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(box), separator, FALSE, FALSE,0);
+ gtk_widget_show(separator);
+
+
+ sprintf(buf, "Family : %s", (char*)arg_get_value(plugin, "FAMILY"));
+ label = gtk_label_new(buf);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+
+ sprintf(buf, "Category : %s", (char*)arg_get_value(plugin, "CATEGORY"));
+ label = gtk_label_new(buf);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+
+ sprintf(buf, "Nessus Plugin ID : %d", (int)arg_get_value(plugin, "ID"));
+ label = gtk_label_new(buf);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+
+ txt = arg_get_value(plugin, "CVE_ID");
+ if( txt != NULL && txt[0] != '\0' )
+ {
+ snprintf(buf, sizeof(buf), "CVE : %s", txt);
+ label = gtk_label_new(buf);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+ }
+
+ txt = arg_get_value(plugin, "BUGTRAQ_ID");
+ if( txt != NULL && txt[0] != '\0' )
+ {
+ snprintf(buf, sizeof(buf), "Bugtraq ID : %s", txt);
+ label = gtk_label_new(buf);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+ }
+
+
+ txt = arg_get_value(plugin, "XREFS");
+ if( txt != NULL && txt[0] != '\0' )
+ {
+ snprintf(buf, sizeof(buf), "Other references : %s", txt);
+ label = gtk_label_new(buf);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+ }
+
+
+
+
+ label = gtk_label_new(arg_get_value(plugin, "VERSION"));
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE,FALSE,0);
+ gtk_widget_show(label);
+
+
+
+
+ separator = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(box), separator, FALSE, FALSE,0);
+ gtk_widget_show(separator);
+
+ label = gtk_label_new("What is shown if the attack is successful : ");
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+
+
+ vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+ vsb = gtk_vscrollbar_new (vadj);
+ table = gtk_table_new(1,2,FALSE);
+ gtk_box_pack_start(GTK_BOX(box), table, TRUE,TRUE,0);
+ gtk_widget_show(table);
+
+ text = gtk_text_new(NULL,vadj);
+ gtk_table_attach (GTK_TABLE (table), vsb, 1, 2, 0, 1,
+ 0, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
+ gtk_container_border_width (GTK_CONTAINER (table), 2);
+ gtk_widget_show(vsb);
+
+ gtk_widget_realize (text);
+ gtk_text_set_editable(GTK_TEXT(text), FALSE);
+ gtk_text_set_word_wrap(GTK_TEXT(text), TRUE);
+ if(arg_get_value(plugin, "DESCRIPTION"))
+ gtk_text_insert(GTK_TEXT(text), NULL,NULL,NULL, arg_get_value(plugin, "DESCRIPTION"),
+ -1);
+ gtk_widget_show(text);
+
+ separator = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(box), separator, FALSE, FALSE,0);
+ gtk_widget_show(separator);
+
+ button = gtk_button_new_with_label("Set plugin timeout...");
+ gtk_signal_connect(GTK_OBJECT(button), "clicked",GTK_SIGNAL_FUNC(set_timeout), arg_get_value(plugin, "ID"));
+ gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 5);
+ gtk_widget_show(button);
+
+ button = gtk_button_new_with_label("Show dependencies");
+ gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(show_deps), arg_get_value(plugin, "NAME"));
+ gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 5);
+ gtk_widget_show(button);
+ if(!arg_get_value(Dependencies, pluginname))
+ {
+ gtk_widget_set_sensitive(button,FALSE);
+ }
+
+ button = gtk_button_new_with_label("Close");
+ gtk_signal_connect(GTK_OBJECT(button), "clicked",GTK_SIGNAL_FUNC(close_window), window);
+ gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE,5);
+ gtk_widget_show(button);
+
+ gtk_widget_realize(window);
+ category = arg_get_value(plugin, "CATEGORY");
- /* execute and later remove the dialog */
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
+
+
+ subbox = gtk_vbox_new(FALSE,3);
+ gtk_box_pack_start(GTK_BOX(hbox), subbox, FALSE,FALSE,0);
+ gtk_widget_show(subbox);
+
+ label = gtk_label_new(pluginname);
+ gtk_box_pack_start(GTK_BOX(subbox), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+
+ label = gtk_label_new(arg_get_value(plugin, "COPYRIGHT"));
+ gtk_box_pack_start(GTK_BOX(subbox), label, FALSE,FALSE,0);
+ gtk_widget_show(label);
+
+
+ gtk_widget_show(box);
+ gtk_widget_show(window);
+
}
#endif
Index: preferences.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/preferences.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- preferences.c 23 Apr 2005 16:37:36 -0000 1.79
+++ preferences.c 17 Mar 2007 21:36:02 -0000 1.80
@@ -1,6 +1,5 @@
/* Nessus
* Copyright (C) 1998 - 2001 Renaud Deraison
- * Copyright (C) 2004 Intevation GmbH
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
@@ -26,67 +25,59 @@
* file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
- * Preferences -- maps the content of the nessusrc file to memory
[...1255 lines suppressed...]
+void prefs_check_defaults(prefs)
+ struct arglist * prefs;
+{
+}
- pwd = getpwuid(getuid());
- if(pwd && pwd->pw_dir)
- return pwd->pw_dir;
- return "";
+int
+preferences_generate_new_file()
+{
+ preferences_new();
+ preferences_init(&Prefs);
+ pluginset_reload(Plugins, Scanners);
+ preferences_save(Prefs);
+ return 0;
}
+
Index: preferences.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/preferences.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- preferences.h 29 Nov 2004 17:35:47 -0000 1.19
+++ preferences.h 17 Mar 2007 21:36:02 -0000 1.20
@@ -1,6 +1,5 @@
/* Nessus
* Copyright (C) 1998 Renaud Deraison
- * Copyright (C) 2004 Intevation GmbH
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,24 +30,17 @@
#ifndef _NESSUSC_PREFERENCES_H
#define _NESSUSC_PREFERENCES_H
-#include "context.h"
-
-int preferences_init(struct context *);
-void preferences_save(struct context *);
-void preferences_save_as(struct context *, char *);
-struct arglist *prefs_get_pluginset(struct context *, char *, struct arglist *);
-int preferences_process_filename(struct context *, char *);
-int preferences_generate_new_file(struct context *, const char *);
-char * plugin_asc_id(struct arglist *);
-char * preferences_get_altname(struct context *, const char *);
-void * prefs_get_default(struct context *, const char *);
-void * prefs_get_value(struct context *, const char *);
-#define prefs_get_int(context, name) ((int)prefs_get_value(context, name))
-#define prefs_get_string(context, name) ((const char *)prefs_get_value(context, name))
-void prefs_set_value(struct context *, const char *, void *, int);
-void prefs_set_int(struct context *, const char *, int);
-void prefs_set_string(struct context *, const char *, const char *);
-int prefs_has_options(struct context *);
+int preferences_init(struct arglist **);
+void preferences_save(struct arglist *);
+void preferences_save_fname(char*, struct arglist*);
+int pluginset_apply(struct arglist *, char *);
+void pluginset_reload(struct arglist *, struct arglist *);
+void prefs_check_defaults(struct arglist *);
+int preferences_process(char *, struct arglist *);
+int preferences_generate_new_file();
+char * plugin_asc_id(struct arglist*);
+char * preferences_get_filename();
+char * preferences_get_altname(const char*);
#ifdef _WIN32
/* applies to some windows misunderstanding */
Index: read_target_file.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/read_target_file.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- read_target_file.c 9 Dec 2004 18:50:21 -0000 1.16
+++ read_target_file.c 17 Mar 2007 21:36:02 -0000 1.17
@@ -1,8 +1,6 @@
#include <includes.h>
#include <errno.h>
-#include "nessus_i18n.h"
-
#ifdef USE_GTK
#include <gtk/gtk.h>
#include "read_target_file.h"
@@ -39,7 +37,7 @@
void target_file_select()
{
GtkWidget * file;
- file = gtk_file_selection_new (_("Load file"));
+ file = gtk_file_selection_new ("Load file");
gtk_file_selection_set_filename (GTK_FILE_SELECTION(file), "");
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file)->ok_button),
"clicked", (GtkSignalFunc) read_target_file,(void *) file );
@@ -66,9 +64,8 @@
#endif
-char *
-target_file_to_list(filename)
- const char * filename;
+char * target_file_to_list(filename)
+ char * filename;
{
HANDLE fd = open(filename, O_RDONLY);
char * ret,*t;
@@ -77,14 +74,25 @@
int n, i, offs, left ;
if(fd < 0)
- {
- show_error(_("Could not open %s\nopen(%s): %s"),
- filename, filename, strerror(errno));
- return(NULL);
- }
-
+ {
+ char * text = emalloc(strlen(filename)+300);
+ sprintf(text,"Could not open %s\nopen(%s) : %s\n", filename, filename, strerror(errno));
+ if(F_quiet_mode)fprintf(stderr, "%s", text);
+#ifdef USE_GTK
+ else show_error(text);
+#endif
+ efree(&text);
+ return(NULL);
+ }
+
if (lstat (filename, &sb) != 0) {
- show_error(_("Cannot stat %s (%s)\n"), filename, strerror(errno));
+ char * text = emalloc(strlen(filename)+300);
+ sprintf(text, "Cannot stat %s (%s)\n", filename, strerror(errno));
+ if (F_quiet_mode) fprintf (stderr, "%s", text);
+# ifdef USE_GTK
+ else show_error(text);
+# endif
+ efree (&text);
return 0;
}
len = (int)sb.st_size;
@@ -94,11 +102,17 @@
do {
if ((n = read (fd, ret + offs, left)) < 0) {
+ char * text = emalloc(strlen(filename)+300);
efree(&ret);
if (n == 0)
- show_error(_("file mapping failed: unexpected end-of-file\n"));
+ sprintf(text, "file mapping failed: unexpected end-of-file\n");
else
- show_error(_("file mapping failed: %s\n"), strerror(errno));
+ sprintf(text, "file mapping failed: %s\n", strerror(errno));
+ if(F_quiet_mode)fprintf(stderr, "%s", text);
+# ifdef USE_GTK
+ else show_error(text);
+# endif
+ efree (&text);
return 0;
}
} while (offs += n, (left -= n) > 0) ;
@@ -125,9 +139,8 @@
#ifdef USE_GTK
-char *
-target_translate(target)
- const char * target;
+char * target_translate(target)
+ char * target;
{
if(!strncmp(target, "file:", 5))
return target_file_to_list(target+strlen("file:"));
@@ -149,7 +162,7 @@
GtkWidget * bidon;
GtkWidget * gtkw;
{
- const char * filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(gtkw));
+ char * filename = (char*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(gtkw));
char * ret = target_file_name(filename);
target_file_apply(ret);
efree(&ret);
Index: read_target_file.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/read_target_file.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- read_target_file.h 3 Nov 2004 14:25:30 -0000 1.6
+++ read_target_file.h 17 Mar 2007 21:36:02 -0000 1.7
@@ -4,7 +4,7 @@
#ifdef USE_GTK
void read_target_file(GtkWidget *, GtkWidget*);
#endif
-char *target_file_to_list(const char *);
-char *target_translate(const char *);
+char * target_file_to_list(char *);
+char* target_translate(char*);
#endif
Index: report.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/report.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- report.c 29 Nov 2004 16:47:46 -0000 1.70
+++ report.c 17 Mar 2007 21:36:02 -0000 1.71
@@ -1,12 +1,18 @@
-/* $Id$
- *
+/* Nessus
* Copyright (C) 1998, 1999, 2000 Renaud Deraison
- * Copyright (C) 2004 by Intevation GmbH
- * Author(s):
- * Thomas Arendsen Hein <thomas@intevation.de>
*
- * This program is free software under the GNU GPL (>=v2)
- * Read the file COPYING coming with the software for details.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* In addition, as a special exception, Renaud Deraison
* gives permission to link the code of this program with any
@@ -18,39 +24,707 @@
* this file, you may extend this exception to your version of the
* file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
+ */
+
+/* Pluto 26.6.00:
+ *
+ * changed infos_and_holes_to into findings_to
*/
#include <includes.h>
-#include "nessus_i18n.h"
-#include "context.h"
-#include "error_dialog.h"
-
+#include "globals.h"
#ifdef USE_GTK
+
+#define MAX_ITEMS_IN_LIST 500 /* only show the 500 first entries */
+#define MAX_ITEMS_IN_LIST_ASC "500"
+#define TOO_MANY_ITEMS "Only the first "MAX_ITEMS_IN_LIST_ASC" entries will be shown.\nExport the report to another format for a complete version"
+
+
+#include "gtk-compat.h"
#include <gtk/gtk.h>
-#include "prefs_dialog/prefs_scope_tree.h"
-#include "prefs_dialog/prefs_context.h"
+#include "xstuff.h"
+#include "xpm/yellow.xpm"
+#include "xpm/orange.xpm"
+#include "xpm/red.xpm"
+#include "xpm/white.xpm"
+#include "report_ng.h"
#endif
#include "report.h"
+#include "families.h"
+#include "nsr_output.h"
+#include "html_output.h"
+#include "html_graph_output.h"
+#include "report_utils.h"
+#include "error_dialog.h"
+#include "latex_output.h"
+#include "text_output.h"
+#include "xml_output.h"
+#include "globals.h"
+#include "comm.h"
#include "backend.h"
-#include "nbe_output.h"
+#include "prefs_dialog/prefs_target.h"
-/* returns filename of report (must be freed) or NULL */
-char *
-report_get_filename(context)
- struct context *context;
+#define SAVE_NSR 0
+#define SAVE_HTML 1
+#define SAVE_TEXT 2
+#define SAVE_LATEX 3
+#define SAVE_HTML_GRAPH 4
+#define SAVE_XML 5
+#define SAVE_MAX SAVE_XML
+
+#ifdef USE_GTK
+
+static void save_report_ask(GtkWidget *, GtkWidget *);
+static void save_report(GtkWidget *, GtkWidget *);
+GtkWidget * report_to_tree(struct arglist *, GtkWidget *);
+static void do_create_report_window(struct arglist *, int, int);
+#endif
+
+
+
+#ifdef USE_GTK
+
+static void
+report_click(GtkWidget * list, GtkWidget * data)
{
- char *report = NULL;
+ GtkWidget * window = gtk_object_get_data(GTK_OBJECT(list), "window");
+ GtkWidget * box = gtk_object_get_data(GTK_OBJECT(list), "box");
+ GList * dlist = GTK_LIST(list)->selection;
+ GtkObject * item;
+ struct arglist * report;
+ GtkWidget * tree = NULL;
+ GtkWidget * old_tree = NULL;
+ int new_tree = 0;
+ if(!dlist)
+ return;
+
+ item = GTK_OBJECT(dlist->data);
+ report = gtk_object_get_data(item, "results");
+
+ if(report){
+ tree = gtk_object_get_data(item, "tree");
+ if(!tree)
+ {
+ tree = report_to_tree(report->value, window);
+ gtk_object_set_data(item, "tree", tree);
+ new_tree++;
+ }
+ }
+
+
+ if(tree)
+ {
+ old_tree = gtk_object_get_data(GTK_OBJECT(box), "tree");
+ if(old_tree){
+ GtkAdjustment * adj;
+ gtk_widget_hide(old_tree);
+ adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(window));
+ gtk_adjustment_set_value(adj, 0);
+ }
+ if(new_tree)
+ {
+ gtk_box_pack_start(GTK_BOX(box), tree, TRUE, TRUE, 0);
+ }
+ gtk_widget_show(tree);
+#if GTK_VERSION > 10
+ gtk_widget_map(tree);
+#endif
+
+ gtk_widget_realize(tree);
+ gtk_object_set_data(GTK_OBJECT(box), "tree", tree);
+ }
+}
- if(context->type == CONTEXT_REPORT && context->dir)
+
+
+
+static
+GtkWidget * summary_host_label(name, window, severity)
+ char * name;
+ GtkWidget * window;
+ int severity;
+{
+ GtkWidget * label;
+ GtkWidget * hbox;
+ char ** pixdata = NULL;
+ GtkStyle * style;
+ GtkWidget * pixmapwid;
+ switch(severity)
+ {
+ case HOLE_PRESENT :
+ pixdata = red_dot_xpm;
+ break;
+ case WARNING_PRESENT :
+ pixdata = orange_dot_xpm;
+ break;
+ case NOTE_PRESENT :
+ pixdata = yellow_dot_xpm;
+ break;
+ default :
+ pixdata = white_dot_xpm;
+ break;
+ }
+ style = gtk_widget_get_style(window);
+ pixmapwid = make_pixmap(window, &style->bg[GTK_STATE_NORMAL], pixdata);
+ hbox = gtk_hbox_new(FALSE,FALSE);
+
+ label = gtk_label_new(name);
+ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwid, FALSE, FALSE, 0);
+ gtk_widget_show(pixmapwid);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+ gtk_widget_show(label);
+ return hbox;
+}
+static void
+fill_summary_box(box, scrolled, results, sorted)
+ GtkWidget * box, * scrolled;
+ struct arglist * results;
+ int sorted;
+{
+ GtkWidget * label = gtk_label_new("Summary");
+ GtkWidget * sep = gtk_hseparator_new();
+ char * data = emalloc(4096);
+ GtkWidget * window;
+ GtkWidget * list;
+ GtkWidget * hbox;
+
+ int count;
+
+ GList * dlist = NULL;
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+
+ gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 0);
+ gtk_widget_show(sep);
+
+ if (sorted) sprintf(data, "Number of ports found : %d", arglist_length(results));
+ else sprintf(data, "Number of hosts tested : %d", arglist_length(results));
+ label = gtk_label_new(data);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+ sprintf(data, "Found %d security holes", number_of_holes(results));
+
+ label = gtk_label_new(data);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+
+ sprintf(data, "Found %d security warnings", number_of_warnings(results));
+ label = gtk_label_new(data);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+
+ sprintf(data, "Found %d security notes", number_of_notes(results));
+ label = gtk_label_new(data);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+
+ sep = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 0);
+ gtk_widget_show(sep);
+
+ window = gtk_scrolled_window_new(NULL,NULL);
+
+ gtk_box_pack_start(GTK_BOX(box), window, TRUE, TRUE, 0);
+
+
+ list = gtk_list_new();
+#if GTK_VERSION < 11
+ gtk_container_add(GTK_CONTAINER(window),list);
+#else
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(window), list);
+#endif
+ gtk_widget_show(list);
+ gtk_object_set_data(GTK_OBJECT(list), "window", scrolled);
+ hbox = gtk_hbox_new(FALSE, FALSE);
+#if GTK_VERSION < 11
+ gtk_container_add(GTK_CONTAINER(scrolled),hbox);
+#else
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), hbox);
+#endif
+ gtk_object_set_data(GTK_OBJECT(list), "box", hbox);
+ gtk_widget_show(hbox);
+ gtk_widget_realize(scrolled);
+ gtk_signal_connect(GTK_OBJECT(list),
+ "selection_changed",
+ GTK_SIGNAL_FUNC(report_click),
+ NULL);
+
+ if (arglist_length(results) > MAX_ITEMS_IN_LIST)
+ show_warning(TOO_MANY_ITEMS);
+ count = MAX_ITEMS_IN_LIST ;
+ while(results && results->next && --count)
+ {
+ GtkWidget * item;
+ int severity;
+
+
+ item = gtk_list_item_new();
+ gtk_object_set_data(GTK_OBJECT(item), "results", results->value);
+
+ if (number_of_holes_by_host(results->value)) severity = HOLE_PRESENT;
+ else if (number_of_warnings_by_host(results->value)) severity = WARNING_PRESENT;
+ else if (number_of_notes_by_host(results->value)) severity = NOTE_PRESENT;
+ else severity = 0;
+
+ label = summary_host_label(results->name, scrolled, severity);
+ gtk_container_add(GTK_CONTAINER(item), label);
+ gtk_widget_show(label);
+ dlist = g_list_append(dlist, item);
+ gtk_widget_show(item);
+ results = results->next;
+ }
+ gtk_list_append_items(GTK_LIST(list), dlist);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ gtk_widget_show(window);
+ gtk_widget_realize(window);
+ free(data);
+}
+
+static void create_report_window(args, interrupted_test)
+ struct arglist * args;
+ int interrupted_test;
+{
+
+ do_create_report_window(args, interrupted_test, 0);
+}
+static void create_report_window_by_port(nul, reportw)
+ GtkWidget * nul;
+ GtkWidget * reportw;
+{
+ struct arglist * hosts = gtk_object_get_data(GTK_OBJECT(reportw), "hosts");
+ hosts = sort_by_port(hosts);
+ hosts = sort_dangerous_hosts(hosts);
+ do_create_report_window(hosts, 0, 1);
+
+}
+
+/*
+ * Creation of the reporting window
+ */
+static void do_create_report_window(args, interrupted_test, sorted_by_port)
+ struct arglist * args;
+ int interrupted_test;
+ int sorted_by_port;
+{
+
+ GtkWidget * window;
+ GtkWidget * widget;
+ GtkWidget * vbox;
+ GtkWidget * hbox;
+ GtkWidget * paned;
+
+ GtkWidget * button;
+ GtkWidget * by_port;
+ GtkWidget * optionmenu;
+ GtkWidget * type;
+ GtkWidget * menu;
+ GtkWidget * summary_box;
+ struct arglist * report = args;
+ struct arglist * hosts;
+
+ if(!args || !args->next){
+ if(!interrupted_test)
+ {
+#ifdef ENABLE_SAVE_KB
+ if(DetachedMode)
+ {
+ struct arglist * arg;
+ show_info("nessusd is now scanning the remote network \n\
+in detached mode");
+ /*
+ * Restore the login button
+ */
+ arg = arg_get_value(MainDialog, "AUTH");
+ gtk_widget_hide(arg_get_value(arg, "CONNECTED"));
+ gtk_widget_hide(arg_get_value(arg, "BUTTON_LOG_OUT"));
+ gtk_widget_show(arg_get_value(arg, "BUTTON_LOG_IN"));
+ GlobalSocket = -1;
+ }
+ else
+#endif
+ show_info("No problem has been found, or none of the \
+hosts tested was alive");
+ }
+ else
+ {
+ show_warning("nessusd abruptly shut the communication down.\n\
+No problem has been found at this stage of the test");
+ }
+ return;
+ }
+ else if(interrupted_test)
{
- report = emalloc(strlen(context->dir) + strlen("/report.nbe") + 1);
- sprintf(report, "%s/report.nbe", context->dir);
+ show_warning("nessusd closed the communication before the end of the test !");
}
- return report;
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+#if GTK_VERSION > 10
+ gtk_window_set_default_size(GTK_WINDOW(window), 640,480);
+#else
+ gtk_widget_set_usize(GTK_WIDGET(window), 640, 480);
+#endif
+ gtk_widget_realize(window);
+ gtk_signal_connect(GTK_OBJECT(window), "destroy",
+ GTK_SIGNAL_FUNC(close_window), window);
+ gtk_signal_connect(GTK_OBJECT(window), "delete_event",
+ GTK_SIGNAL_FUNC(delete_event), window);
+
+ if (sorted_by_port) gtk_window_set_title(GTK_WINDOW(window), "Nessus Report by port");
+ else gtk_window_set_title(GTK_WINDOW(window), "Nessus Report");
+
+ gtk_container_border_width(GTK_CONTAINER(window), 10);
+
+ paned = gtk_hpaned_new();
+#if GTK_VERSION <= 11
+ gtk_paned_gutter_size(GTK_PANED(paned), 15);
+#else
+ gtk_paned_set_gutter_size(GTK_PANED(paned), 15);
+#endif
+ gtk_container_add(GTK_CONTAINER(window), paned);
+ gtk_widget_show(paned);
+
+ vbox = gtk_vbox_new(FALSE, 0);
+
+ summary_box = gtk_vbox_new(FALSE, 5);
+
+ gtk_paned_add1(GTK_PANED(paned), summary_box);
+ gtk_paned_add2(GTK_PANED(paned), vbox);
+
+
+
+
+ widget = gtk_scrolled_window_new(NULL,NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 5);
+ gtk_widget_show(widget);
+
+ fill_summary_box(summary_box, widget, args, sorted_by_port);
+ gtk_widget_show(summary_box);
+
+
+ hosts = emalloc(sizeof(struct arglist));
+
+ gtk_widget_realize(widget);
+
+ hbox = gtk_hbox_new(TRUE,10);
+
+ if (!sorted_by_port) {
+ by_port = gtk_button_new_with_label("Sort by port");
+ gtk_signal_connect(GTK_OBJECT(by_port),"clicked",
+ GTK_SIGNAL_FUNC(create_report_window_by_port),by_port);
+
+ gtk_box_pack_start(GTK_BOX(hbox), by_port, TRUE, TRUE, 0);
+ gtk_widget_show(by_port);
+
+ gtk_object_set_data(GTK_OBJECT(by_port), "hosts", report);
+
+ button = gtk_button_new_with_label("Save as...");
+
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
+
+ optionmenu = gtk_option_menu_new();
+ menu = gtk_menu_new();
+ gtk_option_menu_set_menu(GTK_OPTION_MENU(optionmenu), menu);
+ gtk_widget_show(menu);
+
+ gtk_object_set_data(GTK_OBJECT(menu), "hosts", report);
+
+ type = gtk_menu_item_new_with_label("Save as NSR");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_NSR);
+ gtk_menu_append(GTK_MENU(menu), type);
+ gtk_widget_show(type);
+
+ type = gtk_menu_item_new_with_label("Save as HTML");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_HTML);
+ gtk_menu_append(GTK_MENU(menu), type);
+ gtk_widget_show(type);
+
+ type = gtk_menu_item_new_with_label("Save as LaTeX");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_LATEX);
+ gtk_menu_append(GTK_MENU(menu), type);
+ gtk_widget_show(type);
+
+ type = gtk_menu_item_new_with_label("Save as ASCII text");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_TEXT);
+ gtk_menu_append(GTK_MENU(menu), type);
+ gtk_widget_show(type);
+
+#ifndef _NO_PIES
+ type = gtk_menu_item_new_with_label("Save as HTML with Pies and Graphs");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_HTML_GRAPH);
+ gtk_menu_append(GTK_MENU(menu), type);
+ gtk_widget_show(type);
+#endif
+
+ type = gtk_menu_item_new_with_label ("Save as XML (experimental)");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_XML);
+ gtk_menu_append(GTK_MENU(menu), type);
+ gtk_widget_show(type);
+
+ gtk_signal_connect(GTK_OBJECT(button),"clicked",
+ GTK_SIGNAL_FUNC(save_report_ask),menu);
+ gtk_box_pack_start(GTK_BOX(hbox), optionmenu, TRUE, TRUE, 0);
+ gtk_widget_show(optionmenu);
+ gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu), 0);
+ }
+ button = gtk_button_new_with_label("Close");
+ gtk_signal_connect(GTK_OBJECT(button),"clicked",
+ GTK_SIGNAL_FUNC(close_window),(void *) window);
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
+
+ gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
+
+ gtk_widget_show(hbox);
+ gtk_widget_show(vbox);
+ gtk_widget_show(window);
+}
+
+
+
+static
+GtkWidget * data_to_tree_build_label(name)
+ char * name;
+{
+ GtkWidget * label;
+ GtkWidget * hbox;
+
+ hbox = gtk_hbox_new(FALSE,FALSE);
+
+ label = gtk_label_new(name);
+ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 15);
+ gtk_widget_show(label);
+ return hbox;
+}
+
+static
+GtkWidget * data_to_tree(arglist)
+ struct arglist * arglist;
+{
+ GtkWidget * tree;
+ int count = MAX_ITEMS_IN_LIST;
+
+ if(!(arglist && arglist->next))
+ return NULL;
+
+ tree = gtk_tree_new();
+
+ if(arglist_length(arglist) > count)
+ show_warning(TOO_MANY_ITEMS);
+
+ while(arglist && arglist->next && count--)
+ {
+ GtkWidget * tree_item;
+ GtkWidget * report_data = data_to_tree_build_label(arglist->value);
+
+ tree_item = gtk_tree_item_new();
+
+ gtk_container_add(GTK_CONTAINER(tree_item), report_data);
+ gtk_widget_show(report_data);
+
+ gtk_tree_append(GTK_TREE(tree), tree_item);
+ gtk_tree_item_expand(GTK_TREE_ITEM(tree_item));
+ gtk_tree_item_collapse(GTK_TREE_ITEM(tree_item));
+
+ gtk_widget_show(tree_item);
+ arglist = arglist->next;
+ }
+
+ return tree;
+}
+
+
+static
+GtkWidget * findings_to_tree_build_label(name, severity)
+ char * name;
+ int severity;
+{
+ GtkWidget * label;
+ GtkWidget * hbox;
+
+ hbox = gtk_hbox_new(FALSE,FALSE);
+
+ label = gtk_label_new(name);
+ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 15);
+ gtk_widget_show(label);
+ return hbox;
+}
+
+
+
+static
+GtkWidget * findings_to_tree(arglist, window)
+ struct arglist * arglist;
+ GtkWidget * window;
+{
+ int level = is_there_any_hole(arglist);
+ GtkWidget * tree;
+ GtkWidget * tree_item;
+ GtkWidget * label;
+ if(!level)
+ return NULL;
+ tree = gtk_tree_new();
+ if(arg_get_value(arglist, "NOTE"))
+ {
+ GtkWidget * subtree;
+
+ tree_item = gtk_tree_item_new();
+ label = findings_to_tree_build_label("Security note", 1);
+ gtk_container_add(GTK_CONTAINER(tree_item), label);
+ gtk_widget_show(label);
+ gtk_tree_append(GTK_TREE(tree), tree_item);
+ subtree = data_to_tree(arg_get_value(arglist, "NOTE"));
+ if(subtree)
+ {
+ gtk_tree_item_set_subtree(GTK_TREE_ITEM(tree_item), subtree);
+ gtk_widget_show(subtree);
+ }
+ gtk_tree_item_expand(GTK_TREE_ITEM(tree_item));
+ gtk_tree_item_collapse(GTK_TREE_ITEM(tree_item));
+
+ gtk_widget_show(tree_item);
+ }
+
+ if(arg_get_value(arglist, "INFO"))
+ {
+ GtkWidget * subtree;
+ tree_item = gtk_tree_item_new();
+ label = findings_to_tree_build_label("Security warnings", 1);
+ gtk_container_add(GTK_CONTAINER(tree_item), label);
+ gtk_widget_show(label);
+ gtk_tree_append(GTK_TREE(tree), tree_item);
+ subtree = data_to_tree(arg_get_value(arglist, "INFO"));
+ if(subtree)
+ {
+ gtk_tree_item_set_subtree(GTK_TREE_ITEM(tree_item), subtree);
+ gtk_widget_show(subtree);
+ }
+ gtk_tree_item_expand(GTK_TREE_ITEM(tree_item));
+ gtk_tree_item_collapse(GTK_TREE_ITEM(tree_item));
+
+ gtk_widget_show(tree_item);
+ }
+
+ if(arg_get_value(arglist, "REPORT"))
+ {
+ GtkWidget * subtree;
+ tree_item = gtk_tree_item_new();
+ label = findings_to_tree_build_label("Security holes", 2);
+ gtk_container_add(GTK_CONTAINER(tree_item), label);
+ gtk_widget_show(label);
+ gtk_tree_append(GTK_TREE(tree), tree_item);
+ subtree = data_to_tree(arg_get_value(arglist, "REPORT"));
+ if(subtree)
+ {
+ gtk_tree_item_set_subtree(GTK_TREE_ITEM(tree_item), subtree);
+ gtk_widget_show(subtree);
+ }
+ gtk_tree_item_expand(GTK_TREE_ITEM(tree_item));
+ gtk_tree_item_collapse(GTK_TREE_ITEM(tree_item));
+ gtk_widget_show(tree_item);
+ }
+
+ return tree;
}
+static
+GtkWidget * report_build_label(name, window, severity)
+ char * name;
+ GtkWidget * window;
+ int severity;
+{
+ GtkWidget * label;
+ GtkWidget * hbox;
+ char ** pixdata = NULL;
+ GdkPixmap * pixmap;
+ GtkStyle * style;
+ GdkBitmap * mask;
+ GtkWidget * pixmapwid;
+ switch(severity)
+ {
+ case HOLE_PRESENT :
+ pixdata = red_dot_xpm;
+ break;
+ case WARNING_PRESENT :
+ pixdata = orange_dot_xpm;
+ break;
+ case NOTE_PRESENT :
+ pixdata = yellow_dot_xpm;
+ break;
+ default :
+ pixdata = white_dot_xpm;
+ break;
+ }
+ style = gtk_widget_get_style(window);
+ pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask,
+ &style->bg[GTK_STATE_NORMAL],(gchar **)pixdata);
+
+ pixmapwid = gtk_pixmap_new(pixmap, mask);
+ hbox = gtk_hbox_new(FALSE,FALSE);
+
+ label = gtk_label_new(name);
+ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwid, FALSE, FALSE, 0);
+ gtk_widget_show(pixmapwid);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+ gtk_widget_show(label);
+ return hbox;
+}
+
+
+GtkWidget * report_to_tree(arglist, window)
+ struct arglist * arglist;
+ GtkWidget * window;
+{
+ GtkWidget * tree;
+ int count = MAX_ITEMS_IN_LIST;
+ tree = gtk_tree_new();
+
+
+ if(arglist_length(arglist) > count)
+ show_warning(TOO_MANY_ITEMS);
+
+ while(arglist && arglist->next && count--)
+ {
+ GtkWidget * tree_item;
+ GtkWidget * label;
+ GtkWidget * subtree;
+
+
+ tree_item = gtk_tree_item_new();
+
+ /*
+ * Make label here
+ */
+
+ label = report_build_label(arglist->name, window, is_there_any_hole(arglist->value));
+ gtk_container_add(GTK_CONTAINER(tree_item), label);
+ gtk_widget_show(label);
+ gtk_tree_append(GTK_TREE(tree), tree_item);
+
+ if((subtree = findings_to_tree(arglist->value, window)))
+ {
+ gtk_tree_item_set_subtree(GTK_TREE_ITEM(tree_item), subtree);
+ gtk_widget_show(subtree);
+ }
+ gtk_tree_item_expand(GTK_TREE_ITEM(tree_item));
+ gtk_tree_item_collapse(GTK_TREE_ITEM(tree_item));
+
+ gtk_widget_show(tree_item);
+ arglist = arglist->next;
+ }
+ return(tree);
+}
+#endif
/* reports back the highest number */
int is_there_any_hole(arglist)
@@ -83,77 +757,38 @@
#ifdef USE_GTK
-void
-report_save(context, backend, name)
- struct context *context;
- int backend;
- const char *name;
-{
- struct context *report_context;
- char *report_filename;
- char *report_name;
- int report_len = strlen("Report YYYYMMDD-HHMMSS") + 1;
- time_t t;
- int error;
-
- context = context_by_type(context, CONTEXT_SCOPE);
- if(!context)
- {
- show_error(_("report_save() called with illegal type"));
- return;
- }
-
- if(name)
- report_context = scopetree_new(CONTEXT_REPORT, name, "");
- else
- {
- report_name = emalloc(report_len);
- t = time(NULL);
- strftime(report_name, report_len, "Report %Y%m%d-%H%M%S", localtime(&t));
- report_context = scopetree_new(CONTEXT_REPORT, report_name, NULL);
- efree(&report_name);
- }
- if(!report_context)
- {
- show_error(_("report_save() coudn't create context"));
- return;
- }
- report_filename = report_get_filename(report_context);
- if(!report_filename)
- {
- show_error(_("report_save() coudn't find a report filename"));
- return;
- }
+/*
+ * Main function of the holes reporter
+ */
+void
+report_tests(hosts, interrupted_test)
+ struct arglist * hosts;
+ int interrupted_test;
+{
- error = backend_to_nbe(backend, report_filename);
- efree(&report_filename);
- if(error)
- {
- show_error(_("report_save() coudn't save the report"));
- return;
- }
- prefs_context_update(report_context);
+ gtk_widget_show(arg_get_value(MainDialog, "WINDOW"));
+#ifdef ENABLE_SAVE_TESTS
+ if(comm_server_restores_sessions(Prefs))
+ {
+ harglst * oldSessions = Sessions;
+ Sessions = comm_get_sessions();
+ prefs_dialog_target_fill_sessions(arg_get_value(MainDialog, "TARGET"),
+ Sessions);
+ if(oldSessions)harg_close_all(oldSessions);
+ }
+#endif
+ hosts = sort_dangerous_hosts(hosts);
+ create_report_window(hosts, interrupted_test);
}
-
/*
* Opens the report
*/
-void
-open_report(GtkWidget * dontcare, GtkWidget *nsr)
+void open_report(GtkWidget * dontcare, GtkWidget *nsr)
{
- const char *filename =
- gtk_file_selection_get_filename(GTK_FILE_SELECTION(nsr));
- int be = backend_import_report((char *)filename);
-
- if(be >= 0)
- {
- char *report_name = g_path_get_basename(filename);
-
- report_save(Context, be, report_name);
- g_free(report_name);
- }
+int be = backend_import_report((char*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(nsr)));
+if(be >= 0)report_tests_ng(be, 0);
}
/*
@@ -162,11 +797,11 @@
void open_report_selectfile()
{
GtkWidget * nsr;
- nsr = gtk_file_selection_new (_("Load file"));
+ nsr = gtk_file_selection_new ("Load file");
/*
* CWD
*/
- gtk_file_selection_set_filename (GTK_FILE_SELECTION(nsr), "");
+ gtk_file_selection_set_filename (GTK_FILE_SELECTION(nsr), ".");
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (nsr)->ok_button),
"clicked", (GtkSignalFunc) open_report,(void *) nsr );
@@ -179,5 +814,105 @@
(gpointer) nsr);
gtk_widget_show(nsr);
+}
+
+/*
+ * Saves the report
+ */
+static void
+save_report_ask(nul,menu)
+ GtkWidget * nul;
+ GtkWidget * menu;
+{
+ GtkWidget * active;
+ GtkWidget * filew;
+ char * filename;
+ char * tmp;
+ char * hostname;
+ int value;
+ char * suffixes[] = {".nsr", ".html", ".txt", ".tex", "", ".xml"};
+ struct arglist * hosts;
+
+ active = gtk_menu_get_active(GTK_MENU(menu));
+ value = (int)gtk_object_get_data(GTK_OBJECT(active), "type");
+ hosts = gtk_object_get_data(GTK_OBJECT(menu), "hosts");
+ if(!hosts)
+ {
+ fprintf(stderr, "Error - NULL hosts in save_report_ask()\n");
+ return ;
+ }
+ if(value < 0)value = 0;
+ if(value > SAVE_MAX)value = SAVE_MAX;
+
+
+ hostname = emalloc(strlen(hosts->name)+1);
+ strncpy(hostname, hosts->name, strlen(hosts->name));
+
+ while((tmp = strchr(hostname, '.')))tmp[0]='_';
+
+ filename = emalloc(strlen(hosts->name)+7);
+ sprintf(filename, "%s%s", hostname, suffixes[value]);
+ efree(&hostname);
+
+ filew = gtk_file_selection_new ("Save file");
+ gtk_object_set_data(GTK_OBJECT(filew), "type", (void*)value);
+ gtk_object_set_data(GTK_OBJECT(filew), "hosts", hosts);
+ gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button),
+ "clicked", (GtkSignalFunc) save_report, filew );
+
+ gtk_signal_connect /*_object*/ (GTK_OBJECT (GTK_FILE_SELECTION
+ (filew)->cancel_button),
+ "clicked", (GtkSignalFunc)close_window, (void *)filew);
+ gtk_file_selection_set_filename (GTK_FILE_SELECTION(filew), filename);
+
+ gtk_widget_show(filew);
+}
+
+/*
+ * save_report
+ *
+ * this function is called when the user
+ * clicks on the 'save' item of the file
+ * menu...
+ */
+static void
+save_report(nul,filew)
+ GtkWidget * nul;
+
+ GtkWidget * filew;
+{
+ char * fname = (char*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(filew));
+ int type = (int)gtk_object_get_data(GTK_OBJECT(filew), "type");
+ struct arglist * hosts = gtk_object_get_data(GTK_OBJECT(filew), "hosts");
+
+ gtk_widget_hide(filew);
+ hosts = sort_dangerous_hosts(hosts);
+ switch(type)
+ {
+ case SAVE_HTML :
+ arglist_to_html(hosts, fname);
+ break;
+ case SAVE_XML :
+ arglist_to_xml(hosts, fname);
+ break;
+
+ case SAVE_LATEX :
+ arglist_to_latex(hosts, fname);
+ break;
+ case SAVE_TEXT :
+ arglist_to_text(hosts, fname);
+ break;
+#ifndef _NO_PIES
+ case SAVE_HTML_GRAPH :
+ arglist_to_html_graph(hosts, fname);
+ break;
+#endif /* _NO_PIES */
+ case SAVE_NSR:
+ default :
+ arglist_to_file(hosts, fname);
+ break;
+ }
+ arg_free(hosts);
+ gtk_widget_destroy(filew);
}
#endif
Index: report_save.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/report_save.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- report_save.c 22 Apr 2005 13:51:31 -0000 1.23
+++ report_save.c 17 Mar 2007 21:36:02 -0000 1.24
@@ -26,17 +26,16 @@
* do so, delete this exception statement from your version.
*
* This code deals with the 'save report' dialog.
- */
-
-
+ */
+
+
#include <includes.h>
#ifdef USE_GTK
#include <gtk/gtk.h>
+#include "gtk-compat.h"
#include "xstuff.h"
+#include "xpm/warning.xpm"
-#include "preferences.h"
-#include "context.h"
-#include "error_dialog.h"
#include "backend.h"
#include "nsr_output.h"
#include "html_output.h"
@@ -48,11 +47,9 @@
#include "xml_output_ng.h"
#include "html_graph_output.h"
#include "nbe_output.h"
-#include "pdf_output.h"
-#include "nessus_i18n.h"
+#include "report_ng.h"
-#include "globals.h"
#define SAVE_NBE 0
#define SAVE_NSR 1
@@ -60,268 +57,393 @@
#define SAVE_TEXT 3
#define SAVE_LATEX 4
#define SAVE_HTML_GRAPH 5
-#define SAVE_PDF 6
-#define SAVE_XML 7
-#define SAVE_XML_NG 8
+#define SAVE_XML 6
+#define SAVE_XML_NG 7
#define SAVE_MAX SAVE_XML_NG
/*------------------------------------------------------------------------*/
-static int
-file_save_ok_callback(widget, filedialog)
- GtkWidget *widget;
- GtkWidget *filedialog;
+static int file_dialog_hide(filedialog)
+ GtkWidget * filedialog;
{
- const char *filename =
- gtk_file_selection_get_filename(GTK_FILE_SELECTION(filedialog));
- char *basename = g_path_get_basename(filename);
- char *ext = strrchr(basename, '.');
- char *fname;
- struct arglist *hosts = NULL;
- GtkWidget *menu = gtk_object_get_data(GTK_OBJECT(filedialog), "menu");
- GtkWidget *active = gtk_menu_get_active(GTK_MENU(menu));
- int type = (int)gtk_object_get_data(GTK_OBJECT(active), "type");
- char *suffixes[] =
- { ".nbe", ".nsr", ".html", ".txt", ".tex", ".pdf", "", ".xml", ".xml" };
-#define MAX_SUFFIX_LEN 5 /* .html */
- char *suffix = suffixes[type];
- int be = (int)arg_get_value(arg_get_value(MainDialog, "REPORT"), "BE");
-
- gtk_widget_hide(filedialog);
+ gtk_widget_hide(filedialog);
+ gtk_widget_destroy(filedialog);
+ return 0;
+}
- if(check_is_dir(filename))
- fname = g_build_filename(filename, basename, NULL);
- else
- fname = g_strdup(filename);
+static int file_save_ok_callback(widget, filedialog)
+ GtkWidget * widget;
+ GtkWidget * filedialog;
+{
+ char * fname = (char*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(filedialog));
+ int type;
+ struct arglist * hosts = NULL;
+ GtkWidget * menu = gtk_object_get_data(GTK_OBJECT(filedialog), "menu");
+ GtkWidget * window = gtk_object_get_data(GTK_OBJECT(filedialog), "window");
+ GtkWidget * active;
+ char * suffixes[] = {".nbe", ".nsr", ".html", ".txt", ".tex", "", ".xml", ".xml"};
+#define MAX_SUFFIX_LEN 5 /* .html */
+ int be = (int)gtk_object_get_data(GTK_OBJECT(filedialog), "be");
+
+ gtk_object_set_data(GTK_OBJECT(window), "report_saved", (void*)1);
+ gtk_widget_hide(filedialog);
- /*
- * Add a default extension
- */
- if(suffix && (!ext || strcmp(ext, suffix)))
- {
- char *tmpname = g_strdup_printf("%s%s", fname, suffix);
+
+
+ active = gtk_menu_get_active(GTK_MENU(menu));
+ type = (int)gtk_object_get_data(GTK_OBJECT(active), "type");
- g_free(fname);
- fname = tmpname;
- }
+
+
+ /*
+ * Add a default extension
+ */
+ if(strrchr(fname, '.'))
+ fname = estrdup(fname);
+ else
+ {
+ char * s;
+ s = emalloc(strlen(fname) + MAX_SUFFIX_LEN + 1);
+ strcat(s, fname);
+ strcat(s, suffixes[type]);
+ fname = s;
+ }
+
+
+
+
- switch (type)
- {
- case SAVE_HTML:
- hosts = backend_convert(be);
- arglist_to_html(hosts, fname);
- break;
- case SAVE_XML:
- hosts = backend_convert(be);
- arglist_to_xml(hosts, fname);
- break;
- case SAVE_XML_NG:
- backend_to_xml_ng(be, fname);
- break;
- case SAVE_LATEX:
- hosts = backend_convert(be);
- arglist_to_latex(hosts, fname);
- break;
- case SAVE_TEXT:
- hosts = backend_convert(be);
- arglist_to_text(hosts, fname);
- break;
+ switch(type)
+ {
+ case SAVE_HTML :
+ hosts = backend_convert(be);
+ arglist_to_html(hosts, fname);
+ break;
+ case SAVE_XML :
+ hosts = backend_convert(be);
+ arglist_to_xml(hosts, fname);
+ break;
+ case SAVE_XML_NG :
+ backend_to_xml_ng(be, fname);
+ break;
+ case SAVE_LATEX :
+ hosts = backend_convert(be);
+ arglist_to_latex(hosts, fname);
+ break;
+ case SAVE_TEXT:
+ hosts = backend_convert(be);
+ arglist_to_text(hosts, fname);
+ break;
#ifndef _NOPIE
- case SAVE_HTML_GRAPH:
- hosts = backend_convert(be);
- arglist_to_html_graph(hosts, fname);
- break;
+ case SAVE_HTML_GRAPH:
+ hosts = backend_convert(be);
+ arglist_to_html_graph(hosts,fname);
+ break;
#endif
- case SAVE_PDF:
- arglist_to_pdf(be, fname);
- break;
- case SAVE_NSR:
- backend_to_nsr(be, fname);
- break;
- case SAVE_NBE:
- default:
- backend_to_nbe(be, fname);
- break;
+ case SAVE_NSR:
+ backend_to_nsr(be, fname);
+ break;
+ case SAVE_NBE:
+ default:
+ backend_to_nbe(be, fname);
+ break;
}
- g_free(basename);
- g_free(fname);
- if(hosts)
- arg_free_all(hosts);
- gtk_widget_destroy(filedialog);
- return 0;
+ efree(&fname);
+ if(hosts)arg_free_all(hosts);
+ gtk_widget_destroy(filedialog);
+ if(gtk_object_get_data(GTK_OBJECT(window), "dont_close"))
+ gtk_object_remove_data(GTK_OBJECT(window), "dont_close");
+ else
+ report_delete_window(window, NULL);
+ return 0;
}
/*
* "inspired" from the Gimp 1.2.2
* See gimp/app/fileops.c for a cleaner function
*/
-void
-report_save_cb(window)
- GtkWidget *window;
+static void
+file_dialog_setup(window)
+ GtkWidget * window;
{
- GtkWidget *filesave;
- GtkWidget *frame;
- GtkWidget *hbox;
- GtkWidget *label;
- GtkWidget *option_menu;
- GtkWidget *menu;
- GtkWidget *save_options;
- GtkWidget *type;
-
- filesave = gtk_file_selection_new(_("Export Report"));
-
- gtk_window_set_position(GTK_WINDOW(filesave), GTK_WIN_POS_MOUSE);
-
- gtk_container_border_width(GTK_CONTAINER(filesave), 2);
- gtk_container_border_width(GTK_CONTAINER(GTK_FILE_SELECTION(filesave)->
- button_area), 2);
-
- g_signal_connect(GTK_FILE_SELECTION(filesave)->ok_button,
- "clicked", G_CALLBACK(file_save_ok_callback), filesave);
-
- g_signal_connect_swapped(GTK_FILE_SELECTION(filesave)->cancel_button,
- "clicked", G_CALLBACK(gtk_widget_destroy), filesave);
-
- save_options = gtk_hbox_new(TRUE, 1);
+ GtkWidget *filesave;
+ GtkWidget *frame;
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtkWidget *option_menu;
+ GtkWidget *menu;
+ GtkWidget *save_options;
+ GtkWidget *type;
+
+ filesave = gtk_file_selection_new("Save Report");
+ gtk_object_set_data(GTK_OBJECT(filesave), "window", window);
+ gtk_object_set_data(GTK_OBJECT(filesave), "be",
+ gtk_object_get_data(GTK_OBJECT(window), "be"));
+
+ gtk_window_set_wmclass(GTK_WINDOW(filesave), "save_report", "Nessus");
+#if GTK_VERSION > 10
+ gtk_window_set_position(GTK_WINDOW(filesave), GTK_WIN_POS_MOUSE);
+#endif
+ gtk_object_set_data(GTK_OBJECT(filesave), "be",
+ gtk_object_get_data(GTK_OBJECT(window), "be"));
+
+ gtk_container_border_width(GTK_CONTAINER(filesave), 2);
+ gtk_container_border_width(GTK_CONTAINER(
+ GTK_FILE_SELECTION(filesave)->button_area), 2);
- frame = gtk_frame_new(_("Export Options"));
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
- gtk_box_pack_start(GTK_BOX(save_options), frame, TRUE, TRUE, 4);
+ gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filesave)->cancel_button),
+ "clicked",
+ GTK_SIGNAL_FUNC (file_dialog_hide),
+ GTK_OBJECT (filesave));
+ gtk_signal_connect (GTK_OBJECT (filesave), "delete_event",
+ GTK_SIGNAL_FUNC (file_dialog_hide),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filesave)->ok_button),
+ "clicked",
+ GTK_SIGNAL_FUNC (file_save_ok_callback),
+ filesave);
+ gtk_quit_add_destroy (1, GTK_OBJECT (filesave));
+
+
+ save_options = gtk_hbox_new (TRUE, 1);
- hbox = gtk_hbox_new(FALSE, 4);
- gtk_container_border_width(GTK_CONTAINER(hbox), 4);
- gtk_container_add(GTK_CONTAINER(frame), hbox);
- gtk_widget_show(hbox);
+ frame = gtk_frame_new ("Save Options");
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
+ gtk_box_pack_start (GTK_BOX (save_options), frame, TRUE, TRUE, 4);
- label = gtk_label_new(_("Report file format : "));
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- gtk_widget_show(label);
+ hbox = gtk_hbox_new (FALSE, 4);
+ gtk_container_border_width (GTK_CONTAINER (hbox), 4);
+ gtk_container_add (GTK_CONTAINER (frame), hbox);
+ gtk_widget_show (hbox);
- option_menu = gtk_option_menu_new();
- gtk_box_pack_start(GTK_BOX(hbox), option_menu, TRUE, TRUE, 0);
- gtk_widget_show(option_menu);
+ label = gtk_label_new ("Report file format : ");
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+ option_menu = gtk_option_menu_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), option_menu, TRUE, TRUE, 0);
+ gtk_widget_show (option_menu);
+
+
+
+
/*---------------------------------------------------------------*
- * We fill the dialog with the various export formats
+ * We fill the dialog with the various export formats
* we know about
*---------------------------------------------------------------*/
- menu = gtk_menu_new();
+ menu = gtk_menu_new();
gtk_object_set_data(GTK_OBJECT(filesave), "menu", menu);
-
+
type = gtk_menu_item_new_with_label("NBE");
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_NBE);
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_NBE);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-
-
- type = gtk_menu_item_new_with_label(_("NSR (deprecated)"));
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_NSR);
+
+
+
+ type = gtk_menu_item_new_with_label("NSR (deprecated)");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_NSR);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-
- type = gtk_menu_item_new_with_label("XML");
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_XML_NG);
+
+ type = gtk_menu_item_new_with_label ("XML");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_XML_NG);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-
- type = gtk_menu_item_new_with_label(_("XML (old style - deprecated)"));
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_XML);
+
+
+ type = gtk_menu_item_new_with_label ("XML (old style - deprecated)");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_XML);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-
-
+
+
+
type = gtk_menu_item_new_with_label("HTML");
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_HTML);
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_HTML);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-
+
type = gtk_menu_item_new_with_label("LaTeX");
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_LATEX);
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_LATEX);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-
- type = gtk_menu_item_new_with_label(_("ASCII text"));
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_TEXT);
+
+ type = gtk_menu_item_new_with_label("ASCII text");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_TEXT);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
#ifndef _NO_PIES
- type = gtk_menu_item_new_with_label(_("HTML with Pies and Graphs"));
- gtk_object_set_data(GTK_OBJECT(type), "type", (void *)SAVE_HTML_GRAPH);
+ type = gtk_menu_item_new_with_label("HTML with Pies and Graphs");
+ gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_HTML_GRAPH);
gtk_menu_append(GTK_MENU(menu), type);
gtk_widget_show(type);
-#endif
+#endif
+
- type = gtk_menu_item_new_with_label("PDF");
- gtk_object_set_data(GTK_OBJECT(type), "type", (void*)SAVE_PDF);
- gtk_menu_append(GTK_MENU(menu), type);
- gtk_widget_show(type);
+
+
+ /*----------------------------------------------------------------*/
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
+ gtk_widget_show(menu);
+ gtk_widget_show (frame);
- /*----------------------------------------------------------------*/
- gtk_option_menu_set_menu(GTK_OPTION_MENU(option_menu), menu);
- gtk_widget_show(menu);
- gtk_widget_show(frame);
+ /* pack the containing save_options hbox into the save-dialog */
+ gtk_box_pack_end (GTK_BOX (GTK_FILE_SELECTION (filesave)->main_vbox),
+ save_options, FALSE, FALSE, 0);
+ gtk_widget_show(save_options);
+ gtk_widget_show(filesave);
+
+}
- /* pack the containing save_options hbox into the save-dialog */
- gtk_box_pack_end(GTK_BOX(GTK_FILE_SELECTION(filesave)->main_vbox),
- save_options, FALSE, FALSE, 0);
- gtk_widget_show(save_options);
- gtk_widget_show(filesave);
+
+/*------------------------------------------------------------------------*/
+static int
+dialog_close_do_save(a, dialog)
+ GtkWidget * a, * dialog;
+{
+ GtkWidget * window = gtk_object_get_data(GTK_OBJECT(dialog), "report");
+ gtk_widget_hide(dialog);
+ file_dialog_setup(window);
+ return 0;
}
-/*
- * Open a pdf file with the configured pdf viewer.
- * XXX: This function eventually should be moved into a more
- * suitable module.
- */
+static int
+dialog_close_dont_save(a, dialog)
+ GtkWidget * a, * dialog;
+{
+ GtkWidget * window = gtk_object_get_data(GTK_OBJECT(dialog), "report");
+ gtk_widget_hide(dialog);
+ gtk_object_set_data(GTK_OBJECT(window), "report_saved", (void*)1);
+ report_delete_window(window, NULL);
+ return 0;
+}
+
+static int
+dialog_close_cancel(a, dialog)
+ GtkWidget * a, * dialog;
+{
+ gtk_widget_hide(dialog);
+ return 0;
+}
+
+
+
+
+
void
-show_pdf(filename)
- char * filename;
+dialog_close_setup(window)
+ GtkWidget * window;
{
- const gchar *pdfviewer = prefs_get_string(Global, "pdfviewer");
+ GtkWidget * dialog;
+ GtkWidget * button;
+ GtkWidget * vbox;
+ GtkWidget * hbox;
+ GtkWidget * label;
+ GtkStyle * style;
+ GtkWidget * pixmapwid;
+ GdkPixmap * pixmap;
+ GdkBitmap * mask;
+ GtkWidget * table;
+ char * name = "Save report";
+ char * error_text =
+ "This report was not saved.\nDo you want to save it ?";
+
+
+ dialog = gtk_object_get_data(GTK_OBJECT(window),
+ "save_dialog");
- if (!check_is_file(filename))
+ if(dialog)
{
- show_warning(_("PDF file %s not found."), filename);
- return;
- }
+ gtk_widget_show(dialog);
+ return;
+ }
+
+ dialog = gtk_window_new(WINDOW_DIALOG);
+ gtk_object_set_data(GTK_OBJECT(dialog), "report", window);
+ gtk_object_set_data(GTK_OBJECT(window), "save_dialog", dialog);
+
+ gtk_window_set_title(GTK_WINDOW(dialog), name);
+ gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
+ GTK_SIGNAL_FUNC (delete_event), NULL);
+ gtk_window_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+ vbox = gtk_vbox_new(FALSE, 15);
+ gtk_container_border_width(GTK_CONTAINER(dialog), 10);
+ gtk_container_add(GTK_CONTAINER(dialog), vbox);
+ gtk_widget_show(vbox);
+
+ hbox = gtk_hbox_new(FALSE,5);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE,0);
+ gtk_widget_show(hbox);
- if (!pdfviewer)
- {
- show_warning(_("You haven't configured a PDF viewer."
- "\nThe report was saved as %s so you can manually open it."),
- filename);
- return;
- }
+ label = gtk_label_new(error_text);
+ gtk_label_set_justify (GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 3);
+ gtk_widget_show(label);
+
+
+
+ button = gtk_button_new_with_label ("Yes");
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_close_do_save), dialog);
+
+ table = gtk_table_new(1,3, TRUE);
+ gtk_box_pack_end(GTK_BOX(vbox), table, TRUE, TRUE, 0);
+ gtk_widget_show(table);
+
+
+
+
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 0,1,0,1);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default (button);
+ gtk_widget_show (button);
+ gtk_widget_realize(dialog);
+
+
+ button = gtk_button_new_with_label ("No");
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_close_dont_save), dialog);
+
+
+
+
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 1,2,0,1);
+ gtk_widget_show (button);
+ gtk_widget_realize(dialog);
- {
- gchar *cmd = g_strdup_printf("'%s' '%s'", pdfviewer, filename);
- /* start PDF viewer */
- if(!g_spawn_command_line_async(cmd, NULL))
- show_error(_("Can't launch PDF viewer: %s"), pdfviewer);
- g_free(cmd);
- }
+ button = gtk_button_new_with_label ("Cancel");
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_close_cancel), dialog);
+
+
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 2,3,0,1);
+ gtk_widget_show (button);
+ gtk_widget_realize(dialog);
+
+
+
+ style = gtk_widget_get_style(dialog);
+ pixmap = gdk_pixmap_create_from_xpm_d(dialog->window, &mask,
+ &style->bg[GTK_STATE_NORMAL],
+ (char **)warning_xpm);
+ pixmapwid = gtk_pixmap_new(pixmap, mask);
+
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwid, FALSE, TRUE,3);
+ gtk_widget_show(pixmapwid);
+ gtk_widget_show(dialog);
}
void
-report_open_pdf(menuitem, ctrls)
- GtkWidget *menuitem;
- gpointer ctrls;
+report_save_cb(w, window)
+ GtkWidget * w, * window;
{
- int be = (int)arg_get_value(arg_get_value(ctrls, "REPORT"), "BE");
- char *basename = g_path_get_basename(Context->dir);
- char *fname = g_strdup_printf("%s.pdf", basename);
- char *filename = g_build_filename(Context->dir, fname, NULL);
-
- g_free(basename);
- g_free(fname);
- arglist_to_pdf(be, filename);
-
- show_pdf(filename);
- g_free(filename);
+ gtk_object_set_data(GTK_OBJECT(window), "dont_close", (void*)1);
+ file_dialog_setup(window);
}
#endif
Index: report_save.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/report_save.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- report_save.h 9 Dec 2004 11:07:30 -0000 1.6
+++ report_save.h 17 Mar 2007 21:36:02 -0000 1.7
@@ -1,8 +1,8 @@
#ifndef NESSUS_REPORT_SAVE_H_
#define NESSUS_REPORT_SAVE_H_
-void report_save_cb(GtkWidget *);
-void report_open_pdf(GtkWidget *, gpointer);
-void show_pdf(char *);
+void report_save_cb(GtkWidget*, GtkWidget*);
+void dialog_close_setup(GtkWidget*);
+
#endif
Index: report_utils.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/report_utils.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- report_utils.c 3 Nov 2004 14:25:33 -0000 1.10
+++ report_utils.c 17 Mar 2007 21:36:02 -0000 1.11
@@ -55,6 +55,111 @@
return arg->next ? 1 + arglist_length(arg->next):0;
}
+struct arglist * sort_by_port(hosts)
+ struct arglist * hosts;
+{
+ struct arglist * by_port;
+ struct arglist * sub_port;
+ struct arglist * hosts_port;
+ struct arglist * sub_arg;
+ struct arglist * tmp_port;
+ char * comm;
+ by_port = emalloc(sizeof(struct arglist));
+
+ if (!hosts || !hosts->next) {
+ return by_port;
+ }
+
+ while (hosts && hosts->next)
+ {
+ struct arglist * ports = arg_get_value(hosts->value, "PORTS");
+ while(ports && ports->next)
+ {
+ struct arglist * reports = arg_get_value(ports->value, "REPORT");
+ struct arglist * infos = arg_get_value(ports->value, "INFO");
+ struct arglist * notes = arg_get_value(ports->value, "NOTE");
+
+ tmp_port = arg_get_value(by_port, ports->name);
+ if(!tmp_port)
+ {
+ tmp_port = emalloc(sizeof(struct arglist));
+ arg_add_value(by_port, ports->name, ARG_ARGLIST, -1, tmp_port);
+ }
+
+ hosts_port = arg_get_value(tmp_port,"HOSTS");
+ if (!hosts_port){
+ hosts_port = emalloc(sizeof(struct arglist));
+ arg_add_value(tmp_port, "HOSTS", ARG_ARGLIST, -1, hosts_port);
+ }
+
+ sub_port = arg_get_value(hosts_port,hosts->name);
+ if (!sub_port){
+ sub_port = emalloc(sizeof(struct arglist));
+ arg_add_value(hosts_port, hosts->name, ARG_ARGLIST, -1, sub_port);
+ /*arg_add_value(sub_port, "STATE", ARG_INT, sizeof(int),(void *)1);*/
+ }
+ if ( reports || infos || notes){
+ if (reports) {
+ sub_arg = arg_get_value(sub_port, "REPORT");
+ if (!sub_arg) {
+ sub_arg = emalloc(sizeof(struct arglist));
+
+ }
+ while (sub_arg && sub_arg->next)sub_arg = sub_arg->next;
+
+ while (reports && reports->next) {
+ comm = emalloc(strlen(reports->value)+1);
+ strncpy(comm, reports->value, strlen(reports->value));
+ /* arg_add_value(tmp_port, hosts->name, ARG_STRING, strlen(comm),comm); */
+ arg_add_value(sub_arg, "REPORT", ARG_STRING, strlen(comm),comm);
+ reports = reports->next;
+ }
+ arg_add_value(sub_port, "REPORT", ARG_ARGLIST, -1, sub_arg);
+ }
+
+ if (notes) {
+ sub_arg = arg_get_value(sub_port, "NOTE");
+ if (!sub_arg) {
+ sub_arg = emalloc(sizeof(struct arglist));
+ arg_add_value(sub_port, "NOTE", ARG_ARGLIST, -1, sub_arg);
+ }
+ while (sub_arg && sub_arg->next)sub_arg = sub_arg->next;
+
+ while (notes && notes->next) {
+ comm = emalloc(strlen(notes->value)+1);
+ strncpy(comm, notes->value, strlen(notes->value));
+ /* arg_add_value(tmp_port, hosts->name, ARG_STRING, strlen(comm),comm); */
+ arg_add_value(sub_arg, "NOTE", ARG_STRING, strlen(comm),comm);
+ notes = notes->next;
+ }
+ }
+
+ if (infos) {
+ sub_arg = arg_get_value(sub_port, "INFO");
+ if (!sub_arg) {
+ sub_arg = emalloc(sizeof(struct arglist));
+ arg_add_value(sub_port, "INFO", ARG_ARGLIST, -1, sub_arg);
+ }
+ while (sub_arg && sub_arg->next)sub_arg = sub_arg->next;
+
+ while (infos && infos->next) {
+ comm = emalloc(strlen(infos->value)+1);
+ strncpy(comm, infos->value, strlen(infos->value));
+ /* arg_add_value(tmp_port, hosts->name, ARG_STRING, strlen(comm),comm); */
+ arg_add_value(sub_arg, "INFO", ARG_STRING, strlen(comm),comm);
+ infos = infos->next;
+ }
+ }
+ }
+ ports = ports->next;
+ }
+ hosts = hosts->next;
+ }
+
+ return by_port;
+}
+
+
/*
* Auxilliary functions
@@ -189,3 +294,68 @@
else return sub_most_dangerous_host_notes(hosts, NULL, 0);
}
+/************************************************************************
+ *
+ * Insertion sort
+ *
+ ************************************************************************/
+
+
+struct arglist * arglist_insert(struct arglist*e, struct arglist** l)
+{
+ int greater = 0;
+ int danger_e = 0;
+ int danger_l = 0;
+
+ danger_e = number_of_holes_by_host(e->value);
+ danger_l = number_of_holes_by_host((*l)->value);
+ if(danger_e > danger_l)greater++;
+
+ if(!(danger_e || danger_l))
+ {
+ danger_e = number_of_warnings_by_host(e->value);
+ danger_l = number_of_warnings_by_host((*l)->value);
+ if(danger_e > danger_l)greater++;
+ }
+ if(!(danger_e || danger_l))
+ {
+ danger_e = number_of_notes_by_host(e->value);
+ danger_l = number_of_notes_by_host((*l)->value);
+ if(danger_e > danger_l)greater++;
+ }
+
+ if(!((*l)->next) || greater)
+ {
+ e->next = *l;
+ *l = e;
+ return *l;
+ }
+ else
+ {
+ arglist_insert(e, &((*l)->next));
+ return *l;
+ }
+}
+
+struct arglist * arglist_insert_sort(struct arglist * l)
+{
+ if(!l->next)
+ return l;
+ else
+ {
+ struct arglist * result_insert;
+
+ result_insert = arglist_insert_sort(l->next);
+ return arglist_insert(l, &result_insert);
+ }
+}
+
+
+
+
+struct arglist * sort_dangerous_hosts(struct arglist * hosts)
+{
+ struct arglist * ret = emalloc(sizeof(struct arglist));
+ arg_dup(ret, hosts);
+ return arglist_insert_sort(ret);
+}
Index: report_utils.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/report_utils.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- report_utils.h 3 Nov 2004 14:25:33 -0000 1.7
+++ report_utils.h 17 Mar 2007 21:36:02 -0000 1.8
@@ -1,6 +1,8 @@
#ifndef NESSUSC_REPORT_UTILS_H__
#define NESSUSC_REPORT_UTILS_H__
+struct arglist * sort_by_port(struct arglist *);
+
int arglist_length(struct arglist *);
int number_of_notes_by_port(struct arglist *);
@@ -17,6 +19,7 @@
int number_of_holes(struct arglist * );
struct arglist *most_dangerous_host(struct arglist *);
+struct arglist * sort_dangerous_hosts(struct arglist *);
int safe_strcmp(char*, char*);
#endif
Index: sighand.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/sighand.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- sighand.c 21 Dec 2004 15:08:17 -0000 1.20
+++ sighand.c 17 Mar 2007 21:36:03 -0000 1.21
@@ -1,6 +1,5 @@
/* Nessus
* Copyright (C) 1998 - 2001 Renaud Deraison
- * Copyright (C) 2004 Intevation GmbH
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
@@ -30,48 +29,54 @@
*/
#include <includes.h>
-#include "nessus_i18n.h"
+#include "nsr_output.h"
#include "error_dialog.h"
-#include "context.h"
+#include "globals.h"
#include "backend.h"
#include "auth.h"
-#include "globals.h" /* for closesocket() */
void
nessus_exit(code)
- int code;
+ int code;
{
- backend_clear_all();
- exit(code);
+ backend_clear_all();
+ exit(code);
}
-
-void
+void
sighand_pipe()
{
- Context->socket = -1;
- show_error(_("Connection closed by the server (SIGPIPE caught)"));
+#ifdef USE_GTK
+ if(!F_quiet_mode)
+ show_error_and_wait("Connection closed by the server (SIGPIPE caught)");
+ else
+#endif
+ fprintf(stderr, "Connection closed by the server (SIGPIPE caught)\n");
}
+
void
sighand_alarm()
{
- show_error(_("Connection timed out"));
+#ifdef USE_GTK
+ if(!F_quiet_mode)show_error_and_wait("Connection timed out");
+ else
+#endif
+ fprintf(stderr, "Connection timed out\n");
}
-
+
void sighand_exit()
{
- /* FIXME: close all open connections */
- if(Context->socket > 0)
- {
- network_printf( "CLIENT <|> STOP_WHOLE_TEST <|> CLIENT\n");
+ if(GlobalSocket > 0)
+ {
+ network_printf( "CLIENT <|> STOP_WHOLE_TEST <|> CLIENT\n");
#ifdef NESSUS_ON_SSL
- close_stream_connection(Context->socket);
-#else
- shutdown(Context->socket, 2);
- closesocket(Context->socket);
-#endif
- Context->socket = -1;
- }
- nessus_exit(1);
+ close_stream_connection(GlobalSocket);
+#else
+ shutdown(GlobalSocket, 2);
+ closesocket(GlobalSocket);
+#endif
+ GlobalSocket = -1;
+ }
+ nessus_exit (1);
}
Index: text_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/text_output.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- text_output.c 3 Nov 2004 14:25:35 -0000 1.10
+++ text_output.c 17 Mar 2007 21:36:03 -0000 1.11
@@ -30,6 +30,7 @@
#include "report.h"
#include "report_utils.h"
#include "error_dialog.h"
+#include "globals.h"
static int line_length(char * text)
@@ -70,7 +71,8 @@
{
/* go to the end and rewind until we find a space */
char * t = text + width - pl;
- while((t[0]!=' ') && (t[0]!='\n'))
+ if ( t >= (text + length) ) t = NULL;
+ while(t != NULL && (t[0]!=' ') && (t[0]!='\n'))
{
t--;
if(t == text)
Index: xml_output.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/xml_output.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- xml_output.c 3 Nov 2004 14:25:35 -0000 1.11
+++ xml_output.c 17 Mar 2007 21:36:03 -0000 1.12
@@ -30,6 +30,7 @@
#include "report.h"
#include "report_utils.h"
#include "error_dialog.h"
+#include "globals.h"
#include "xml_output.h"
static char *parse_portname ( char *name, int howto );
Index: xml_output_ng.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/xml_output_ng.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- xml_output_ng.c 6 Jul 2005 14:53:28 -0000 1.34
+++ xml_output_ng.c 17 Mar 2007 21:36:03 -0000 1.35
@@ -41,7 +41,6 @@
#include <includes.h>
-#include "nessus_i18n.h"
#include <stdarg.h>
#include "report.h"
@@ -49,8 +48,6 @@
#include "backend.h"
#include "data_mining.h"
#include "globals.h"
-#include "context.h"
-#include "preferences.h"
#include "report_utils.h"
int backend_to_xml_ng (int, char *);
@@ -187,12 +184,21 @@
static void
xml_info_host (int be, FILE* fd, int indent, struct arglist * t)
{
- const char *host = prefs_get_string(Context, "nessusd_host");
-
xml_fprintf (fd, indent, "<host>\n");
- xml_fprintf_element(fd, indent+1, "name", (char*)host);
+ if (First_time)
+ {
+ t = Prefs;
+ if (t)
+ {
+ xml_fprintf_element (
+ fd, indent+1, "name", (char *) arg_get_value (t, "nessusd_host"));
+ }
+ }
+ else
+ xml_fprintf (fd, indent+1,
+ "<error txt=\"No server name information (not connected ?).\"/>\n");
- t = arg_get_value(Context->prefs, "SERVER_INFO");
+ t = arg_get_value(Prefs, "SERVER_INFO");
if (t)
{
xml_fprintf_element (fd, indent+1, "osname", (char *) arg_get_value (t, "server_info_os"));
@@ -253,19 +259,20 @@
xml_info (int be, FILE* fd, int indent)
{
struct arglist * t;
- t = arg_get_value(Context->prefs, "SERVER_INFO");
+ t = arg_get_value(Prefs, "SERVER_INFO");
if (t)
{
- xml_fprintf (fd, 2, "<info>\n");
+ xml_fprintf (fd, indent, "<info>\n");
xml_info_nessusd(be, fd, indent+1, t);
xml_info_host(be, fd, indent+1, t);
xml_info_date(be, fd, indent+1, t);
- xml_fprintf (fd, 2, "</info>\n\n");
+ xml_fprintf (fd, indent, "</info>\n");
} else {
- xml_fprintf (fd, 2, "<info>\n");
+ fprintf (stderr, "xml_output: No SERVER_INFO found.\n");
+ xml_fprintf (fd, indent, "<info>\n");
xml_fprintf (fd, indent+1, "<!-- no version information found -->");
- xml_fprintf (fd, 2, "</info>\n\n");
+ xml_fprintf (fd, indent, "</info>\n");
}
} /* xml_info */
@@ -280,7 +287,7 @@
efree(&esc_name);
t = t->next;
}
- xml_fprintf (fd, indent, "</scanners>\n\n");
+ xml_fprintf (fd, indent, "</scanners>\n");
} /* xml_config_scanners */
static void
@@ -288,7 +295,7 @@
{
char* esc_name = escape_string(name);
char* esc_value = escape_string(value);
- xml_fprintf (fd, indent+1,
+ xml_fprintf (fd, indent,
"<pref name=\"%s\" value=\"%s\" />\n", esc_name, esc_value);
efree(&esc_name);
efree(&esc_value);
@@ -297,8 +304,8 @@
static void
xml_config_global (FILE* fd, int indent, struct arglist* t)
{
- xml_fprintf (fd, indent, "<global> ");
- while(t && t->next)
+ xml_fprintf (fd, indent, "<global>\n");
+ while( t->next != NULL )
{
if (t->type == ARG_STRING) {
xml_config_global_pref(fd, indent+1, t->name, t->value);
@@ -307,7 +314,7 @@
}
t = t->next;
} /* while */
- fprintf (fd, "</global>\n");
+ xml_fprintf (fd, indent, "</global>\n");
} /* xml_config_global */
static void
@@ -333,7 +340,7 @@
xml_setting (fd, indent+1, t->name, (t->value?"yes":"no"));
t = t->next;
}
- xml_fprintf (fd, indent, "</plugins>\n\n");
+ xml_fprintf (fd, indent, "</plugins>\n");
} /* xml_config_server */
static void
@@ -351,7 +358,7 @@
}
t = t->next;
}
- xml_fprintf (fd, indent, "</server>\n\n");
+ xml_fprintf (fd, indent, "</server>\n");
} /* xml_config_server */
static void
@@ -361,27 +368,31 @@
xml_fprintf (fd, indent, "<config>\n");
- xml_config_global (fd, indent+1, Context->prefs);
+ t = Prefs;
+ if (t)
+ {
+ xml_config_global (fd, indent+1, t);
+ }
- t = arg_get_value(Context->prefs, "SCANNER_SET");
+ t = arg_get_value(Prefs, "SCANNER_SET");
if (t)
{
xml_config_scanners(fd, indent+1, t);
}
- t = arg_get_value(Context->prefs, "SERVER_PREFS");
+ t = arg_get_value(Prefs, "SERVER_PREFS");
if (t)
{
xml_config_server(fd, indent+1, t);
}
- t = arg_get_value(Context->prefs, "PLUGINS_PREFS");
+ t = arg_get_value(Prefs, "PLUGINS_PREFS");
if (t)
{
xml_config_plugins(fd, indent+1, t);
}
- xml_fprintf (fd, indent, "</config>\n\n");
+ xml_fprintf (fd, indent, "</config>\n");
}
static void
@@ -398,7 +409,7 @@
xml_fprintf_element (fd, indent+1, "risk", getrisk((char*)arg_get_value (u, "DESCRIPTION")));
xml_fprintf_element (fd, indent+1, "summary", arg_get_value (u, "SUMMARY"));
xml_fprintf_element (fd, indent+1, "copyright", (char *) arg_get_value (u, "COPYRIGHT"));
- xml_fprintf (fd, indent, "</plugin>\n\n");
+ xml_fprintf (fd, indent, "</plugin>\n");
} /* xml_plugins_plugin */
static void
@@ -408,7 +419,7 @@
xml_fprintf (fd, indent, "<plugins>\n");
- t = Context->scanners;
+ t = Scanners;
if (t && t->type == ARG_ARGLIST)
{
while (t->next)
@@ -425,7 +436,7 @@
else
xml_fprintf (fd, indent+1, "<error txt=\"No scanners list.\"/>\n");
- t = Context->plugins;
+ t = Plugins;
if (t && t->type == ARG_ARGLIST)
{
while (t->next)
@@ -442,8 +453,7 @@
else
xml_fprintf (fd, indent+1, "<error txt=\"No plugins list.\"/>\n");
-
- xml_fprintf (fd, indent, "</plugins>\n\n");
+ xml_fprintf (fd, indent, "</plugins>\n");
}
@@ -698,7 +708,7 @@
q = subset_next(q);
}
- xml_fprintf (fd, indent, "</results>\n\n");
+ xml_fprintf (fd, indent, "</results>\n");
subset_free(sq);
} /* xml_results */
@@ -710,7 +720,7 @@
if(!fd)
{
- show_error(_("Can't open %s for writing: %s."), strerror(errno));
+ show_error(strerror(errno));
return -1;
}
Index: xstuff.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/xstuff.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- xstuff.c 4 Nov 2004 19:31:18 -0000 1.13
+++ xstuff.c 17 Mar 2007 21:36:03 -0000 1.14
@@ -33,8 +33,8 @@
#include "nessus.h"
#include "xstuff.h"
+#include "globals.h"
#include "sighand.h"
-#include "context.h"
int init_display(int *argc, char *** argv)
{
@@ -51,6 +51,11 @@
int delete_event(GtkWidget * nul, void * data)
{
return(FALSE);
+}
+void close_display()
+{
+ gtk_main_quit();
+ nessus_exit(0);
}
struct pixmap_and_mask
Index: xstuff.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/xstuff.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- xstuff.h 4 Nov 2004 19:31:18 -0000 1.6
+++ xstuff.h 17 Mar 2007 21:36:03 -0000 1.7
@@ -20,6 +20,7 @@
#define _NESSUSC_XSTUFF_H
int init_display(int *argc, char *** argv);
+void close_display();
int close_window(GtkWidget * , GtkWidget * );
int delete_event(GtkWidget * nul, void * data);
GtkWidget *make_pixmap(GtkWidget *, GdkColor *, char **);
_______________________________________________
Nessus-cvs mailing list
Nessus-cvs@list.nessus.org
http://mail.nessus.org/mailman/listinfo/nessus-cvs