Nmap Development mailing list archives
Re: [NmapFE PATCH] Use spin button for verbosity/debugging levels
From: Kris Katterjohn <kjak () ispwest com>
Date: Mon, 25 Sep 2006 20:10:57 -0500
Fyodor wrote:
On Mon, Sep 25, 2006 at 12:06:48AM -0500, Kris Katterjohn wrote:The attached patch uses a spin button for selecting the verbosity and debugging levels instead of the...limited...way that's used now. I like the debug info! :)Thanks for contributing. I tried the patch and saw just two issues: o It barred people from setting these options unless they are root. Neither -v or -d require any special permissions, and the current NmapFE allows them to be used by unprivileged users.
Ah, I accidentally copied that over from another part. I almost always use functionality that's root-only and it didn't even cross my mind to test it with my normal account. Sorry about that.
o When I click the new "verbose" or "debug" buttons, it defaults to a value of zero. I think it should default to one (so clicking the verbose checkbox turns it on), rather than making them check the box and then change the spin field to 1.
Good idea. I like it.
If you can send a new patch which addresses these issues, I'd be happy to incorporate it. Cheers, -F
The attached patch incorporates both of my previous patches (removes that enum) and has the updates you talked about. As before, it's a diff against 4.20ALPHA7. Thanks, Kris Katterjohn
--- x/nmapfe/nmapfe.c 2006-08-24 20:47:59.000000000 -0500 +++ y/nmapfe/nmapfe.c 2006-09-25 20:03:05.000000000 -0500 @@ -234,15 +234,6 @@ static gchar *protportEntries[] = { NULL }; -static gchar *verboseEntries[] = { - "Quiet", - "Verbose", - "Very Verbose", - "Debug", - "Verbose Debug", - NULL -}; - static gchar *outputFormatEntries[] = { "Normal", "grep-able", @@ -433,7 +424,6 @@ GtkAdjustment *adjust; opt.throttleValue = NORMAL_THROTTLE; opt.resolveValue = DEFAULT_RESOLVE; opt.protportValue = DEFAULT_PROTPORT; - opt.verboseValue = QUIET_VERBOSE; opt.outputFormatValue = NORMAL_OUTPUT; #ifdef WIN32 @@ -1213,29 +1203,48 @@ GtkAdjustment *adjust; gtk_widget_show_all(frame); } - /* Verbosity frame */ - { - gint i; + /* Verbosity & Debugging frame */ + frame = gtk_frame_new("Verbosity & Debugging Levels"); + gtk_table_attach_defaults(GTK_TABLE(nbpage), frame, 0, 1, 1, 2); - frame = gtk_frame_new("Verbosity"); - gtk_table_attach_defaults(GTK_TABLE(nbpage), frame, 0, 1, 1, 2); - - vbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); - gtk_container_add(GTK_CONTAINER(frame), vbox); - - opt.verboseType = gtk_combo_box_new_text(); - - for (i = 0; verboseEntries[i]; i++) { - gtk_combo_box_append_text(GTK_COMBO_BOX(opt.verboseType), verboseEntries[i]); - } + table = gtk_table_new(2, 2, FALSE); + gtk_container_set_border_width(GTK_CONTAINER(table), 5); + gtk_container_add(GTK_CONTAINER(frame), table); - g_signal_connect(G_OBJECT(opt.verboseType), "changed", - G_CALLBACK (verboseType_cb), NULL); + opt.verbose = gtk_check_button_new_with_label("Verbosity"); + gtk_table_attach_defaults(GTK_TABLE(table), opt.verbose, 0, 1, 0, 1); + gtk_widget_show(opt.verbose); + + adjust = (GtkAdjustment *) gtk_adjustment_new(1.0, 1.0, 2.0, 1.0, 10.0, 10.0); + opt.verboseValue = gtk_spin_button_new(adjust, 1.0, 0); + gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(opt.verboseValue), TRUE); + g_signal_connect(GTK_OBJECT(opt.verbose), "released", + GTK_SIGNAL_FUNC(toggle_button_set_sensitive_cb), opt.verboseValue); + g_signal_connect(GTK_OBJECT(opt.verboseValue), "changed", + GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); + if (!GTK_TOGGLE_BUTTON(opt.verbose)->active) + gtk_widget_set_sensitive(GTK_WIDGET(opt.verboseValue), FALSE); + gtk_table_attach_defaults(GTK_TABLE(table), opt.verboseValue, 1, 2, 0, 1); + gtk_widget_show(opt.verboseValue); + + opt.debug = gtk_check_button_new_with_label("Debugging"); + gtk_table_attach_defaults(GTK_TABLE(table), opt.debug, 0, 1, 1, 2); + gtk_widget_show(opt.debug); + + adjust = (GtkAdjustment *) gtk_adjustment_new(1.0, 1.0, 9.0, 1.0, 10.0, 10.0); + opt.debugValue = gtk_spin_button_new(adjust, 1.0, 0); + gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(opt.debugValue), TRUE); + g_signal_connect(GTK_OBJECT(opt.debug), "released", + GTK_SIGNAL_FUNC(toggle_button_set_sensitive_cb), opt.debugValue); + g_signal_connect(GTK_OBJECT(opt.debugValue), "changed", + GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); + if (!GTK_TOGGLE_BUTTON(opt.debug)->active) + gtk_widget_set_sensitive(GTK_WIDGET(opt.debugValue), FALSE); + gtk_table_attach_defaults(GTK_TABLE(table), opt.debugValue, 1, 2, 1, 2); + gtk_widget_show(opt.debugValue); - gtk_box_pack_start(GTK_BOX(vbox), opt.verboseType, TRUE, FALSE, 0); - gtk_widget_show_all (frame); - } + gtk_widget_show(table); + gtk_widget_show(frame); frame = gtk_frame_new("Source"); @@ -1455,7 +1464,6 @@ GtkAdjustment *adjust; gtk_combo_box_set_active(GTK_COMBO_BOX (opt.outputFormatType), opt.outputFormatValue); /* Fifth Notebook - Options */ gtk_combo_box_set_active(GTK_COMBO_BOX (opt.resolveType), opt.resolveValue); - gtk_combo_box_set_active(GTK_COMBO_BOX (opt.verboseType), opt.verboseValue); display_nmap_command(); --- x/nmapfe/nmapfe.h 2006-08-24 20:47:59.000000000 -0500 +++ y/nmapfe/nmapfe.h 2006-09-25 19:51:33.000000000 -0500 @@ -198,17 +198,6 @@ enum { NO_PROTPORT }; -/* verbosity options */ -enum { - QUIET_VERBOSE, - V1_VERBOSE, - V2_VERBOSE, - D1_VERBOSE, - D2_VERBOSE, - NO_VERBOSE -}; - - /* output format options */ enum { NORMAL_OUTPUT, @@ -292,9 +281,11 @@ struct NmapFEoptions { /* DNS options */ GtkWidget *resolveType; guint resolveValue; - /* verbosity options */ - GtkWidget *verboseType; - guint verboseValue; + /* verbosity/debugging options */ + GtkWidget *verbose; + GtkWidget *verboseValue; + GtkWidget *debug; + GtkWidget *debugValue; /* source options */ GtkWidget *useSourceDevice; GtkWidget *SourceDevice; --- x/nmapfe/nmapfe_sig.c 2006-08-24 20:47:59.000000000 -0500 +++ y/nmapfe/nmapfe_sig.c 2006-09-25 19:51:30.000000000 -0500 @@ -577,6 +577,28 @@ static int command_size = 0; else if (opt.resolveValue == NEVER_RESOLVE) strcat(command, "-n "); + if (GTK_TOGGLE_BUTTON(opt.verbose)->active) { + int val = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(opt.verboseValue)); + + if (val == 1) + strcat(command, "-v "); + else if (val == 2) + strcat(command, "-vv "); + } + + if (GTK_TOGGLE_BUTTON(opt.debug)->active) { + int val = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(opt.debugValue)); + + if (val > 0) { + strcat(command, "-d"); + + if (val > 1) + sprintf(command+strlen(command), "%d", val); + + strcat(command, " "); + } + } + if (GTK_WIDGET_SENSITIVE(opt.useDecoy) && GTK_TOGGLE_BUTTON(opt.useDecoy)->active) { const char *val = gtk_entry_get_text(GTK_ENTRY(opt.Decoy)); @@ -667,15 +689,6 @@ static int command_size = 0; } } - if (opt.verboseValue == V1_VERBOSE) - strcat(command, "-v "); - else if (opt.verboseValue == V2_VERBOSE) - strcat(command, "-vv "); - else if (opt.verboseValue == D1_VERBOSE) - strcat(command, "-d "); - else if (opt.verboseValue == D2_VERBOSE) - strcat(command, "-d2 "); - strcat(command, gtk_entry_get_text(GTK_ENTRY(opt.targetHost))); return(command); @@ -863,14 +876,6 @@ void protportType_cb(GtkComboBox *w, gpo /* callback for factory generated menu items: set variable to action */ -void verboseType_cb(GtkComboBox *w, gpointer d) -{ - opt.verboseValue = gtk_combo_box_get_active(w); - display_nmap_command(); -} - - -/* callback for factory generated menu items: set variable to action */ void outputFormatType_cb(GtkComboBox *w, gpointer d) { opt.outputFormatValue = gtk_combo_box_get_active(w); --- x/nmapfe/nmapfe_sig.h 2006-08-24 20:47:59.000000000 -0500 +++ y/nmapfe/nmapfe_sig.h 2006-09-25 19:51:30.000000000 -0500 @@ -132,7 +132,6 @@ void mainMenu_fcb(int *variable, guint a void throttleType_cb (GtkComboBox *, gpointer); void resolveType_cb (GtkComboBox *, gpointer); void protportType_cb (GtkComboBox *, gpointer); -void verboseType_cb (GtkComboBox *, gpointer); void outputFormatType_cb (GtkComboBox *, gpointer); void pingButton_toggled_cb(GtkWidget *ping_button, void *ignored);
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- [NmapFE PATCH] Use spin button for verbosity/debugging levels Kris Katterjohn (Sep 24)
- Re: [NmapFE PATCH] Use spin button for verbosity/debugging levels Kris Katterjohn (Sep 24)
- Re: [NmapFE PATCH] Use spin button for verbosity/debugging levels Fyodor (Sep 25)
- Re: [NmapFE PATCH] Use spin button for verbosity/debugging levels Kris Katterjohn (Sep 25)