diff --git a/nmapfe/nmapfe.c b/nmapfe/nmapfe.c index 95b951ce8..78e980427 100644 --- a/nmapfe/nmapfe.c +++ b/nmapfe/nmapfe.c @@ -428,7 +428,6 @@ GtkAdjustment *adjust; /* initialize our options */ opt.viewValue = 1; opt.appendLog = FALSE; - opt.uid = 0; opt.scanValue = SYN_SCAN; opt.throttleValue = NORMAL_THROTTLE; opt.resolveValue = DEFAULT_RESOLVE; @@ -437,12 +436,12 @@ GtkAdjustment *adjust; opt.outputFormatValue = NORMAL_OUTPUT; #ifdef WIN32 - opt.uid = 0; + opt.isr00t = 1; /* for nmap version */ #include "nmap_winconfig.h" #define VERSION NMAP_VERSION #else - opt.uid = getuid(); + opt.isr00t = !geteuid(); #endif /* main (toplevel) window */ @@ -552,11 +551,11 @@ GtkAdjustment *adjust; GtkCellRenderer *renderer; GtkTreeModel *model; model = create_dropdown_store (scanentries, - (opt.uid == 0) ? TRUE : FALSE); + opt.isr00t ? TRUE : FALSE); opt.scanType = gtk_combo_box_new_with_model (model); g_object_unref (model); - opt.scanValue = (opt.uid == 0) ? SYN_SCAN : CONNECT_SCAN; + opt.scanValue = opt.isr00t ? SYN_SCAN : CONNECT_SCAN; gtk_table_attach_defaults (GTK_TABLE(table), opt.scanType, 0, 4, 0, 1); gtk_widget_show (opt.scanType); @@ -658,7 +657,7 @@ GtkAdjustment *adjust; opt.OSInfo = gtk_check_button_new_with_label("OS Detection"); g_signal_connect(GTK_OBJECT(opt.OSInfo), "released", GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); - if (opt.uid == 0) + if (opt.isr00t) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opt.OSInfo), TRUE); else gtk_widget_set_sensitive(GTK_WIDGET(opt.OSInfo), FALSE); @@ -710,7 +709,7 @@ GtkAdjustment *adjust; g_signal_connect(GTK_OBJECT(opt.icmpechoPing), "released", GTK_SIGNAL_FUNC(pingButton_toggled_cb), opt.icmpechoPing); gtk_table_attach_defaults(GTK_TABLE(table), opt.icmpechoPing, 0, 1, 0, 1); - if (opt.uid == 0) + if (opt.isr00t) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opt.icmpechoPing), TRUE); else gtk_widget_set_sensitive(GTK_WIDGET(opt.icmpechoPing), FALSE); @@ -720,7 +719,7 @@ GtkAdjustment *adjust; opt.icmptimePing = gtk_check_button_new_with_label("ICMP Timestamp"); g_signal_connect(GTK_OBJECT(opt.icmptimePing), "released", GTK_SIGNAL_FUNC(pingButton_toggled_cb), opt.icmptimePing); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.icmptimePing), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.icmptimePing, 0, 1, 1, 2); gtk_widget_show(opt.icmptimePing); @@ -729,7 +728,7 @@ GtkAdjustment *adjust; opt.icmpmaskPing = gtk_check_button_new_with_label("ICMP Netmask"); g_signal_connect(GTK_OBJECT(opt.icmpmaskPing), "released", GTK_SIGNAL_FUNC(pingButton_toggled_cb), opt.icmpmaskPing); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.icmpmaskPing), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.icmpmaskPing, 0, 1, 2, 3); gtk_widget_show(opt.icmpmaskPing); @@ -758,13 +757,13 @@ GtkAdjustment *adjust; opt.synPing = gtk_check_button_new_with_label("TCP SYN Ping"); g_signal_connect(GTK_OBJECT(opt.synPing), "released", GTK_SIGNAL_FUNC(pingButton_toggled_cb), opt.synPing); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.synPing), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.synPing, 1, 2, 1, 2); gtk_widget_show(opt.synPing); opt.synPingLabel = gtk_label_new("Port(s):"); - if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.synPing)->active)) + if ((!opt.isr00t) || (! GTK_TOGGLE_BUTTON(opt.synPing)->active)) gtk_widget_set_sensitive(GTK_WIDGET(opt.synPingLabel), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.synPingLabel, 2, 3, 1, 2); gtk_widget_show(opt.synPingLabel); @@ -774,7 +773,7 @@ GtkAdjustment *adjust; /*gtk_object_set(GTK_OBJECT(opt.synPingPorts), "width", 100, NULL);*/ g_signal_connect(GTK_OBJECT(opt.synPingPorts), "changed", GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); - if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.synPing)->active)) + if ((!opt.isr00t) || (! GTK_TOGGLE_BUTTON(opt.synPing)->active)) gtk_widget_set_sensitive(GTK_WIDGET(opt.synPingPorts), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.synPingPorts, 3, 4, 1, 2); gtk_widget_show(opt.synPingPorts); @@ -783,13 +782,13 @@ GtkAdjustment *adjust; opt.udpPing = gtk_check_button_new_with_label("UDP Ping"); g_signal_connect(GTK_OBJECT(opt.udpPing), "released", GTK_SIGNAL_FUNC(pingButton_toggled_cb), opt.udpPing); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.udpPing), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.udpPing, 1, 2, 2, 3); gtk_widget_show(opt.udpPing); opt.udpPingLabel = gtk_label_new("Port(s):"); - if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.udpPing)->active)) + if ((!opt.isr00t) || (! GTK_TOGGLE_BUTTON(opt.udpPing)->active)) gtk_widget_set_sensitive(GTK_WIDGET(opt.udpPingLabel), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.udpPingLabel, 2, 3, 2, 3); gtk_widget_show(opt.udpPingLabel); @@ -799,7 +798,7 @@ GtkAdjustment *adjust; /*gtk_object_set(GTK_OBJECT(opt.udpPingPorts), "width", 100, NULL);*/ g_signal_connect(GTK_OBJECT(opt.udpPingPorts), "changed", GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); - if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.udpPing)->active)) + if ((!opt.isr00t) || (! GTK_TOGGLE_BUTTON(opt.udpPing)->active)) gtk_widget_set_sensitive(GTK_WIDGET(opt.udpPingPorts), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.udpPingPorts, 3, 4, 2, 3); gtk_widget_show(opt.udpPingPorts); @@ -846,7 +845,7 @@ GtkAdjustment *adjust; opt.ipv4Ttl = gtk_check_button_new_with_label("IPv4 TTL"); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.ipv4Ttl), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.ipv4Ttl, 0, 1, 2, 3); gtk_widget_show(opt.ipv4Ttl); @@ -859,14 +858,14 @@ GtkAdjustment *adjust; /* gtk_object_set(GTK_OBJECT(opt.ipv4TtlValue), "width", 55, NULL);*/ g_signal_connect(GTK_OBJECT(opt.ipv4TtlValue), "changed", GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); - if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.ipv4Ttl)->active)) + if ((!opt.isr00t) || (! GTK_TOGGLE_BUTTON(opt.ipv4Ttl)->active)) gtk_widget_set_sensitive(GTK_WIDGET(opt.ipv4TtlValue), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.ipv4TtlValue, 1, 2, 2, 3); gtk_widget_show(opt.ipv4TtlValue); opt.minPar = gtk_check_button_new_with_label("Min. Parallel"); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.minPar), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.minPar, 0, 1, 3, 4); gtk_widget_show(opt.minPar); @@ -879,14 +878,14 @@ GtkAdjustment *adjust; GTK_SIGNAL_FUNC(toggle_button_set_sensitive_cb), opt.minParSocks); g_signal_connect(GTK_OBJECT(opt.minParSocks), "changed", GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); - if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.minPar)->active)) + if ((!opt.isr00t) || (! GTK_TOGGLE_BUTTON(opt.minPar)->active)) gtk_widget_set_sensitive(GTK_WIDGET(opt.minParSocks), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.minParSocks, 1, 2, 3, 4); gtk_widget_show(opt.minParSocks); opt.maxPar = gtk_check_button_new_with_label("Max. Parallel"); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.maxPar), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.maxPar, 0, 1, 4, 5); gtk_widget_show(opt.maxPar); @@ -899,14 +898,14 @@ GtkAdjustment *adjust; GTK_SIGNAL_FUNC(toggle_button_set_sensitive_cb), opt.maxParSocks); g_signal_connect(GTK_OBJECT(opt.maxParSocks), "changed", GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); - if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.maxPar)->active)) + if ((!opt.isr00t) || (! GTK_TOGGLE_BUTTON(opt.maxPar)->active)) gtk_widget_set_sensitive(GTK_WIDGET(opt.maxParSocks), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.maxParSocks, 1, 2, 4, 5); gtk_widget_show(opt.maxParSocks); opt.startRtt = gtk_check_button_new_with_label("Initial RTT"); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.startRtt), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.startRtt, 2, 3, 0, 1); gtk_widget_show(opt.startRtt); @@ -919,20 +918,20 @@ GtkAdjustment *adjust; GTK_SIGNAL_FUNC(toggle_button_set_sensitive_cb), opt.startRttTime); g_signal_connect(GTK_OBJECT(opt.startRttTime), "changed", GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); - if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.startRtt)->active)) + if ((!opt.isr00t) || (! GTK_TOGGLE_BUTTON(opt.startRtt)->active)) gtk_widget_set_sensitive(GTK_WIDGET(opt.startRttTime), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.startRttTime, 3, 4, 0, 1); gtk_widget_show(opt.startRttTime); label = gtk_label_new("ms"); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), label, 4, 5, 0, 1); gtk_widget_show(label); opt.minRtt = gtk_check_button_new_with_label("Min. RTT"); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.minRtt), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.minRtt, 2, 3, 1, 2); gtk_widget_show(opt.minRtt); @@ -945,20 +944,20 @@ GtkAdjustment *adjust; GTK_SIGNAL_FUNC(toggle_button_set_sensitive_cb), opt.minRttTime); g_signal_connect(GTK_OBJECT(opt.minRttTime), "changed", GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); - if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.minRtt)->active)) + if ((!opt.isr00t) || (! GTK_TOGGLE_BUTTON(opt.minRtt)->active)) gtk_widget_set_sensitive(GTK_WIDGET(opt.minRttTime), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.minRttTime, 3, 4, 1, 2); gtk_widget_show(opt.minRttTime); label = gtk_label_new("ms"); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), label, 4, 5, 1, 2); gtk_widget_show(label); opt.maxRtt = gtk_check_button_new_with_label("Max. RTT"); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.maxRtt), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.maxRtt, 2, 3, 2, 3); gtk_widget_show(opt.maxRtt); @@ -971,20 +970,20 @@ GtkAdjustment *adjust; GTK_SIGNAL_FUNC(toggle_button_set_sensitive_cb), opt.maxRttTime); g_signal_connect(GTK_OBJECT(opt.maxRttTime), "changed", GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); - if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.maxRtt)->active)) + if ((!opt.isr00t) || (! GTK_TOGGLE_BUTTON(opt.maxRtt)->active)) gtk_widget_set_sensitive(GTK_WIDGET(opt.maxRttTime), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.maxRttTime, 3, 4, 2, 3); gtk_widget_show(opt.maxRttTime); label = gtk_label_new("ms"); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), label, 4, 5, 2, 3); gtk_widget_show(label); opt.hostTimeout = gtk_check_button_new_with_label("Host Timeout"); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.hostTimeout), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.hostTimeout, 2, 3, 3, 4); gtk_widget_show(opt.hostTimeout); @@ -997,20 +996,20 @@ GtkAdjustment *adjust; GTK_SIGNAL_FUNC(toggle_button_set_sensitive_cb), opt.hostTimeoutTime); g_signal_connect(GTK_OBJECT(opt.hostTimeoutTime), "changed", GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); - if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.hostTimeout)->active)) + if ((!opt.isr00t) || (! GTK_TOGGLE_BUTTON(opt.hostTimeout)->active)) gtk_widget_set_sensitive(GTK_WIDGET(opt.hostTimeoutTime), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.hostTimeoutTime, 3, 4, 3, 4); gtk_widget_show(opt.hostTimeoutTime); label = gtk_label_new("ms"); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), label, 4, 5, 3, 4); gtk_widget_show(label); opt.scanDelay = gtk_check_button_new_with_label("Scan Delay"); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.scanDelay), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.scanDelay, 2, 3, 4, 5); gtk_widget_show(opt.scanDelay); @@ -1023,13 +1022,13 @@ GtkAdjustment *adjust; GTK_SIGNAL_FUNC(toggle_button_set_sensitive_cb), opt.scanDelayTime); g_signal_connect(GTK_OBJECT(opt.scanDelayTime), "changed", GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); - if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.scanDelay)->active)) + if ((!opt.isr00t) || (! GTK_TOGGLE_BUTTON(opt.scanDelay)->active)) gtk_widget_set_sensitive(GTK_WIDGET(opt.scanDelayTime), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.scanDelayTime, 3, 4, 4, 5); gtk_widget_show(opt.scanDelayTime); label = gtk_label_new("ms"); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), label, 4, 5, 4, 5); gtk_widget_show(label); @@ -1249,7 +1248,7 @@ GtkAdjustment *adjust; opt.useSourceDevice = gtk_check_button_new_with_label("Device"); g_signal_connect(GTK_OBJECT(opt.useSourceDevice), "toggled", GTK_SIGNAL_FUNC(validate_option_change), NULL); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.useSourceDevice), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.useSourceDevice, 0, 1, 0, 1); gtk_widget_show(opt.useSourceDevice); @@ -1270,7 +1269,7 @@ GtkAdjustment *adjust; opt.useSourcePort = gtk_check_button_new_with_label("Port"); g_signal_connect(GTK_OBJECT(opt.useSourcePort), "released", GTK_SIGNAL_FUNC(validate_option_change), NULL); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.useSourcePort), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.useSourcePort, 0, 1, 1, 2); gtk_widget_show(opt.useSourcePort); @@ -1291,7 +1290,7 @@ GtkAdjustment *adjust; opt.useSourceIP = gtk_check_button_new_with_label("IP"); g_signal_connect(GTK_OBJECT(opt.useSourceIP), "released", GTK_SIGNAL_FUNC(validate_option_change), NULL); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.useSourceIP), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.useSourceIP, 0, 1, 2, 3); gtk_widget_show(opt.useSourceIP); @@ -1312,7 +1311,7 @@ GtkAdjustment *adjust; opt.useDecoy = gtk_check_button_new_with_label("Decoy"); g_signal_connect(GTK_OBJECT(opt.useDecoy), "released", GTK_SIGNAL_FUNC(validate_option_change), NULL); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.useDecoy), FALSE); gtk_table_attach_defaults(GTK_TABLE(table), opt.useDecoy, 0, 1, 3, 4); gtk_widget_show(opt.useDecoy); @@ -1344,7 +1343,7 @@ GtkAdjustment *adjust; opt.useFragments = gtk_check_button_new_with_label("Fragmentation"); g_signal_connect(GTK_OBJECT(opt.useFragments), "released", GTK_SIGNAL_FUNC(validate_option_change), NULL); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.useFragments), FALSE); gtk_box_pack_start(GTK_BOX(vbox), opt.useFragments, FALSE, TRUE, 0); gtk_widget_show(opt.useFragments); @@ -1353,7 +1352,7 @@ GtkAdjustment *adjust; opt.useIPv6 = gtk_check_button_new_with_label("IPv6"); g_signal_connect(GTK_OBJECT(opt.useIPv6), "released", GTK_SIGNAL_FUNC(validate_option_change), NULL); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.useIPv6), FALSE); gtk_box_pack_start(GTK_BOX(vbox), opt.useIPv6, FALSE, TRUE, 0); gtk_widget_show(opt.useIPv6); @@ -1362,11 +1361,17 @@ GtkAdjustment *adjust; opt.useOrderedPorts = gtk_check_button_new_with_label("Ordered Ports"); g_signal_connect(GTK_OBJECT(opt.useOrderedPorts), "released", GTK_SIGNAL_FUNC(validate_option_change), NULL); - if (opt.uid != 0) + if (!opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.useOrderedPorts), FALSE); gtk_box_pack_start(GTK_BOX(vbox), opt.useOrderedPorts, FALSE, TRUE, 0); gtk_widget_show(opt.useOrderedPorts); + opt.randomizeHosts = gtk_check_button_new_with_label("Randomize Host Order"); + g_signal_connect(GTK_OBJECT(opt.randomizeHosts), "released", + GTK_SIGNAL_FUNC(validate_option_change), NULL); + gtk_box_pack_start(GTK_BOX(vbox), opt.randomizeHosts, FALSE, TRUE, 0); + gtk_widget_show(opt.randomizeHosts); + gtk_widget_show(vbox); gtk_widget_show(frame); diff --git a/nmapfe/nmapfe.h b/nmapfe/nmapfe.h index 0e70bf601..ee710f29e 100644 --- a/nmapfe/nmapfe.h +++ b/nmapfe/nmapfe.h @@ -208,7 +208,6 @@ enum { NO_VERBOSE }; - /* output format options */ enum { NORMAL_OUTPUT, @@ -229,7 +228,7 @@ struct NmapFEoptions { GtkWidget *commandEntry; gboolean appendLog; guint viewValue; - guint uid; + gboolean isr00t; /* scan types */ GtkWidget *scanType; guint scanValue; @@ -308,6 +307,7 @@ struct NmapFEoptions { GtkWidget *useFragments; GtkWidget *useIPv6; GtkWidget *useOrderedPorts; + GtkWidget *randomizeHosts; }; GtkWidget* create_main_win (void); diff --git a/nmapfe/nmapfe_error.h b/nmapfe/nmapfe_error.h index 34f2c92a6..4bceadbfd 100644 --- a/nmapfe/nmapfe_error.h +++ b/nmapfe/nmapfe_error.h @@ -115,8 +115,13 @@ #include #endif -void fatal(char *fmt, ...); -void error(char *fmt, ...); -void pfatal(char *err, ...); +#ifndef __attribute__ +#define __attribute__(args) +#endif + +void fatal(char *fmt, ...) __attribute__ ((format (printf, 1, 2))); +void error(char *fmt, ...) __attribute__ ((format (printf, 1, 2))); +void pfatal(char *err, ...) __attribute__ ((format (printf, 1, 2))); + #endif /* NMAPFE_ERROR_H */ diff --git a/nmapfe/nmapfe_sig.c b/nmapfe/nmapfe_sig.c index 64225aa29..1eb1841f2 100644 --- a/nmapfe/nmapfe_sig.c +++ b/nmapfe/nmapfe_sig.c @@ -183,9 +183,9 @@ main (int argc, #ifndef WIN32 signal(SIGPIPE, SIG_IGN); - opt.uid = getuid(); + opt.isr00t = !geteuid(); #else - opt.uid = 0; /* With Windows (in general), every user is a Super User! */ + opt.isr00t = 1; /* With Windows (in general), every user is a Super User! */ #endif main_win = create_main_win(); @@ -193,7 +193,7 @@ main (int argc, gtk_text_buffer_get_end_iter (opt.buffer, &iter); gtk_text_buffer_insert_with_tags_by_name (opt.buffer, &iter, - (opt.uid == 0) + (opt.isr00t) ? "You are root - All options granted." : "You are *NOT* root - Some options aren't available.", -1, "normal", NULL); @@ -473,6 +473,10 @@ static int command_size = 0; GTK_TOGGLE_BUTTON(opt.useOrderedPorts)->active) strcat(command, "-r "); + if (GTK_WIDGET_SENSITIVE(opt.randomizeHosts) && + GTK_TOGGLE_BUTTON(opt.randomizeHosts)->active) + strcat(command, "--randomize-hosts "); + if (GTK_WIDGET_SENSITIVE(opt.useInputFile) && GTK_TOGGLE_BUTTON(opt.useInputFile)->active) { const char *val = gtk_entry_get_text(GTK_ENTRY(opt.inputFilename)); @@ -892,13 +896,10 @@ static int execute_unix(char *command) } +#ifdef WIN32 /* Parts cribbed from _Win32 System Programming Second Edition_ pp 304 */ static int execute_win(char *command) { -#ifndef WIN32 - fatal("The execute_win function should ONLY be called from Windows!"); - return -1; -#else /* For pipes[] array: 0 == READ; 1 == WRITE */ @@ -933,8 +934,9 @@ STARTUPINFO Nmap_Start; return Nmap_Proc.dwProcessId; -#endif + } +#endif /* WIN32 */ int execute(char *command) { @@ -986,7 +988,7 @@ void scanType_cb j = gtk_combo_box_get_active(w); - if (opt.uid == 0) { + if (opt.isr00t) { k = j; } else { for (k = 0; user[k].scantype; k++) { @@ -1028,7 +1030,7 @@ void scanType_cb if ((opt.scanValue == CONNECT_SCAN) || (opt.scanValue == BOUNCE_SCAN)) { gtk_widget_set_sensitive(GTK_WIDGET(opt.useDecoy), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(opt.Decoy), FALSE); - } else if (opt.uid == 0) { + } else if (opt.isr00t) { gtk_widget_set_sensitive(GTK_WIDGET(opt.useDecoy), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(opt.Decoy), TRUE); } @@ -1038,7 +1040,7 @@ void scanType_cb (opt.scanValue != SYN_SCAN) && (opt.scanValue != NULL_SCAN) && (opt.scanValue != XMAS_SCAN) && (opt.scanValue != WIN_SCAN)) gtk_widget_set_sensitive(GTK_WIDGET(opt.useFragments), FALSE); - else if (opt.uid == 0) + else if (opt.isr00t) gtk_widget_set_sensitive(GTK_WIDGET(opt.useFragments), TRUE); if ((opt.scanValue == BOUNCE_SCAN) || (opt.scanValue == IDLE_SCAN)) { @@ -1070,7 +1072,7 @@ gboolean status = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ping_button)); gtk_widget_set_sensitive(GTK_WIDGET(opt.tcpPing), !status); gtk_widget_set_sensitive(GTK_WIDGET(opt.tcpPingLabel), localstatus); gtk_widget_set_sensitive(GTK_WIDGET(opt.tcpPingPorts), localstatus); - if (opt.uid == 0) { + if (opt.isr00t) { gtk_widget_set_sensitive(GTK_WIDGET(opt.icmpechoPing), !status); gtk_widget_set_sensitive(GTK_WIDGET(opt.icmpmaskPing), !status); gtk_widget_set_sensitive(GTK_WIDGET(opt.icmptimePing), !status); @@ -1090,11 +1092,11 @@ gboolean status = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ping_button)); gtk_widget_set_sensitive(GTK_WIDGET(opt.tcpPingLabel), status); gtk_widget_set_sensitive(GTK_WIDGET(opt.tcpPingPorts), status); } - else if ((ping_button == opt.synPing) && (opt.uid == 0)) { + else if ((ping_button == opt.synPing) && (opt.isr00t)) { gtk_widget_set_sensitive(GTK_WIDGET(opt.synPingLabel), status); gtk_widget_set_sensitive(GTK_WIDGET(opt.synPingPorts), status); } - else if ((ping_button == opt.udpPing) && (opt.uid == 0)) { + else if ((ping_button == opt.udpPing) && (opt.isr00t)) { gtk_widget_set_sensitive(GTK_WIDGET(opt.udpPingLabel), status); gtk_widget_set_sensitive(GTK_WIDGET(opt.udpPingPorts), status); }