]> hackdaworld.org Git - my-code/hdw-sniff.git/commitdiff
small fixes in documentation + initial checkin of wep - crack tool master origin
authorhackbard <hackbard>
Tue, 23 Aug 2005 13:06:46 +0000 (13:06 +0000)
committerhackbard <hackbard>
Tue, 23 Aug 2005 13:06:46 +0000 (13:06 +0000)
README
wep.c
wep.h [new file with mode: 0644]

diff --git a/README b/README
index ab0d0c719671b89ff12557a42a75726c6ab8d29b..4f799a402704052ed7100be9b35d8040514d34a9 100644 (file)
--- a/README
+++ b/README
@@ -10,7 +10,8 @@ install
 - required:
 
        - my minimalistic apis (get it via cvs from hackdaworld.org)
-       - libpcap (freshmeat may help)
+       - ncurses, libpcap (freshmeat may help)
+       - flite
        - wlan card supporting monitor mode
 
 - build: (an example)
diff --git a/wep.c b/wep.c
index 886ac379bce6725643ba44add9f9911121dc161d..8686469f528235940fd9d2adf47a10fc8a011242 100644 (file)
--- a/wep.c
+++ b/wep.c
 /*
  *
- * wep.c - bruteforce wep key
+ * wep.c - wordlist/bruteforce wep key attack
  *
  */
 
+#include "wep.h"
+
 #include <stdio.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <fcntl.h>
 
-#define MAX_C 20
+#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));
 
-int main(int argc,char *argv[]) {
-       int file_fd,c,i;
-       char my_buf[MAX_C+1];
+  return 1;
 
-       file_fd=open(argv[1],O_RDONLY);
-       if(file_fd>0) 
-               c=read(file_fd,my_buf,MAX_C);
-       for(i=0;i<MAX_C;i++) printf("%x ",my_buf[i]);
-       return 0;
 }
                        
-       
diff --git a/wep.h b/wep.h
new file mode 100644 (file)
index 0000000..ef71dc8
--- /dev/null
+++ b/wep.h
@@ -0,0 +1,32 @@
+/* wep .h
+ *
+ * hackbard@hackdaworld.org
+ *
+ */
+
+#include "network.h"
+#include "list.h"
+#include "event.h"
+
+#define MAX_C_SF 64
+#define MAX_C_FLITE 32
+#define MAX_X_WL 64
+#define MAX_TEXT 128
+#define MAX_BUF 256
+
+#define PORT 1025
+
+typedef struct s_wep {
+  t_list bssid;
+  t_network net;
+  t_event event;
+  int port;
+  char savefile[MAX_C_SF];
+  int sf_fd;
+  unsigned char sf;
+  char flite[MAX_C_FLITE];
+  unsigned char f;
+  char wordlist[MAX_C_WL];
+} t_wep;
+
+