t_display *display;
t_sta *sta;
char help[32];
- char *blank;
display=(t_display *)&(info->display);
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;i<cnt;i++) {
+ sta=(t_sta *)info->sniffed_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;i<cnt;i++) {
+ else if(info->view==VIEW_SINGLE) {
+ list_reset(&(info->sniffed_sta));
+ for(i=0;i<info->c_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;
}
int get_user_interaction(t_info *info) {
char *string;
+ int hlp=0;
string=(char *)malloc(info->display.max_x*sizeof(char));
event_stop(&(info->event));
display_console(info,"quit!");
}
-
+ else if(info->input.content[0]=='n') {
+ hlp=list_count(&(info->sniffed_sta));
+ if(info->c_line<hlp-1) info->c_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]);
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);
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));