From: hackbard Date: Wed, 8 Jun 2005 21:36:39 +0000 (+0000) Subject: info view mode introduced (still buggy) X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80bdf766cc69d2e685a2633b2aaa028448fbb8b3;p=my-code%2Fhdw-sniff.git info view mode introduced (still buggy) --- diff --git a/main.c b/main.c index 8a6a4c2..dee4596 100644 --- a/main.c +++ b/main.c @@ -17,7 +17,6 @@ int display_console(t_info *info,char *string) { t_display *display; t_sta *sta; char help[32]; - char *blank; display=(t_display *)&(info->display); @@ -26,74 +25,95 @@ int display_console(t_info *info,char *string) { size=strlen(string); - count=list_count(&(info->sniffed_sta)); - cnt=((count>y-5)?y-5:count); - - display_line(display,0,0,x,0,'-'); - display_string(display,GUI_OFFSET_STA,1,"sta/ap",6); - display_string(display,GUI_OFFSET_SSID,1,"| ssid",6); - display_string(display,GUI_OFFSET_AP,1,"| ap",4); - display_string(display,GUI_OFFSET_WEP,1,"| wep",5); - display_string(display,GUI_OFFSET_MGMT,1,"| mgmt",6); - display_string(display,GUI_OFFSET_CTRL,1,"| ctrl",6); - display_string(display,GUI_OFFSET_DATA,1,"| data",6); - display_string(display,GUI_OFFSET_ACTIVE,1,"| act",5); - display_line(display,0,2,x,2,'-'); - - list_reset(&(info->sniffed_sta)); + if(info->view==VIEW_ALL) { + count=list_count(&(info->sniffed_sta)); + cnt=((count>y-5)?y-5:count); + + display_line(display,0,0,x,0,'-'); + display_string(display,GUI_OFFSET_STA,1,"sta/ap",6); + display_string(display,GUI_OFFSET_SSID,1,"| ssid",6); + display_string(display,GUI_OFFSET_AP,1,"| ap",4); + display_string(display,GUI_OFFSET_WEP,1,"| wep",5); + display_string(display,GUI_OFFSET_MGMT,1,"| mgmt",6); + display_string(display,GUI_OFFSET_CTRL,1,"| ctrl",6); + display_string(display,GUI_OFFSET_DATA,1,"| data",6); + display_string(display,GUI_OFFSET_ACTIVE,1,"| act",5); + display_line(display,0,2,x,2,'-'); + + list_reset(&(info->sniffed_sta)); + + for(i=0;isniffed_sta.current->data; + snprintf(help,32,"%02x:%02x:%02x:%02x:%02x:%02x", + sta->addr[0],sta->addr[1],sta->addr[2], + sta->addr[3],sta->addr[4],sta->addr[5]); + display_string(display,GUI_OFFSET_STA,3+i,help,17); + s=strlen(sta->ssid); + s=((s>=16)?16:s); + help[0]='|'; help[1]=' '; + memcpy(&help[2],sta->ssid,s); + display_string(display,GUI_OFFSET_SSID,3+i,help,s+2); + snprintf(help,4,"| %c",sta->ap?'y':'n'); + display_string(display,GUI_OFFSET_AP,3+i,help,3); + snprintf(help,5,"| %c",sta->wep?'y':'n'); + display_string(display,GUI_OFFSET_WEP,3+i,help,4); +/* + snprintf(help,21,"| %04d | %04d | %04d", + sta->count_mgmt,sta->count_ctrl, + sta->count_data); +*/ + snprintf(help,21,"| %04d | n.a. | n.a.", + sta->count_mgmt); + display_string(display,GUI_OFFSET_MGMT,3+i,help,20); + snprintf(help,5,"| %c",sta->active); + display_string(display,GUI_OFFSET_ACTIVE,3+i,help,4); + list_next(&(info->sniffed_sta)); + } + } - for(i=0;iview==VIEW_SINGLE) { + list_reset(&(info->sniffed_sta)); + for(i=0;ic_line;i++) list_next(&(info->sniffed_sta)); sta=(t_sta *)info->sniffed_sta.current->data; - snprintf(help,32,"%02x:%02x:%02x:%02x:%02x:%02x", + display_line(display,0,0,x,0,'-'); + snprintf(help,22,"sta %02x:%02x:%02x:%02x:%02x:%02x", sta->addr[0],sta->addr[1],sta->addr[2], sta->addr[3],sta->addr[4],sta->addr[5]); - display_string(display,GUI_OFFSET_STA,3+i,help,17); + display_string(display,1,1,help,21); + display_line(display,0,2,x,2,'-'); + display_string(display,1,3,info->clean_line,x); + display_string(display,1,3,"ssid: ",6); s=strlen(sta->ssid); - s=((s>=16)?16:s); - help[0]='|'; help[1]=' '; - memcpy(&help[2],sta->ssid,s); - display_string(display,GUI_OFFSET_SSID,3+i,help,s+2); - snprintf(help,4,"| %c",sta->ap?'y':'n'); - display_string(display,GUI_OFFSET_AP,3+i,help,3); - snprintf(help,5,"| %c",sta->wep?'y':'n'); - display_string(display,GUI_OFFSET_WEP,3+i,help,4); -/* - snprintf(help,21,"| %04d | %04d | %04d", - sta->count_mgmt,sta->count_ctrl, - sta->count_data); -*/ - snprintf(help,21,"| %04d | n.a. | n.a.", - sta->count_mgmt); - display_string(display,GUI_OFFSET_MGMT,3+i,help,20); - snprintf(help,5,"| %c",sta->active); - display_string(display,GUI_OFFSET_ACTIVE,3+i,help,4); - list_next(&(info->sniffed_sta)); + memcpy(help,sta->ssid,s); + display_string(display,7,3,help,s); + display_string(display,1,5,"more specific info soon ...",27); } /* footer */ display_line(display,0,y-3,x,y-3,'-'); snprintf(help,14,"total: %06d",info->count); - display_string(display,3,y-2,help,13); - snprintf(help,19,"management: %06d",info->count_m); - display_string(display,18,y-2,help,18); - snprintf(help,16,"control: %06d",info->count_c); - display_string(display,38,y-2,help,15); + display_string(display,1,y-2,help,13); + snprintf(help,13,"mgmt: %06d",info->count_m); + display_string(display,15,y-2,help,12); + snprintf(help,12,"ctrl: %06d",info->count_c); + display_string(display,28,y-2,help,11); snprintf(help,13,"data: %06d",info->count_d); - display_string(display,55,y-2,help,12); + display_string(display,40,y-2,help,12); display_line(display,0,y-1,x,y-1,'-'); if(size!=0) { - blank=(char *)malloc(display->max_x); - memset(blank,0x20,display->max_x); - display_string(display,0,y,blank,x); + display_string(display,0,y,info->clean_line,x); display_string(display,1,y,string,size); - free(blank); } display_draw(display); + if(info->view==VIEW_ALL) + display_set_cursor(display,0,3+info->c_line); + + return 23; } @@ -105,6 +125,7 @@ int noop(t_input *input,void *ptr) { int get_user_interaction(t_info *info) { char *string; + int hlp=0; string=(char *)malloc(info->display.max_x*sizeof(char)); @@ -136,7 +157,18 @@ int get_user_interaction(t_info *info) { event_stop(&(info->event)); display_console(info,"quit!"); } - + else if(info->input.content[0]=='n') { + hlp=list_count(&(info->sniffed_sta)); + if(info->c_linec_line++; + } + else if(info->input.content[0]=='p') { + if(info->c_line>0) info->c_line--; + } + else if(info->input.content[0]==0x0d) { + display_clear_screen(&(info->display)); + if(info->view==VIEW_ALL) info->view=VIEW_SINGLE; + else info->view=VIEW_ALL; + } else { snprintf(string,info->display.max_x,"unknown event (%x)", info->input.content[0]); @@ -260,7 +292,7 @@ int main(int argc, char **argv) { puts("set monitoring mode ..."); system(sys_call); } - sprintf(sys_call,"/sbin/ifconfig %s up",info.device); + sprintf(sys_call,"ifconfig %s up",info.device); puts("setting up device ..."); system(sys_call); @@ -302,29 +334,25 @@ int main(int argc, char **argv) { puts(""); return -23; } + info.clean_line=(char *)malloc(info.display.max_x); + memset(info.clean_line,0x20,info.display.max_x); + info.view=VIEW_ALL; + + display_console(&info, + "Welcome to hdw-sniff, Copyright (C) 2004/05 hackbard"); + sleep(2); input_init(&(info.input),info.log_fd); - //input.mode=CONTENT_BUFFER; input_ios_init(&info.input); + list_init(&(info.sniffed_sta),info.log_fd); + event_init(&(info.event),info.log_fd); event_set_timeout(&(info.event),HOP_SEC,HOP_USEC); event_math(0,&(info.event),READ,ADD); event_math(pcap_fd,&(info.event),READ,ADD); - list_init(&(info.sniffed_sta),info.log_fd); - - display_console(&info, - " Welcome to hdw-sniff ... :-D"); - - sleep(2); - - display_console(&info, - " Copyright (C) 2004/05 hackbard@hackdaworld.org (press any button)"); - - getchar(); - event_start(&(info.event),&info,react_on_event,hop_channel); list_shutdown(&(info.sniffed_sta)); diff --git a/main.h b/main.h index 1628c91..6d655fc 100644 --- a/main.h +++ b/main.h @@ -63,10 +63,16 @@ #define MAX_BYTE_WEP 13 /* maximal 104 bit key */ +#define VIEW_ALL 0x00 +#define VIEW_SINGLE 0x01 + /* type definitions */ typedef struct s_info { t_event event; t_display display; + char *clean_line; + int c_line,c_page; + unsigned char view; t_input input; int count; /* count packages */ int count_m;