/* * ftelnetd - fake telnet daemon * * ftelnetd.c * Main file, nothing interesting here. Just parsing the *argv[] elements and * function calls. * * Tue Dec 12 22:47:31 CET 2006 * * by Levent Kayan * levent[at]corehack[dot]org * */ #include "ftelnetd.h" #include "banner.h" #include "ferror.h" #include "log.h" #include #include #include #include #include #include /* fake mode */ int mode; int main(int argc, char **argv) { /* group and user id -> default r00t*/ gid_t grp_id = 0; uid_t usr_id = 0; /* default logfile */ char *logfile = "ftelnetd.log"; int c = 0; int port = DEFPORT; if (argc < 2 ) { fprintf(stderr, "[!] -h for help and usage\n"); exit(EXIT_FAILURE); } while ((c = getopt(argc, argv, "hf:p:g:u:l:vd")) != -1 ) { switch (c) { case 'h': usage(argv[0]); break; case 'f': /* choose fake mode */ mode = atoi(optarg); /* TODO: switch */ if (mode < 0 || mode > 5) { fprintf(stderr, "[-] Wrong mode!\n"); exit(EXIT_FAILURE); } /* list all available fake modes */ if (mode == 5) { print_modes(); } break; case 'p': /*TODO: check numeric etc. */ port = atoi(optarg); if ( port < 1 || port > 65535 ) { ERR_GEN; } break; case 'g': grp_id = atoi(optarg); break; case 'u': usr_id = atoi(optarg); break; case 'l': logfile = NULL; logfile = optarg; break; case 'v': puts(VERSION); exit(EXIT_SUCCESS); break; case 'd': /* check chosen mode then allow to daemonise */ if (mode < 3 || mode > 0) { if (daemon_init() < 0) { ERR_GEN; } } break; default: exit(EXIT_FAILURE); } } /* check if a fake mode is chosen */ if (mode < 0) { fprintf(stderr, "[-] Plesae choose a fake mode first!\n"); exit(EXIT_FAILURE); } else { open_logfile(logfile); build_server(port, grp_id, usr_id); } return 0; } /* EOF */