github.com/n00py/Slackor@v0.0.0-20200610224921-d007fcea1740/impacket/tests/dot11/test_Dot11Decoder.py (about) 1 #!/usr/bin/env python 2 # sorry, this is very ugly, but I'm in python 2.5 3 import sys 4 sys.path.insert(0,"../..") 5 6 from impacket.ImpactDecoder import Dot11Decoder #,Dot11Types 7 from six import PY2 8 import unittest 9 10 class TestDot11Decoder(unittest.TestCase): 11 12 def setUp(self): 13 self.WEPKey=None #Unknown 14 self.WEPData=b'\x08\x41\x3a\x01\x00\x17\x3f\x44\x4f\x96\x00\x13\xce\x67\x0e\x73\x00\x17\x3f\x44\x4f\x96\xb0\x04\xeb\xcd\x8b\x00\x6e\xdf\x93\x36\x39\x5a\x39\x66\x6b\x96\xd1\x7a\xe1\xae\xb6\x11\x22\xfd\xf0\xd4\x0d\x6a\xb8\xb1\xe6\x2e\x1f\x25\x7d\x64\x1a\x07\xd5\x86\xd2\x19\x34\xb5\xf7\x8a\x62\x33\x59\x6e\x89\x01\x73\x50\x12\xbb\xde\x17\xdd\xb5\xd4\x35' 15 dot11_decoder = Dot11Decoder() 16 self.in0=dot11_decoder.decode(self.WEPData) 17 self.in1=self.in0.child() 18 self.in2=self.in1.child() 19 self.in3=self.in2.child() 20 if self.WEPKey: 21 self.in4=self.in3.child() 22 self.in5=self.in4.child() 23 24 def test_01_Dot11Decoder(self): 25 'Test Dot11 decoder' 26 if PY2: 27 self.assertEqual(str(self.in0.__class__), "impacket.dot11.Dot11") 28 else: 29 self.assertEqual(str(self.in0.__class__), "<class 'impacket.dot11.Dot11'>") 30 31 def test_02_Dot11DataFrameDecoder(self): 32 'Test Dot11DataFrame decoder' 33 if PY2: 34 self.assertEqual(str(self.in1.__class__), "impacket.dot11.Dot11DataFrame") 35 else: 36 self.assertEqual(str(self.in1.__class__), "<class 'impacket.dot11.Dot11DataFrame'>") 37 38 def test_03_Dot11WEP(self): 39 'Test Dot11WEP decoder' 40 if PY2: 41 self.assertEqual(str(self.in2.__class__), "impacket.dot11.Dot11WEP") 42 else: 43 self.assertEqual(str(self.in2.__class__), "<class 'impacket.dot11.Dot11WEP'>") 44 45 def test_04_Dot11WEPData(self): 46 'Test Dot11WEPData decoder' 47 48 if not self.WEPKey: 49 return 50 51 self.assertEqual(str(self.in3.__class__), "impacket.dot11.Dot11WEPData") 52 53 # Test if wep data "get_packet" is correct 54 wepdata=b'\x6e\xdf\x93\x36\x39\x5a\x39\x66\x6b\x96\xd1\x7a\xe1\xae\xb6\x11\x22\xfd\xf0\xd4\x0d\x6a\xb8\xb1\xe6\x2e\x1f\x25\x7d\x64\x1a\x07\xd5\x86\xd2\x19\x34\xb5\xf7\x8a\x62\x33\x59\x6e\x89\x01\x73\x50\x12\xbb\xde\x17' 55 self.assertEqual(self.in3.get_packet(),wepdata) 56 57 def test_05_LLC(self): 58 'Test LLC decoder' 59 if self.WEPKey: 60 self.assertEqual(str(self.in4.__class__), "impacket.dot11.LLC") 61 62 def test_06_Data(self): 63 'Test LLC Data decoder' 64 65 if self.WEPKey: 66 dataclass=self.in4.__class__ 67 else: 68 dataclass=self.in3.__class__ 69 70 self.assertTrue(str(dataclass).find('ImpactPacket.Data') > 0) 71 72 suite = unittest.TestLoader().loadTestsFromTestCase(TestDot11Decoder) 73 unittest.TextTestRunner(verbosity=1).run(suite)