printf("no logfile specified, writing to stdout ...\n");
}
else {
- if((file_fd=open(argv[3],O_RDWR))!=0) {
+ if((file_fd=open(argv[3],O_RDWR | O_CREAT))!=0) {
printf("writing to logfile %s ...\n",argv[3]);
}
else {
const u_char *package) {
/* local variables */
- char tmp_buf[20],crypted_snap[6];
+ char tmp_buf[20],crypted_snap[11];
struct linux_wlan_ng_prism_hdr *prism_hdr;
struct ieee802_11_hdr *w_hdr;
struct snaphdr *snap_hdr;
+ struct beacon_struct *beacon_hdr;
struct ethhdr *e_hdr;
struct iphdr *ip_hdr;
struct info_struct *my_info_struct;
prism_hdr->msglen);
printf("device: %s |\n",prism_hdr->devname);
/* ieee802.11 header */
+
+ /* we need smaller w_hdr for non distributed frames */
+ if((w_hdr->frame_ctl & (1<<8)) & (w_hdr->frame_ctl & (1<<9))) {
+ printf("=> distributed packet !!!!11\n");
+ } else w_o-=(sizeof(struct snaphdr)-sizeof(unsigned short));
+
printf("ieee802.11 header: (%d bytes)\n",w_o);
w_hdr=(struct ieee802_11_hdr *)(package+p_o);
strcpy(tmp_buf,"probe request");
else if((w_hdr->frame_ctl & IEEE802_11_STYPE_PROBE_RESP)>0)
strcpy(tmp_buf,"probe response");
- else if((w_hdr->frame_ctl & IEEE802_11_STYPE_BEACON)>0)
- strcpy(tmp_buf,"beacon");
+ else if((w_hdr->frame_ctl & IEEE802_11_STYPE_BEACON)==IEEE802_11_STYPE_BEACON) {
+ // beacon_hdr=(struct beacon_struct *)(package+p_o+w_o);
+ // printf("ssid: ");
+ // for(i=0;i<(((beacon_hdr->ssid)&0x2)>>
+ // strcpy(tmp_buf,"beacon");
+ }
else if((w_hdr->frame_ctl & IEEE802_11_STYPE_ATIM)>0)
strcpy(tmp_buf,"announcement traffic indication message");
else if((w_hdr->frame_ctl & IEEE802_11_STYPE_DISASSOC)>0)
"ok":"unknown");
}
- /* ieee802.3 */
- /* we need smaller w_hdr for non distributed frames */
- if((w_hdr->frame_ctl & (1<<8)) & (w_hdr->frame_ctl & (1<<9))) {
- printf("=> distributed packet !!!!11\n");
- } else w_o-=(sizeof(struct snaphdr)-sizeof(unsigned short));
-
/* ethernet */
if((strncmp(my_info_struct->dev,"eth",3)==0) |
((w_hdr->frame_ctl & IEEE802_11_FTYPE_DATA)>0)) {
}
else {
snap_hdr=(struct snaphdr *)(package+p_o+w_o);
- if(snap_hdr->snap[0]==0xaa &
- snap_hdr->snap[1]==0xaa &
- snap_hdr->snap[2]==0x03 &
- snap_hdr->snap[3]==0x00 &
- snap_hdr->snap[4]==0x00 &
- snap_hdr->snap[5]==0x00) {
+ if((snap_hdr->snap[0]==0xaa) &
+ (snap_hdr->snap[1]==0xaa) &
+ (snap_hdr->snap[2]==0x03) &
+ (snap_hdr->snap[3]==0x00) &
+ (snap_hdr->snap[4]==0x00) &
+ (snap_hdr->snap[5]==0x00)) {
printf("- no encryption!\n");
if(snap_hdr->proto==ntohs(ETH_P_IP)) {
/* we want ip header to get parsed */
else {
printf("- crypted packet!\n");
/* print crypted snap - write into file */
- printf("snap: (aa aa 03 00 00 00) ");
- for(i=0;i<6;i++) {
- printf("%x ",snap_hdr->snap[i]);
- if(file_fd>0) write(file_fd,snap_hdr->snap+i,1);
+ printf("snap: (iv + crypted aa aa 03 00 00 00) ");
+ for(i=0;i<10;i++) {
+ printf("%x ",*(snap_hdr->snap+i));
+ crypted_snap[i]=*(snap_hdr->snap+i);
+ // if(file_fd>0)
+ // write(file_fd,snap_hdr->snap+i-4,1);
}
printf("\n");
- // write(file_fd,'\n',1);
+ crypted_snap[10]='\n';
+ if(file_fd>0) {
+ printf("debug: saved to file\n");
+ write(file_fd,crypted_snap,11);
+ }
/* dont look at ipheader */
e_hdr->h_proto=htons(0);
}
struct iwreq my_iwreq;
- if (info->channel>=14) info->channel=1;
+ if (info->channel>=C_MAX) info->channel=1;
memset(&my_iwreq,0,sizeof(my_iwreq));
strcpy(my_iwreq.ifr_name,info->dev);