⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gwepdecrypt.cpp

📁 About WepDecrypt: Wepdecrypt is a Wireless LAN Tool written in c which guesses WEP Keys based o
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		Win->output_buffer->append("\nYou must supply a Crack Mode");		return;	}		if (Win->mac_button->value()){		if (!Win->mac_input->size()){			Win->output_buffer->append("\nMac can't be empty");			return;		}		if (!strncmp(Win->mac_input->value(), "Mac Filter", 10)){			Win->output_buffer->append("\nYou must supply a Mac");			return;		}					//fprintf(stdout, "-b %s ", Win->mac_input->value());		sprintf(command[i], "-b%s", Win->mac_input->value());		i++;	}		if (Win->client_button->value()){		if (!Win->server_data_input->size()){			Win->output_buffer->append("\nServer data can't be empty");			return;		}		if (!strncmp(Win->server_data_input->value(), "Client Mode", 11)){			Win->output_buffer->append("\nYou must set server data");			return;		}		strncpy(server_data, Win->server_data_input->value(), 30);				// Check server data		for (j=0;j<strlen(server_data);j++){				if (server_data[j] == ':') break; 		}		if (j==strlen(server_data) || j==(strlen(server_data) - 1)){			Win->output_buffer->append("\nBad client connection data");			return ;		}				// Check server		//fprintf(stdout, "-c %s", Win->server_data_input->value());		sprintf(command[i], "-c%s", Win->server_data_input->value()); i++;		sprintf(command[i], "-l0"); i++;	}		if (Win->blocks_to_decrypt_button->value()){		if (!Win->client_button->value()){			Win->output_buffer->append("\nYou have to set the client data");			return;		}		if (!Win->blocks_to_decrypt_input->value()){			Win->output_buffer->append("\nYou have to set the number of blocks to get\n from the server");			return;		}		sprintf(command[i-1], "-l%i", Win->blocks_to_decrypt_input->value()-1);			}		if (Win->generator_mode_button->value()){		if (!Win->generator_mode_input->value()){			Win->output_buffer->append("\nYou have to set the generator mode");			return;		}						switch(Win->generator_mode_input->value()){			case 1:				sprintf(command[i], "-dall");				break;			case 2:				sprintf(command[i], "-dalpha");				break;			case 3:				sprintf(command[i], "-dalphanumeric");				break;			case 4:				sprintf(command[i], "-dnumeric");				break;			case 5:				sprintf(command[i], "-drandom");				break;			case 6:				sprintf(command[i], "-dprintable");				break;		}		i++;	}				if (Win->num_net_button->value()){		if (!Win->num_net_input->value()){			Win->output_buffer->append("\nYou must set a Number network");			return;		}		//fprintf(stdout, "-n %i ", Win->num_net_input->value());		sprintf(command[i], "-n%i", Win->num_net_input->value());		i++;	}		if (strncmp(Win->firstkey_input->value(), "First Key", 8) != 0){		if (!Win->firstkey_input->size()){			Win->output_buffer->append("\nFirst Key can't be empty");			return;		}		//fprintf(stdout, "-i %s ", Win->firstkey_input->value());		sprintf(command[i], "-i%s", Win->firstkey_input->value());		i++;	}		if (strncmp(Win->lastkey_input->value(), "Last Key", 7) != 0){		if (!Win->lastkey_input->size()){			Win->output_buffer->append("\nLast Key can't be empty");			return;		}		//fprintf(stdout, "-e %s ", Win->lastkey_input->value());		sprintf(command[i], "-e%s", Win->lastkey_input->value());		i++;	}		//fprintf(stdout, "\n");#ifndef __CYGWIN__	if ((test_file=open("/usr/bin/wepdecrypt", O_RDONLY)) == -1){		Win->output_buffer->append("\nWepdecrypt executable can't be found\nplease install it at /usr/bin/");		return;	}	else		close(test_file);#else	if ((test_file=open("wepdecrypt.exe", O_RDONLY)) == -1){		Win->output_buffer->append("\nWepdecrypt executable can't be found\nplease install it at the same directory\nas gwepdecrypt");		return;	}	else		close(test_file);#endif		command[i] = NULL;		Fl::add_fd(STDIN_FILENO, fd_ready, (void*)Win);	pipe(Win->pipefd);		Win->output_buffer->append("\nProcessing ...\n");	Win->child_pid = fork();		if (Win->child_pid == -1){ // Error		fprintf(stderr, "Error fork()\n");		exit(0);	}		if (!Win->child_pid){		dup2(Win->pipefd[1], STDOUT_FILENO);		close(Win->pipefd[0]);		close(Win->pipefd[1]);#ifndef __CYGWIN__		execv("/usr/bin/wepdecrypt", command);#else		execv("wepdecrypt.exe", command);#endif	}		if (Win->child_pid){		dup2(Win->pipefd[0], STDIN_FILENO);		fcntl(STDIN_FILENO, F_SETFL, O_SYNC| O_NONBLOCK);		close(Win->pipefd[0]);		close(Win->pipefd[1]);			}}void stop_cb(Fl_Widget * , void * v){	MainWindow * win = (MainWindow *) v;		if (!win->child_pid) return;		size = 0;	kill(win->child_pid, SIGINT);	win->child_pid=0;}#ifndef __CYGWIN__void about_cb(Fl_Widget *, void * ){	char ** argv;		if (show_about == 0) {		Fl_Window * about_window = new Fl_Window(205,95);		Fl_Multiline_Output * about_box = new Fl_Multiline_Output(10, 10, 185, 55, NULL);		Fl_Button * ok = new Fl_Button(85, 70, 40, 20, "OK");				show_about = 1;						about_box->value(" Gwepdecrypt version 0.3\n        Wepdecrypt's gui\n       by Fernando Tarin");				about_window->label("About");		about_window->end();	    				about_window->show(1, argv);				Fl::focus(ok);		ok->shortcut(FL_Enter);		ok->callback(close_about_window_cb, (void *) about_window);		Fl::run();	}}void close_about_window_cb(Fl_Widget * v , void * w){	Fl::delete_widget((Fl_Widget *) w);	show_about = 0;}#endifvoid version_cb(Fl_Widget *, void * v){	int test_file;	char version[25];		MainWindow * Win = (MainWindow *) v;		if (Win->child_pid) return;			Win->output_buffer->remove(0, Win->output_buffer->length());	Win->output_buffer->append("- WepDecrypt Gui -\n");		sprintf(version, "\nGwepdecrypt version %s", VERSION);	Win->output_buffer->append(version);	Win->output_buffer->append("\nWepdecrypt graphic user interface\n\n");	#ifndef __CYGWIN__	if ((test_file=open("/usr/bin/wepdecrypt", O_RDONLY)) == -1){		Win->output_buffer->append("\nWepdecrypt executable can't be found\nplease install it at /usr/bin/");		return;	}	else		close(test_file);#else	if ((test_file=open("wepdecrypt.exe", O_RDONLY)) == -1){		Win->output_buffer->append("\nWepdecrypt executable can't be found\nplease install it at the same directory\nas gwepdecrypt");		return;	}	else		close(test_file);#endif		Fl::add_fd(STDIN_FILENO, fd_ready, (void*)Win);		pipe(Win->pipefd);	Win->child_pid = fork();		if (Win->child_pid == -1){ // Error		fprintf(stderr, "Error fork()\n");		exit(0);	}		if (!Win->child_pid){		dup2(Win->pipefd[1], STDOUT_FILENO);		close(Win->pipefd[0]);		close(Win->pipefd[1]);#ifndef __CYGWIN__		execl("/usr/bin/wepdecrypt", "wepdecrypt", "-v", NULL);#else		execl("wepdecrypt", "wepdecrypt", "-v", NULL);#endif			}		if (Win->child_pid){		dup2(Win->pipefd[0], STDIN_FILENO);		fcntl(STDIN_FILENO, F_SETFL, O_SYNC| O_NONBLOCK);		close(Win->pipefd[0]);		close(Win->pipefd[1]);		Win->child_pid = 0;	}}void help_cb(Fl_Widget *, void * v){	MainWindow * Win = (MainWindow *) v;		if (Win->child_pid) return;			Win->output_buffer->remove(0, Win->output_buffer->length());	Win->output_buffer->append("- WepDecrypt Gui -\n");			Win->output_buffer->append("\nGwepdecrypt options:\n");	Win->output_buffer->append("--------------------------------------------------\n");	Win->output_buffer->append("1. Dump file (filename):  network dumpfile to read\n");	Win->output_buffer->append("2. Word file (filename):  wordlist to use as passwords\n");	Win->output_buffer->append("3. Mac Filter (mac_addres): Filters the mac address from the dump file\n");	Win->output_buffer->append("4. Mode: run wepdecrypt in diffente modes\n");	Win->output_buffer->append("5. Client Mode (server:port): Host and port where server is running\n");	Win->output_buffer->append("6. Number blocks: sets the number of blocks to get from the server\n");	Win->output_buffer->append("7. Generator Mode: sets the mode for the key generator\n");	Win->output_buffer->append("8. Number Network: network number to attack\n");	Win->output_buffer->append("9. First key: specifies the first key\n");	Win->output_buffer->append("10. Last key: specifies the final key\n");	Win->output_buffer->append("--------------------------------------------------");}void sigchld(int sign){		waitpid(-1,NULL,WNOHANG);}void set_log_options(LogFile *log, MainWindow *win){	char * home, config_file[75], message[100];	FILE * fp;	#ifndef __CYGWIN__	home = getenv("HOME");	sprintf(config_file, "%s/.wepdecrypt", home);#else	sprintf(config_file, "wepdecrypt.conf", home);#endif		if ((fp = fopen(config_file, "r")) == NULL){#ifndef __CYGWIN__		strncpy(log->directory, "/tmp/", 6);#else		strncpy(log->directory, ".\\", 3);#endif		if ((fp = fopen(config_file,"w+")) == NULL){			sprintf(message, "\nError in config file:\nCan't create config file");			win->output_buffer->append(message);			return;		}		fprintf(fp,"#Wepdecrypt configuration file\n");		fprintf(fp,"#Server listening port\nPort=3617\n\n#Blocksize can be set up to 1099511627775\nBlocksize=4294967296\n\n#Full path to server logfile\nLogfile=/var/tmp/wepdecrypt_s.log\n\n#Verbosity levels: 1 - LOW 2 - MEDIUM 3 - HIGH\nVerbosity=2\n\n"				   "#Full path to directory where gui generated logs will be saved\nGuidirlog=%s\n\n", log->directory);		fclose(fp);		return;	}		else{		if (!manage_config_file(0, NULL, NULL, NULL, NULL, log->directory)){			sprintf(message,"\nBad data in config file:\nPlease delete %s",config_file);			win->output_buffer->append(message);#ifndef __CYGWIN__			strncpy(log->directory, "/tmp/", 6);#else			strncpy(log->directory, ".\\", 3);#endif			return;		}				if ((fp = fopen(config_file, "a")) == NULL){			if (!strlen(log->directory)){#ifndef __CYGWIN__				strncpy(log->directory, "/tmp/", 6);#else				strncpy(log->directory, ".\\", 3);#endif			}			sprintf(message,"\nError in config file:\nCan't append data to config file");			win->output_buffer->append(message);			return;		}				if (!strlen(log->directory)){#ifndef __CYGWIN__			strncpy(log->directory, "/tmp/", 6);#else			strncpy(log->directory, ".\\", 3);#endif			fprintf(fp, "#Full path to directory where gui generated logs will be saved\nGuidirlog=%s\n\n", log->directory);		}				fclose(fp);		return;			}}void set_log_dir(Fl_Widget *, void * v){	int verbosity, port;	char * dir_name, * home, config_file[75];	char block_size[15], log_file[55];	FILE * fp;#ifndef __CYGWIN__	DIR * dir;#endif	LogFile * log = (LogFile *) v;			dir_name = fl_dir_chooser("Choose a Directory", NULL, 0);	if (dir_name != NULL){		strncpy(log->directory, dir_name, strlen(dir_name)+1);#ifndef __CYGWIN__		if ((dir=opendir(log->directory)) == NULL){			strncpy(log->directory, "/tmp/", 6);					}#endif		chdir(log->directory);#ifndef __CYGWIN__				home = getenv("HOME");		sprintf(config_file, "%s/.wepdecrypt", home);#else		sprintf(config_file, "wepdecrypt.conf");#endif				manage_config_file(0, &port, block_size, &verbosity, log_file, NULL);				fp = fopen(config_file,"w+");		fprintf(fp,"#Server listening port\nPort=%i\n\n#Blocksize can be set up to 1099511627775\nBlocksize=%s\n\n#Full path to server logfile\nLogfile=%s\n\n#Verbosity levels: 1 - LOW 2 - MEDIUM 3 - HIGH\nVerbosity=%i\n\n"				   "#Full path to directory where gui generated logs will be saved\nGuidirlog=%s\n\n", port, block_size, log_file, verbosity, log->directory);		fclose(fp);#ifndef __CYGWIN__		if (dir != NULL) closedir(dir);#endif			}}int manage_config_file(int mode, int * port, char * block_size, int * verbosity, char * log_file, char * guidirlog){	int i, j;	char * home, config_file[75], conf_setting[20], conf_value[75], line[95];	FILE * fp;	#ifndef __CYGWIN__	home = getenv("HOME");	sprintf(config_file, "%s/.wepdecrypt", home);#else	sprintf(config_file, "wepdecrypt.conf");#endif		fp = fopen(config_file, "r");		while(!feof(fp)){					i = 0; j = 0;		while (i < 94){			line[i] = fgetc(fp);			if (line[i] == '\n') break;			i++;		}		line[i] = '\0';					if (line[0] == '#' || line[0] == '\n' || line[0] <= '\0') continue;		i = 0;					while ((line[i] != '=') && (i < 19)){			conf_setting[i] = line[i];			i++;		}					conf_setting[i] = '\0'; i++; 					while ((line[i] != '\0') && (i < 95) && (j < 74)){							conf_value[j] = line[i];			j++; i++;		}		conf_value[j] = '\0';					if (strncmp(conf_setting,"Port",4) == 0) { if (port != NULL) (*port) = atoi(conf_value); }		else if (strncmp(conf_setting,"Blocksize",9) == 0) { if (block_size != NULL) strncpy(block_size, conf_value, strlen(conf_value)+1); }		else if (strncmp(conf_setting,"Verbosity",9) == 0) { if (verbosity != NULL) (*verbosity) = atoi(conf_value); }		else if (strncmp(conf_setting,"Logfile",7) == 0) { if (log_file != NULL) strncpy(log_file, conf_value, strlen(conf_value)+1); }		else if (strncmp(conf_setting,"Guidirlog",9) == 0) {if (guidirlog != NULL) strncpy(guidirlog, conf_value, strlen(conf_value)+1); }		else{			//Bad data in config file						fclose(fp);			return 0;		}	}		return 1;	fclose(fp);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -