def decode(self, aBuffer): if self.dot11.get_fromDS() and self.dot11.get_toDS(): if self.dot11.is_QoS_frame(): p = dot11.Dot11DataAddr4QoSFrame(aBuffer) else: p = dot11.Dot11DataAddr4Frame(aBuffer) elif self.dot11.is_QoS_frame(): p = dot11.Dot11DataQoSFrame(aBuffer) else: p = dot11.Dot11DataFrame(aBuffer) self.set_decoded_protocol(p) if not self.dot11.get_protectedFrame(): self.llc_decoder = LLCDecoder() packet = self.llc_decoder.decode(p.body_string) else: if not self.dot11.get_fromDS() and self.dot11.get_toDS(): bssid = p.get_address1() elif self.dot11.get_fromDS() and not self.dot11.get_toDS(): bssid = p.get_address2() elif not self.dot11.get_fromDS() and not self.dot11.get_toDS(): bssid = p.get_address3() else: # WDS, this is the RA bssid = p.get_address1() wep_decoder = Dot11WEPDecoder(self.key_manager) wep_decoder.set_bssid(bssid) packet = wep_decoder.decode(p.body_string) if packet is None: wpa_decoder = Dot11WPADecoder() packet = wpa_decoder.decode(p.body_string) if packet is None: wpa2_decoder = Dot11WPA2Decoder() packet = wpa2_decoder.decode(p.body_string) if packet is None: data_decoder = DataDecoder() packet = data_decoder.decode(p.body_string) p.contains(packet) return p
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'))