]> hackdaworld.org Git - my-code/hdw-sniff.git/commitdiff
more beacon work
authorhackbard <hackbard>
Thu, 2 Jun 2005 21:18:48 +0000 (21:18 +0000)
committerhackbard <hackbard>
Thu, 2 Jun 2005 21:18:48 +0000 (21:18 +0000)
main.c
main.h
parse.c
parse.h

diff --git a/main.c b/main.c
index 1ed6040162674d8327cabe510a73dc6d71d3a3b6..fda8c45b18a393bf96824712b812e005967001fe 100644 (file)
--- a/main.c
+++ b/main.c
 
 int display_console(t_info *info,char *string) {
 
-  int x,y;
+  int x,y,size;
   t_display *display;
+  char help[32];
 
   display=(t_display *)&(info->display);
 
   x=display->max_x-1;
   y=display->max_y-1;
 
+  size=strlen(string);
+
   display_line(display,0,0,2,0,'-');
   display_string(display,4,0,"sta",3);
   display_line(display,8,0,12,0,'-');
@@ -28,12 +31,31 @@ int display_console(t_info *info,char *string) {
   display_string(display,13,0,"bssid",5);
   display_line(display,19,0,23,0,'-');
 
-  display_string(display,24,0,"M",1);
-  display_line(display,26,0,x,0,'-');
+  display_string(display,25,0,"M",1);
+  display_line(display,27,0,x,0,'-');
 
   //display_line(display,0,0,0,y,'|');
   //display_line(display,x,0,x,y,'|');
 
+  /* footer */
+  display_line(display,0,y-3,x,y-3,'-');
+
+  memset(help,0,32);
+  snprintf(help,32,"total: %06d",info->count);
+  display_string(display,3,y-2,help,13);
+
+  memset(help,0,32);
+  snprintf(help,32,"management: %06d",info->count_m);
+  display_string(display,18,y-2,help,18);
+
+  memset(help,0,32);
+  snprintf(help,32,"control: %06d",info->count_c);
+  display_string(display,38,y-2,help,15);
+
+  memset(help,0,32);
+  snprintf(help,32,"data: %06d",info->count_d);
+  display_string(display,55,y-2,help,12);
+
   display_line(display,0,y-1,x,y-1,'-');
 
   display_draw(display);
@@ -204,7 +226,7 @@ int main(int argc, char **argv) {
   puts("set monitoring mode ...");
   system(sys_call);
  }
- sprintf(sys_call,"ifconfig %s up",info.device);
+ sprintf(sys_call,"/sbin/ifconfig %s up",info.device);
  puts("setting up device ...");
  system(sys_call);
 
diff --git a/main.h b/main.h
index 754c5f83e54d6f72df8d73d2b08932a86616405b..e9fd87224fc95e75e1211c0e3c1db8ec1e6f8176 100644 (file)
--- a/main.h
+++ b/main.h
@@ -56,6 +56,9 @@ typedef struct s_info {
   t_display display;
   t_input input;
   int count; /* count packages */
+  int count_m;
+  int count_c;
+  int count_d;
   unsigned char mode; /* monitoring/managed mode */
   char device[MAX_DEV_CHARS]; /* sniffed devie */
   int log_fd; /* file descriptor for logfile */
diff --git a/parse.c b/parse.c
index b325728ad47eb638ec7ae6bcd83283bcfab02f06..647c1761751c895a7f56ba0c5c9eaf36b8d7f722 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -44,21 +44,27 @@ void parse_package(unsigned char *ptr,const struct pcap_pkthdr *pcap_header,cons
      for example prism header ... */
 
   if(FCTL_TYPE(package[0])==FCTL_TYPE_MGMT) {
-    if(FCTL_STYPE(package[0])==FCTL_STYPE_BEACON)
+    info->count_m++;
+    if(FCTL_STYPE(package[0])==FCTL_STYPE_BEACON) {
       f3hdr=(t_frame3_hdr *)package;
-      beacon_fb=(t_beacon_fb *)package+sizeof(t_frame3_hdr);
-    dprintf(info->log_fd,"beacon: ");
-    for(i=0;i<ADDR_LEN;i++) dprintf(info->log_fd,"%02x ",*((f3hdr->addr2)+i));
-    dprintf(info->log_fd,"  essid: ");
-    for(i=0;i<beacon_fb->ssid_length;i++)
-      dprintf(info->log_fd,"%c ",(beacon_fb->ssid)+i);
-    dprintf(info->log_fd,"\n");
+      beacon_fb=(t_beacon_fb *)(package+sizeof(t_frame3_hdr));
+      // new_sta.
+      /* debug output */
+      dprintf(info->log_fd,"beacon: ");
+      for(i=0;i<ADDR_LEN;i++) dprintf(info->log_fd,"%02x ",*((f3hdr->addr2)+i));
+        dprintf(info->log_fd,"  essid: (len=%x) ",beacon_fb->ssid_length);
+      for(i=0;i<beacon_fb->ssid_length;i++)
+        dprintf(info->log_fd,"%c ",*(u8 *)(beacon_fb->ssid+i));
+      dprintf(info->log_fd,"\n");
+    }
   }
-
-  else {
-    dprintf(info->log_fd,"other: ");
-    for(i=0;i<16;i++) dprintf(info->log_fd,"%02x ",package[i]);
-    dprintf(info->log_fd,"\n");
+  else if(FCTL_TYPE(package[0])==FCTL_TYPE_CTRL) {
+    info->count_c++;
+  }
+  else if(FCTL_TYPE(package[0])==FCTL_TYPE_DATA) {
+    info->count_d++;
   }
 
+  display_console(info,"");
+
 }
diff --git a/parse.h b/parse.h
index 96eca6da486f8897deeaa7d459e3e47b7108dd19..31aa94ba09f792503a9456b4261dae583f4d2552 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -97,7 +97,7 @@ typedef struct s_beacon_fb {
   u16 cap_info;
   u8 ssid_element_id;
   u8 ssid_length;
-  u32 ssid;
+  u8 ssid[32];
   u8 srates_element_id;
   u8 srates_element_length;
   u8 rest; /* go on here ... */