void clean_exit(int errcode) { DEBUG_MSG("clean_exit: %d", errcode); INSTANT_USER_MSG("\nTerminating %s...\n", GBL_PROGRAM); #ifdef HAVE_EC_LUA /* Cleanup lua */ ec_lua_fini(); #endif /* flush the exit message */ ui_msg_flush(MSG_ALL); /* stop the mitm attack */ mitm_stop(); /* terminate the sniffing engine */ EXECUTE(GBL_SNIFF->cleanup); /* kill all the running threads but the current */ ec_thread_kill_all(); /* close the UI */ ui_cleanup(); /* call all the ATEXIT functions */ exit(errcode); }
static int finger_submit_init(void *dummy) { char finger[FINGER_LEN + 1]; char os[OS_LEN + 1]; /* don't display messages while operating */ GBL_OPTIONS->quiet = 1; memset(finger, 0, sizeof(finger)); memset(os, 0, sizeof(finger)); /* get the user input */ ui_input("Fingerprint ('quit' to exit) : ", finger, sizeof(finger), NULL); /* exit on user request */ if (!strcasecmp(finger, "quit") || !strcmp(finger, "")) return PLUGIN_FINISHED; ui_input("Operating System ('quit' to exit) : ", os, sizeof(os), NULL); /* exit on user request */ if (!strcasecmp(os, "quit") || !strcmp(os, "")) return PLUGIN_FINISHED; USER_MSG("\n"); /* send the fingerprint */ fingerprint_submit(finger, os); /* flush all the messages */ ui_msg_flush(MSG_ALL); return PLUGIN_FINISHED; }
void daemon_interface(void) { DEBUG_MSG("daemon_interface"); /* check if the plugin exists */ if (GBL_OPTIONS->plugin && search_plugin(GBL_OPTIONS->plugin) != ESUCCESS) FATAL_ERROR("%s plugin can not be found !", GBL_OPTIONS->plugin); /* build the list of active hosts */ build_hosts_list(); /* start the mitm attack */ mitm_start(); /* initialize the sniffing method */ EXECUTE(GBL_SNIFF->start); /* if we have to activate a plugin */ if (GBL_OPTIONS->plugin && plugin_init(GBL_OPTIONS->plugin) != PLUGIN_RUNNING) /* end the interface */ return; /* discard the messages */ LOOP { CANCELLATION_POINT(); sleep(1); ui_msg_flush(MSG_ALL); } /* NOT REACHED */ }
/* flush pending messages */ gboolean gtkui_flush_msg(gpointer data) { /* variable not used */ (void) data; ui_msg_flush(MSG_ALL); return(TRUE); }
int main(int argc, char *argv[]) { /* * Alloc the global structures * We can access these structs via the macro in ec_globals.h */ globals_alloc(); GBL_PROGRAM = strdup(EC_PROGRAM); GBL_VERSION = strdup(EC_VERSION); SAFE_CALLOC(GBL_DEBUG_FILE, strlen(EC_PROGRAM) + strlen("-") + strlen(EC_VERSION) + strlen("_debug.log") + 1, sizeof(char)); sprintf(GBL_DEBUG_FILE, "%s-%s_debug.log", GBL_PROGRAM, EC_VERSION); DEBUG_INIT(); DEBUG_MSG("main -- here we go !!"); /* initialize the filter mutex */ filter_init_mutex(); /* register the main thread as "init" */ ec_thread_register(EC_PTHREAD_SELF, "init", "initialization phase"); /* activate the signal handler */ signal_handler(); /* ettercap copyright */ fprintf(stdout, "\n" EC_COLOR_BOLD "%s %s" EC_COLOR_END " copyright %s %s\n\n", GBL_PROGRAM, GBL_VERSION, EC_COPYRIGHT, EC_AUTHORS); /* getopt related parsing... */ parse_options(argc, argv); /* check the date */ time_check(); /* load the configuration file */ load_conf(); /* * get the list of available interfaces * * this function will not return if the -I option was * specified on command line. it will instead print the * list and exit */ capture_getifs(); /* initialize the user interface */ ui_init(); /* initialize the network subsystem */ network_init(); /* * always disable the kernel ip forwarding (except when reading from file). * the forwarding will be done by ettercap. */ if(!GBL_OPTIONS->read && !GBL_OPTIONS->unoffensive && !GBL_OPTIONS->only_mitm) { disable_ip_forward(); #ifdef OS_LINUX if (!GBL_OPTIONS->read) disable_interface_offload(); #endif /* binds ports and set redirect for ssl wrapper */ if(GBL_SNIFF->type == SM_UNIFIED && GBL_OPTIONS->ssl_mitm) ssl_wrap_init(); } /* * drop root privileges * we have already opened the sockets with high privileges * we don't need anymore root privs. */ drop_privs(); /***** !! NO PRIVS AFTER THIS POINT !! *****/ /* load all the plugins */ plugin_load_all(); /* print how many dissectors were loaded */ conf_dissectors(); /* load the mac-fingerprints */ manuf_init(); /* load the tcp-fingerprints */ fingerprint_init(); /* load the services names */ services_init(); /* load http known fileds for user/pass */ http_fields_init(); #ifdef HAVE_EC_LUA /* Initialize lua */ ec_lua_init(); #endif /* set the encoding for the UTF-8 visualization */ set_utf8_encoding((u_char*)GBL_CONF->utf8_encoding); /* print all the buffered messages */ if (GBL_UI->type == UI_TEXT) USER_MSG("\n"); ui_msg_flush(MSG_ALL); /**** INITIALIZATION PHASE TERMINATED ****/ /* * we are interested only in the mitm attack i * if entered, this function will not return... */ if (GBL_OPTIONS->only_mitm) only_mitm(); /* create the dispatcher thread */ ec_thread_new("top_half", "dispatching module", &top_half, NULL); /* this thread becomes the UI then displays it */ ec_thread_register(EC_PTHREAD_SELF, GBL_PROGRAM, "the user interface"); ui_start(); /******************************************** * reached only when the UI is shutted down ********************************************/ /* Call all the proper stop methods to ensure * that no matter what UI was selected, everything is * turned off gracefully */ clean_exit(0); return 0; //Never reaches here }
/* * this function is called on idle loop in wdg */ void curses_flush_msg(void) { ui_msg_flush(MSG_ALL); }
/* flush pending messages */ gboolean gtkui_flush_msg(gpointer data) { ui_msg_flush(MSG_ALL); return(TRUE); }