#include "main.h"
-// void parse_package(unsigned char *ptr,const struct pcap_pkthdr *pcap_header,const unsigned char *package);
-
/* functions */
int display_console(t_info *info,char *string) {
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_string(display,GUI_OFFSET_SIGNAL,1,"| sq",4);
display_line(display,0,2,x,2,'-');
list_reset(&(info->sniffed_sta));
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);
+ snprintf(help,5,"| %02u",sta->sq);
+ display_string(display,GUI_OFFSET_SIGNAL,3+i,help,4);
list_next(&(info->sniffed_sta));
}
}
int usage(void) {
puts("usage: hdw-sniff <options>");
puts("\toptions:");
- puts("\t\t-m <mode> \tmonitor and/or wlanng");
+ puts("\t\t-m <mode> \tieee80211 or prism");
puts("\t\t-d <device> \twlan0,eth0");
puts("\t\t-l <logfile>");
puts("\t\t-k <key> \t(string)");
case 'h':
usage();
case 'm':
- if(!strncmp(argv[i+1],"monitor",7)) {
- info.mode|=MODE_MONITOR;
- puts("will go to monitor mode.");
+ if(!strncmp(argv[i+1],"ieee80211",9)) {
+ info.mode|=MODE_IEEE80211;
+ puts("expecting ieee802.11 header in package");
}
- else if(!strncmp(argv[i+1],"wlanng",6)) {
- info.mode|=MODE_WLANNG;
- puts("expecting wlanng header in package.");
+ else if(!strncmp(argv[i+1],"prism",5)) {
+ info.mode|=MODE_PRISM;
+ puts("expecting prism header in package.");
}
else {
printf("unknown mode: %s\n",argv[1]);
}
/* setting up device */
- if(info.mode&MODE_MONITOR) {
- sprintf(sys_call,"iwconfig %s mode monitor",info.device);
- puts("set monitoring mode ...");
- system(sys_call);
- }
+ if(info.mode&MODE_IEEE80211)
+ sprintf(sys_call,"iwpriv %s monitor 2",info.device);
+ else if(info.mode&MODE_PRISM)
+ sprintf(sys_call,"iwpriv %s monitor 3",info.device);
+
+ puts("set monitoring mode ...");
+ system(sys_call);
+
sprintf(sys_call,"ifconfig %s up",info.device);
puts("setting up device ...");
system(sys_call);
#define MAX_DEV_CHARS 6
#define MAX_SYSCALL_CHARS 128
-#define HDW_SNIFF_MAX_WIDTH 80
-#define HDW_SNIFF_MAX_HEIGHT 8
-
#define HOP_SEC 0
#define HOP_USEC 200000
#define GUI_OFFSET_CTRL 57
#define GUI_OFFSET_DATA 64
#define GUI_OFFSET_ACTIVE 71
+#define GUI_OFFSET_SIGNAL 77
+
+#define HDW_SNIFF_MAX_WIDTH (GUI_OFFSET_SIGNAL+5)
+#define HDW_SNIFF_MAX_HEIGHT 8
/* modes */
-#define MODE_MONITOR (1<<0)
-#define MODE_WLANNG (1<<1)
+#define MODE_IEEE80211 (1<<0)
+#define MODE_PRISM (1<<1)
#define MODE_QUIT (1<<2)
#define MODE_HEXOUT (1<<3)
#define MODE_ASCIIOUT (1<<4)
int count_m;
int count_c;
int count_d;
- unsigned char mode; /* monitoring/managed mode */
+ unsigned char mode; /* ieee802.11/prism mode */
char device[MAX_DEV_CHARS]; /* sniffed devie */
int log_fd; /* file descriptor for logfile */
int pcap_fd; /* fd for reading pcap events */
* different protocols should get to seperated files though ...
*/
+unsigned int int_s(unsigned int val) {
+
+ unsigned int swapped;
+
+ swapped=(val&0x000000ff)<<24;
+ swapped|=(val&0x0000ff00)<<8;
+ swapped|=(val&0x00ff0000)>>8;
+ swapped|=(val&0xff000000)>>24;
+
+ return swapped;
+}
+
int switch_active_state(char *state) {
switch(*state) {
return 23;
}
-void parse_package(unsigned char *ptr,const struct pcap_pkthdr *pcap_header,const unsigned char *package) {
+void parse_package(unsigned char *ptr,const struct pcap_pkthdr *pcap_header,const unsigned char *pkg) {
t_info *info;
int i;
t_sta new_sta;
t_sta *sta;
+ unsigned char *package=NULL;
//t_frame4_hdr *f4hdr;
t_frame3_hdr *f3hdr;
//t_frame2_hdr *f2hdr;
//t_frame1_hdr *f1hdr;
t_beacon_fb *beacon_fb;
+ t_prism_hdr *prismhdr=NULL;
int ret;
char string[MESSAGE_MAX];
char sc[MAX_SYSCALL_CHARS];
/* maybe there is offset to the actual ieee802.11 frame,
for example prism header ...
in that case, hack the source! */
+ if(info->mode&MODE_IEEE80211) {
+ package=(unsigned char *)pkg;
+ prismhdr=NULL;
+ }
+ else if(info->mode&MODE_PRISM) {
+ package=(unsigned char *)pkg+sizeof(t_prism_hdr);
+ prismhdr=(t_prism_hdr *)pkg;
+ }
/* management */
if(FCTL_TYPE(package[0])==FCTL_TYPE_MGMT) {
if(CAP_INFO_PRIVACY(beacon_fb->cap_info)) sta->wep=WEP;
sta->count_mgmt++;
switch_active_state(&(sta->active));
+ if(info->mode&MODE_IEEE80211) sta->sq=0;
+ else if(info->mode&MODE_PRISM)
+ sta->sq=(prismhdr->signal.data)-(prismhdr->noise.data);
strncpy(string,"last: beacon, source: ",MESSAGE_MAX);
for(i=0;i<ADDR_LEN;i++)
snprintf(&string[22+3*i],4,"%02x%c",sta->addr[i],