]> hackdaworld.org Git - my-code/hdw-sniff.git/commitdiff
19c3 updates
authorhackbard <hackbard>
Mon, 30 Dec 2002 16:00:13 +0000 (16:00 +0000)
committerhackbard <hackbard>
Mon, 30 Dec 2002 16:00:13 +0000 (16:00 +0000)
Makefile
hdw-sniff.c
hdw_outlib.c [new file with mode: 0644]
hdw_outlib.h [new file with mode: 0644]
list.c
list.h

index fb4a778a878cdbde84c1658baa0fa622c507ddd9..7169c03d2e165e963b6b522c166ecff369867ccb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,7 @@ TARGETS = hdw-sniff
 all: $(TARGETS)
 
 hdw-sniff:
-       $(CC) $(CFLAGS) -Wall list.c hdw-sniff.c $(LDFLAGS) -o hdw-sniff 
+       $(CC) $(CFLAGS) -Wall list.c hdw_outlib.c hdw-sniff.c $(LDFLAGS) \
+                                                               -o hdw-sniff 
 #      $(CC) $(CFLAGS) -Wall hdw-sniff.c $(LDFLAGS) -o hdw-sniff
 
index d2e70776557d7ecd3b45cf68f2fcbcbb5eb68284..bd0b8edabee6a367ff58a8951fbd60ab5ab6d104 100644 (file)
@@ -172,7 +172,7 @@ void pcap_process(u_char *info,const struct pcap_pkthdr *pcap_header,
        /* ieee802.11 header */
 
        /* we need smaller w_hdr for non distributed frames */
-       if((w_hdr->frame_ctl & (1<<8)) & (w_hdr->frame_ctl & (1<<9))) {
+       if((w_hdr->frame_ctl & (1<<8)) && (w_hdr->frame_ctl & (1<<9))) {
                printf("=> distributed packet !!!!11\n");
        } else w_o-=(sizeof(struct snaphdr)-sizeof(unsigned short));
 
@@ -207,9 +207,11 @@ void pcap_process(u_char *info,const struct pcap_pkthdr *pcap_header,
                                                :strcpy(tmp_buf1,"ibssid = ");
                strncpy(tmp_buf2,beacon_hdr->ssid_s.ssid,
                                beacon_hdr->ssid_s.length);
+               
                tmp_buf2[beacon_hdr->ssid_s.length]='\0';
                strcpy(tmp_buf,"beacon");
-               add_ssid_2_list(tmp_buf2,my_info_struct->ssid_list);
+               add_ssid_2_list(tmp_buf2,beacon_hdr->capability,
+                               my_info_struct->ssid_list);
        }
        else if((w_hdr->frame_ctl & IEEE802_11_STYPE_ATIM)>0)
                strcpy(tmp_buf,"announcement traffic indication message");
@@ -224,7 +226,7 @@ void pcap_process(u_char *info,const struct pcap_pkthdr *pcap_header,
        else strcpy(tmp_buf,"control or data frame type");
 
        printf("=> %s\n",tmp_buf);
-       if(strlen(tmp_buf1)>0 & strlen(tmp_buf2)>0) printf("   %s%s\n",
+       if((strlen(tmp_buf1)>0) && (strlen(tmp_buf2)>0)) printf("   %s%s\n",
                                                        tmp_buf1,
                                                        tmp_buf2);
        printf("duration/id: 0x%x\n",w_hdr->duration_id);
@@ -264,7 +266,7 @@ void pcap_process(u_char *info,const struct pcap_pkthdr *pcap_header,
                        printf("- no encryption!\n");
                        if(snap_hdr->proto==ntohs(ETH_P_IP)) {
                                e_o=sizeof(struct snaphdr);
-                               parse_ip(snap_hdr+e_o);
+                               parse_ip((char *)(snap_hdr+e_o));
                        }
 
                }
diff --git a/hdw_outlib.c b/hdw_outlib.c
new file mode 100644 (file)
index 0000000..bc552cc
--- /dev/null
@@ -0,0 +1,52 @@
+/* call out ieee802.11 information
+ *
+ * author: hackbard
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+char sys_call[20];
+
+int tell_ssid(char *ssid) {
+       sprintf(sys_call,"flite \"new ssid. %s\"",ssid);
+       system(sys_call);
+       return 1;
+}
+
+int lcd_ssid(char *ssid,unsigned short cap) {
+       int lcd_fd;
+       char lcd_com[2];
+       char c_msg[7];
+       
+       if((lcd_fd=open("/dev/lcd",O_WRONLY|O_NDELAY)) <= 0) {
+               printf("failed to open lcd device");
+               exit -1;
+       }
+       
+       printf("debug: lcd_fd = %d\n",lcd_fd);
+       strcpy(sys_call,ssid);
+       lcd_com[0]=27;
+       lcd_com[1]='c';
+       write(lcd_fd,lcd_com,sizeof(lcd_com));
+       lcd_com[0]=27;
+       lcd_com[1]='h';
+       write(lcd_fd,lcd_com,sizeof(lcd_com));
+       if((1<<4 & cap)) sprintf(c_msg," wep");
+       else sprintf(c_msg," no_wep");
+       dprintf(lcd_fd,"ssid: %s\ncap: %x%s",sys_call,cap,c_msg);
+       // write(lcd_fd,sys_call,sizeof(sys_call));
+       close(lcd_fd);
+       return 1;
+}
+       
+       
+
diff --git a/hdw_outlib.h b/hdw_outlib.h
new file mode 100644 (file)
index 0000000..8fd1149
--- /dev/null
@@ -0,0 +1,10 @@
+/* outlib.h - prototypes
+ *
+ * author: hackbard
+ *
+ */
+
+/* prototypes */
+int tell_ssid(char *ssid);
+int lcd_ssid(char *ssidi,unsigned short cap);
+
diff --git a/list.c b/list.c
index 03fec7cab22078fd5ebc065468f53b9e06b2964d..3b4946ef3ce384d97a1ad4782e8835c0092a63a4 100644 (file)
--- a/list.c
+++ b/list.c
@@ -4,22 +4,22 @@
  *
  */
 
+#include "hdw_outlib.h"
 #include "list.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 
-char sys_call[20];
+// char sys_call[20];
 
-int add_ssid_2_list(char *ssid, struct list *my_list) {
+int add_ssid_2_list(char *ssid,unsigned short cap,struct list *my_list) {
 
        struct list *new_entry;
 
        if(my_list->next==NULL) {
-               // printf("debug: new ssid found!\n");
-               sprintf(sys_call,"flite \"new ssid. %s\"",ssid);
-               system(sys_call);
+               tell_ssid(ssid);
+               lcd_ssid(ssid,cap);
                new_entry=(struct list *)malloc(sizeof(struct list));
                my_list->next=new_entry;
                strcpy(my_list->ssid,ssid);
@@ -27,7 +27,7 @@ int add_ssid_2_list(char *ssid, struct list *my_list) {
        } else if(!strcmp(my_list->ssid,ssid)) {
        /* do nothing! */
        } else {
-               add_ssid_2_list(ssid,my_list->next);
+               add_ssid_2_list(ssid,cap,my_list->next);
        }
        return 1;
 }
diff --git a/list.h b/list.h
index b5549147e1f04f32134456ca1bd22b998edddbd8..075bc509ff9f2f28c574e962bd4113e51bdaa089 100644 (file)
--- a/list.h
+++ b/list.h
@@ -10,4 +10,4 @@ struct list {
 };
 
 /* prototypes */
-int add_ssid_2_list(char *ssid, struct list *my_list);
+int add_ssid_2_list(char *ssid,unsigned short cap, struct list *my_list);