+#include <openssl/rc4.h>
+
+#include "network.h"
+#include "list.h"
+#include "event.h"
+
+int usage(void) {
+ puts("usage:");
+ put("");
+ puts("-p <port>");
+ puts("-s <save file>");
+ puts("-f /path/to/flite");
+ puts("-w /path/to/wordlist");
+ return 1;
+}
+
+int main(int argc,char **argv) {
+
+ /* data */
+ t_wep wep;
+ int i;
+ time_t time;
+ char buf[MAX_BUF];
+ unsigned char text[MAX_TEXT];
+
+ /* default values */
+ memset(&wep,0,sizeof(t_wep));
+ wep.port=PORT;
+ strncpy(wep.flite,"/usr/bin/flite",MAX_C_FLITE);
+ strncpy(wep.savefile,"",MAX_C_SF);
+ strncpy(wep.wordlist,"",MAX_C_WL);
+
+ time(&time);
+
+ /* parse argv */
+ for(i=0;i<argc;i++) {
+ if(argv[i][0]=='-') {
+ switch(argv[i][1]) {
+ case 'p':
+ wep.port=atoi(argv[++i]);
+ break;
+ case 's':
+ strncpy(wep.savefile,argv[++i],MAX_C_SF);
+ wep.sf=1;
+ break;
+ case 'f':
+ strncpy(wep.flite,argv[++i],MAX_C_FLITE);
+ wep.f=1;
+ break;
+ case 'w':
+ strncpy(wep.wordlist,argv[++i],MAX_XWL);
+ break;
+ default:
+ usage();
+ return -1;
+ }
+ } else {
+ usage();
+ return -1;
+ }
+ }
+
+ if(!strcmp(wep.wordlist,"")) {
+ puts("you need to specify a wordlist!");
+ return -1;
+ }
+
+ text=ctime(&time);
+ printf("\n--- wep, started at: %s ---\n",text);
+
+ if(wep.sf) {
+ wep.sf_fd=open(wep.savefile,O_WRONLY|O_CREAT|O_APPEND|S_IRUSR|S_IWUSR);
+ if(wep.sf==-1) {
+ printf("[wep] failed to open %s as a save file\n",wep.savefile);
+ return -1;
+ }
+ dprintf(wep.sf_fd,"\n--- wep, started at: %s ---\n",text);
+ }
+
+ if(wep.f) {
+ snprintf(text,MAX_TEXT,"%s 'wep cracker started. good luck.'");
+ system(text);
+ }
+
+ /* network init */
+ network_init(&(wep.net),2);
+ network_set_listen_port(&net,wep.port);
+ if(network_listen(&net)!=N_SUCCESS) {
+ printf("unable to listen on port %d\n",wep.port);
+ return -1;
+ }
+
+ /* list init */
+ list_init(&(wep.bssid),2);
+
+ /* event init */
+ event_init(&(wep.event),2);
+ event_math(wep.net.l_fd,&(wep),READ,ADD);
+ event_start(&(wep.event),&wep,parse_incoming,brute_key);
+
+ event_shutdown(&(wep.event));
+ network_shutdown(&(wep.net));
+ list_shutdown(&(wep.bssid));