Ich hab beispielsweise das Programm
#include "nmap.h"
#include "osscan.h"
#include "scan_engine.h"
#include "idle_scan.h"
#include "timing.h"
/* global options */
extern struct ops o; /* option structure */
extern char **environ;
int main(int argc, char *argv[], char *envp[]) {
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;
char *cptr;
int ret;
int i;
char nmapargs[1024];
char fakeargs[1024];
char nmappath[MAXPATHLEN];
char *pptr;
char path[4096];
struct stat st;
char *endptr;
int interactivemode = 0;
int fd;
struct timeval tv;
/* You never know when "random" numbers will come in handy ... */
gettimeofday(&tv, NULL);
srand((tv.tv_sec ^ tv.tv_usec) ^ getpid());
/* initialize our options */
options_init();
/* Trap these sigs for cleanup */
#if HAVE_SIGNAL
signal(SIGINT, sigdie);
signal(SIGTERM, sigdie);
signal(SIGHUP, sigdie);
signal(SIGCHLD, reaper);
#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"))) {
snprintf(command, sizeof(command), "nmap %s", cptr);
myargc = arg_parse(command, &myargv);
if (myargc for help\n");
while(1) {
printf("nmap> ");
fflush(stdout);
if (fgets(command, sizeof(command), stdin) == NULL && feof(stdin)) {
fatal("EOF reached -- quitting");
}
myargc = arg_parse(command, &myargv);
if (myargc for help\n");
continue;
}
if (strcasecmp(myargv[0], "h") == 0 ||
strcasecmp(myargv[0], "help") == 0) {
printinteractiveusage();
continue;
} else if (strcasecmp(myargv[0], "x") == 0 ||
strcasecmp(myargv[0], "q") == 0 ||
strcasecmp(myargv[0], "e") == 0 ||
strcasecmp(myargv[0], ".") == 0 ||
strcasecmp(myargv[0], "exit") == 0 ||
strcasecmp(myargv[0], "quit") == 0) {
printf("Quitting by request.\n");
exit(0);
} else if (strcasecmp(myargv[0], "n") == 0 ||
strcasecmp(myargv[0], "nmap") == 0) {
options_init();
o.interactivemode = 1;
nmap_main(myargc, myargv);
} else if (*myargv[0] == '!') {
cptr = strchr(command, '!');
system(cptr + 1);
} else if (*myargv[0] == 'd') {
o.debugging++;
} else if (strcasecmp(myargv[0], "f") == 0) {
switch((ret = fork())) {
case 0: /* Child */
/* My job is as follows:
1) Go through arguments for the following 3 purposes:
A. Build env variable nmap execution will read args from
B. Find spoof and realpath variables
C. If realpath var was not set, find an Nmap to use
2) Exec the sucka!@#$!
*/
fakeargs[0] = nmappath[0] = '\0';
strcpy(nmapargs, "NMAP_ARGS=");
for(i=1; i myargc -1) {
fatal("Bad arguments to f!");
}
strncpy(fakeargs, myargv[i], sizeof(fakeargs));
} else if (strcasecmp(myargv[i], "--nmap_path") == 0) {
if (++i > myargc -1) {
fatal("Bad arguments to f!");
}
strncpy(nmappath, myargv[i], sizeof(nmappath));
} else {
if (strlen(nmapargs) + strlen(myargv[i]) + 1 for help\n", myargv[0]);
continue;
}
arg_parse_free(myargv);
}
return 0;
}
Welcher Teil ist denn von denen Grinch?