From: hackbard Date: Mon, 30 Dec 2002 16:00:13 +0000 (+0000) Subject: 19c3 updates X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=f495a11c9e880f1f55aa8e6c44c065228e55e5c5;p=my-code%2Fhdw-sniff.git 19c3 updates --- diff --git a/Makefile b/Makefile index fb4a778..7169c03 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ TARGETS = hdw-sniff all: $(TARGETS) hdw-sniff: - $(CC) $(CFLAGS) -Wall list.c hdw-sniff.c $(LDFLAGS) -o hdw-sniff + $(CC) $(CFLAGS) -Wall list.c hdw_outlib.c hdw-sniff.c $(LDFLAGS) \ + -o hdw-sniff # $(CC) $(CFLAGS) -Wall hdw-sniff.c $(LDFLAGS) -o hdw-sniff diff --git a/hdw-sniff.c b/hdw-sniff.c index d2e7077..bd0b8ed 100644 --- a/hdw-sniff.c +++ b/hdw-sniff.c @@ -172,7 +172,7 @@ void pcap_process(u_char *info,const struct pcap_pkthdr *pcap_header, /* 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))) { + 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)); @@ -207,9 +207,11 @@ void pcap_process(u_char *info,const struct pcap_pkthdr *pcap_header, :strcpy(tmp_buf1,"ibssid = "); strncpy(tmp_buf2,beacon_hdr->ssid_s.ssid, beacon_hdr->ssid_s.length); + tmp_buf2[beacon_hdr->ssid_s.length]='\0'; strcpy(tmp_buf,"beacon"); - add_ssid_2_list(tmp_buf2,my_info_struct->ssid_list); + add_ssid_2_list(tmp_buf2,beacon_hdr->capability, + my_info_struct->ssid_list); } else if((w_hdr->frame_ctl & IEEE802_11_STYPE_ATIM)>0) strcpy(tmp_buf,"announcement traffic indication message"); @@ -224,7 +226,7 @@ void pcap_process(u_char *info,const struct pcap_pkthdr *pcap_header, else strcpy(tmp_buf,"control or data frame type"); printf("=> %s\n",tmp_buf); - if(strlen(tmp_buf1)>0 & strlen(tmp_buf2)>0) printf(" %s%s\n", + if((strlen(tmp_buf1)>0) && (strlen(tmp_buf2)>0)) printf(" %s%s\n", tmp_buf1, tmp_buf2); printf("duration/id: 0x%x\n",w_hdr->duration_id); @@ -264,7 +266,7 @@ void pcap_process(u_char *info,const struct pcap_pkthdr *pcap_header, printf("- no encryption!\n"); if(snap_hdr->proto==ntohs(ETH_P_IP)) { e_o=sizeof(struct snaphdr); - parse_ip(snap_hdr+e_o); + parse_ip((char *)(snap_hdr+e_o)); } } diff --git a/hdw_outlib.c b/hdw_outlib.c new file mode 100644 index 0000000..bc552cc --- /dev/null +++ b/hdw_outlib.c @@ -0,0 +1,52 @@ +/* call out ieee802.11 information + * + * author: hackbard + * + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include + +char sys_call[20]; + +int tell_ssid(char *ssid) { + sprintf(sys_call,"flite \"new ssid. %s\"",ssid); + system(sys_call); + return 1; +} + +int lcd_ssid(char *ssid,unsigned short cap) { + int lcd_fd; + char lcd_com[2]; + char c_msg[7]; + + if((lcd_fd=open("/dev/lcd",O_WRONLY|O_NDELAY)) <= 0) { + printf("failed to open lcd device"); + exit -1; + } + + printf("debug: lcd_fd = %d\n",lcd_fd); + strcpy(sys_call,ssid); + lcd_com[0]=27; + lcd_com[1]='c'; + write(lcd_fd,lcd_com,sizeof(lcd_com)); + lcd_com[0]=27; + lcd_com[1]='h'; + write(lcd_fd,lcd_com,sizeof(lcd_com)); + if((1<<4 & cap)) sprintf(c_msg," wep"); + else sprintf(c_msg," no_wep"); + dprintf(lcd_fd,"ssid: %s\ncap: %x%s",sys_call,cap,c_msg); + // write(lcd_fd,sys_call,sizeof(sys_call)); + close(lcd_fd); + return 1; +} + + + diff --git a/hdw_outlib.h b/hdw_outlib.h new file mode 100644 index 0000000..8fd1149 --- /dev/null +++ b/hdw_outlib.h @@ -0,0 +1,10 @@ +/* outlib.h - prototypes + * + * author: hackbard + * + */ + +/* prototypes */ +int tell_ssid(char *ssid); +int lcd_ssid(char *ssidi,unsigned short cap); + diff --git a/list.c b/list.c index 03fec7c..3b4946e 100644 --- a/list.c +++ b/list.c @@ -4,22 +4,22 @@ * */ +#include "hdw_outlib.h" #include "list.h" #include #include #include -char sys_call[20]; +// char sys_call[20]; -int add_ssid_2_list(char *ssid, struct list *my_list) { +int add_ssid_2_list(char *ssid,unsigned short cap,struct list *my_list) { struct list *new_entry; if(my_list->next==NULL) { - // printf("debug: new ssid found!\n"); - sprintf(sys_call,"flite \"new ssid. %s\"",ssid); - system(sys_call); + tell_ssid(ssid); + lcd_ssid(ssid,cap); new_entry=(struct list *)malloc(sizeof(struct list)); my_list->next=new_entry; strcpy(my_list->ssid,ssid); @@ -27,7 +27,7 @@ int add_ssid_2_list(char *ssid, struct list *my_list) { } else if(!strcmp(my_list->ssid,ssid)) { /* do nothing! */ } else { - add_ssid_2_list(ssid,my_list->next); + add_ssid_2_list(ssid,cap,my_list->next); } return 1; } diff --git a/list.h b/list.h index b554914..075bc50 100644 --- a/list.h +++ b/list.h @@ -10,4 +10,4 @@ struct list { }; /* prototypes */ -int add_ssid_2_list(char *ssid, struct list *my_list); +int add_ssid_2_list(char *ssid,unsigned short cap, struct list *my_list);