From: hackbard Date: Thu, 2 Jun 2005 21:18:48 +0000 (+0000) Subject: more beacon work X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dbed1c13fcd9df91f6bad2654f1634d5628f72d;p=my-code%2Fhdw-sniff.git more beacon work --- diff --git a/main.c b/main.c index 1ed6040..fda8c45 100644 --- a/main.c +++ b/main.c @@ -13,14 +13,17 @@ 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 754c5f8..e9fd872 100644 --- 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 b325728..647c176 100644 --- 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;ilog_fd,"%02x ",*((f3hdr->addr2)+i)); - dprintf(info->log_fd," essid: "); - for(i=0;issid_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;ilog_fd,"%02x ",*((f3hdr->addr2)+i)); + dprintf(info->log_fd," essid: (len=%x) ",beacon_fb->ssid_length); + for(i=0;issid_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 96eca6d..31aa94b 100644 --- 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 ... */