def decode(self, aBuffer): wep = dot11.Dot11WEP(aBuffer) self.set_decoded_protocol(wep) if wep.is_WEP() is False: return None key = self.find_key(self.bssid) if key: decoded_string = wep.get_decrypted_data(key) wep_data = Dot11WEPDataDecoder() packet = wep_data.decode(decoded_string) else: data_decoder = DataDecoder() packet = data_decoder.decode(wep.body_string) wep.contains(packet) return wep
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'))