More dot11 stuff added

This commit is contained in:
7u83 2022-09-15 07:47:41 +02:00
parent 97533f67cc
commit b292b88d49
5 changed files with 71 additions and 18 deletions

View File

@ -324,9 +324,11 @@ static int dataman_process_msg(struct cw_Conn *nc, uint8_t * rawmsg, int len,
char frame[1000];
dot11_init_assoc_resp(frame);
dot11_copy_mac(dot11_get_sa(dot11frame),dot11_get_da(frame));
dot11_copy_mac(dot11_get_bssid(dot11frame),dot11_get_bssid(frame));
dot11_copy_mac(dot11_get_da(dot11frame),dot11_get_sa(frame));
dot11_set_seq(frame,0);

View File

@ -706,6 +706,9 @@ void cw_dbg_dot11_frame(uint8_t * frame,int len)
case DOT11_ASSOC_REQ:
cw_dbg_dot11_elems(frame+28,len-28);
break;
case DOT11_ASSOC_RESP:
cw_dbg_dot11_elems((frame),len-6);
break;
}
}

View File

@ -139,6 +139,13 @@ extern const uint8_t dot11_tab_br[256];
#define dot11_put_dword(dst,v) ((*((uint32_t*)(dst))=htobe32(v)),4)
#define dot11_put_qword(dst,v) ((*((uint64_t*)(dst))=htobe64(v)),8)
#define dot11_set_byte(ptr,b) (*(ptr) = b)
#define dot11_set_word(dst,v) ((*((uint16_t*)(dst))=htobe16(v)))
#define dot11_set_dword(dst,v) ((*((uint32_t*)(dst))=htobe32(v)))
#define dot11_set_qword(dst,v) ((*((uint64_t*)(dst))=htobe64(v)))
#define dot11_set_byte(ptr,b) (*(ptr) = b)
uint16_t dot11_get_word(uint8_t * ptr);
@ -208,6 +215,9 @@ void dot11_timer_set(uint64_t val);
#define dot11_put_address(dst,addr) (memcpy(dst,addr,6),6)
#define dot11_put_sequence_control(dst,v) (dot11_put_word(dst,v))
#define dot11_put_capability(dst,v) dot11_put_word(dst,v)
int dot11_put_ssid(uint8_t *dst,uint8_t * ssid,int len);
@ -252,6 +262,8 @@ extern struct cw_StrListElem dot11_names[];
* @return uint16_t Frame Control field
*/
#define dot11_get_fc(frame) dot11_get_word(frame)
/** Get duration/aid field
* @param frame uint8_t pointer to frame */
#define dot11_get_duration(frame) dot11_get_word(frame+2)
#define dot11_get_da(frame) ((frame)+4)
#define dot11_get_sa(frame) ((frame)+10)
@ -259,16 +271,34 @@ extern struct cw_StrListElem dot11_names[];
#define dot11_get_seq(frame) dot11_get_word((frame)+22)
#define dot11_get_body(frame) ((frame)+24)
#define dot11_set_duration(frame,d) dot11_set_word(frame+2,d)
#define dot11_set_seq(frame,s) dot11_set_word((frame)+22,s)
#define dot11_assoc_req_get_cap(frame) \
dot11_get_word((frame)+2+2+12+6+2)
dot11_get_word((frame)+24)
#define dot11_assoc_req_get_listen_interval(frame) \
dot11_get_word((frame)+2+2+12+6+4)
dot11_get_word((frame)+24+2)
/*
#define dot11_assoc_req_get_ssid_len(frame)\
((frame)[29])
#define dot11_assoc_req_get_ssid(frame)\
(frame+30)
*/
#define dot11_assoc_resp_set_cap(frame,cap)\
dot11_set_word(dot11_get_body(frame),cap)
#define dot11_assoc_resp_set_status_code(frame,code)\
dot11_set_word(dot11_get_body(frame)+2,code)
#define dot11_assoc_resp_set_assoc_id(frame,id)\
dot11_set_word(dot11_get_body(frame)+4,id)
//#define dot11_assoce_resp_get_var_body(frame)
// (get_frame_body(frame)+6)

View File

@ -71,11 +71,7 @@ int dot11_put_dsss_param_set(uint8_t *dst,int ch) {
}
#define DOT11_INLINE
#define DOT11_INLINE
DOT11_INLINE
uint8_t * dot11_get_body(uint8_t * frame)
{
}

View File

@ -96,23 +96,23 @@ struct bootcfg bootcfg;
int test()
{
int rc;
char *f;
uint8_t *f,*frame;
size_t len;
f=cw_load_file("wificap-002",&len);
f=(uint8_t*)cw_load_file("wificap-002",&len);
cw_dbg(DBG_X, "Loaded %d bytes",len);
// static int got_radiotap = 0;
struct libwifi_frame frame = {0};
rc = libwifi_get_wifi_frame(&frame, (unsigned char*)(f+16+1), len-16-1, 0);
// struct libwifi_frame frame = {0};
/// rc = libwifi_get_wifi_frame(&frame, (unsigned char*)(f+16+1), len-16-1, 0);
struct libwifi_frame_ctrl *frame_control = (struct libwifi_frame_ctrl *) (f+16);
printf("SO: %d\n",frame_control->type);
// struct libwifi_frame_ctrl *frame_control = (struct libwifi_frame_ctrl *) (f+16);
// printf("SO: %d\n",frame_control->type);
if (rc != 0) {
printf("[!] Error getting libwifi_frame: %d\n", rc);
}
// if (rc != 0) {
// printf("[!] Error getting libwifi_frame: %d\n", rc);
// }
cw_dbg(DBG_X,"Frame CTL:%d,%d",frame.frame_control.type, frame.frame_control.subtype);
// cw_dbg(DBG_X,"Frame CTL:%d,%d",frame.frame_control.type, frame.frame_control.subtype);
// cw_dbg(DBG_X,"MY RESULT: Type %d, SubType %d",cw_dot11_get_type(f+16), cw_dot11_get_subtype(f+16));
// cw_dbg(DBG_X,"FRAME: %s",dot11_get_frame_name(f+16+1));
@ -126,8 +126,30 @@ int test()
cw_dbg(DBG_X,"R:\n%s",dstr);
cw_dbg_dot11_frame(f+16,len-16);
frame = f+16;
uint8_t rframe[1000];
dot11_init_assoc_resp(rframe);
dot11_set_duration(rframe,100);
dot11_copy_mac(dot11_get_sa(frame),dot11_get_da(rframe));
dot11_copy_mac(dot11_get_bssid(frame),dot11_get_bssid(rframe));
dot11_copy_mac(dot11_get_da(frame),dot11_get_sa(rframe));
dot11_set_seq(rframe,0);
dot11_assoc_resp_set_cap(rframe,dot11_assoc_req_get_cap(frame));
dot11_assoc_resp_set_status_code(rframe,0);
dot11_assoc_resp_set_assoc_id(rframe,17);
cw_dbg_dot11_frame(rframe,24+6);
free(f);
return 0;
}