Mailing List Archive

nessus-core/nessus/prefs_dialog prefs_about.c, 1.19, 1.20 prefs_about.h, 1.2, 1.3 prefs_dialog.c, 1.80, 1.81 prefs_dialog.h, 1.6, 1.7 prefs_dialog_auth.c, 1.52, 1.53 prefs_dialog_auth.h, 1.5, 1.6 prefs_dialog_misc.c, 1.6, 1.7 prefs_dialog_plugins_prefs.c,
Update of /usr/local/cvs/nessus-core/nessus/prefs_dialog
In directory raccoon.nessus.org:/tmp/cvs-serv69892/nessus/prefs_dialog

Modified Files:
prefs_about.c prefs_about.h prefs_dialog.c prefs_dialog.h
prefs_dialog_auth.c prefs_dialog_auth.h prefs_dialog_misc.c
prefs_dialog_plugins_prefs.c prefs_dialog_plugins_prefs.h
prefs_dialog_scan_opt.c prefs_dialog_scan_opt.h
prefs_dialog_user.c prefs_dialog_user.h prefs_help.h
prefs_kb.c prefs_kb.h prefs_plugins.c prefs_plugins.h
prefs_target.c prefs_target.h
Log Message:
Sync back to 2.2 as NessusClient is now on another branch


Index: prefs_about.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_about.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- prefs_about.c 14 Dec 2004 07:43:53 -0000 1.19
+++ prefs_about.c 17 Mar 2007 21:36:03 -0000 1.20
@@ -1,166 +1,121 @@
-/* $Id$
+/* Nessus
+ * Copyright (C) 1998 - 2001 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
*
- * 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.
+ * 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
+ * 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 "nessus_i18n.h"

#ifdef USE_GTK
#include <gtk/gtk.h>
#include <corevers.h>
-#include "xstuff.h"
+#include "../xstuff.h"
+#include "../xpm/nessus.xpm"
#include "globals.h"
-
-#include "xpm/nessus.xpm"
-#include "xpm/logo_tenable.xpm"
-#include "xpm/logo_intevation.xpm"
-#include "xpm/logo_bsi.xpm"
-#ifdef HAVE_GNU_GETTEXT
-# include "xpm/logo_bsi_de.xpm"
-#endif
-
-
-static void
-about_add_text(box, text)
- GtkWidget *box;
- const char *text;
-{
- GtkWidget *label;
-
- label = gtk_label_new(text);
- gtk_widget_show(label);
- gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- gtk_label_set_selectable(GTK_LABEL(label), TRUE);
-}
-
-static void
-about_add_logo(box, xpm, alt_text, url)
- GtkWidget *box;
- char **xpm;
- const char *alt_text;
- const char *url;
+struct arglist *
+prefs_dialog_about(window)
+ GtkWidget* window;
{
- GtkWidget *vbox;
- GtkWidget *pixmap;
-
- vbox = gtk_vbox_new(FALSE, 4);
- gtk_widget_show(vbox);
- gtk_box_pack_start(GTK_BOX(box), vbox, FALSE, FALSE, 0);
+ struct arglist * ctrls = emalloc(sizeof(struct arglist));
+ GtkWidget * frame;
+ GtkWidget * vbox;
+ GtkWidget * pixmapwid;
+ GdkPixmap * pixmap;
+ GdkBitmap * mask;
+ GtkStyle *style = NULL;
+ GtkWidget * label;
+ GtkWidget * table;
+ GtkWidget * hr;
+
+ frame = gtk_frame_new("Credits");
+ gtk_container_border_width(GTK_CONTAINER(frame), 10);
+ gtk_widget_show(frame);
+ arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);
+
+ vbox = gtk_vbox_new(FALSE, FALSE);
+ gtk_container_add(GTK_CONTAINER(frame), vbox);
+ gtk_widget_show(vbox);
+
+
+ if(F_show_pixmaps)
+ {
+ style = gtk_widget_get_style(frame);
+ pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask,
+ &style->bg[GTK_STATE_NORMAL],
+ (gchar **)nessus_xpm);
+ pixmapwid = gtk_pixmap_new(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(vbox), pixmapwid, FALSE, FALSE, 10);
+ gtk_widget_show(pixmapwid);

- if(F_show_pixmaps)
- {
- pixmap = make_pixmap(vbox, NULL, xpm);
- gtk_widget_show(pixmap);
- gtk_box_pack_start(GTK_BOX(vbox), pixmap, FALSE, FALSE, 0);
- gtk_misc_set_alignment(GTK_MISC(pixmap), 0, 0.5);
- }
- else
- about_add_text(vbox, alt_text);
+ hr = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(vbox), hr, FALSE, FALSE, 10);
+ gtk_widget_show(hr);
+ }

- about_add_text(vbox, url);
+ label = gtk_label_new("Nessus "NESSUS_FULL_VERSION"\nCopyright (C) 1998 - 2004 : ");
+ gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 10);
+ gtk_widget_show(label);
+
+ table = gtk_table_new(4,2, FALSE);
+ gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 10);
+ gtk_widget_show(table);
+
+ label = gtk_label_new("Author : ");
+ gtk_table_attach(GTK_TABLE(table), label, 0,1,0,1, GTK_FILL|GTK_EXPAND,1,1,1);
+ gtk_widget_show(label);
+
+ label = gtk_label_new("Renaud Deraison");
+ gtk_table_attach(GTK_TABLE(table), label,1,2,0,1, GTK_FILL|GTK_EXPAND,1,1,1);
+ gtk_widget_show(label);
+
+ label = gtk_label_new("SSL Support : ");
+ gtk_table_attach(GTK_TABLE(table), label, 0,1,1,2, GTK_FILL|GTK_EXPAND,1,1,1);
+ gtk_widget_show(label);
+
+ label = gtk_label_new("Michel Arboi");
+ gtk_table_attach(GTK_TABLE(table), label,1,2,1,2, GTK_FILL|GTK_EXPAND,1,1,1);
+ gtk_widget_show(label);
+
+ label = gtk_label_new("Pie/Charts library : ");
+ gtk_table_attach(GTK_TABLE(table), label, 0,1,2,3, GTK_FILL|GTK_EXPAND,1,1,1);
+ gtk_widget_show(label);
+
+ label = gtk_label_new("Bruce Verderaime");
+ gtk_table_attach(GTK_TABLE(table), label,1,2,2,3, GTK_FILL|GTK_EXPAND,1,1,1);
+ gtk_widget_show(label);
+
+
+
+ label = gtk_label_new("Project site : http://www.nessus.org");
+ gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 10);
+ gtk_widget_show(label);
+
+ label = gtk_label_new("Mailing list : http://list.nessus.org");
+ gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 10);
+ gtk_widget_show(label);
+ return(ctrls);
}
-
-
-void
-prefs_dialog_about(menuitem, ctrls)
- GtkMenuItem *menuitem;
- gpointer ctrls;
-{
- GtkWindow *window = GTK_WINDOW(arg_get_value(ctrls, "WINDOW"));
- GtkWidget *dialog;
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *vseparator;
- gchar *text;
- char **bsilogo = logo_bsi_xpm;
-#ifdef HAVE_GNU_GETTEXT
- char *lc_messages;
#endif
-
- dialog = gtk_dialog_new_with_buttons(_("About the Nessus Client"),
- window, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
-
- gtk_window_set_transient_for(GTK_WINDOW(dialog), window);
- g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);
-
- gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
-
- hbox = gtk_hbox_new(FALSE, 10);
- gtk_widget_show(hbox);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
- gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox);
-
- /*
- * left column
- */
-
- vbox = gtk_vbox_new(FALSE, 12);
- gtk_widget_show(vbox);
- gtk_box_pack_start_defaults(GTK_BOX(hbox), vbox);
-
- about_add_logo(vbox, nessus_xpm,
- _("Nessus"), _("http://www.nessus.org/"));
-
- text = g_strdup_printf(_("Nessus Client %s"
- "\nCopyright 1998-2004 Renaud Deraison"), NESSUS_FULL_VERSION);
- about_add_text(vbox, text);
- g_free(text);
-
- about_add_text(vbox, _("Authors:"
- "\n Renaud Deraison"
- "\n Thomas Arendsen Hein"
- "\n Jan-Oliver Wagner"
- "\n Michel Arboi (SSL Support)"
- "\n Bruce Verderaime (Pie/Charts)"
- ));
-
- about_add_text(vbox, _("Mailing list: http://list.nessus.org/"));
-
- /*
- * right column
- */
-
- vseparator = gtk_vseparator_new();
- gtk_widget_show(vseparator);
- gtk_box_pack_start_defaults(GTK_BOX(hbox), vseparator);
-
- vbox = gtk_vbox_new(FALSE, 12);
- gtk_widget_show(vbox);
- gtk_box_pack_start_defaults(GTK_BOX(hbox), vbox);
-
- about_add_logo(vbox, logo_tenable_xpm,
- _("Tenable Network Security"), _("http://www.tenablesecurity.com/"));
-
- about_add_logo(vbox, logo_intevation_xpm,
- _("Intevation GmbH"), _("http://www.intevation.net/"));
-
-#ifdef HAVE_GNU_GETTEXT
- lc_messages = setlocale(LC_MESSAGES, NULL);
- if(lc_messages && !strncmp(lc_messages, "de", 2))
- bsilogo = logo_bsi_de_xpm;
-#endif
- about_add_logo(vbox, bsilogo,
- _("Federal Office for Information Security"),
- _("http://www.bsi.de/english/"));
-
- gtk_widget_show(dialog);
-}
-#endif /* USE_GTK */

Index: prefs_about.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_about.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- prefs_about.h 3 Nov 2004 14:25:36 -0000 1.2
+++ prefs_about.h 17 Mar 2007 21:36:03 -0000 1.3
@@ -1,6 +1,6 @@
#ifndef PREFS_ABOUT_H__
#define PREFS_ABOUT_H__

-void prefs_dialog_about(GtkMenuItem *, gpointer);
+struct arglist * prefs_dialog_about(GtkWidget *);

#endif

Index: prefs_dialog.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_dialog.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- prefs_dialog.c 19 Jan 2005 21:23:41 -0000 1.80
+++ prefs_dialog.c 17 Mar 2007 21:36:03 -0000 1.81
@@ -29,156 +29,35 @@

#include <includes.h>

-#include "nessus_i18n.h"
-
#ifdef USE_GTK
#include <gtk/gtk.h>
-#include "xstuff.h"
-#include "context.h"
-#include "preferences.h"
-#include "sighand.h"
[...2159 lines suppressed...]
+ {
+ show_error("You must enter the name of the primary target\n\
+to attack in the 'target' section");
+ return(0);
+ }
+

+
/*
* Set up the GUI for the attack, and start it !
*/
- monitor_dialog_setup(hostname);
-
- return (0);
+ close_window(w, arg_get_value(ctrls, "WINDOW"));
+ monitor_dialog_setup(hostname, 0);
+
+ return(0);
}
#endif

Index: prefs_dialog.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_dialog.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- prefs_dialog.h 18 Nov 2004 13:50:25 -0000 1.6
+++ prefs_dialog.h 17 Mar 2007 21:36:04 -0000 1.7
@@ -19,10 +19,7 @@
#ifndef _NESSUSC_PREFS_DIALOG_H
#define _NESSUSC_PREFS_DIALOG_H

-#include "context.h"
-
-void prefs_dialog_setup(struct context *);
-void prefs_dialog_apply(struct context *, struct arglist *);
-int prefs_dialog_execute(GtkWidget *, struct arglist *);
-void prefs_dialog_set_defaults(struct context *, struct arglist *);
+void prefs_dialog_setup(GtkWidget* , struct arglist *);
+int prefs_dialog_ok(GtkWidget * , struct arglist *);
+void prefs_dialog_set_defaults(struct arglist * , struct arglist *);
#endif

Index: prefs_dialog_auth.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_dialog_auth.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- prefs_dialog_auth.c 21 Apr 2005 15:08:29 -0000 1.52
+++ prefs_dialog_auth.c 17 Mar 2007 21:36:04 -0000 1.53
@@ -1,687 +1,342 @@
-/* $Id$
+
+/* Nessus
+ * Copyright (C) 1998 Renaud Deraison
*
- * Copyright (C) 2004 by Intevation GmbH
- * Author(s):
- * Thomas Arendsen Hein <thomas@intevation.de>
+ * 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
+ * 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 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 "nessus_i18n.h"

#ifdef USE_GTK
#include <gtk/gtk.h>

-#include "nessus.h"
-#include "error_dialog.h"
-#include "context.h"
-#include "preferences.h"
-#include "prefs_context.h"
-#include "prefs_scope_tree.h"
-#include "prefs_help.h"
+#include "../xstuff.h"
+#include "../nessus.h"
+#include "../auth.h"
+#include "../error_dialog.h"
+#include "../xpm/computer.xpm"
+#include "../xpm/user.xpm"
+#include "prefs_dialog.h"
+#include "prefs_plugins.h"
+#include "prefs_dialog_plugins_prefs.h"
#include "globals.h"
+extern char * stored_pwd;

-#ifndef USE_AF_INET
+static char * get_username();
+static int prefs_dialog_login_callback(GtkWidget* , struct arglist *);
+static int prefs_dialog_logout_callback(GtkWidget* , struct arglist *);
+struct arglist * prefs_dialog_auth();
+
+#ifndef USE_AF_INET
#undef ENABLE_CRYPTO_LAYER
#endif

-struct auth_fileselect {
- struct auth_dialog *auth;
- GtkWidget *box;
- GtkWidget *entry;
-};
-
-struct auth_dialog {
- struct context *context;
- GtkWindow *parent;
- GtkWidget *dialog;
- GtkWidget *hostname;
- GtkWidget *port;
- GtkWidget *username;
- GtkWidget *password;
-#ifdef NESSUS_ON_SSL
- GtkWidget *use_ssl;
- GtkWidget *use_client_cert;
- struct auth_fileselect *trusted_ca;
- struct auth_fileselect *cert_file;
- struct auth_fileselect *key_file;
-#endif /* NESSUS_ON_SSL */
-};
-
-
-#ifdef USE_AF_INET
-const gchar *
-prefs_dialog_auth_hostname(auth)
- struct auth_dialog *auth;
+/*
+ * get_username : returns the name of the current user
+ */
+static char *
+get_username
+ (void)
{
- const gchar *text;
-
- text = gtk_entry_get_text(GTK_ENTRY(auth->hostname));
- if((!text) || (!strlen(text)))
- {
- gtk_widget_grab_focus(auth->hostname);
- show_warning(_("You must enter a valid hostname or IP"));
- return NULL;
- }
- return text;
-}
+ /*ENABLE_CRYPTO_LAYER*/
+ char * user;
+ struct passwd * pwd;
+ /* Look up the user's name. */
+ user = getenv ("USER");
+ if (user)
+ return user;

-int
-prefs_dialog_auth_port(auth)
- struct auth_dialog *auth;
-{
- int port = gtk_spin_button_get_value(GTK_SPIN_BUTTON(auth->port));
- if((port < 0) || (port > 65536))
- {
- gtk_widget_grab_focus(auth->port);
- show_warning(_("The port number is out of range"));
- return -1;
- }
- return port;
-}
+ user = getenv ("LOGNAME");
+ if (user)
+ return user;

-void
-prefs_dialog_auth_defaultport_clicked(button, auth)
- GtkButton *button;
- struct auth_dialog *auth;
-{
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(auth->port),
- (int)prefs_get_default(auth->context, "nessusd_port"));
+ pwd = getpwuid (getuid ());
+ if (pwd && pwd->pw_name)
+ return pwd->pw_name;
+ return "";
}

-#ifdef NESSUS_ON_SSL
-void
-prefs_dialog_auth_fileselect_popup(button, auth_fileselect)
- GtkButton *button;
- struct auth_fileselect *auth_fileselect;
+struct arglist * prefs_dialog_auth(window)
+ GtkWidget * window;
{
- GtkWidget *dialog = gtk_file_selection_new(_("Select File"));
-
- gtk_window_set_transient_for(GTK_WINDOW(dialog),
- GTK_WINDOW(auth_fileselect->auth->dialog));
- gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog),
- gtk_entry_get_text(GTK_ENTRY(auth_fileselect->entry)));
- if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
- {
- gchar *filename = g_strdup(
- gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog)));
-
- gtk_widget_hide(dialog);
- if(check_is_dir(filename))
- show_error(_("Please choose a filename."));
- else if(!check_is_file(filename))
- show_error(_("File \"%s\" doesn't exist."), filename);
- else
- gtk_entry_set_text(GTK_ENTRY(auth_fileselect->entry), filename);
- g_free(filename);
- }
- gtk_widget_destroy(dialog);
-}
-#endif /* NESSUS_ON_SSL */
-#endif /* USE_AF_INET */
+ struct arglist * ctrls = emalloc(sizeof(struct arglist));
+ GtkWidget * frame;
+ GtkWidget * label;
+ GtkWidget * button;
+ GtkWidget * table;
+ GtkStyle *style = NULL;
+ GtkWidget * pixmapwid;
+ GdkPixmap * pixmap;
+ GdkBitmap * mask;
+ GtkWidget * box;
+ GtkWidget * separator;
+ GtkWidget * entry;
+ char * default_server = arg_get_value(Prefs, "nessusd_host");
+ char * default_user = arg_get_value(Prefs, "nessusd_user");
+
+ /*
+ * Set up the main frame
+ */
+ frame = gtk_frame_new("New session setup");
+ gtk_container_border_width(GTK_CONTAINER(frame), 10);
+ gtk_widget_show(frame);
+ arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);
+ /*
+ * Set up the table which will contain everything
+ */
+ /*ENABLE_CRYPTO_LAYER*/
+ table = gtk_table_new(6, 2, TRUE);
+ gtk_container_add(GTK_CONTAINER (frame), table);
+ gtk_container_border_width(GTK_CONTAINER(table), 10);
+ gtk_widget_show(table);

-const gchar *
-prefs_dialog_auth_username(auth)
- struct auth_dialog *auth;
-{
- const gchar *text;
- text = gtk_entry_get_text(GTK_ENTRY(auth->username));
- if((!text) || (!strlen(text)))
+#ifdef USE_AF_INET
+ entry = gtk_entry_new();
+# ifdef DEFAULT_SERVER
+ gtk_entry_set_text
+ (GTK_ENTRY(entry), default_server? default_server:DEFAULT_SERVER);
+# endif /* DEFAULT_SERVER */
+ arg_add_value(ctrls, "HOSTNAME", ARG_PTR, -1, entry);
+ gtk_table_attach_defaults(GTK_TABLE(table), entry, 1,2,0,1);
+ gtk_widget_show(entry);
+
+ box = gtk_hbox_new(FALSE,0);
+ gtk_table_attach_defaults(GTK_TABLE(table), box, 0,1,1,2);
+ gtk_widget_show(box);
+ label = gtk_label_new("Port : ");
+ gtk_box_pack_end(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+
+ entry = gtk_entry_new();
{
- gtk_widget_grab_focus(auth->username);
- show_warning(_("You must enter a valid username"));
- return NULL;
+ char tbuf[10];
+ sprintf (tbuf, "%d", NESIANA_PORT);
+ gtk_entry_set_text (GTK_ENTRY(entry), tbuf);
+ arg_add_value(ctrls, "PORT", ARG_PTR, -1, entry);
}
- return text;
-}
+ gtk_table_attach_defaults(GTK_TABLE(table), entry, 1,2,1,2);
+ gtk_widget_show(entry);

-const gchar *
-prefs_dialog_auth_password(auth)
- struct auth_dialog *auth;
-{
- const gchar *text;
- text = gtk_entry_get_text(GTK_ENTRY(auth->password));
- if(!(text && (strlen(text)
-#ifdef NESSUS_ON_SSL
- || (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auth->use_ssl)) &&
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auth->use_client_cert)))
-#endif /* NESSUS_ON_SSL */
- )))
- {
- gtk_widget_grab_focus(auth->password);
- show_warning(_("You must enter a valid password"));
- return NULL;
- }
- return text;
-}
+ separator = gtk_hseparator_new();
+ gtk_table_attach_defaults(GTK_TABLE(table), separator, 0,2,2,3);
+ gtk_widget_show(separator);
+#endif /* AF_INET */
+
+ entry = gtk_entry_new();
+ gtk_entry_set_text (GTK_ENTRY(entry), default_user?default_user:get_username ());
+
+ /*ENABLE_CRYPTO_LAYER*/
+ gtk_table_attach_defaults(GTK_TABLE(table), entry, 1,2,3,4);
+ arg_add_value(ctrls, "USERNAME", ARG_PTR, -1, entry);
+ gtk_widget_show(entry);
+
+ box = gtk_hbox_new(FALSE,0);
+ /*ENABLE_CRYPTO_LAYER*/
+ gtk_table_attach_defaults(GTK_TABLE(table), box, 0,1,4,5);
+ gtk_widget_show(box);
+
+ /*ENABLE_CRYPTO_LAYER*/
+ label = gtk_label_new("Password : ");
+ gtk_box_pack_end(GTK_BOX(box), label, FALSE, FALSE,0);
+ gtk_widget_show(label);
+
+ entry = gtk_entry_new();
+ gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
+ gtk_table_attach_defaults(GTK_TABLE(table), entry, 1,2,4,5);
+ arg_add_value(ctrls, "PASSWORD", ARG_PTR, -1, entry);
+ gtk_widget_show(entry);

-#ifdef NESSUS_ON_SSL
-const gchar *
-prefs_dialog_auth_trusted_ca(auth, context)
- struct auth_dialog *auth;
- struct context *context;
-{
- const gchar *text;
- int paranoia_level = prefs_get_int(context, "paranoia_level");
+ button = gtk_button_new_with_label("Log in");
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ /*ENABLE_CRYPTO_LAYER*/
+ gtk_table_attach(GTK_TABLE(table), button, 1,2,6,7,GTK_FILL | GTK_EXPAND,0,10,10);
+ arg_add_value(ctrls, "BUTTON_LOG_IN", ARG_PTR, -1, button);
+ gtk_signal_connect /*_object*/(GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc)prefs_dialog_login_callback,
+ (void *)ctrls);

- text = gtk_entry_get_text(GTK_ENTRY(auth->trusted_ca->entry));
- if(!(text && strlen(text)) && (paranoia_level == 2 || paranoia_level == 3))
- {
- gtk_widget_grab_focus(auth->trusted_ca->entry);
- show_warning(_("You must enter a filename for Trusted CA"));
- return NULL;
- }
- return text;
-}
+ gtk_widget_show(button);
+
+ button = gtk_button_new_with_label(" Log out");
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ /*ENABLE_CRYPTO_LAYER*/
+ gtk_table_attach(GTK_TABLE(table), button, 1,2,7,8,GTK_FILL | GTK_EXPAND,0,10,10);
+ arg_add_value(ctrls, "BUTTON_LOG_OUT", ARG_PTR, -1, button);
+ gtk_signal_connect /*_object*/(GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc)prefs_dialog_logout_callback,
+ (void *)ctrls);
+

-const gchar *
-prefs_dialog_auth_cert_file(auth)
- struct auth_dialog *auth;
-{
- const gchar *text;
- text = gtk_entry_get_text(GTK_ENTRY(auth->cert_file->entry));
- if(!(text && strlen(text)))
- {
- gtk_widget_grab_focus(auth->cert_file->entry);
- show_warning(_("You must enter a filename for the SSL Certificate"));
- return NULL;
- }
- return text;
-}
+
+ label = gtk_label_new(" Connected");
+ /*ENABLE_CRYPTO_LAYER*/
+ gtk_table_attach(GTK_TABLE(table), label, 0,1,5,6, GTK_FILL | GTK_EXPAND, 0,10,10);
+ arg_add_value(ctrls, "CONNECTED", ARG_PTR, -1, label);
+
+ box = gtk_hbox_new(FALSE,5);
+ gtk_table_attach_defaults(GTK_TABLE(table), box, 0,1,0,1);
+ gtk_widget_show(box);
+
+ gtk_widget_realize(window);

-const gchar *
-prefs_dialog_auth_key_file(auth)
- struct auth_dialog *auth;
-{
- const gchar *text;
- text = gtk_entry_get_text(GTK_ENTRY(auth->key_file->entry));
- if(!(text && strlen(text)))
+ if(F_show_pixmaps)
{
- gtk_widget_grab_focus(auth->key_file->entry);
- show_warning(_("You must enter a filename for the SSL Key"));
- return NULL;
+ style = gtk_widget_get_style(frame);
+#ifdef USE_AF_INET
+ pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask,
+ &style->bg[GTK_STATE_NORMAL],
+ (gchar **)computer_xpm);
+ pixmapwid = gtk_pixmap_new(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(box), pixmapwid, FALSE,FALSE,0);
+ gtk_widget_show(pixmapwid);
+#endif
}
- return text;
-}
-#endif /* NESSUS_ON_SSL */
-
-
-char *
-prefs_dialog_auth_do_connect(context, ctrls)
- struct context *context;
- gpointer ctrls;
-{
- void *context_window = arg_get_value(MainDialog, "CONTEXT");
- const char *hostname = prefs_get_string(context, "nessusd_host");
- GtkWindow *window = NULL;
- GtkWidget *dialog;
- GtkWidget *vbox;
- GtkWidget *label;
- gchar *text;
- char *err;
-
- if(context_window)
- window = GTK_WINDOW(context_window);
-
- dialog = gtk_dialog_new_with_buttons(_("Connecting ..."),
- window,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT
- | GTK_DIALOG_NO_SEPARATOR,
- NULL);
- /* prevent the dialog from being closed */
- g_signal_connect(G_OBJECT(dialog), "delete_event",
- G_CALLBACK(gtk_true), NULL);
-
- vbox = gtk_vbox_new(FALSE, 4);
- gtk_widget_show(vbox);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
- gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbox);
-
- text = g_strdup_printf(_("Connecting to Nessus server \"%s\" ..."), hostname);
- label = gtk_label_new(text);
+
+#ifdef USE_AF_INET
+ label = gtk_label_new("Nessusd Host : ");
+ gtk_box_pack_end(GTK_BOX(box), label,FALSE,FALSE,0);
gtk_widget_show(label);
- gtk_box_pack_start_defaults(GTK_BOX(vbox), label);
-
- context->pbar = gtk_progress_bar_new();
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(context->pbar),
- _("Initiating connection ..."));
- gtk_widget_show(context->pbar);
- gtk_box_pack_start_defaults(GTK_BOX(vbox), context->pbar);
-
- gtk_widget_show(dialog);
- arg_set_value(ctrls, "CONTEXT", -1, dialog);
-
- while(gtk_events_pending())
- gtk_main_iteration();
-
- err = connect_to_nessusd(context);
-
- arg_set_value(ctrls, "CONTEXT", -1, window);
- gtk_widget_destroy(dialog);
- g_free(text);
-
- if(err)
- return err;
- else
+#endif
+
+ box = gtk_hbox_new(FALSE,0);
+ /*ENABLE_CRYPTO_LAYER*/
+ gtk_table_attach_defaults(GTK_TABLE(table), box, 0,1,3,4);
+ gtk_widget_show(box);
+
+ if(F_show_pixmaps)
{
- /* FIXME plugin list is only filled if gtk_notebook_set_page is called */
- gtk_notebook_set_page(
- GTK_NOTEBOOK(arg_get_value(MainDialog, "NOTEBOOK")), 1);
- prefs_context_update(context);
- scopetreeview_connected_update(context);
- return NULL;
+ pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask,
+ &style->bg[GTK_STATE_NORMAL],
+ (gchar **)user_xpm);
+ pixmapwid = gtk_pixmap_new(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(box), pixmapwid, FALSE,FALSE,0);
+ gtk_widget_show(pixmapwid);
}
-}
-
-GtkWidget *
-prefs_dialog_auth_vbox(text, content)
- const gchar *text;
- GtkWidget *content;
-{
- GtkWidget *label;
- GtkWidget *vbox;
-
- vbox = gtk_vbox_new(FALSE, 0);
- gtk_widget_show(vbox);
-
- label = gtk_label_new(text);
+ label = gtk_label_new("Login : ");
+ gtk_box_pack_end(GTK_BOX(box), label, FALSE, FALSE,0);
gtk_widget_show(label);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-
- gtk_box_pack_start(GTK_BOX(vbox), content, FALSE, FALSE, 0);
-
- return vbox;
-}
-
-#ifdef NESSUS_ON_SSL
-struct auth_fileselect *
-prefs_dialog_auth_fileselect(auth, text, pref_name, box)
- struct auth_dialog *auth;
- const gchar *text;
- const gchar *pref_name;
- GtkWidget *box;
-{
- struct auth_fileselect *auth_fileselect;
- GtkWidget *hbox;
- GtkWidget *button;
- const gchar *pref = prefs_get_string(auth->context, pref_name);
-
- auth_fileselect = emalloc(sizeof(struct auth_fileselect));
- auth_fileselect->auth = auth;
-
- hbox = gtk_hbox_new(FALSE, 0);
- gtk_widget_show(hbox);
-
- auth_fileselect->entry = gtk_entry_new();
- gtk_widget_show(auth_fileselect->entry);
- if(pref)
- gtk_entry_set_text(GTK_ENTRY(auth_fileselect->entry), pref);
- gtk_box_pack_start_defaults(GTK_BOX(hbox), auth_fileselect->entry);
-
- button = gtk_button_new_with_mnemonic(_("Select ..."));
- gtk_widget_show(button);
- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
- g_signal_connect((gpointer)button, "clicked",
- G_CALLBACK(prefs_dialog_auth_fileselect_popup),
- auth_fileselect);
-
- auth_fileselect->box = prefs_dialog_auth_vbox(text, hbox);
- gtk_box_pack_start_defaults(GTK_BOX(box), auth_fileselect->box);
-
- return auth_fileselect;
+ return(ctrls);
}

-
-void
-prefs_dialog_auth_update(widget, auth)
- GtkWidget *widget;
- struct auth_dialog *auth;
+static int prefs_dialog_logout_callback(w, ctrls)
+ GtkWidget * w;
+ struct arglist * ctrls;
{
- gboolean use_ssl = gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(auth->use_ssl));
- gboolean use_client_cert = gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(auth->use_client_cert));
-
- gtk_widget_set_sensitive(auth->use_client_cert, use_ssl);
- gtk_widget_set_sensitive(auth->trusted_ca->box, use_ssl);
- gtk_widget_set_sensitive(auth->cert_file->box, use_ssl && use_client_cert);
- gtk_widget_set_sensitive(auth->key_file->box, use_ssl && use_client_cert);
+ shutdown(GlobalSocket, 2);
+ closesocket(GlobalSocket);
+ GlobalSocket = -1;
+
+ gtk_widget_hide(arg_get_value(ctrls, "BUTTON_LOG_OUT"));
+ gtk_widget_show(arg_get_value(ctrls, "BUTTON_LOG_IN"));
+ gtk_widget_hide(arg_get_value(ctrls, "CONNECTED"));
+ return 0;
}
-#endif /* NESSUS_ON_SSL */
-
-void
-prefs_dialog_auth_create_dialog(context, auth)
- struct context *context;
- struct auth_dialog *auth;
+static int prefs_dialog_login_callback(w, ctrls)
+ GtkWidget * w;
+ struct arglist * ctrls;
{
- GtkTooltips *tooltips = gtk_tooltips_new();
- GtkWidget *dialog;
- GtkWidget *dialog_vbox;
- GtkWidget *frame;
- GtkWidget *hbox;
- GtkWidget *hbox2;
- GtkWidget *button;
+ char * username;
+ char * password = NULL;
#ifdef USE_AF_INET
- GtkObject *port_adj;
-# ifdef NESSUS_ON_SSL
- GtkWidget *vbox;
-# endif /* NESSUS_ON_SSL */
-#endif /* USE_AF_INET */
-
- auth->context = context;
-
- /*ENABLE_CRYPTO_LAYER*/
- auth->dialog = dialog = gtk_dialog_new_with_buttons(
- _("Connect to Nessus Server"), auth->parent,
- 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_OK);
- gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
- gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
-
- dialog_vbox = gtk_vbox_new(FALSE, 4);
- gtk_widget_show(dialog_vbox);
- gtk_container_set_border_width(GTK_CONTAINER(dialog_vbox), 4);
- gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), dialog_vbox);
-
-
+ char * hostname;
+ int port;
+#endif
+ char * t;
+ char * err;
#ifdef USE_AF_INET
- frame = gtk_frame_new(_("Nessus Server"));
- gtk_widget_show(frame);
- gtk_box_pack_start_defaults(GTK_BOX(dialog_vbox), frame);
-
- hbox = gtk_hbox_new(TRUE, 8);
- gtk_widget_show(hbox);
- gtk_container_add(GTK_CONTAINER(frame), hbox);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
-
- /*
- * nessusd_host
- */
- auth->hostname = gtk_entry_new();
- gtk_widget_show(auth->hostname);
- gtk_entry_set_text(GTK_ENTRY(auth->hostname),
- prefs_get_string(context, "nessusd_host"));
- gtk_tooltips_set_tip(tooltips, auth->hostname, HLP_AUTH_SERVER, "");
- gtk_box_pack_start_defaults(GTK_BOX(hbox),
- prefs_dialog_auth_vbox(_("Hostname:"), auth->hostname));
-
- /*
- * nessusd_port
- */
- hbox2 = gtk_hbox_new(FALSE, 0);
- gtk_widget_show(hbox2);
-
- auth->port = gtk_entry_new();
- port_adj = gtk_adjustment_new(
- prefs_get_int(context, "nessusd_port"), 1, 65535, 1, 100, 100);
- auth->port = gtk_spin_button_new(GTK_ADJUSTMENT(port_adj), 1, 0);
- gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(auth->port), TRUE);
- gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(auth->port), TRUE);
- gtk_tooltips_set_tip(tooltips, auth->port, HLP_AUTH_PORT, "");
- gtk_widget_show(auth->port);
- gtk_box_pack_start_defaults(GTK_BOX(hbox2), auth->port);
-
- button = gtk_button_new_with_mnemonic(_("_Default"));
- gtk_widget_show(button);
- gtk_box_pack_start(GTK_BOX(hbox2), button, FALSE, FALSE, 0);
- gtk_tooltips_set_tip(tooltips, button, HLP_AUTH_PORT_DEFAULT, "");
- g_signal_connect((gpointer)button, "clicked",
- G_CALLBACK(prefs_dialog_auth_defaultport_clicked),
- auth);
-
- gtk_box_pack_start_defaults(GTK_BOX(hbox),
- prefs_dialog_auth_vbox(_("Port:"), hbox2));
-
-
-
- frame = gtk_frame_new(_("Authentication"));
- gtk_widget_show(frame);
- gtk_box_pack_start_defaults(GTK_BOX(dialog_vbox), frame);
-
- hbox = gtk_hbox_new(TRUE, 8);
- gtk_container_add(GTK_CONTAINER(frame), hbox);
-#else
- hbox = gtk_hbox_new(TRUE, 8);
- gtk_container_add(GTK_CONTAINER(dialog_vbox), hbox);
-#endif /* USE_AF_INET */
- gtk_widget_show(hbox);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
-
- /*
- * nessusd_user
- */
- auth->username = gtk_entry_new();
- gtk_widget_show(auth->username);
- gtk_entry_set_text(GTK_ENTRY(auth->username),
- prefs_get_string(context, "nessusd_user"));
- gtk_tooltips_set_tip(tooltips, auth->username, HLP_LOGIN_USER, "");
- gtk_box_pack_start_defaults(GTK_BOX(hbox),
- prefs_dialog_auth_vbox(_("Login:"), auth->username));
-
- /*
- * password
- */
- auth->password = gtk_entry_new();
- gtk_widget_show(auth->password);
- gtk_entry_set_visibility(GTK_ENTRY(auth->password), FALSE);
- /* gtk_tooltips_set_tip(tooltips, auth->password, HLP_LOGIN_PASSWORD, ""); */
- gtk_box_pack_start_defaults(GTK_BOX(hbox),
- prefs_dialog_auth_vbox(_("Password:"), auth->password));
- gtk_widget_grab_focus(auth->password);
- gtk_entry_set_activates_default(GTK_ENTRY(auth->password), TRUE);
-
-#ifdef NESSUS_ON_SSL
- frame = gtk_frame_new(_("SSL options"));
- gtk_widget_show(frame);
- gtk_box_pack_start_defaults(GTK_BOX(dialog_vbox), frame);
-
- vbox = gtk_vbox_new(FALSE, 4);
- gtk_container_add(GTK_CONTAINER(frame), vbox);
- gtk_widget_show(vbox);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
-
- hbox = gtk_hbox_new(TRUE, 8);
- gtk_widget_show(hbox);
- gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox);
-
- /*
- * use_ssl
- */
- auth->use_ssl = gtk_check_button_new_with_mnemonic(
- _("Use SSL encryption"));
- gtk_widget_show(auth->use_ssl);
- gtk_box_pack_start_defaults(GTK_BOX(hbox), auth->use_ssl);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auth->use_ssl),
- prefs_get_int(context, "use_ssl") &&
- strcasecmp(prefs_get_string(context, "ssl_version"), "NONE"));
- g_signal_connect(G_OBJECT(auth->use_ssl), "toggled",
- G_CALLBACK(prefs_dialog_auth_update), auth);
-
- /*
- * use_client_cert
- */
- auth->use_client_cert = gtk_check_button_new_with_mnemonic(
- _("Authentication by certi_ficate"));
- gtk_widget_show(auth->use_client_cert);
- gtk_box_pack_start_defaults(GTK_BOX(hbox), auth->use_client_cert);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auth->use_client_cert),
- prefs_get_int(context, "use_client_cert"));
- g_signal_connect(G_OBJECT(auth->use_client_cert), "toggled",
- G_CALLBACK(prefs_dialog_auth_update), auth);
-
- /*
- * trusted_ca
- */
- auth->trusted_ca = prefs_dialog_auth_fileselect(
- auth, _("Trusted CA:"), "trusted_ca", vbox);
-
- /*
- * cert_file
- */
- auth->cert_file = prefs_dialog_auth_fileselect(
- auth, _("User Certificate File:"), "cert_file", vbox);
-
- /*
- * key_file
- */
- auth->key_file = prefs_dialog_auth_fileselect(
- auth, _("User Key File:"), "key_file", vbox);
-
- prefs_dialog_auth_update(NULL, auth);
-#endif /* NESSUS_ON_SSL */
-}
-
-gboolean
-prefs_dialog_auth_connect_dialog(context, ctrls)
- struct context *context;
- gpointer ctrls;
-{
- void *context_window = arg_get_value(ctrls, "CONTEXT");
- struct auth_dialog *auth = emalloc(sizeof(struct auth_dialog));
-
- auth->parent = context_window?GTK_WINDOW(context_window):NULL;
- prefs_dialog_auth_create_dialog(context, auth);
-
- arg_set_value(ctrls, "CONTEXT", -1, auth->dialog);
- for(;;)
- {
- if(gtk_dialog_run(GTK_DIALOG(auth->dialog)) == GTK_RESPONSE_OK)
+ t = (char*)gtk_entry_get_text(GTK_ENTRY(arg_get_value(ctrls, "HOSTNAME")));
+ if((!t) ||(!strlen(t)))
+ {
+ show_warning("You must enter an hostname");
+ return(1);
+ }
+ hostname = emalloc(strlen(t)+1);
+ strncpy(hostname, t, strlen(t));
+ t = (char*)gtk_entry_get_text(GTK_ENTRY(arg_get_value(ctrls, "PORT")));
+ if((!t) ||(!strlen(t)))
+ {
+ show_warning("You must enter a valid port number !");
+ return(1);
+ }
+ port = atoi(t);
+ if((port < 0) || (port > 65536))
+ {
+ show_warning("Your port specification is illegal");
+ return(1);
+ }
+#endif
+ t = (char*)gtk_entry_get_text(GTK_ENTRY(arg_get_value(ctrls, "USERNAME")));
+ if((!t) ||(!strlen(t)))
{
- const char *hostname;
- int port;
- const char *username;
- const char *password;
- char *err;
-#ifdef NESSUS_ON_SSL
- const char *trusted_ca;
- const char *cert_file;
- const char *key_file;
- int use_ssl = 0;
- int use_client_cert = 0;
-#endif /* NESSUS_ON_SSL */
-
- efree(&context->passwd);
-#ifdef USE_AF_INET
- if(!(hostname = prefs_dialog_auth_hostname(auth)) ||
- (port = prefs_dialog_auth_port(auth)) < 0)
- continue;
-#endif /* USE_AF_INET */
- if(!(username = prefs_dialog_auth_username(auth)) ||
- !(password = prefs_dialog_auth_password(auth)))
- continue;
-
-#ifdef NESSUS_ON_SSL
- if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auth->use_ssl)))
- use_ssl = 1;
- if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auth->use_client_cert)))
- use_client_cert = 1;
-
- if(use_ssl)
- {
- if(!(trusted_ca = prefs_dialog_auth_trusted_ca(auth, context)))
- continue;
-
- if(use_client_cert)
- {
- if(!(cert_file = prefs_dialog_auth_cert_file(auth)) ||
- !(key_file = prefs_dialog_auth_key_file(auth)))
- continue;
- prefs_set_string(context, "cert_file", cert_file);
- prefs_set_string(context, "key_file", key_file);
- }
-
- prefs_set_string(context, "trusted_ca", trusted_ca);
- }
- prefs_set_int(context, "use_ssl", use_ssl);
- prefs_set_int(context, "use_client_cert", use_client_cert);
-#endif /* NESSUS_ON_SSL */
-
- prefs_set_string(context, "nessusd_host", hostname);
- prefs_set_int(context, "nessusd_port", port);
- prefs_set_string(context, "nessusd_user", username);
- if(password[0])
- context->passwd = estrdup(password);
- else
- context->passwd = estrdup("*"); /* XXX this is ugly */
- err = prefs_dialog_auth_do_connect(context, ctrls);
- if(err)
- {
- show_error("%s", err);
- continue;
- }
+ show_warning("You must enter a valid username");
+ return(1);
}
- break;
- }
- arg_set_value(ctrls, "CONTEXT", -1, auth->parent);
- gtk_widget_destroy(auth->dialog);
-#ifdef NESSUS_ON_SSL
- efree(&auth->trusted_ca);
- efree(&auth->cert_file);
- efree(&auth->key_file);
-#endif /* NESSUS_ON_SSL */
- efree(&auth);
-
- return (context->socket >= 0);
-}
-
-void
-prefs_dialog_auth_connect(menuitem, ctrls)
- GtkMenuItem *menuitem;
- gpointer ctrls;
-{
- prefs_dialog_auth_connect_dialog(Context, ctrls);
-}
-
-/*
- * Try connecting if not already connected and context->passwd is
- * available. passwd may be empty (but != NULL) for user certificates.
- * If this fails, raise the login dialog.
- * Returns TRUE if connected.
- */
-gboolean
-prefs_dialog_auth_connection(context)
- struct context *context;
-{
- if(context->socket >= 0)
- return TRUE;
-
- if(!context->passwd ||
- !prefs_get_int(Global, "nessusd_autoconnect") ||
- prefs_dialog_auth_do_connect(context, MainDialog))
- return prefs_dialog_auth_connect_dialog(context, MainDialog);
-
- return (context->socket >= 0);
-}
+ username = emalloc(strlen(t)+1);
+ strncpy(username, t, strlen(t));
+ /*ENABLE_CRYPTO_LAYER*/
+ t = (char*)gtk_entry_get_text(GTK_ENTRY(arg_get_value(ctrls, "PASSWORD")));
+ if((!t) ||(!strlen(t)))
+ {
+ show_warning("You must enter a valid password");
+ return(1);
+ }
+ password = emalloc(strlen(t)+1);
+ strncpy(password, t, strlen(t));

-void
-prefs_dialog_auth_disconnect(menuitem, ctrls)
- GtkMenuItem *menuitem;
- gpointer ctrls;
-{
-#ifdef NESSUS_ON_SSL
- close_stream_connection(Context->socket);
+#ifdef USE_AF_INET
+ /*ENABLE_CRYPTO_LAYER*/
+ err = connect_to_nessusd(hostname, port, username, password);
#else
- shutdown(Context->socket, 2);
- closesocket(Context->socket);
+ err = connect_to_nessusd("localhost", -1, username, password);
#endif
- Context->socket = -1;
- prefs_context_update(Context);
- scopetreeview_connected_update(Context);
+ if(err){
+ /*ENABLE_CRYPTO_LAYER*/
+ show_error(err);
+ }
+ else
+ {
+ /*ENABLE_CRYPTO_LAYER*/
+ gtk_widget_hide(arg_get_value(ctrls, "BUTTON_LOG_IN"));
+ gtk_widget_show(arg_get_value(ctrls, "BUTTON_LOG_OUT"));
+ gtk_widget_show(arg_get_value(ctrls, "CONNECTED"));
+
+ /*
+ * Go to the plugins page
+ */
+ gtk_notebook_set_page(GTK_NOTEBOOK(arg_get_value(MainDialog, "NOTEBOOK")), 1);
+ if(First_time==0)
+ {
+ prefs_plugins_redraw(NULL,NULL,arg_get_value(MainDialog, "PLUGINS"));
+ prefs_dialog_set_defaults(MainDialog, Prefs);
+ }
+ prefs_plugins_prefs_redraw(NULL, NULL, arg_get_value(MainDialog, "PLUGINS_PREFS"));
+
+ First_time++;
+ }
+ return(0);
}
#endif

Index: prefs_dialog_auth.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_dialog_auth.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- prefs_dialog_auth.h 22 Nov 2004 16:10:25 -0000 1.5
+++ prefs_dialog_auth.h 17 Mar 2007 21:36:04 -0000 1.6
@@ -1,29 +1,24 @@
-/* $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_PREFS_DIALOG_AUTH_H
#define _NESSUSC_PREFS_DIALOG_AUTH_H

-void prefs_dialog_auth_connect(GtkMenuItem *, gpointer);
-void prefs_dialog_auth_disconnect(GtkMenuItem *, gpointer);
-gboolean prefs_dialog_auth_connect_dialog(struct context *, struct arglist *);
-gboolean prefs_dialog_auth_connection(struct context *);
+struct arglist * prefs_dialog_auth(GtkWidget *);

#endif

Index: prefs_dialog_misc.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_dialog_misc.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- prefs_dialog_misc.c 18 Nov 2004 15:08:05 -0000 1.6
+++ prefs_dialog_misc.c 17 Mar 2007 21:36:04 -0000 1.7
@@ -31,12 +31,10 @@

#ifdef USE_GTK
#include <gtk/gtk.h>
+#include "../xstuff.h"
+#include "../preferences.h"
+#include "globals.h"

-#include "../nessus_i18n.h"
-
-/*
- * XXX: this isn't used anywhere
- */

struct arglist * prefs_dialog_misc()
{
@@ -48,7 +46,7 @@
GtkWidget * label;
struct arglist * ctrls = emalloc(sizeof(struct arglist));

- frame = gtk_frame_new(_("Misc."));
+ frame = gtk_frame_new("Misc.");
gtk_container_border_width(GTK_CONTAINER(frame), 10);
gtk_widget_show(frame);
arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);
@@ -62,7 +60,7 @@
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show(hbox);

- label = gtk_label_new(_("Max threads : "));
+ label = gtk_label_new("Max threads : ");
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
gtk_widget_show(label);

@@ -71,7 +69,7 @@
gtk_widget_show(max_threads);
arg_add_value(ctrls, "MAX_THREADS", ARG_PTR, -1, max_threads);

- remember_plugin_set = gtk_check_button_new_with_label(_("Remember the set of plugins"));
+ remember_plugin_set = gtk_check_button_new_with_label("Remember the set of plugins");
gtk_box_pack_start(GTK_BOX(vbox), remember_plugin_set, FALSE, FALSE, 0);
gtk_widget_show(remember_plugin_set);
arg_add_value(ctrls, "REMEMBER_PLUGIN_SET", ARG_PTR, -1, remember_plugin_set);

Index: prefs_dialog_plugins_prefs.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_dialog_plugins_prefs.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- prefs_dialog_plugins_prefs.c 18 Nov 2004 13:50:25 -0000 1.22
+++ prefs_dialog_plugins_prefs.c 17 Mar 2007 21:36:04 -0000 1.23
@@ -1,5 +1,5 @@
/* Nessus
- * Copyright (C) 1999, 2000 Renaud Deraison
+ * Copyright (C) 1999 - 2005 Renaud Deraison
*
* 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,506 +31,592 @@

#ifdef USE_GTK
#include <gtk/gtk.h>
-#include "context.h"
[...961 lines suppressed...]
+ gtk_widget_show(box);
+
+ button = gtk_check_button_new_with_label(estrdup(name));
+ gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 5);
+ gtk_widget_show(button);
+ if(def)
+ {
+ if(!strcmp(def, "yes"))
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE);
else
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), !strcmp(value,
- "yes"));
- arg_add_value(pref->value, "CHECKBOX", ARG_PTR, -1, button);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), FALSE);
+ }
+ else
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), !strcmp(value, "yes"));
+ arg_add_value(pref->value, "CHECKBOX", ARG_PTR, -1, button);
}
#endif

Index: prefs_dialog_plugins_prefs.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_dialog_plugins_prefs.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- prefs_dialog_plugins_prefs.h 18 Nov 2004 13:50:26 -0000 1.4
+++ prefs_dialog_plugins_prefs.h 17 Mar 2007 21:36:04 -0000 1.5
@@ -1,8 +1,6 @@
#ifndef _NESSUSC_PREFS_DIALOG_PLUGINS_PREFS_H
#define _NESSUSC_PREFS_DIALOG_PLUGINS_PREFS_H
-
-#include "context.h"
-
-struct arglist *prefs_dialog_plugins_prefs();
-void prefs_plugins_prefs_redraw(struct context *, struct arglist *);
+struct arglist * prefs_dialog_plugins_prefs();
+int prefs_plugins_prefs_redraw(GtkWidget *, void *, struct arglist *);
+void prefs_plugins_reset(struct arglist *, struct arglist *, struct arglist*);
#endif

Index: prefs_dialog_scan_opt.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_dialog_scan_opt.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- prefs_dialog_scan_opt.c 22 Nov 2004 09:30:41 -0000 1.23
+++ prefs_dialog_scan_opt.c 17 Mar 2007 21:36:04 -0000 1.24
@@ -38,12 +38,11 @@
#include "prefs_dialog_scan_opt.h"
#include "globals.h"

-#include "../nessus_i18n.h"
-
static void scanner_infos_cb(GtkWidget *, struct arglist *);
-
-struct arglist *prefs_dialog_scan_opt(context)
- struct context *context;
+
+
+
+struct arglist * prefs_dialog_scan_opt()
{
GtkWidget * frame;
GtkWidget * table;
@@ -62,21 +61,21 @@

struct arglist * ctrls = emalloc(sizeof(struct arglist));

- frame = gtk_frame_new(_("General scan options"));
+ frame = gtk_frame_new("Scan options");
gtk_container_border_width(GTK_CONTAINER(frame), 10);
arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);

gtk_widget_show(frame);


- box = gtk_vbox_new(FALSE, 5);
+ box = gtk_vbox_new(FALSE, 10);

gtk_container_add(GTK_CONTAINER(frame), box);
gtk_container_border_width(GTK_CONTAINER(box), 10);
gtk_widget_show(box);


- ping_hosts = gtk_check_button_new_with_label(_("Determine if hosts are alive before testing them"));
+ ping_hosts = gtk_check_button_new_with_label("Determine if hosts are alive before testing them");
arg_add_value(ctrls, "PING_HOSTS", ARG_PTR, -1, ping_hosts);
/*gtk_box_pack_start(GTK_BOX(box), ping_hosts, FALSE, FALSE, 0);
gtk_widget_show(ping_hosts);*/
@@ -89,8 +88,7 @@


gtk_table_set_row_spacing(GTK_TABLE(table), 0, 10);
- label = gtk_label_new(_("Port range:"));
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
+ label = gtk_label_new("Port range : ");
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0,1);
gtk_widget_show(label);

@@ -99,7 +97,7 @@
gtk_widget_show(port_range);
arg_add_value(ctrls, "PORT_RANGE", ARG_PTR, -1, port_range);

- unscanned_as_closed = gtk_check_button_new_with_label(_("Consider unscanned ports as closed"));
+ unscanned_as_closed = gtk_check_button_new_with_label("Consider unscanned ports as closed");
arg_add_value(ctrls, "UNSCANNED_CLOSED", ARG_PTR, -1, unscanned_as_closed);
gtk_table_attach_defaults(GTK_TABLE(table), unscanned_as_closed, 0,2,1,2);
gtk_widget_show(unscanned_as_closed);
@@ -109,8 +107,7 @@


gtk_table_set_row_spacing(GTK_TABLE(table), 1, 10);
- label = gtk_label_new(_("Number of hosts to test at the same time:"));
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
+ label = gtk_label_new("Number of hosts to test at the same time : ");
gtk_table_attach_defaults(GTK_TABLE(table), label, 0,1,2,3);
gtk_widget_show(label);

@@ -120,8 +117,7 @@
arg_add_value(ctrls, "MAX_HOSTS", ARG_PTR, -1, entry);

gtk_table_set_row_spacing(GTK_TABLE(table), 2, 10);
- label = gtk_label_new(_("Number of checks to perform at the same time:"));
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
+ label = gtk_label_new("Number of checks to perform at the same time : ");
gtk_table_attach_defaults(GTK_TABLE(table), label, 0,1,3,4);
gtk_widget_show(label);

@@ -132,8 +128,7 @@



- label = gtk_label_new(_("Path to the CGIs:"));
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
+ label = gtk_label_new("Path to the CGIs : ");
gtk_table_attach_defaults(GTK_TABLE(table), label, 0,1,4,5);
gtk_widget_show(label);

@@ -143,27 +138,86 @@
arg_add_value(ctrls, "CGI_PATH", ARG_PTR, -1, entry);


- reverse_lookup = gtk_check_button_new_with_label(_("Do a reverse lookup on the IP before testing it"));
+ reverse_lookup = gtk_check_button_new_with_label("Do a reverse lookup on the IP before testing it");
arg_add_value(ctrls, "REVERSE_LOOKUP", ARG_PTR, -1, reverse_lookup);
gtk_box_pack_start(GTK_BOX(box), reverse_lookup, FALSE, FALSE, 0);
gtk_widget_show(reverse_lookup);

- optimize_test = gtk_check_button_new_with_label(_("Optimize the test"));
+ optimize_test = gtk_check_button_new_with_label("Optimize the test");
arg_add_value(ctrls, "OPTIMIZE_TEST", ARG_PTR, -1, optimize_test);
gtk_box_pack_start(GTK_BOX(box), optimize_test, FALSE, FALSE, 0);
gtk_widget_show(optimize_test);


- safe_checks = gtk_check_button_new_with_label(_("Safe checks"));
+ safe_checks = gtk_check_button_new_with_label("Safe checks");
arg_add_value(ctrls, "SAFE_CHECKS", ARG_PTR, -1, safe_checks);
gtk_box_pack_start(GTK_BOX(box), safe_checks, FALSE, FALSE, 0);
gtk_widget_show(safe_checks);

- use_mac_addr = gtk_check_button_new_with_label(_("Designate hosts by their MAC address"));
+ use_mac_addr = gtk_check_button_new_with_label("Designate hosts by their MAC address");
arg_add_value(ctrls, "USE_MAC_ADDR", ARG_PTR, -1, use_mac_addr);
gtk_box_pack_start(GTK_BOX(box), use_mac_addr, FALSE, FALSE, 0);
gtk_widget_show(use_mac_addr);

+
+#ifdef ENABLE_SAVE_KB
+#if 0
+ opt = gtk_check_button_new_with_label("Detached scan");
+ arg_add_value(ctrls, "DETACHED_SCAN", ARG_PTR, -1, opt);
+ gtk_box_pack_start(GTK_BOX(box), opt, FALSE, FALSE, 0);
+ gtk_widget_show(opt);
+ gtk_signal_connect(GTK_OBJECT(opt),
+ "clicked",
+ GTK_SIGNAL_FUNC(detached_cb),
+ ctrls);
+
+ hbox = gtk_hbox_new(TRUE, TRUE);
+ /*gtk_container_set_border_width(GTK_CONTAINER(hbox), 5); */
+ gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 0);
+ gtk_widget_show(hbox);
+ label = gtk_label_new("Send results to this email address : ");
+ arg_add_value(ctrls, "EMAIL_ADDR_LABEL", ARG_PTR, -1, label);
+ gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+ gtk_widget_set_sensitive(label, FALSE);
+ gtk_widget_show(label);
+
+ entry = gtk_entry_new();
+ arg_add_value(ctrls, "EMAIL_ADDR", ARG_PTR, -1, entry);
+ gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
+ gtk_widget_set_sensitive(entry, FALSE);
+ gtk_widget_show(entry);
+
+
+ opt = gtk_check_button_new_with_label("Continuous scan");
+ arg_add_value(ctrls, "CONTINUOUS_SCAN", ARG_PTR, -1, opt);
+ gtk_box_pack_start(GTK_BOX(box), opt, FALSE, FALSE, 0);
+ gtk_widget_set_sensitive(opt, FALSE);
+ gtk_widget_show(opt);
+ gtk_signal_connect(GTK_OBJECT(opt),
+ "clicked",
+ GTK_SIGNAL_FUNC(continuous_cb),
+ ctrls);
+
+ hbox = gtk_hbox_new(TRUE, TRUE);
+ /*gtk_container_set_border_width(GTK_CONTAINER(hbox), 5); */
+ gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 0);
+ gtk_widget_show(hbox);
+
+
+ label = gtk_label_new("Delay between two scans : ");
+ arg_add_value(ctrls, "DELAY_LABEL", ARG_PTR, -1, label);
+ gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+ gtk_widget_set_sensitive(label, FALSE);
+ gtk_widget_show(label);
+
+
+ opt = gtk_entry_new();
+ arg_add_value(ctrls, "DELAY", ARG_PTR, -1, opt);
+ gtk_box_pack_start(GTK_BOX(hbox), opt, TRUE, TRUE, 0);
+ gtk_widget_set_sensitive(opt, FALSE);
+ gtk_widget_show(opt);
+#endif
+#endif
scanners_window = gtk_scrolled_window_new(NULL,NULL);
gtk_container_border_width(GTK_CONTAINER(scanners_window), 0);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scanners_window),
@@ -171,14 +225,17 @@
gtk_box_pack_end(GTK_BOX(box), scanners_window, TRUE, TRUE, 0);
gtk_widget_show(scanners_window);

- label = gtk_label_new(_("Port scanner:"));
+ label = gtk_label_new("Port scanner : ");
gtk_box_pack_end(GTK_BOX(box), label, FALSE, FALSE, 0);
- gtk_misc_set_alignment((GtkMisc *)label, 0, 1);
gtk_widget_show(label);

list = gtk_list_new();
arg_add_value(ctrls, "SCANNERS_LIST", ARG_PTR, -1, list);
+#if GTK_VERSION < 11
+ gtk_container_add(GTK_CONTAINER(scanners_window), list);
+#else
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scanners_window), list);
+#endif
gtk_signal_connect(GTK_OBJECT(list),
"selection_changed",
GTK_SIGNAL_FUNC(scanner_infos_cb),
@@ -186,7 +243,8 @@


gtk_widget_show(list);
- fill_scanner_list(context, ctrls);
+ fill_scanner_list(ctrls);
+ arg_add_value(ctrls, "SCANNERS_NUM", ARG_INT, sizeof(int), (void *)ScannersNum);
return(ctrls);
}

@@ -197,15 +255,15 @@
{
int state = GTK_TOGGLE_BUTTON(w)->active;
plug_set_launch(scanner,state);
+ pluginset_reload(Plugins, Scanners);
}

void
-fill_scanner_list(context, ctrls)
- struct context *context;
- struct arglist *ctrls;
+fill_scanner_list(ctrls)
+ struct arglist * ctrls;
{
GtkTooltips * tooltips;
- struct arglist * scans = context->scanners;
+ struct arglist * scans = Scanners;
GList * dlist = NULL;

dlist = arg_get_value(ctrls, "DLIST");
@@ -258,6 +316,21 @@
gtk_list_append_items(GTK_LIST(arg_get_value(ctrls, "SCANNERS_LIST")), dlist);
}

+int prefs_scanner_redraw(w, dumb, ctrls)
+ GtkWidget * w;
+ void * dumb;
+ struct arglist * ctrls;
+{
+ int num;
+
+ num = (int)arg_get_value(ctrls, "SCANNERS_NUM");
+ if(num != ScannersNum){
+ fill_scanner_list(ctrls);
+ arg_set_value(ctrls, "SCANNERS_NUM", sizeof(int), (void *)ScannersNum);
+ }
+ return 0;
+}
+

static void
scanner_infos_cb(widget, ctrls)
@@ -274,6 +347,6 @@

list_item = GTK_OBJECT(dlist->data);
scanner = gtk_object_get_data(list_item,"list_item_data");
- plugin_info_window_setup(Context->scanners, scanner);
+ plugin_info_window_setup(Scanners, scanner);
}
#endif

Index: prefs_dialog_scan_opt.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_dialog_scan_opt.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- prefs_dialog_scan_opt.h 18 Nov 2004 13:50:26 -0000 1.4
+++ prefs_dialog_scan_opt.h 17 Mar 2007 21:36:04 -0000 1.5
@@ -19,8 +19,7 @@
#ifndef _NESSUSC_PREFS_DIALOG_SCAN_OPT_H
#define _NESSUSC_PREFS_DIALOG_SCAN_OPT_H

-#include "context.h"
-
-struct arglist *prefs_dialog_scan_opt(struct context *);
-void fill_scanner_list(struct context *, struct arglist *);
+struct arglist * prefs_dialog_scan_opt();
+int prefs_scanner_redraw(GtkWidget * , void *, struct arglist *);
+void fill_scanner_list(struct arglist *);
#endif

Index: prefs_dialog_user.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_dialog_user.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- prefs_dialog_user.c 9 Dec 2004 17:44:48 -0000 1.17
+++ prefs_dialog_user.c 17 Mar 2007 21:36:04 -0000 1.18
@@ -29,344 +29,147 @@

#include <includes.h>

-#include "../nessus_i18n.h"
-#include "context.h"
-
-#include "error_dialog.h"
-
#ifdef USE_GTK
#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#include "../xstuff.h"
+#include "../preferences.h"
+#include "../password_dialog.h"
+#include "globals.h"
+#include "error_dialog.h"
+static int add_rule_callback(GtkWidget *, struct arglist *);
+static void sigh_button_event(GtkWidget *, GdkEventButton *, struct arglist *);

-/*
- * Reset the rules tree to the three default groups
- */
-static void reset_rules_tree(ctrls)
- struct arglist * ctrls;
-{
- GtkWidget * tree;
- GtkTreeStore * store;
- GtkTreeIter iter;
-
- tree = arg_get_value(ctrls, "RULES_TREE");
- store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
-
- gtk_tree_store_clear(store);
- /* fill the tree with the 3 default groups */
- gtk_tree_store_append(store, &iter, NULL); /* Acquire a top-level iterator */
- gtk_tree_store_set(store, &iter, 0,
- _("Server rules (priority over user rules): can not be shown"), -1);
- gtk_tree_store_append(store, &iter, NULL); /* Acquire a top-level iterator */
- gtk_tree_store_set(store, &iter, 0,
- _("Serverside user rules (priority over clientside user rules)"), -1);
- gtk_tree_store_append(store, &iter, NULL); /* Acquire a top-level iterator */
- gtk_tree_store_set(store, &iter, 0,
- _("Clientside user rules"), -1);
-}
-
-/*
- * Fill the treelist widget of the rules page
- * with the serverside user rules and with the
- * clientside user rules.
- */
-void fill_rules_list(context, ctrls)
- struct context *context;
- struct arglist *ctrls;
-{
- GtkWidget * tree;
- GtkTreeStore * store;
- GtkTreePath * path;
- GtkTreeIter iter, parent;
- struct arglist * p = arg_get_value(context->prefs, "SERVER_PREFS");
- char * rule;
-
- /* first of all, reset the tree */
- reset_rules_tree(ctrls);
-
- if (!p)
- return; /* something is not in order */
-
- /* get the objects */
- tree = arg_get_value(ctrls, "RULES_TREE");
- store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
-
- /* go to the second entry */
- path = gtk_tree_path_new_from_string("1");
- gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &parent, path);

- /* append the serverside user rules */
- p = arg_get_value(p, "RULES");
- while (p && p->next)
- {
- rule = emalloc(strlen((char *)p->value)+1);
- strcpy(rule, p->value);
- gtk_tree_store_append(store, &iter, &parent);
- gtk_tree_store_set(store, &iter, 0, rule, -1);
- p = p->next;
- }
- gtk_tree_view_expand_row(GTK_TREE_VIEW(tree), path, FALSE);
- gtk_tree_path_free(path);

- /* go to the third entry */
- path = gtk_tree_path_new_from_string("2");
- gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &parent, path);
- gtk_tree_path_free(path);

- /* append the clientside user rules */
- p = arg_get_value(context->prefs, "CLIENTSIDE_USERRULES");
- while (p && p->next)
- {
- rule = emalloc(strlen((char *)p->value)+1);
- strcpy(rule, p->value);
- gtk_tree_store_append(store, &iter, &parent);
- gtk_tree_store_set(store, &iter, 0, rule, -1);
- p = p->next;
- }
-
- path = gtk_tree_path_new_from_string("2");
- gtk_tree_view_expand_row(GTK_TREE_VIEW(tree), path, FALSE);
- gtk_tree_path_free(path);
-}
-
-/*
- * Check whether the given string is a syntactically correct
- * representation of a subnet.
- * The function returns 1 if it is valid and 0 if not.
- *
- * Subnets are of these forms:
- * n1.n2.n3.n4 (equals to n1.n2.n3.n4/32)
- * n1.n2.n3.n4/x
- * n1.n2.n3.n4/n5.n6.n7.n8
- * with each n in 0..255 and x in 0..32
- */
-int
-is_valid_subnet_str(subnet)
- char * subnet;
+
+struct arglist * prefs_dialog_user(prefs)
+ struct arglist * prefs;
{
- unsigned int n1, n2, n3, n4, n5, n6, n7, n8, x;
- char c;
-
- if (sscanf(subnet, "%u.%u.%u.%u%c", &n1, &n2, &n3, &n4, &c) == 4)
- {
- if (n1 <= 255 && n2 <= 255 && n3 <= 255 && n4 <= 255)
- return 1;
- }
-
- if (sscanf(subnet, "%u.%u.%u.%u/%u%c", &n1, &n2, &n3, &n4, &x, &c) == 5)
- {
- if (n1 <= 255 && n2 <= 255 && n3 <= 255 && n4 <= 255 && x <= 32)
- return 1;
- }
-
- if (sscanf(subnet, "%u.%u.%u.%u/%u.%u.%u.%u%c", &n1, &n2, &n3, &n4,
- &n5, &n6, &n7, &n8, &c) == 8)
- {
- if (n1 <= 255 && n2 <= 255 && n3 <= 255 && n4 <= 255 &&
- n5 <= 255 && n6 <= 255 && n7 <= 255 && n8 <= 255)
- return 1;
- }
+ struct arglist * ctrls = emalloc(sizeof(struct arglist));
+ GtkWidget * frame;
+ GtkWidget * table;
+ GtkWidget * label;
+ GtkWidget * button;
+ GtkWidget * entry;
+ GtkWidget * list;
+ GtkWidget * s_window;
+ /*ENABLE_CRYPTO_LAYER*/
+ frame = gtk_frame_new("User");
+ gtk_container_border_width(GTK_CONTAINER(frame), 10);
+ gtk_widget_show(frame);
+ arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);
+
+ table = gtk_table_new(3,7,FALSE);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 15);
+ gtk_table_set_col_spacing(GTK_TABLE(table), 1, 10);
+ gtk_container_add(GTK_CONTAINER(frame), table);
+ gtk_container_border_width(GTK_CONTAINER(table), 10);
+ gtk_widget_show(table);
+ /*ENABLE_CRYPTO_LAYER*/
+ label = gtk_label_new("Rules : ");
+ gtk_table_attach(GTK_TABLE(table), label, 0,1,4,5, GTK_FILL | GTK_EXPAND, 0,0,0);
+ gtk_widget_show(label);
+ entry = gtk_entry_new();
+ gtk_table_attach(GTK_TABLE(table), entry, 1,2,4,5, GTK_FILL | GTK_EXPAND, 0,0,0);
+ gtk_widget_show(entry);
+ arg_add_value(ctrls, "RULE", ARG_PTR, -1, entry);
+
+ button = gtk_button_new_with_label("Add rule");
+ gtk_table_attach(GTK_TABLE(table), button, 2,3,4,5, 0, 0, 0,0);
+ gtk_signal_connect(GTK_OBJECT(button), "clicked",
+ GTK_SIGNAL_FUNC(add_rule_callback), ctrls);
+ gtk_widget_show(button);

- return 0;
+
+ s_window = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(s_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_table_attach_defaults(GTK_TABLE(table), s_window, 0,3,5,7);
+ gtk_widget_show(s_window);
+ list = gtk_list_new();
+ gtk_signal_connect(GTK_OBJECT(list),
+ "button_release_event",
+ GTK_SIGNAL_FUNC(sigh_button_event),
+ ctrls);
+ gtk_table_set_row_spacing(GTK_TABLE(table), 1, 10);
+#if GTK_VERSION < 11
+ gtk_container_add(GTK_CONTAINER(s_window), list);
+#else
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(s_window), list);
+#endif
+ gtk_widget_show(list);
+ arg_add_value(ctrls, "RULES", ARG_PTR, -1, list);
+ arg_add_value(ctrls, "PREFERENCES", ARG_ARGLIST, -1, prefs);
+ return(ctrls);
}
-
-/*
- * Add a rule as specified through the combo and entry widget to the
- * treestore and treelist.
- */
-static void add_rule_callback(w, ctrls)
+
+
+static void sigh_button_event(w, event, ctrls)
GtkWidget * w;
+ GdkEventButton * event;
struct arglist * ctrls;
{
- GtkCombo * action_combo;
- GtkEntry * target_entry;
- GtkWidget * tree;
- GtkTreeStore * store;
- GtkTreeIter iter, parent;
- char * action = NULL;
- char * target = NULL;
- char * rule = NULL;
- GtkTreePath * path;
-
- action_combo = arg_get_value(ctrls, "ACTION");
- action = (char *)gtk_entry_get_text(GTK_ENTRY(action_combo->entry));
- target_entry = arg_get_value(ctrls, "TARGET");
- target = (char*)gtk_entry_get_text(target_entry);
- tree = arg_get_value(ctrls, "RULES_TREE");
- store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
-
- if (!strcmp(action, "default accept") ||
- !strcmp(action, "default deny") ||
- !strcmp(action, "default reject"))
+ if (event->type==GDK_BUTTON_RELEASE)
{
- rule = emalloc(strlen(action)+1);
- sprintf(rule, "%s", action);
- } else {
- if (strlen(target) == 0 || ! is_valid_subnet_str(target))
- {
- show_warning(_("The target for this rule must be a valid IP or Subnet.\n"));
- return;
- }
- rule = emalloc(strlen(action)+strlen(target)+1+1);
- sprintf(rule, "%s %s", action, target);
+ GList * dlist;
+ struct arglist * p = arg_get_value(ctrls, "PREFERENCES");
+ struct arglist * r = arg_get_value(p, "RULES");
+ dlist = GTK_LIST(w)->selection;
+ if(dlist)while(dlist)
+ {
+ char * name = gtk_object_get_data(GTK_OBJECT(dlist->data), "rule");
+ gtk_widget_hide(dlist->data);
+ if(name)arg_set_value(r, name, 0, "");
+ else fprintf(stderr, "Warning: could not actually delete the selected rule");
+ dlist = dlist->next;
+ }
}
-
- /* add the rule to the list store */
- path = gtk_tree_path_new_from_string("2");
- gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &parent, path);
- gtk_tree_store_append(store, &iter, &parent);
- gtk_tree_store_set(store, &iter, 0, rule, -1);
-
- gtk_tree_view_expand_row(GTK_TREE_VIEW(tree), path, FALSE);
- gtk_tree_path_free(path);
}

-/*
- * Remove the rule that is currently selected (provided the selected
- * line is a removable rule.
- */
-static void remove_rule_callback(w, ctrls)
+
+static int add_rule_callback(w, ctrls)
GtkWidget * w;
struct arglist * ctrls;
-{
- GtkWidget * tree;
- GtkTreeStore * store;
- GtkTreePath * path;
- GtkTreeViewColumn *focus_column;
- GtkTreeIter iter, parent;
-
- tree = arg_get_value(ctrls, "RULES_TREE");
- store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
-
- /* Get the selected entry */
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(tree), &path, &focus_column);
-
- if (!path)
- return; /* no line selected */
-
- gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path);
-
- /* check whether this is a line that is allowed to be removed */
- gtk_tree_path_free(path);
- path = gtk_tree_path_new_from_string("2"); /* must be under third group */
- gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &parent, path);
- if (!gtk_tree_store_is_ancestor(store, &parent, &iter))
- return; /* no, its not */
-
- /* remove the line */
- gtk_tree_store_remove(store, &iter);
-
- gtk_tree_path_free(path);
-}
-
-struct arglist *
-prefs_dialog_user()
-{
- struct arglist * ctrls = emalloc(sizeof(struct arglist));
- GtkWidget * frame;
- GtkWidget * vbox;
- GtkWidget * hbox;
- GtkWidget * label;
- GtkWidget * combo;
- GList * combo_items = NULL;
- GtkWidget * scrolledwindow;
- GtkTreeStore *store;
- GtkWidget *tree;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkWidget * button;
- GtkWidget * entry;
-
- /* The overall frame */
- frame = gtk_frame_new(_("User Access Rules"));
- gtk_container_border_width(GTK_CONTAINER(frame), 10);
- gtk_widget_show(frame);
- arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);
-
- /* the overall vbox that will contain all widgets */
- vbox = gtk_vbox_new(FALSE, 4);
- gtk_container_add(GTK_CONTAINER(frame), vbox);
- gtk_widget_show(vbox);
-
- /* The hbox that contains the selection elements for the rule */
- hbox = gtk_hbox_new(FALSE, 5);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show(hbox);
-
- /* The label for action entry */
- label = gtk_label_new(_("Action:"));
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- gtk_widget_show(label);
-
- /* A combo selection for the action */
- combo_items = g_list_append(combo_items, "accept");
- combo_items = g_list_append(combo_items, "reject");
- combo_items = g_list_append(combo_items, "deny");
- combo_items = g_list_append(combo_items, "default accept");
- combo_items = g_list_append(combo_items, "default reject");
- combo_items = g_list_append(combo_items, "default deny");
- combo = gtk_combo_new();
- gtk_combo_set_value_in_list(GTK_COMBO(combo), TRUE, FALSE);
- gtk_widget_show(combo);
- gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0);
- gtk_combo_set_popdown_strings(GTK_COMBO(combo), combo_items);
- arg_add_value(ctrls, "ACTION", ARG_PTR, -1, combo);
-
- /* The label for target entry */
- label = gtk_label_new(_("Target:"));
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+{
+ struct arglist * p = arg_get_value(ctrls, "PREFERENCES");
+ int num = 1;
+ GtkWidget * text;
+ GtkWidget * list, * box, *label, * item;
+ GList * dlist = NULL;
+ char * rule, *z;
+ struct arglist * t;
+ char * name;
+
+ p = arg_get_value(p, "RULES");
+ list = arg_get_value(ctrls, "RULES");
+ text = arg_get_value(ctrls, "RULE");
+ t = p;
+ while(t && t->next){num++;t=t->next;}
+
+ if(text)
+ {
+ z = (char*)gtk_entry_get_text(GTK_ENTRY(text));
+ rule = emalloc(strlen(z)+1);
+ strncpy(rule, z, strlen(z));
+
+ name = emalloc(10);
+ sprintf(name, "%d", num);
+ arg_add_value(p, name, ARG_STRING, strlen(rule), rule);
+ item = gtk_list_item_new();
+ gtk_object_set_data(GTK_OBJECT(item), "rule", name);
+ box = gtk_hbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(item), box);
+ gtk_widget_show(box);
+ label = gtk_label_new(rule);
gtk_widget_show(label);
-
- /* The entry for the target */
- entry = gtk_entry_new();
- gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
- gtk_widget_show(entry);
- arg_add_value(ctrls, "TARGET", ARG_PTR, -1, entry);
-
- /* The button to add a rule */
- button = gtk_button_new_with_label(_("Add rule"));
- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
- gtk_signal_connect(GTK_OBJECT(button), "clicked",
- GTK_SIGNAL_FUNC(add_rule_callback), ctrls);
- gtk_widget_show(button);
-
- /* The scrolled window where to have the treelist */
- scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
- gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 5);
- gtk_widget_show(scrolledwindow);
-
- /* A tree store for the specified rules */
- store = gtk_tree_store_new(1, G_TYPE_STRING);
-
- /* A treelist with the rules */
- tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
- g_object_unref(G_OBJECT(store));
- gtk_container_add(GTK_CONTAINER(scrolledwindow), tree);
- gtk_widget_show(tree);
- arg_add_value(ctrls, "RULES_TREE", ARG_PTR, -1, tree);
-
- /* fill the tree with defaults */
- reset_rules_tree(ctrls);
-
- /* The renderer for the treelist */
- renderer = gtk_cell_renderer_text_new();
-
- /* The column with the rules */
- column = gtk_tree_view_column_new_with_attributes(_("Rules"), renderer,
- "text", 0,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
-
- /* The hbox that contains the remove button */
- hbox = gtk_hbox_new(FALSE, 5);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show(hbox);
-
- /* The button to remove a rule */
- button = gtk_button_new_with_label(_("Remove rule"));
- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
- gtk_signal_connect(GTK_OBJECT(button), "clicked",
- GTK_SIGNAL_FUNC(remove_rule_callback), ctrls);
- gtk_widget_show(button);
-
- return(ctrls);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+ dlist = g_list_append(dlist, item);
+ gtk_widget_show(item);
+ gtk_list_append_items(GTK_LIST(list), dlist);
+ gtk_entry_set_text(GTK_ENTRY(text), "");
+ }
+ return(0);
}
#endif

Index: prefs_dialog_user.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_dialog_user.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- prefs_dialog_user.h 18 Nov 2004 13:50:26 -0000 1.3
+++ prefs_dialog_user.h 17 Mar 2007 21:36:04 -0000 1.4
@@ -19,7 +19,6 @@
#ifndef _NESSUSC_PREFS_DIALOG_USER_H
#define _NESSUSC_PREFS_DIALOG_USER_H

-void fill_rules_list(struct context *, struct arglist *);
-struct arglist *prefs_dialog_user();
+struct arglist * prefs_dialog_user(struct arglist *);

#endif

Index: prefs_help.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_help.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- prefs_help.h 20 Jan 2005 08:41:42 -0000 1.24
+++ prefs_help.h 17 Mar 2007 21:36:05 -0000 1.25
@@ -19,221 +19,175 @@
#ifndef _NESSUSC_PREFS_HELP_H
#define _NESSUSC_PREFS_HELP_H

-#include "../nessus_i18n.h"
-
-#define HLP_AUTH_SERVER \
-_("Enter the server name, where the Nessus Server resides on. \
-This may be a domain name or an IP address.")
-
+#define HLP_AUTH_SERVER "Enter the server name, where the Nessusd server resides on. \
+This may be a domain name or an IP address."
+#ifdef DEFAULT_PORT
#define HLP_AUTH_PORT \
-_("Enter the port number where you will be serviced by \
-the Nessus Server. With older server systems, this is \
-the port 3001, but the official port is 1241.")
-
-#define HLP_AUTH_PORT_DEFAULT \
-_("Set to default Nessus port 1241.")
-
+"Enter the port number where you will be serviced by\
+ the Nessud server. With older server systems, this is\
+ the port 3001, but the official port is 1241."
+#else
+#define HLP_AUTH_PORT \
+"Enter the port number where you will be serviced by\
+ the Nessud server."
+#endif
#ifdef USE_ZLIB_COMPRESSION
-# define HLP_CIPHER_CHOICE \
-_("Enter the channel encryption <cipher>/<hash>:<compression>. \
-A good choice for <cipher> is BLOWFISH, or TWOFISH an a good choice \
-for <hash> is RIPEMD160. If you do not want any compression, use \
-<cipher>/<hash>, only. If your bandwidth is a precious, use \
-<cipher>/<hash>:9. For lowest compression (optimized \
-for speed on your local computer) use <cipher>/<hash>:0.")
+#define HLP_CIPHER_CHOICE "Enter the channel encrytion <cipher>/<hash>:<compression>. \
+A good choice for <cipher> is BLOWFISH, or TWOFISH an a good choice for <hash> is \
+RIPEMD160. If your do not want any compression, use <cipher>/<hash>, only. If your \
+bandwidth is a precious, use <cipher>/<hash>:9. For lowest compression (optimized \
+for speed on your local computer) use <cipher>/<hash>:0."
#else
-# define HLP_CIPHER_CHOICE \
-_("Enter the secure channel encrytion type as \
-<cipher>/<hash>:<compression>. A good choice for <cipher> is \
-blowfish, or twofish an \
-a good choice for <hash> is ripemd160.")
+#define HLP_CIPHER_CHOICE "Enter the secure channel encrytion type as \
+<cipher>/<hash>:<compression>. A good choice for <cipher> is blowfish, or twofish an \
+a good choice for <hash> is ripemd160."
#endif
+#define HLP_LOGIN_USER "Enter the user name where you are registerd with on the \
+Nessusd server. If you log in for the first time, you will be asked for a password. \
+Maybe you need to ask your Nessusd administrator to create a login for you."

-#define HLP_LOGIN_USER \
-_("Enter the user name where you are registerd with on the \
-Nessus Server. If you log in for the first time, you will be \
-asked for a password. Maybe you need to ask your Nessus Server \
-administrator to create a login for you.")
-
-#define HLP_MISC_MAX_HOSTS \
-_("Maximal of number of hosts that the Nessus Server will test at \
-the same time. Be aware that the Nessus Server will spawn max_hosts \
-x max_checks processes!")
+#define HLP_MISC_MAX_HOSTS "Maximal of number of hosts that the server will test at \
+the same time. Be aware that the remote host will spawn max_hosts x max_checks \
+processes !"

-#define HLP_MISC_MAX_CHECKS \
-_("Maximal number of security checks that will be launched at \
-the same time against each host. Be aware that the Nessus Server will spawn \
-max_hosts x max_checks processes!")
+#define HLP_MISC_MAX_CHECKS "Maximal number of security checks that will be launched at \
+the same time against each host. Be aware that the remote host will spawn \
+max_hosts x max_checks processes !"

-#define HLP_TEST_FILE \
-_("Name of the remote file that several plugins will attempt \
-to read.")
+#define HLP_TEST_FILE "Name of the remote file that several plugins will attempt \
+to read"

-#define HLP_SCAN_OPT_PING \
-_("If this option is checked, then Nessus Server will send \
-some TCP packets to the target host to determine if the target host \
-is alive. This method does not use ICMP as ICMP is unreliable as less \
-and less hosts are answering to ICMP echo requests.")
+#define HLP_SCAN_OPT_PING "If this option is checked, then nessusd will send \
+some TCP packets to the remote host and will determine if the remote host \
+is alive. This method does not use ICMP as ICMP is unreliable and as less \
+and less hosts are answering to ICMP echo requests"

-#define HLP_SCAN_OPT_REVERSE_LOOKUP \
-_("If this option is set, Nessus Server will do a reverse \
-lookup on the IP addresses before it tests them. This may \
-slow down the whole test.")
+#define HLP_SCAN_OPT_REVERSE_LOOKUP "If this option is set, nessusd will do a reverse \
+lookup on the IP addresses before it tests them. This may somehow slow down the \
+whole test"

-#define HLP_SCAN_OPT_FIREWALL \
-_("Are the target hosts protected by a firewall ? If so \
-and if we are outside the firewall, it is a good idea to \
-turn this option ON, so that \
-Nessus Server will perform some additional tests to check \
-that the remote firewall is well \
-configured (this option is still experimental).")
+#define HLP_SCAN_OPT_FIREWALL "Are the remote hosts protected by a firewall ? If so \
+and if we are outside the firewall, it is a good idea to turn this option ON, so that \
+Nessus will perform some additional tests to check that the remote firewall is well \
+configured (this option is still experimental)"

-#define HLP_SCAN_OPT_OPTIMIZE \
-_("Security tests may ask the Nessus Server to be \
+#define HLP_SCAN_OPT_OPTIMIZE "Security tests may ask the server to be \
launched if and only if some information gathered by other \
test exist in the knowledge base, or if and only if a given \
port is open. This option speeds up the test, but may \
-make Nessus Server miss some vulnerability. If you are paranoid, \
-disable this option")
+make Nessus miss some vulnerability. If you are paranoid, \
+disable this option"

-#define HLP_SCAN_OPT_SAFE_CHECKS \
-_("Some security checks may harm the target server, by \
+#define HLP_SCAN_OPT_SAFE_CHECKS "\
+Some security checks may harm the remote server, by \
disabling the remote service temporarily or until \
-a reboot. If you enable this option, Nessus Server will \
+a reboot. If you enable this option, Nessus will \
rely on banners instead of actually performing \
a security check. You will obtain a less reliable \
report, but you will less likely disrupt the network users \
by doing a test. From a security point of view, we \
-recommend you disable this option. From a sysadmin \
-point of view, we recommand you enable it.")
+recommand you disable this option. From a sysadmin \
+point of view, we recommand you enable it"

-#define HLP_SCAN_OPT_USE_MAC_ADDR \
-_("If you enable this option, the hosts on the local network \
+
+#define HLP_SCAN_OPT_USE_MAC_ADDR "\
+If you enable this option, the hosts on the local network \
will be designated by their ethernet MAC address instead of \
their IP address. This is especially useful if you are using \
-Nessus in a DHCP network. If unsure, disable this option.")
+Nessus in a DHCP network. If unsure, disable this option"

-#define HLP_SCAN_OPT_PORT_RANGE \
-_("Ports that will be scanned by Nessus Server. You can enter \
-single ports, such as \"1-8000\"; or more complex sets, such \
-as \"21,23,25,1024-2048,6000\". \
-Put \"-1\" for no portscan, or put \"default\" to scan the default ports \
-in the Nessus services file.")
+#define HLP_SCAN_OPT_PORT_RANGE "Ports that will be scanned by Nessus. You can enter \
+single ports, such as \"1-8000\"; or more complex sets, such as \"21,23,25,1024-2048,6000\". \
+Put \"-1\" for no portscan, or put \"default\" to scan default ports in the Nessus services file."

-#define HLP_UNSCANNED_CLOSED \
-_("To save scanning time, you may ask Nessus Server to declare \
+#define HLP_UNSCANNED_CLOSED "To save scanning time, you may ask Nessus to declare \
TCP ports it did not scan as closed. This will result in an incomplete audit \
-but it will reduce scanning time and prevent Nessus Server from sending \
-packets to ports you did not specify. \
-If this option is disabled, then Nessus Server will consider ports whose \
-state it does not know as open.")
+but it will reduce scanning time and prevent nessusd from sending packets \
+to ports you did not specify. \
+If this option is disabled, then Nessus will consider ports whose state it does not know as open"

-#define HLP_HOST_EXPANSION_DNS \
-_("Nessus Server will perform an AXFR request \
-(that is, a zone transfer) to the target name server and will \
-attempt to obtain the list of the hosts of the target domain. \
-Then, it will test each host.")
+#define HLP_HOST_EXPANSION_DNS "Nessus will perform an AXFR request \
+(that is, a zone transfer) to the remote name server and will attempt to obtain \
+the list of the hosts of the remote domain. Then, it will test each host."

-#define HLP_HOST_EXPANSION_NFS \
-_("Nessus Server will determine which hosts \
-can mount the filesystems exported by the target server, and will test them. \
-Beware : this test is recursive.")
+#define HLP_HOST_EXPANSION_NFS "Nessus will determine which hosts \
+can mount the filesystems exported by the remote server, and will test them. \
+Beware : this test is recursive"

-#define HLP_HOST_EXPANSION_IP \
-_("Nessus Server will test the whole subnet \
-of the target host. If you select this option, you should allow Nessus Server \
-to ping the hosts before scanning them in the 'Scan options' section.")
+#define HLP_HOST_EXPANSION_IP "Nessus will test the whole subnet \
+of the remote host. If you select this option, you should allow Nessus to \
+ping the hosts before scanning them in the 'Scan options' section"

-#define HLP_TARGET_PRIMARY_TARGET \
-_("The first host(s) that will be attacked by Nessus Server. \
-The options below allow you to extend the test to a larger set of \
-computer. You may define several primary targets by separating \
-them with a comma (,). ie : \"host1,host2\".")

-#define HLP_TARGET_READ_FROM_FILE \
-_("A textfile can be specified that contains the list of targets. \
-This textfile may contain comma-separated lists of host and also \
-may contain many of such lines.")
+#define HLP_TARGET_PRIMARY_TARGET "The first host(s) that will be attacked by Nessus. \
+The options below allow you to extend the test to a larger set of computer. You may \
+define several primary targets by separating them with a comma (,). ie : \"host1,host2\""
+
+#define HLP_CGI_PATH "It is possible to check for the presence of CGIs in multiple paths\
+ like /cgi-bin, /cgis, /home-cgis, and so on. In that case, put all your paths here\
+ separated by colons. For instance: '/cgi-bin:/cgi-aws:/~deraison/cgi'"

-#define HLP_CGI_PATH \
-_("It is possible to check for the presence of CGIs in multiple paths \
-like /cgi-bin, /cgis, /home-cgis, and so on. In that case, put all your \
-paths here separated by colons. For instance: \
-'/cgi-bin:/cgi-aws:/~deraison/cgi'.")
+#define HLP_WARNING "The warning sign means that this plugin may harm the \n\
+remote host by disabling the attacked service or by crashing the host. \n\
+You should be careful when you enable it since it may force you to reboot \n\
+your servers or restart some services manually"

-#define HLP_WARNING \
-_("The warning sign means that this plugin may harm the \
-target host by disabling the attacked service or by crashing the host. \
-You should be careful when you enable it since it may force you to reboot \
-your servers or restart some services manually.")

#ifdef ENABLE_SAVE_KB

-# define HLP_ENABLE_KB_SAVING \
-_("If you turn on this option, all the information \
-collected about the target hosts will be saved on the side of \
-Nessus Server for further re-use. See \
-http://www.nessus.org/doc/kb_saving.html for details.")
+#define HLP_ENABLE_KB_SAVING "If you turn on this option, all the information \
+collected about the remote hosts will be saved on the side of nessusd \
+for further re-use. See http://www.nessus.org/doc/kb_saving.html for details"

-# define HLP_KB_TEST_ALL \
-_("If you select this option, all the hosts selected \
-in the 'Target' section of the Nessus Client will be tested.")
+#define HLP_KB_TEST_ALL "If you select this option, all the hosts selected \
+in the 'Target' section of the client will be tested."

-# define HLP_KB_TEST_TESTED \
-_("If you select this option, only the hosts to \
-which a recent knowledge base is attached will be tested.")
+#define HLP_KB_TEST_TESTED "If you select this option, only the hosts to \
+which a recent knowledge base is attached will be tested."

-# define HLP_KB_TEST_UNTESTED \
-_("If you select this option, only the hosts which \
+#define HLP_KB_TEST_UNTESTED "If you select this option, only the hosts which \
have no (or an outdated) knowledge base attached will be tested. \
-Use this option to populate your knowledge bases.")
+Use this option to populate your knowledge bases"

-# define HLP_RESTORE_KB \
-_("If you select this option, the knowledge bases \
-of the target hosts will be restored in memory if they are recent enough. \
-You can use this option with the following ones to prevent Nessus Server \
-to scan a host which was scanned in the past, or to prevent the security \
-checks that were performed in the past to be performed again.")
+#define HLP_RESTORE_KB "If you select this option, the knowledge bases \
+of the remote hosts will be restored in memory if they are recent enough. \
+You can use this option with the following ones to prevent nessusd \
+to port scan a host which was scanned in the past, or to prevent the security \
+checks that were performed in the past to be performed again."

-# define HLP_KB_NO_SCANNER \
-_("If you select this option, the port scanners \
-that were launched in the past against the targetted hosts will not \
-be launched again and the data of the knowledge base will be used \
-as the result of the portscan.")

-# define HLP_KB_NO_INFO \
-_("If you select this option, all the plugins \
+#define HLP_KB_NO_SCANNER "If you select this option, the port scanners \
+that were launched in the past against the targetted hosts will not be launched again \
+and the data of the knowledge base will be used as the result of the portscan"
+
+#define HLP_KB_NO_INFO "If you select this option, all the plugins \
that performs information gathering and which have already been \
-launched against the target hosts will not be launched again.")
+launched against the remote hosts will not be launched again"

-# define HLP_KB_NO_ATTACK \
-_("If you select this option, all the plugins \
+
+#define HLP_KB_NO_ATTACK "If you select this option, all the plugins \
that performs attacks and which have already been launched against the \
-target hosts will not be launched again.")
+remote hosts will not be launched again"

-# define HLP_KB_NO_DENIAL \
-_("If you select this option, all the plugins \
-that may harm the target hosts and which have already been launched \
-will not be launched again.")
+#define HLP_KB_NO_DENIAL "If you select this option, all the plugins \
+that may harm the remote hosts and which have already been launched \
+will not be launched again"

-# define HLP_KB_MAX_AGE \
-_("This value defines the maximum age (in seconds) \
-of a knowledge base.")

-# define HLP_DIFF_SCAN \
-_("If this option is set, the client will only report \
-what has changed between the new scan and the last one.")

-#endif
+#define HLP_KB_MAX_AGE "This value defines the maximum age (in seconds \
+of a knowledge base."

-#define HLP_ENABLE_DEPS_AT_RUNTIME \
-_("If you enable this option, then Nessus Server \
-will enable the plugins that are depended on by the set of plugins you \
-selected.")

-#define HLP_SILENT_DEPS _("If you enable this option, then nessusd \
-will not report data coming from the plugins that you did not specifically \
-enable.")
+#define HLP_DIFF_SCAN "If this option is set, the client will only report \
+what has changed between the new scan and the last one"

+#endif

+#define HLP_ENABLE_DEPS_AT_RUNTIME "If you enable this option, then nessusd \
+will enable the plugins that are depended on by the set of plugins you \
+selected. "
+#define HLP_SILENT_DEPS "If you enable this option, then nessusd \
+will not report data coming from the plugins that you did not specifically \
+enable. "
#endif

Index: prefs_kb.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_kb.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- prefs_kb.c 18 Nov 2004 13:50:26 -0000 1.12
+++ prefs_kb.c 17 Mar 2007 21:36:05 -0000 1.13
@@ -32,20 +32,21 @@
#ifdef ENABLE_SAVE_KB
#ifdef USE_GTK
#include <gtk/gtk.h>
-#include "context.h"
+#include "../xstuff.h"
+#include "globals.h"
#include "prefs_help.h"

-#define ENABLE_KB_SAVING _("Enable KB saving")
-#define TEST_ALL _("Test all hosts")
-#define TEST_TESTED _("Only test hosts that have been tested in the past")
-#define TEST_UNTESTED _("Only test hosts that have never been tested in the past")
+#define ENABLE_KB_SAVING "Enable KB saving"
+#define TEST_ALL "Test all hosts"
+#define TEST_TESTED "Only test hosts that have been tested in the past"
+#define TEST_UNTESTED "Only test hosts that have never been tested in the past"

-#define RESTORE_KB _("Reuse the knowledge bases about the hosts for the test")
+#define RESTORE_KB "Reuse the knowledge bases about the hosts for the test"

-#define NO_SCANNER _("Do not execute scanners that have already been executed")
-#define NO_INFO _("Do not execute info gathering plugins that have already been executed")
-#define NO_ATTACK _("Do not execute attack plugins that have already been executed")
-#define NO_DENIAL _("Do not execute DoS plugins that have already been executed")
+#define NO_SCANNER "Do not execute scanners that have already been executed"
+#define NO_INFO "Do not execute info gathering plugins that have already been executed"
+#define NO_ATTACK "Do not execute attack plugins that have already been executed"
+#define NO_DENIAL "Do not execute DoS plugins that have already been executed"


static void set_state(c, name, value)
@@ -202,12 +203,11 @@


void
-prefs_dialog_kb_get_prefs(context, ctrls)
- struct context *context;
- struct arglist *ctrls;
+prefs_dialog_kb_get_prefs(ctrls)
+ struct arglist * ctrls;
{
GtkWidget * bt;
- struct arglist *prefs = arg_get_value(context->prefs, "SERVER_PREFS");
+ struct arglist *prefs = arg_get_value(Prefs, "SERVER_PREFS");
bt = arg_get_value(ctrls, "ENABLE_SAVE_KB");
if(GTK_TOGGLE_BUTTON(bt) -> active)
arg_addset_value(prefs, "save_knowledge_base", "yes");
@@ -283,7 +283,7 @@

tooltips = gtk_tooltips_new();

- frame = gtk_frame_new(_("Nessus Knowledge Base"));
+ frame = gtk_frame_new("Nessus Knowledge Base");
gtk_container_border_width(GTK_CONTAINER(frame), 10);
arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);

@@ -372,7 +372,7 @@
gtk_box_pack_start(GTK_BOX(box), sbox, TRUE, TRUE, 5);
gtk_widget_show(sbox);

- label = gtk_label_new(_("Max age of a saved KB (in secs) : "));
+ label = gtk_label_new("Max age of a saved KB (in secs) : ");
gtk_box_pack_start(GTK_BOX(sbox), label, TRUE, TRUE, 5);
gtk_widget_show(label);


Index: prefs_kb.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_kb.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- prefs_kb.h 18 Nov 2004 13:50:26 -0000 1.3
+++ prefs_kb.h 17 Mar 2007 21:36:05 -0000 1.4
@@ -3,7 +3,7 @@

#ifdef ENABLE_SAVE_KB

-void prefs_dialog_kb_get_prefs(struct context *, struct arglist *);
+void prefs_dialog_kb_get_prefs(struct arglist*);
void prefs_dialog_kb_set_prefs(struct arglist *, struct arglist *);
struct arglist * prefs_dialog_kb();


Index: prefs_plugins.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_plugins.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- prefs_plugins.c 5 Sep 2005 13:17:52 -0000 1.59
+++ prefs_plugins.c 17 Mar 2007 21:36:05 -0000 1.60
@@ -1,5 +1,5 @@
/* Nessus
- * Copyright (C) 1998, 2005 Renaud Deraison
+ * Copyright (C) 1998 Renaud Deraison
*
* 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
@@ -26,7 +26,7 @@
* 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>

#ifdef USE_GTK
@@ -37,92 +37,154 @@
#include "../families.h"
#include "../preferences.h"
#include "globals.h"
+#include "../xpm/warning_small.xpm"
#include "../error_dialog.h"
#include "prefs_help.h"
#include "filter.h"
-#include "prefs_plugins.h"
-#include "prefs_plugins_tree.h"
+#include "comm.h"


+static struct plugin_families * families;

-static int
-set_filter(w, ctrls)
- GtkWidget *w;
- struct arglist *ctrls;
+int prefs_plugins_redraw(GtkWidget *, void *, struct arglist *);
+void fill_plugins_family(struct arglist *);
+static void prefs_family_toggle_callback(GtkWidget * , struct arglist *);
+static void prefs_plugin_list_toggle_callback(GtkWidget * , struct arglist * );
+static void prefs_plugin_list_callback(GtkWidget * , struct arglist * );
+static void prefs_family_list_callback(GtkWidget * , struct arglist * );
+static GtkWidget * warning_sign(GtkWidget *);
+static int glist_cmp( gconstpointer a, gconstpointer b);
+
+
+static int warning_expl()
{
- struct plugin_filter filter;
- char *old;
- struct arglist *plugins = Context->plugins;
+ show_info(HLP_WARNING);
+ return 0;
+}

- ask_filter(&filter);
- if(!filter.pattern)
- return 0;
+
+static GtkWidget *
+warning_sign(w)
+ GtkWidget * w;
+{
+ GtkStyle * style;
+ GtkWidget * p;
+ GtkWidget * ret;
+
+ style = gtk_widget_get_style(w);
+ p = make_pixmap(w, &style->bg[GTK_STATE_NORMAL], warning_small_xpm);
+
+ ret = gtk_button_new();
+ gtk_widget_set_usize(ret, 20, 20);
+#if GTK_VERSION > 10
+ gtk_button_set_relief(GTK_BUTTON(ret), GTK_RELIEF_NONE);
+#endif
+ gtk_container_add(GTK_CONTAINER(ret), p);
+ gtk_signal_connect(GTK_OBJECT(ret),
+ "clicked",
+ GTK_SIGNAL_FUNC(warning_expl),
+ NULL);
+ gtk_widget_show(p);
+ return ret;
+}


- if((old = arg_get_value(ctrls, "FILTER")))
- {
- arg_set_value(ctrls, "FILTER", sizeof(filter), &filter);
- }
- else
- arg_add_value(ctrls, "FILTER", ARG_STRUCT, sizeof(filter), &filter);
+static int
+set_filter(w, ctrls)
+ GtkWidget * w;
+ struct arglist * ctrls;
+{
+ struct plugin_filter filter;
+ char * old;
+ struct arglist * plugins = Plugins;
+ GList * dlist;

+ ask_filter(&filter);
+ if(!filter.pattern)
+ return 0;
+
+
+ if((old = arg_get_value(ctrls, "FILTER")))
+ {
+ arg_set_value(ctrls, "FILTER", sizeof(filter), &filter);
+ }
+ else
+ arg_add_value(ctrls, "FILTER", ARG_STRUCT, sizeof(filter), &filter);

+
Filter = filter;
memcpy(&Filter, &filter, sizeof(filter));
-
+
if(plugins)
- while(plugins->next)
+ while(plugins->next)
+ {
+ if(filter_plugin(&filter, plugins->value))plug_set_launch(plugins->value, 0);
+ plugins = plugins->next;
+ }
+
+ dlist = GTK_LIST(arg_get_value(ctrls,"FAMILIES_LIST"))->children;
+ while(dlist)
+ {
+ char * name = gtk_object_get_data(GTK_OBJECT(dlist->data), "list_item_data");
+ if(family_empty(name, Plugins))
+ gtk_widget_hide(GTK_WIDGET(dlist->data));
+ else
{
- if(filter_plugin(&filter, plugins->value))
- plug_set_launch(plugins->value, 0);
- plugins = plugins->next;
+ if(!family_enabled(name, Plugins))
+ {
+ GtkWidget * checkbox = gtk_object_get_data(GTK_OBJECT(dlist->data),
+ "list_item_checkbox");
+
+ GTK_TOGGLE_BUTTON(checkbox)->active = 0;
}
-
- prefs_fill_plugin_tree_model(Context, ctrls);
-
+ gtk_widget_show(GTK_WIDGET(dlist->data));
+ }
+ dlist = dlist->next;
+ }
+ prefs_family_list_callback(arg_get_value(ctrls,"FAMILIES_LIST"), ctrls);
+
return 0;
}
-
-static int
-disable_all(w, data)
- GtkWidget *w;
- gpointer data;
+static int
+disable_all(w, ctrls)
+ GtkWidget * w;
+ struct arglist * ctrls;
{
- prefs_plugin_tree_enable_all(GTK_TREE_VIEW(data), FALSE);
-
- return 0;
+ struct arglist * buttons = arg_get_value(ctrls, "families_buttons");
+ while(buttons && buttons->next)
+ {
+ gtk_object_set_data(GTK_OBJECT(buttons->value), "be_lazy", (void*)1);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(buttons->value), 0);
+ family_enable(buttons->name, Plugins, DISABLE_FAMILY);
+ gtk_object_remove_data(GTK_OBJECT(buttons->value), "be_lazy");
+ buttons = buttons->next;
+ }
+ pluginset_reload(Plugins, Scanners);
+ return 0;
}

-static int
-enable_all(w, data)
- GtkWidget *w;
- gpointer data;
+static int
+enable_all(w, ctrls)
+ GtkWidget * w;
+ struct arglist * ctrls;
{
- prefs_plugin_tree_enable_all(GTK_TREE_VIEW(data), TRUE);
-
- return 0;
+ struct arglist * buttons = arg_get_value(ctrls, "families_buttons");
+ if(buttons)
+ while(buttons->next)
+ {
+ gtk_object_set_data(GTK_OBJECT(buttons->value), "be_lazy", (void*)1);
+ family_enable(buttons->name, Plugins, ENABLE_FAMILY);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(buttons->value), 1);
+ gtk_object_remove_data(GTK_OBJECT(buttons->value), "be_lazy");
+ buttons = buttons->next;
+ }
+ pluginset_reload(Plugins, Scanners);
+ return 0;
}

-static void
-expand_all(w, data)
- GtkWidget *w;
- gpointer data;
-{
- gtk_tree_view_expand_all(GTK_TREE_VIEW(data));

- /* normally the tree should automatically be redrawn. This doesn't
- * happen in gtk+ 2.0.2, though, so we trigger a redraw explicitly
- */
- gtk_widget_queue_draw(GTK_WIDGET(data));
-}

-static void
-collapse_all(w, data)
- GtkWidget *w;
- gpointer data;
-{
- gtk_tree_view_collapse_all(GTK_TREE_VIEW(data));
-}
+

/*
* plugin_list_setup
@@ -130,118 +192,469 @@
* Draws the main window showing informations
* about the plugins of the server
*/
-struct arglist *
-prefs_dialog_plugins(context)
- struct context *context;
+struct arglist *
+prefs_dialog_plugins(window)
+ GtkWidget * window;
{
- struct arglist *ctrls = emalloc(sizeof(struct arglist));
- GtkWidget *frame;
- GtkWidget *w_box;
- GtkWidget *hbox;
- GtkWidget *button;
- GtkWidget *tree_window;
- GtkWidget *tree;
-
- frame = gtk_frame_new(_("Plugin selection"));
+ struct arglist * ctrls = emalloc(sizeof(struct arglist));
+ GtkWidget * frame;
+ GtkWidget * families_window;
+ GtkWidget * plugins_window;
+ GtkWidget * w_box;
+ GtkWidget * list;
+ GtkWidget * vbox, * hbox;
+ GtkWidget * button;
+#if GTK_VERSION > 10
+#if GTK_VERSION < 20
+ GtkAccelGroup * accel = gtk_accel_group_new();
+#endif
+#endif
+
+ frame = gtk_frame_new("Plugin selection");
gtk_container_border_width(GTK_CONTAINER(frame), 10);
arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);
-
+
w_box = gtk_vbox_new(TRUE, 5);
gtk_container_border_width(GTK_CONTAINER(w_box), 5);
gtk_container_add(GTK_CONTAINER(frame), w_box);
- gtk_box_set_homogeneous(GTK_BOX(w_box), FALSE);
-
- /* tree view of the plugins */
- tree_window = gtk_scrolled_window_new(NULL, NULL);
- gtk_container_border_width(GTK_CONTAINER(tree_window), 10);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tree_window),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(tree_window),
- GTK_SHADOW_IN);
- gtk_box_pack_start(GTK_BOX(w_box), tree_window, TRUE, TRUE, 0);
- tree = prefs_create_plugins_tree(context, ctrls);
- gtk_container_add(GTK_CONTAINER(tree_window), tree);
- gtk_widget_show(tree);
- gtk_widget_show(tree_window);
-
- /* enable all / disable all buttons */
+
+
+
+
+ families_window = gtk_scrolled_window_new(NULL,NULL);
+ gtk_container_border_width(GTK_CONTAINER(families_window), 10);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(families_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ vbox = gtk_vbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(w_box), vbox, TRUE, TRUE, 0);
+ gtk_widget_show(vbox);
+
+ gtk_box_pack_start(GTK_BOX(vbox), families_window, TRUE, TRUE, 0);
+
+
hbox = gtk_hbox_new(FALSE, 5);
- gtk_box_pack_start(GTK_BOX(w_box), hbox, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show(hbox);
-
- button = gtk_button_new_with_label(_("Enable all"));
+
+ button = gtk_button_new_with_label("Enable all");
gtk_signal_connect(GTK_OBJECT(button),
- "clicked", GTK_SIGNAL_FUNC(enable_all), tree);
+ "clicked",
+ GTK_SIGNAL_FUNC(enable_all),
+ ctrls);
+
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
-
-
- button = gtk_button_new_with_label(_("Disable all"));
+ button = gtk_button_new_with_label("Disable all");
gtk_signal_connect(GTK_OBJECT(button),
- "clicked", GTK_SIGNAL_FUNC(disable_all), tree);
+ "clicked",
+ GTK_SIGNAL_FUNC(disable_all),
+ ctrls);
+
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
-
- /* expand all / collapse all buttons */
- hbox = gtk_hbox_new(FALSE, 5);
- gtk_box_pack_start(GTK_BOX(w_box), hbox, FALSE, FALSE, 0);
- gtk_widget_show(hbox);
-
- button = gtk_button_new_with_label(_("Expand all"));
+
+#if GTK_VERSION < 20
+ button = gtk_button_new_with_label("Filter...");
+#else
+ button = gtk_button_new_with_mnemonic("Fi_lter...");
+#endif
gtk_signal_connect(GTK_OBJECT(button),
- "clicked", GTK_SIGNAL_FUNC(expand_all), tree);
+ "clicked",
+ GTK_SIGNAL_FUNC(set_filter),
+ ctrls);
+
+
+#if GTK_VERSION > 10
+#if GTK_VERSION < 20
+ gtk_widget_add_accelerator(GTK_WIDGET(button),
+ "clicked",
+ accel,
+ 'l',
+ 0,
+ GTK_ACCEL_LOCKED);
+ gtk_window_add_accel_group(GTK_WINDOW(window), accel);
+#endif
+#endif
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
-
- button = gtk_button_new_with_label(_("Collapse all"));
+
+
+
+
+#if 0
+ button = gtk_button_new_with_label("Upload plugin...");
gtk_signal_connect(GTK_OBJECT(button),
- "clicked", GTK_SIGNAL_FUNC(collapse_all), tree);
+ "clicked",
+ GTK_SIGNAL_FUNC(hdl_plugin_upload),
+ ctrls);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
- gtk_widget_show(button);
-
-
- /* dependency buttons */
+ gtk_widget_show(button);
+#endif
+
+
hbox = gtk_hbox_new(FALSE, 5);
- gtk_box_pack_start(GTK_BOX(w_box), hbox, FALSE, FALSE, 5);
+ gtk_box_pack_start(GTK_BOX(vbox),
+ hbox,
+ FALSE, FALSE, 5);
gtk_widget_show(hbox);
-
- button =
- gtk_check_button_new_with_label(_("Enable dependencies at runtime"));
+
+ button = gtk_check_button_new_with_label("Enable dependencies at runtime");
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
arg_add_value(ctrls, "ENABLE_DEPS_AT_RUNTIME", ARG_PTR, -1, button);
-
- button =
- gtk_check_button_new_with_label(_("Silent dependencies"));
+
+ button = gtk_check_button_new_with_label("Silent dependencies");
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
arg_add_value(ctrls, "SILENT_DEPS", ARG_PTR, -1, button);
+

- button = gtk_button_new_with_mnemonic(_("Fi_lter..."));
- gtk_signal_connect(GTK_OBJECT(button),
- "clicked", GTK_SIGNAL_FUNC(set_filter), ctrls);
- gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
- gtk_widget_show(button);
+
+
+ plugins_window = gtk_scrolled_window_new(NULL,NULL);
+ gtk_container_border_width(GTK_CONTAINER(plugins_window), 10);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(plugins_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+
+ gtk_box_pack_start(GTK_BOX(w_box), plugins_window, TRUE, TRUE, 0);
+
+
+ list = gtk_list_new();
+ arg_add_value(ctrls, "FAMILIES_LIST", ARG_PTR, -1, list);
+#if GTK_VERSION < 11
+ gtk_container_add(GTK_CONTAINER(families_window),list);
+#else
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(families_window), list);
+#endif
+ gtk_widget_show(list);
+
+ gtk_signal_connect(GTK_OBJECT(list),
+ "selection_changed",
+ GTK_SIGNAL_FUNC(prefs_family_list_callback),
+ ctrls);
+
+ list = gtk_list_new();
+ arg_add_value(ctrls, "PLUGINS_LIST", ARG_PTR, -1, list);
+#if GTK_VERSION < 11
+ gtk_container_add(GTK_CONTAINER(plugins_window), list);
+#else
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(plugins_window),list);
+#endif
+ gtk_widget_show(list);
+ gtk_signal_connect(GTK_OBJECT(list),
+ "selection_changed",
+ GTK_SIGNAL_FUNC(prefs_plugin_list_callback),
+ ctrls);
+ arg_add_value(ctrls, "FAMILIES", ARG_PTR, -1, families);
+ fill_plugins_family(ctrls);
+ gtk_widget_show(families_window);
+ gtk_widget_show(plugins_window);
+ gtk_widget_show(w_box);
+ gtk_widget_show(frame);
+ arg_add_value(ctrls, "PLUGINS_NUM", ARG_INT, sizeof(int), (void *)PluginsNum);
+ arg_add_value(ctrls, "SCANNERS_NUM", ARG_INT, sizeof(int), (void*)ScannersNum);
+ return(ctrls);
+}

- fill_plugins_family(context, ctrls);

- gtk_widget_show(w_box);
- gtk_widget_show(frame);

- return (ctrls);
+static void
+prefs_plugin_list_callback(widget, ctrls)
+ GtkWidget * widget;
+ struct arglist * ctrls;
+{
+ GtkObject * list_item;
+ char * cur_plug;
+ GList * dlist;
+ GtkWidget * list = arg_get_value(ctrls, "PLUGINS_LIST");
+ dlist = GTK_LIST(list)->selection;
+ if(!dlist)return;
+
+ list_item = GTK_OBJECT(dlist->data);
+ cur_plug = gtk_object_get_data(list_item,"list_item_data");
+ plugin_info_window_setup(Plugins, cur_plug);
}

+static void
+prefs_family_toggle_callback(w, ctrls)
+ GtkWidget * w;
+ struct arglist * ctrls;
+{
+ int enable = GTK_TOGGLE_BUTTON (w)->active;
+ GList * dlist = NULL;
+ GtkObject * list_item;
+ char * name;
+ GtkWidget * item;
+ int check_manually = 1;
+
+ if(gtk_object_get_data(GTK_OBJECT(w), "be_lazy"))
+ return;
+

-void
-fill_plugins_family(context, ctrls)
- struct context *context;
- struct arglist *ctrls;
+ item = w->parent->parent;
+ list_item = GTK_OBJECT(item);
+ name = gtk_object_get_data(list_item,"list_item_data");
+ dlist = GTK_LIST(arg_get_value(ctrls, "PLUGINS_LIST"))->children;
+
+ if(check_manually)family_enable(name, Plugins, enable);
+ pluginset_reload(Plugins, Scanners);
+
+ prefs_family_list_callback(arg_get_value(ctrls,"FAMILIES_LIST"), ctrls);
+}
+
+static
+void prefs_plugin_list_toggle_callback(w, plugin)
+ GtkWidget * w;
+ struct arglist * plugin;
{
- /* init tree data */
- prefs_fill_plugin_tree_model(context, ctrls);
+ int state = GTK_TOGGLE_BUTTON(w)->active;
+
+ plug_set_launch(plugin,state);
+ pluginset_reload(Plugins, Scanners);
}

+static
+void
+prefs_family_list_callback(widget, ctrls)
+ GtkWidget * widget;
+ struct arglist * ctrls;
+{
+ GList * dlist;
+ GtkObject * list_item;
+ char * cur_family;
+ struct arglist * plugs = Plugins;
+ GtkTooltips * tooltips;
+ struct plugin_filter * filter = arg_get_value(ctrls, "FILTER");
+
+ if(gtk_object_get_data(GTK_OBJECT(widget), "be_lazy"))
+ return;
+
+
+
+
+ dlist = GTK_LIST(arg_get_value(ctrls, "FAMILIES_LIST"))->selection;
+ if(!dlist)return;
+
+ list_item = GTK_OBJECT(dlist->data);
+ cur_family = gtk_object_get_data(list_item,"list_item_data");
+ dlist = GTK_LIST(arg_get_value(ctrls, "PLUGINS_LIST"))->children;
+ if(dlist)gtk_list_remove_items(GTK_LIST(arg_get_value(ctrls, "PLUGINS_LIST")),dlist);
+ dlist = NULL;
+ tooltips = gtk_tooltips_new();
+ if(plugs)while(plugs->next)
+ {
+ GtkWidget * item;
+ GtkWidget * box;
+ GtkWidget * button;
+ GtkWidget * label;
+
+
+ if(arg_get_value(plugs->value, "FAMILY") &&
+ !strcmp(arg_get_value(plugs->value, "FAMILY"), cur_family))
+ {
+ char * cat = arg_get_value(plugs->value, "CATEGORY");
+ int warning = cat? (!strcmp(cat, "denial") ||
+ !strcmp(cat, "kill_host") ||
+ !strcmp(cat, "flood") ||
+ !strcmp(cat, "destructive_attack")):0;
+ GtkWidget * sign = NULL;
+
+ if(filter)
+ {
+ if(filter_plugin(filter, plugs->value))
+ {
+ plugs = plugs->next;
+ continue;
+ }
+ }
+ item = gtk_list_item_new();
+
+
+ button = gtk_check_button_new();
+ gtk_widget_set_usize(button, 20, 20);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button),
+ (int)plug_get_launch(plugs->value));
+
+ label = gtk_label_new(plugs->name);
+ box = gtk_hbox_new(FALSE,5);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+
+
+ gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE,0);
+ if(warning)
+ {
+ sign = warning_sign(widget);
+ gtk_box_pack_end(GTK_BOX(box), sign, FALSE, FALSE, 0);
+ }
+ gtk_container_add(GTK_CONTAINER(item), box);
+ gtk_signal_connect(GTK_OBJECT(button),
+ "clicked",
+ GTK_SIGNAL_FUNC(prefs_plugin_list_toggle_callback),
+ plugs->value);
+ gtk_widget_show(button);
+ if(warning)gtk_widget_show(sign);
+ gtk_widget_show(box);
+ gtk_widget_show(item);
+ if(arg_get_value(plugs->value, "SUMMARY"))
+ gtk_tooltips_set_tip(tooltips, item,
+ (gchar *)arg_get_value(plugs->value, "SUMMARY"),"");
+ dlist = g_list_append(dlist, item);
+ gtk_object_set_data(GTK_OBJECT(item),
+ "list_item_data",
+ plugs->name);
+ gtk_object_set_data(GTK_OBJECT(item),
+ "button",
+ button);
+ gtk_object_set_data(GTK_OBJECT(item),
+ "plugin",
+ plugs->value);
+ }
+ plugs = plugs->next;
+ }
+ gtk_tooltips_enable(tooltips);
+ dlist = g_list_sort(dlist, glist_cmp);
+ gtk_list_append_items(GTK_LIST(arg_get_value(ctrls, "PLUGINS_LIST")), dlist);
+ pluginset_reload(Plugins, Scanners);
+}
+
+
+int prefs_plugins_redraw(w, dumb, ctrls)
+ GtkWidget * w;
+ void * dumb;
+ struct arglist * ctrls;
+{
+ int num;
+
+ num = (int)arg_get_value(ctrls, "PLUGINS_NUM");
+ if(num != PluginsNum){
+ fill_plugins_family(ctrls);
+ arg_set_value(ctrls, "PLUGINS_NUM", sizeof(int), (void *)PluginsNum);
+ }
+ return 0;
+}
+
+static int glist_cmp( gconstpointer a, gconstpointer b)
+{
+ GtkWidget * item_a = (GtkWidget*)a;
+ GtkWidget * item_b = (GtkWidget*)b;
+
+ char * str_a, * str_b;
+
+ str_a = gtk_object_get_data(GTK_OBJECT(item_a), "list_item_data");
+ str_b = gtk_object_get_data(GTK_OBJECT(item_b), "list_item_data");
+ return strcmp(str_a, str_b);
+}
+
+void
+fill_plugins_family(ctrls)
+ struct arglist * ctrls;
+{
+ GtkTooltips * tooltips;
+ struct arglist * plugs = Plugins;
+ struct plugin_families * lfamilies, *f;
+ struct arglist * buttons;
+ GList * dlist = NULL;
+
+
+
+
+
+ buttons = arg_get_value(ctrls, "families_buttons");
+ if(buttons)
+ {
+ /* arg_free(buttons); */
+ buttons = emalloc(sizeof(struct arglist));
+ arg_set_value(ctrls,"families_buttons",-1, buttons);
+ }
+ else
+ {
+ buttons = emalloc(sizeof(struct arglist));
+ arg_add_value(ctrls, "families_buttons", ARG_ARGLIST, -1, buttons);
+ }
+

+ tooltips = gtk_tooltips_new();
+ lfamilies = families = family_init();
+ if(plugs)
+ while(plugs->next)
+ {
+ family_add(families, plugs->value);
+ plugs = plugs->next;
+ }
+ plugs = Plugins;
+

+ if(lfamilies)
+ while(lfamilies->next)
+ {
+ GtkWidget * item;
+ GtkWidget * box;
+ GtkWidget * button;
+ GtkWidget * label;
+ struct plugin_families * old = arg_get_value(ctrls, "FAMILIES");
+ int flag = 0;
+ if(old)
+ while(old->next && !flag)
+ {
+ if(old->name)flag = !strcmp(old->name, lfamilies->name);
+ old = old->next;
+ }
+
+ if(flag){
+ lfamilies = lfamilies->next;
+ continue;
+ }
+
+ item = gtk_list_item_new();
+
+
+ button = gtk_check_button_new();
+ arg_add_value(buttons, lfamilies->name, ARG_PTR, -1, button);
+ gtk_tooltips_set_tip(tooltips, button, lfamilies->name, "");
+
+ gtk_widget_set_usize(button, 15, 15);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button),
+ family_enabled(lfamilies->name, Plugins) ? TRUE:FALSE);
+ label = gtk_label_new(lfamilies->name);
+ box = gtk_hbox_new(FALSE,5);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+ gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE,0);
+
+ gtk_container_add(GTK_CONTAINER(item), box);
+ gtk_signal_connect(GTK_OBJECT(button),
+ "clicked",
+ GTK_SIGNAL_FUNC(prefs_family_toggle_callback),
+ ctrls);
+
+ gtk_widget_show(button);
+ gtk_widget_show(box);
+ gtk_widget_show(item);
+ dlist = g_list_append(dlist, item);
+ gtk_object_set_data(GTK_OBJECT(item),
+ "list_item_checkbox",
+ button);
+ gtk_object_set_data(GTK_OBJECT(item),
+ "list_item_data",
+ lfamilies->name);
+ lfamilies = lfamilies->next;
+ }

+ dlist = g_list_sort(dlist, glist_cmp);
+ gtk_tooltips_enable(tooltips);
+ gtk_list_append_items(GTK_LIST(arg_get_value(ctrls, "FAMILIES_LIST")), dlist);
+ f = arg_get_value(ctrls, "FAMILIES");
+ arg_set_value(ctrls, "FAMILIES", -1, families);
+ while(f && f->next)
+ {
+ struct plugin_families * prev;
+ efree(&f->name);
+ prev = f;
+ f = f->next;
+ efree(&prev);
+ }
+}
#endif

Index: prefs_plugins.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_plugins.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- prefs_plugins.h 18 Nov 2004 13:50:26 -0000 1.5
+++ prefs_plugins.h 17 Mar 2007 21:36:05 -0000 1.6
@@ -19,8 +19,6 @@
#ifndef _NESSUSC_PREFS_PLUGINS_H
#define _NESSUSC_PREFS_PLUGINS_H

-#include "context.h"
-
-struct arglist *prefs_dialog_plugins(struct context *);
-void fill_plugins_family(struct context *, struct arglist *);
+struct arglist * prefs_dialog_plugins(GtkWidget*);
+int prefs_plugins_redraw(GtkWidget *, void *, struct arglist *);
#endif

Index: prefs_target.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_target.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- prefs_target.c 18 Nov 2004 13:50:27 -0000 1.27
+++ prefs_target.c 17 Mar 2007 21:36:05 -0000 1.28
@@ -31,62 +31,490 @@

#ifdef USE_GTK
#include <gtk/gtk.h>
-#include "read_target_file.h"
-#include "nessus_i18n.h"
+#include "../xstuff.h"
+#include "../preferences.h"
+#include "prefs_dialog.h"
+#include "../monitor_dialog.h"
+#include "../error_dialog.h"
+#include "../read_target_file.h"
+#include "globals.h"
+#include "../comm.h"

-struct arglist *
-prefs_dialog_target()
+
+static void
+save_session_cb(w, ctrls)
+ GtkWidget* w;
+ struct arglist *ctrls;
{
- GtkWidget * frame;
- GtkWidget * vbox;
- GtkWidget * label;
- GtkWidget * check_dns;
- GtkWidget * entry;
- GtkWidget * hbox;
- GtkWidget * button;
- struct arglist * ctrls = emalloc(sizeof(struct arglist));
+ GtkWidget * wg = arg_get_value(ctrls, "SAVE_EMPTY_SESSIONS");
+ gtk_widget_set_sensitive(wg, GTK_TOGGLE_BUTTON(w) -> active);
+}

- /* The overall frame */
- frame = gtk_frame_new(_("Target selection"));
- gtk_container_border_width(GTK_CONTAINER(frame), 10);
- gtk_widget_show(frame);
- arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);
+static void
+delete_session_cb(nul, clist)
+ GtkWidget* nul, *clist;
+{
+ GList * selection;
+ char * key;
+ int data = -1;
+ int n = 0;
+
+ if(!clist)return;
+ /*gtk_clist_freeze(GTK_CLIST(clist));*/
+ if(!GTK_CLIST(clist)->rows)n++;
+

- /* the overall vbox that will contain all widgets */
- vbox = gtk_vbox_new(FALSE, 4);
- gtk_container_add(GTK_CONTAINER(frame), vbox);
- gtk_widget_show(vbox);
+ selection = GTK_CLIST(clist)->selection;
+ if(selection)
+ {
+ data = (int)selection->data;
+ key = gtk_clist_get_row_data(GTK_CLIST(clist), data);
+ comm_delete_session(key);
+ gtk_clist_remove(GTK_CLIST(clist), data);
+ /*selection = selection->next;*/
+ }
+ /* gtk_clist_thaw(GTK_CLIST(clist));
+ gtk_widget_realize(clist);*/
+}

- /* The hbox that contains the target entry and file selection button */
- hbox = gtk_hbox_new(FALSE, 5);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show(hbox);

- /* The label for target entry */
- label = gtk_label_new(_("Target(s):"));
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- gtk_widget_show(label);

- /* The target entry */
- entry = gtk_entry_new();
- gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
- gtk_widget_show(entry);
- arg_add_value(ctrls, "TARGET", ARG_PTR, -1, entry);
+static void
+restore_session_cb(nul, clist)
+ GtkWidget * nul, * clist;
+{
+ GList * selection;
+ char * key;
+ struct arglist * prefs;
+ struct arglist * serv;
+ struct arglist * t;
+ char expansion[30];
+ char * s;
+ char * hostname;
+ GtkWidget * gtkw;
+ struct arglist * ctrls = MainDialog;
+
+ if(!clist)
+ {
+ show_error("There is no session to restore !");
+ return;
+ }
+ selection = GTK_CLIST(clist)->selection;
+ if(!selection)
+ {
+ show_error("You must select a session to restore !");
+ return;
+ }
+ if(selection->next)
+ {
+ show_error("Can only restore one session at a time !");
+ return;
+ }
+
+ key = gtk_clist_get_row_data(GTK_CLIST(clist), (int)selection->data);
+ bzero(expansion, 30);
+ prefs = arg_get_value(ctrls, "PREFERENCES");
+ serv = arg_get_value(prefs, "SERVER_PREFS");
+ if(!serv)
+ {
+ serv = emalloc(sizeof(struct arglist));
+ arg_add_value(prefs, "SERVER_PREFS", ARG_ARGLIST, -1, serv);
+ }
+
+ /*
+ * Host expansion
+ */
+ t = arg_get_value(ctrls, "TARGET");
+ gtkw = arg_get_value(t, "DNS_EXPAND");
+ if(GTK_TOGGLE_BUTTON(gtkw)->active)
+ strcat(expansion, "dns;");
+
+ strcat(expansion, "ip;");
+
+ if(!strlen(expansion))strncpy(expansion, "none;", 5);
+ expansion[strlen(expansion)-1]=0;
+
+ s = (char*)gtk_entry_get_text(GTK_ENTRY(arg_get_value(t, "TARGET")));
+ hostname = target_translate(s); /* if the target is a file, then
+ translate it */
+
+ s = emalloc(strlen(expansion)+1);
+ strncpy(s, expansion, strlen(expansion));
+
+ if(arg_get_value(serv, "host_expansion"))
+ arg_set_value(serv, "host_expansion", strlen(s), s);
+ else
+ arg_add_value(serv, "host_expansion", ARG_STRING, strlen(s), s);
+

- /* The button for reading target from a file */
- button = gtk_button_new_with_label(_("Read file..."));
- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
- gtk_signal_connect(GTK_OBJECT(button), "clicked",
- (GtkSignalFunc)target_file_select, NULL);
- gtk_widget_show(button);
- arg_add_value(ctrls, "READ_FROM_FILE", ARG_PTR, -1, button);
+
+ /*
+ * Plugins preferences
+ */
+ {
+ struct arglist * plugs[2];
+ int i;
+
+ plugs[0] = Plugins;
+ plugs[1] = Scanners;
+
+ for(i=0;i<2;i++)
+ {
+ struct arglist * plugins = plugs[i];
+
+ while(plugins && plugins->next)
+ {
+ struct arglist * pref;
+ char * type;
+ char * value;
+
+ if((pref = arg_get_value(plugins->value, "plugin_prefs")))
+ while(pref && pref->next)
+ {
+ if((type = (char*)arg_get_value(pref->value, "type")))
+ {
+ if(!strcmp(type, PREF_ENTRY))
+ {
+ GtkWidget * entry = arg_get_value(pref->value, "ENTRY");
+ if(entry)
+ {
+ value = (char*)gtk_entry_get_text(GTK_ENTRY(entry));
+ arg_set_value(pref->value, "value", strlen(value),
+ estrdup(value));
+ }
+ }
+ else if(!strcmp(type, PREF_CHECKBOX))
+ {
+ GtkWidget * button = arg_get_value(pref->value, "CHECKBOX");
+
+ if(button)
+ {
+ char * value = GTK_TOGGLE_BUTTON(button)->active ? "yes":"no";
+ arg_set_value(pref->value, "value", strlen(value),
+ estrdup(value));
+ }
+ }
+ else if(!strcmp(type, PREF_RADIO))
+ {
+ GSList * list = arg_get_value(pref->value, "RADIOBUTTONS");
+ char * value = NULL;
+
+ if(list)while(list && !value)
+ {
+ GtkWidget * button = list->data;
+ if(GTK_TOGGLE_BUTTON(button)->active)
+ value = (char*)gtk_object_get_data(GTK_OBJECT(button), "name");
+ list = list->next;
+ }
+ else {
+ char * t;
+ if(pref->value)
+ value = arg_get_value(pref->value, "value");
+ if(value&&(t = strchr(value, ';')))t[0] = 0;
+ }
+ if(value)arg_set_value(pref->value, "value", strlen(value),
+ estrdup(value));
+ }
+ }
+ pref = pref->next;
+ }
+ plugins = plugins->next;
+ }
+ }
+ }
+
+
+
+ /*
+ * Scan options
+ */
+
+ t = arg_get_value(ctrls, "SCAN_OPTIONS");
+ gtkw = arg_get_value(t, "PING_HOSTS");
+ s = emalloc(4);
+
+ if(GTK_TOGGLE_BUTTON(gtkw)->active)strncpy(s, "yes", 3);
+ else strncpy(s, "no", 4);
+
+ if(arg_get_value(serv, "ping_hosts"))
+ arg_set_value(serv, "ping_hosts", strlen(s), s);
+ else
+ arg_add_value(serv, "ping_hosts", ARG_STRING, strlen(s), s);
+
+
+ gtkw = arg_get_value(t, "REVERSE_LOOKUP");
+ s = emalloc(4);
+ if(GTK_TOGGLE_BUTTON(gtkw)->active)strncpy(s, "yes", 3);
+ else strncpy(s, "no", 4);
+
+ if(arg_get_value(serv, "reverse_lookup"))
+ arg_set_value(serv, "reverse_lookup", strlen(s), s);
+ else
+ arg_add_value(serv, "reverse_lookup", ARG_STRING, strlen(s), s);
+
+ gtkw = arg_get_value(t, "OPTIMIZE_TEST");
+ s = emalloc(4);
+ if(GTK_TOGGLE_BUTTON(gtkw)->active)strncpy(s, "yes", 3);
+ else strncpy(s, "no", 4);
+
+ if(arg_get_value(serv, "optimize_test"))
+ arg_set_value(serv, "optimize_test", strlen(s), s);
+ else
+ arg_add_value(serv, "optimize_test", ARG_STRING, strlen(s), s);
+
+
+ gtkw = arg_get_value(t, "PORT_RANGE");
+ s = emalloc(strlen((char*)gtk_entry_get_text(GTK_ENTRY(gtkw)))+1);
+ strncpy(s, gtk_entry_get_text(GTK_ENTRY(gtkw)),
+ strlen(gtk_entry_get_text(GTK_ENTRY(gtkw))));
+
+ if(arg_get_value(serv, "port_range"))
+ arg_set_value(serv, "port_range", strlen(s), s);
+ else
+ arg_add_value(serv, "port_range", ARG_STRING, strlen(s), s);
+
+ gtkw = arg_get_value(t, "MAX_HOSTS");
+
+ s = emalloc(strlen(gtk_entry_get_text(GTK_ENTRY(gtkw)))+1);
+
+ strncpy(s, gtk_entry_get_text(GTK_ENTRY(gtkw)),
+ strlen(gtk_entry_get_text(GTK_ENTRY(gtkw))));
+
+ if(arg_get_value(serv, "max_hosts"))
+ arg_set_value(serv, "max_hosts", strlen(s), s);
+ else
+ arg_add_value(serv, "max_hosts", ARG_STRING, strlen(s), s);
+
+ gtkw = arg_get_value(t, "MAX_CHECKS");
+
+ s = emalloc(strlen(gtk_entry_get_text(GTK_ENTRY(gtkw)))+1);
+
+ strncpy(s, gtk_entry_get_text(GTK_ENTRY(gtkw)),
+ strlen(gtk_entry_get_text(GTK_ENTRY(gtkw))));
+
+ if(arg_get_value(serv, "max_checks"))
+ arg_set_value(serv, "max_checks", strlen(s), s);
+ else
+ arg_add_value(serv, "max_checks", ARG_STRING, strlen(s), s);
+
+
+ gtkw = arg_get_value(t, "CGI_PATH");
+ s = (char*)gtk_entry_get_text(GTK_ENTRY(gtkw));
+ s = emalloc(strlen(s)+1);
+ strncpy(s, gtk_entry_get_text(GTK_ENTRY(gtkw)),
+ strlen(gtk_entry_get_text(GTK_ENTRY(gtkw))));
+
+ if(arg_get_value(serv, "cgi_path"))
+ arg_set_value(serv, "cgi_path", strlen(s), s);
+ else
+ arg_add_value(serv, "cgi_path", ARG_STRING, strlen(s), s);
+
+ /*
+ * Check for the errors
+ */
+ if(GlobalSocket < 0)
+ {
+ show_error("You must connect to a nessusd host before you start \n\
+a scan in the 'nessusd' section");
+ return;
+ }
+
+
+ /*
+ * Set up the GUI for the attack, and start it !
+ */
+ close_window(nul, arg_get_value(ctrls, "WINDOW"));
+ monitor_dialog_setup(key, 1);
+}
+
+void
+prefs_dialog_target_free_list(ctrls)
+ struct arglist *ctrls;
+{
+ GtkWidget * clist = arg_get_value(ctrls, "SESSIONS");
+ int last;
+ char*empty[] = {"", ""};
+ int i;
+ if(!clist)return;
+ last = gtk_clist_append(GTK_CLIST(clist), empty);
+ for(i=last;i>=0;i--)gtk_clist_remove(GTK_CLIST(clist), i);
+}

- /* Checkbox for Zone transfer */
- check_dns = gtk_check_button_new_with_label(_("Perform a DNS zone transfer"));
- gtk_box_pack_start(GTK_BOX(vbox), check_dns, FALSE, FALSE, 0);
- gtk_widget_show(check_dns);
- arg_add_value(ctrls, "DNS_EXPAND", ARG_PTR, -1, check_dns);

- return(ctrls);
+
+
+void
+prefs_dialog_target_fill_sessions(dialog, sessions)
+ struct arglist * dialog;
+ harglst * sessions;
+{
+ hargwalk * hw;
+ char * key;
+ int i = 0;
+ GtkWidget * clist = arg_get_value(dialog, "SESSIONS");
+ int last;
+ char**empty;
+
+
+
+ if(!clist)return;
+ if(!sessions)return;
+
+ empty = emalloc(2*sizeof(char*));
+ empty[0] = estrdup("");
+ empty[1] = estrdup("");
+
+
+
+ hw = harg_walk_init(sessions);
+ gtk_clist_freeze(GTK_CLIST(clist));
+ last = gtk_clist_append(GTK_CLIST(clist), empty);
+ for(i=last;i>=0;i--)gtk_clist_remove(GTK_CLIST(clist), i);
+ i = 0;
+ while((key = (char*)harg_walk_next(hw)))
+ {
+ char * data[2];
+ int row;
+ data[0] = key;
+ data[1] = harg_get_string(sessions, key);
+ row = gtk_clist_append(GTK_CLIST(clist), data);
+ gtk_clist_set_row_data(GTK_CLIST(clist), row, key);
+ i++;
+ }
+#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));
+}
+struct arglist * prefs_dialog_target(preferences)
+ struct arglist * preferences;
+{
+ GtkWidget * frame;
+ GtkWidget * table;
+ GtkWidget * label;
+ GtkWidget * check_dns;
+ GtkWidget * entry;
+ GtkWidget * hbox;
+ GtkWidget * button;
+ struct arglist * ctrls = emalloc(sizeof(struct arglist));
+#ifdef ENABLE_SAVE_TESTS
+ GtkWidget * clist;
+ GtkWidget * scrolled;
+ char * titles[] = {"Session", "Targets"};
+#endif
+ frame = gtk_frame_new("Target selection");
+ gtk_container_border_width(GTK_CONTAINER(frame), 10);
+ gtk_widget_show(frame);
+
+ arg_add_value(ctrls,"PREFERENCES", ARG_PTR, -1, frame);
+ arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);
+
+
+ table = gtk_table_new(7, 2, FALSE);
+ gtk_container_add(GTK_CONTAINER(frame), table);
+ gtk_container_border_width(GTK_CONTAINER(table), 10);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 5);
+ gtk_widget_show(table);
+
+ label = gtk_label_new("Target(s) : ");
+ gtk_table_attach(GTK_TABLE(table), label, 0,1,0,1,GTK_FILL | GTK_EXPAND,0,0,0);
+ gtk_widget_show(label);
+
+ hbox = gtk_hbox_new(FALSE, 10);
+ gtk_table_attach(GTK_TABLE(table), hbox, 1,2,0,1, GTK_FILL|GTK_EXPAND, 0,0,0);
+ gtk_widget_show(hbox);
+
+ entry = gtk_entry_new();
+ gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+ gtk_widget_show(entry);
+
+ button = gtk_button_new_with_label("Read file...");
+ gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gtk_signal_connect /*_object*/ (GTK_OBJECT (button),
+ "clicked", (GtkSignalFunc)target_file_select, NULL);
+
+ gtk_widget_show(button);
+
+
+ gtk_widget_show(entry);
+ arg_add_value(ctrls, "TARGET", ARG_PTR, -1, entry);
+
+
+ check_dns = gtk_check_button_new_with_label("Perform a DNS zone transfer");
+ arg_add_value(ctrls, "DNS_EXPAND", ARG_PTR, -1, check_dns);
+ gtk_table_attach(GTK_TABLE(table), check_dns, 1,2,1,2,GTK_FILL | GTK_EXPAND,0,0,0);
+
+ gtk_widget_show(check_dns);
+
+#ifdef ENABLE_SAVE_TESTS
+ button = gtk_check_button_new_with_label("Save this session");
+ arg_add_value(ctrls, "SAVE_THIS_SESSION", ARG_PTR, -1, button);
+ gtk_table_attach(GTK_TABLE(table), button, 0,2, 2, 3, GTK_FILL|GTK_EXPAND,0,0,0);
+ gtk_widget_show(button);
+ gtk_signal_connect(GTK_OBJECT(button),
+ "clicked",
+ GTK_SIGNAL_FUNC(save_session_cb),
+ ctrls);
+
+
+
+ hbox = gtk_hbox_new(TRUE, 10);
+ gtk_table_attach(GTK_TABLE(table), hbox, 0,2,3,4, GTK_FILL|GTK_EXPAND,0,0,0);
+ gtk_widget_show(hbox);
+
+ button = gtk_check_button_new_with_label("Save empty sessions");
+ arg_add_value(ctrls, "SAVE_EMPTY_SESSIONS", ARG_PTR, -1, button);
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 10);
+ gtk_widget_show(button);
+
+ label = gtk_label_new("Previous sessions : ");
+ gtk_table_attach(GTK_TABLE(table), label, 0, 2, 4, 5,GTK_FILL|GTK_EXPAND,0,0,0);
+ gtk_widget_show(label);
+
+ scrolled = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ gtk_table_attach(GTK_TABLE(table), scrolled, 0, 2, 5, 6,GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND,0,0);
+ gtk_widget_show(scrolled);
+ clist = gtk_clist_new_with_titles(2, titles);
+#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);
+
+ gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE);
+#if GTK_VERSION > 10
+ gtk_clist_set_reorderable(GTK_CLIST(clist), TRUE);
+#endif
+ arg_add_value(ctrls, "SESSIONS", ARG_PTR, -1, clist);
+
+ hbox = gtk_hbox_new(TRUE, 5);
+ gtk_table_attach(GTK_TABLE(table), hbox, 0, 2, 6, 7, GTK_FILL|GTK_EXPAND,0,0,0);
+ gtk_widget_show(hbox);
+
+ button = gtk_button_new_with_label("Restore session");
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gtk_signal_connect(GTK_OBJECT(button),
+ "clicked", (GtkSignalFunc)restore_session_cb, clist);
+ gtk_widget_show(button);
+
+ button = gtk_button_new_with_label("Delete session");
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gtk_signal_connect /*_object*/ (GTK_OBJECT (button),
+ "clicked", (GtkSignalFunc)delete_session_cb, clist);
+ gtk_widget_show(button);
+#endif
+
+ return(ctrls);
}
+
+
#endif
+

Index: prefs_target.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/prefs_dialog/prefs_target.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- prefs_target.h 18 Nov 2004 13:50:27 -0000 1.4
+++ prefs_target.h 17 Mar 2007 21:36:05 -0000 1.5
@@ -19,5 +19,7 @@
#ifndef _NESSUSC_PREFS_TARGET_H
#define _NESSUSC_PREFS_TARGET_H

-struct arglist *prefs_dialog_target();
+struct arglist * prefs_dialog_target(struct arglist *);
+void prefs_dialog_target_free_list(struct arglist*);
+void prefs_dialog_target_fill_sessions(struct arglist*, harglst*);
#endif

_______________________________________________
Nessus-cvs mailing list
Nessus-cvs@list.nessus.org
http://mail.nessus.org/mailman/listinfo/nessus-cvs