diff --git a/main.cc b/main.cc index aa764078d..a7e1fe09e 100644 --- a/main.cc +++ b/main.cc @@ -137,14 +137,9 @@ extern NmapOps o; /* option structure */ int main(int argc, char *argv[]) { /* The "real" main is nmap_main(). This function hijacks control at the beginning to do the following: - 1) Check if Nmap called under name listed in INTERACTIVE_NAMES or with - interactive. + 1) Check if Nmap was called with --interactive. 2) Start interactive mode or just call nmap_main */ - char *interactive_names[] = INTERACTIVE_NAMES; - int numinames = sizeof(interactive_names) / sizeof(char *); - int nameidx; - char *nmapcalledas; char command[2048]; int myargc, fakeargc; char **myargv = NULL, **fakeargv = NULL; @@ -197,13 +192,6 @@ int main(int argc, char *argv[]) { #endif #endif - /* First we figure out whether the name nmap is called as qualifies it - for interactive mode treatment */ - nmapcalledas = strrchr(argv[0], '/'); - if (!nmapcalledas) { - nmapcalledas = argv[0]; - } else nmapcalledas++; - if ((cptr = getenv("NMAP_ARGS"))) { if (snprintf(command, sizeof(command), "nmap %s", cptr) >= (int) sizeof(command)) { error("Warning: NMAP_ARGS variable is too long, truncated"); @@ -222,14 +210,6 @@ int main(int argc, char *argv[]) { return ret; } - for(nameidx = 0; nameidx < numinames; nameidx++) { - if (strcasecmp(nmapcalledas, interactive_names[nameidx]) == 0) { - printf("Entering Interactive Mode because argv[0] == %s\n", nmapcalledas); - interactivemode = 1; - break; - } - } - if (interactivemode == 0 && argc == 2 && strcmp("--interactive", argv[1]) == 0) { interactivemode = 1; @@ -333,6 +313,10 @@ int main(int argc, char *argv[]) { if ((pptr = getenv("PATH"))) { Strncpy(path, pptr, sizeof(path)); pptr = path; + /* Get the name Nmap was called as. */ + char *nmapcalledas = path_get_basename(argv[0]); + if (nmapcalledas == NULL) + pfatal("Could not get nmap executable basename"); while(pptr && *pptr) { endptr = strchr(pptr, ':'); if (endptr) { @@ -345,6 +329,7 @@ int main(int argc, char *argv[]) { if (endptr) pptr = endptr + 1; else pptr = NULL; } + free(nmapcalledas); } } } diff --git a/nmap.h b/nmap.h index 436ba0b97..f2d3f9f25 100644 --- a/nmap.h +++ b/nmap.h @@ -323,9 +323,6 @@ void *realloc(); #define MAX_RETRANSMISSIONS 10 /* 11 probes to port at maximum */ #endif -/* If nmap is called with one of the names below, it will start up in interactive mode -- alternatively, you can rename Nmap any of the following names to have it start up interactivey by default. */ -#define INTERACTIVE_NAMES { "BitchX", "Calendar", "X", "awk", "bash", "bash2", "calendar", "cat", "csh", "elm", "emacs", "ftp", "fvwm", "g++", "gcc", "gimp", "httpd", "irc", "man", "mutt", "nc", "ncftp", "netscape", "perl", "pine", "ping", "sleep", "slirp", "ssh", "sshd", "startx", "tcsh", "telnet", "telnetd", "tia", "top", "vi", "vim", "xdvi", "xemacs", "xterm", "xv" } - /* Number of hosts we pre-ping and then scan. We do a lot more if randomize_hosts is set. Every one you add to this leads to ~1K of extra always-resident memory in nmap */