Esempio n. 1
0
 def decrypt_data(self, key_string):
     'Return \'WEP Data\' decrypted'
     
     # Needs to be at least 8 bytes of payload 
     if len(self.body_string)<8:
         return self.body_string
     
     # initialize the first bytes of the key from the IV 
     # and copy rest of the WEP key (the secret part) 
     key=self.get_iv()+key_string
     rc4=RC4(key)
     out=rc4.decrypt(data)
     dwd=Dot11WEPData(out)
     
     if False: # is ICV correct
         return dwd
     else:
         return self.body_string
 def setUp(self):
     # 802.11 Data Frame
     #
     self.dot11frame = b'\x08\x41\x2c\x00\x00\x21\x29\x68\x33\x5d\x00\x18\xde\x7c\x37\x9f\x00\x21\x29\x68\x33\x5b\xf0\xd6\x0c\x31\x65\x00\x8d\x23\x81\xe9\x25\x1c\xb5\xaa\x83\xd2\xc7\x16\xba\x6e\xe1\x8e\x7d\x3a\x2c\x71\xc0\x0f\x6a\xb8\x2f\xbc\x54\xc4\xb0\x14\xab\x03\x11\x5e\xde\xcc\xab\x2b\x18\xeb\xeb\x25\x0f\x75\xeb\x6b\xf5\x7f\xd6\x5c\xb9\xe1\xb2\x6e\x50\xba\x4b\xb4\x8b\x9f\x34\x71\xda\x9e\xcf\x12\xcb\x8f\x36\x1b\x02\x53'
     
     d = Dot11(self.dot11frame, FCS_at_end = False)
     
     self.assertEqual(d.get_type(),Dot11Types.DOT11_TYPE_DATA)
     self.assertEqual(d.get_subtype(),Dot11Types.DOT11_SUBTYPE_DATA)
     self.assertEqual(d.get_type_n_subtype(),Dot11Types.DOT11_TYPE_DATA_SUBTYPE_DATA)
     
     data = Dot11DataFrame(d.get_body_as_string())
     d.contains(data)
     
     self.wep_header = Dot11WEP(data.body_string)
     data.contains(self.wep_header)
     
     self.wep_data = Dot11WEPData(self.wep_header.body_string)
     self.wep_header.contains(self.wep_data)
     
     self.km=KeyManager()
     self.km.add_key([0x00,0x21,0x29,0x68,0x33,0x5d],unhexlify(b'999cbb701ca2ef030e302dcc35'))