iv + snap support added -> logfile
authorhackbard <hackbard>
Tue, 19 Nov 2002 00:06:42 +0000 (00:06 +0000)
committerhackbard <hackbard>
Tue, 19 Nov 2002 00:06:42 +0000 (00:06 +0000)
hdw-sniff.c
wep.c [new file with mode: 0644]

index f17c826..32e1661 100644 (file)
@@ -52,7 +52,7 @@ int main(int argc, char *argv[]) {
                printf("no logfile specified, writing to stdout ...\n");
        } 
        else {
-               if((file_fd=open(argv[3],O_RDWR))!=0) {
+               if((file_fd=open(argv[3],O_RDWR | O_CREAT))!=0) {
                        printf("writing to logfile %s ...\n",argv[3]);
                }
                else {
@@ -124,7 +124,7 @@ void pcap_process(u_char *info,const struct pcap_pkthdr *pcap_header,
                        const u_char *package) {
        
        /* local variables */
-       char tmp_buf[20],crypted_snap[6];
+       char tmp_buf[20],crypted_snap[11];
        struct linux_wlan_ng_prism_hdr *prism_hdr;
        struct ieee802_11_hdr *w_hdr;
        struct snaphdr *snap_hdr;
@@ -233,12 +233,12 @@ void pcap_process(u_char *info,const struct pcap_pkthdr *pcap_header,
        } 
        else {
                snap_hdr=(struct snaphdr *)(package+p_o+w_o);
-               if(snap_hdr->snap[0]==0xaa &
-                  snap_hdr->snap[1]==0xaa &
-                  snap_hdr->snap[2]==0x03 &
-                  snap_hdr->snap[3]==0x00 &
-                  snap_hdr->snap[4]==0x00 &
-                  snap_hdr->snap[5]==0x00) {
+               if((snap_hdr->snap[0]==0xaa) &
+                  (snap_hdr->snap[1]==0xaa) &
+                  (snap_hdr->snap[2]==0x03) &
+                  (snap_hdr->snap[3]==0x00) &
+                  (snap_hdr->snap[4]==0x00) &
+                  (snap_hdr->snap[5]==0x00)) {
                        printf("- no encryption!\n");
                        if(snap_hdr->proto==ntohs(ETH_P_IP)) {
                                /* we want ip header to get parsed */
@@ -250,12 +250,25 @@ void pcap_process(u_char *info,const struct pcap_pkthdr *pcap_header,
                        printf("- crypted packet!\n");
                        /* print crypted snap - write into file */
                        printf("snap: (aa aa 03 00 00 00) ");
+                       for(i=0;i<4;i++) {
+                               printf("%x ",*(snap_hdr->snap-4+i));
+                               crypted_snap[i]=*(snap_hdr->snap-4+i);
+                               // if(file_fd>0) 
+                               //      write(file_fd,snap_hdr->snap+i-4,1);
+                       }
+                       printf("| ");
                        for(i=0;i<6;i++) {
                                printf("%x ",snap_hdr->snap[i]);
-                               if(file_fd>0) write(file_fd,snap_hdr->snap+i,1);
+                               crypted_snap[4+i]=snap_hdr->snap[i];
+                               // if(file_fd>0) 
+                               //      write(file_fd,snap_hdr->snap+i,1);
                        }
                        printf("\n");
-                       // write(file_fd,'\n',1);
+                       crypted_snap[10]='\n';
+                       if(file_fd>0) {
+                               printf("debug: saved to file\n");
+                               write(file_fd,crypted_snap,11);
+                       }
                        /* dont look at ipheader */
                        e_hdr->h_proto=htons(0);
                }
diff --git a/wep.c b/wep.c
new file mode 100644 (file)
index 0000000..e2f6799
--- /dev/null
+++ b/wep.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+#define MAX_C 20
+
+int main(int argc,char *argv[]) {
+       int file_fd,c,i;
+       char my_buf[MAX_C+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;
+}
+                       
+