def decode(self, aBuffer): d = dot11.Dot11(aBuffer, self.__FCS_at_end) self.set_decoded_protocol(d) self.subtype = d.get_subtype() if self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_CONTROL_CLEAR_TO_SEND: self.ctrl_cts_decoder = Dot11ControlFrameCTSDecoder() packet = self.ctrl_cts_decoder.decode(d.body_string) elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_CONTROL_ACKNOWLEDGMENT: self.ctrl_ack_decoder = Dot11ControlFrameACKDecoder() packet = self.ctrl_ack_decoder.decode(d.body_string) elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_CONTROL_REQUEST_TO_SEND: self.ctrl_rts_decoder = Dot11ControlFrameRTSDecoder() packet = self.ctrl_rts_decoder.decode(d.body_string) elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_CONTROL_POWERSAVE_POLL: self.ctrl_pspoll_decoder = Dot11ControlFramePSPollDecoder() packet = self.ctrl_pspoll_decoder.decode(d.body_string) elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_CONTROL_CF_END: self.ctrl_cfend_decoder = Dot11ControlFrameCFEndDecoder() packet = self.ctrl_cfend_decoder.decode(d.body_string) elif self.subtype is dot11.Dot11Types.DOT11_SUBTYPE_CONTROL_CF_END_CF_ACK: self.ctrl_cfendcfack_decoder = Dot11ControlFrameCFEndCFACKDecoder() packet = self.ctrl_cfendcfack_decoder.decode(d.body_string) else: data_decoder = DataDecoder() packet = data_decoder.decode(d.body_string) d.contains(packet) return d
def decode(self, aBuffer): d = dot11.Dot11(aBuffer, self.__FCS_at_end) self.set_decoded_protocol(d) type = d.get_type() if type == dot11.Dot11Types.DOT11_TYPE_CONTROL: dot11_control_decoder = Dot11ControlDecoder() packet = dot11_control_decoder.decode(d.body_string) elif type == dot11.Dot11Types.DOT11_TYPE_DATA: dot11_data_decoder = Dot11DataDecoder(self.key_manager) dot11_data_decoder.set_dot11_hdr(d) packet = dot11_data_decoder.decode(d.body_string) elif type == dot11.Dot11Types.DOT11_TYPE_MANAGEMENT: dot11_management_decoder = Dot11ManagementDecoder() dot11_management_decoder.set_subtype(d.get_subtype()) packet = dot11_management_decoder.decode(d.body_string) else: data_decoder = DataDecoder() packet = data_decoder.decode(d.body_string) d.contains(packet) return d
def setUp(self): self.dot11 = dot11.Dot11(FCS_at_end=False) # dot11.fc self.dot11.set_version(0) self.dot11.set_type_n_subtype( dot11.Dot11Types.DOT11_TYPE_DATA_SUBTYPE_DATA) # dot11.fc.flags self.dot11.set_fromDS(0) self.dot11.set_toDS(1) self.dot11.set_moreFrag(0) self.dot11.set_retry(0) self.dot11.set_powerManagement(0) self.dot11.set_moreData(0) self.dot11.set_protectedFrame(1) self.dot11.set_order(0) # dot11.Data self.dot11data = dot11.Dot11DataFrame() self.dot11data.set_duration(44) self.dot11data.set_address1([0x00, 0x21, 0x29, 0x68, 0x33, 0x5d]) # Bssid self.dot11data.set_address2([0x00, 0x18, 0xde, 0x7c, 0x37, 0x9f]) # Source self.dot11data.set_address3([0x00, 0x21, 0x29, 0x68, 0x33, 0x5d]) # Destination self.dot11data.set_fragment_number(0) self.dot11data.set_sequence_number(3439) # WEP self.wep = dot11.Dot11WEP() self.wep.set_iv(0x0c3165) self.wep.set_keyid(0) # WEPData self.wepdata = dot11.Dot11WEPData() # LLC self.llc = dot11.LLC() self.llc.set_DSAP(0xaa) self.llc.set_SSAP(0xaa) self.llc.set_control(0x03) # SNAP self.snap = dot11.SNAP() self.snap.set_OUI(0x000000) self.snap.set_protoID(0x0800) # IP self.ip = ImpactPacket.IP() self.ip.set_ip_v(0x04) self.ip.set_ip_tos(0x00) self.ip.set_ip_id(0xa607) # IP.flags self.ip.set_ip_rf(0) self.ip.set_ip_df(0) self.ip.set_ip_mf(0) # self.ip.set_ip_off(0) self.ip.set_ip_ttl(128) self.ip.set_ip_p(0x01) # ICMP self.ip.set_ip_src('192.168.1.102') self.ip.set_ip_dst('64.233.163.103') # ICMP self.icmp = ImpactPacket.ICMP() self.icmp.set_icmp_type(self.icmp.ICMP_ECHO) self.icmp.set_icmp_code(0x00) self.icmp.set_icmp_id(0x0400) self.icmp.set_icmp_seq(0x8405) # Data datastring = 'abcdefghijklmnopqrstuvwabcdefghi' self.data = ImpactPacket.Data(datastring) # Build the protocol stack self.dot11.contains(self.dot11data) self.dot11data.contains(self.wep) self.wep.contains(self.wepdata) self.wepdata.contains(self.llc) self.llc.contains(self.snap) self.snap.contains(self.ip) self.ip.contains(self.icmp) self.icmp.contains(self.data) # Instantiated the Key Manager self.km = KeyManager() self.km.add_key([0x00, 0x21, 0x29, 0x68, 0x33, 0x5b], '999cbb701ca2ef030e302dcc35'.decode('hex_codec'))