def setUp(self): # 802.11 Management Frame # self.rawProbeResponseframe = '\x00\x00\x18\x00\x2e\x48\x00\x00\x00\x02\x85\x09\xa0\x00\xb0\x01\x00\x00\x00\x00\x00\x00\x00\x00\x50\x00\x3a\x01\x00\x21\xfe\x39\x3f\x77\x00\x1b\x11\x32\x66\x23\x00\x1b\x11\x32\x66\x23\x20\x73\x7f\xa0\x22\xf8\x3f\x01\x00\x00\x64\x00\x11\x04\x00\x07\x66\x72\x65\x65\x62\x73\x64\x01\x08\x82\x84\x8b\x96\x24\x30\x48\x6c\x03\x01\x06\x2a\x01\x04\x2f\x01\x04\x32\x04\x0c\x12\x18\x60\xdd\x75\x00\x50\xf2\x04\x10\x4a\x00\x01\x10\x10\x44\x00\x01\x02\x10\x41\x00\x01\x00\x10\x3b\x00\x01\x03\x10\x47\x00\x10\x11\x4e\xf7\x46\xa9\xc6\xfb\x1d\x70\x1b\x00\x1b\x11\x32\x66\x23\x10\x21\x00\x06\x44\x2d\x4c\x69\x6e\x6b\x10\x23\x00\x07\x44\x49\x52\x2d\x33\x32\x30\x10\x24\x00\x07\x44\x49\x52\x2d\x33\x32\x30\x10\x42\x00\x08\x30\x30\x30\x30\x30\x30\x30\x30\x10\x54\x00\x08\x00\x06\x00\x50\xf2\x04\x00\x01\x10\x11\x00\x07\x44\x49\x52\x2d\x33\x32\x30\x10\x08\x00\x02\x00\x8e\xdd\x05\x00\x50\xf2\x05\x00\xdd\x09\x00\x10\x18\x02\x01\xf0\x00\x00\x00\xdd\x18\x00\x50\xf2\x01\x01\x00\x00\x50\xf2\x02\x01\x00\x00\x50\xf2\x02\x01\x00\x00\x50\xf2\x02\x00\x00' self.radiotap_decoder = RadioTapDecoder() radiotap = self.radiotap_decoder.decode(self.rawProbeResponseframe) self.assertEqual(str(radiotap.__class__), "impacket.dot11.RadioTap") self.dot11 = radiotap.child() self.assertEqual(str(self.dot11.__class__), "impacket.dot11.Dot11") type = self.dot11.get_type() self.assertEqual(type, Dot11Types.DOT11_TYPE_MANAGEMENT) subtype = self.dot11.get_subtype() self.assertEqual(subtype, Dot11Types.DOT11_SUBTYPE_MANAGEMENT_PROBE_RESPONSE) typesubtype = self.dot11.get_type_n_subtype() self.assertEqual( typesubtype, Dot11Types.DOT11_TYPE_MANAGEMENT_SUBTYPE_PROBE_RESPONSE) self.management_base = self.dot11.child() self.assertEqual(str(self.management_base.__class__), "impacket.dot11.Dot11ManagementFrame") self.management_probe_response = self.management_base.child() self.assertEqual(str(self.management_probe_response.__class__), "impacket.dot11.Dot11ManagementProbeResponse")
def setUp(self): # 802.11 Management Frame # self.rawframe = "\x00\x00\x1c\x00\xef\x18\x00\x00\x39\x55\x6f\x05\x3c\x00\x00\x00\x10\x02\x85\x09\xa0\x00\xb8\x9d\x60\x00\x00\x1b\xb0\x00\x3a\x01\x00\x18\xf8\x6c\x76\x42\x70\x1a\x04\x54\xe3\x86\x00\x18\xf8\x6c\x76\x42\x30\xc8\x00\x00\x01\x00\x00\x00\xdd\x09\x00\x10\x18\x02\x00\x10\x00\x00\x00\x8a\x64\xe9\x3b" self.radiotap_decoder = RadioTapDecoder() radiotap = self.radiotap_decoder.decode(self.rawframe) self.assertEqual(str(radiotap.__class__), "impacket.dot11.RadioTap") self.dot11 = radiotap.child() self.assertEqual(str(self.dot11.__class__), "impacket.dot11.Dot11") type = self.dot11.get_type() self.assertEqual(type, Dot11Types.DOT11_TYPE_MANAGEMENT) subtype = self.dot11.get_subtype() self.assertEqual(subtype, Dot11Types.DOT11_SUBTYPE_MANAGEMENT_AUTHENTICATION) typesubtype = self.dot11.get_type_n_subtype() self.assertEqual( typesubtype, Dot11Types.DOT11_TYPE_MANAGEMENT_SUBTYPE_AUTHENTICATION) self.management_base = self.dot11.child() self.assertEqual(str(self.management_base.__class__), "impacket.dot11.Dot11ManagementFrame") self.management_authentication = self.management_base.child() self.assertEqual(str(self.management_authentication.__class__), "impacket.dot11.Dot11ManagementAuthentication")
def setUp(self): # 802.11 Management Frame # self.rawframe='\x00\x00\x10\x00\x6e\x00\x00\x00\x00\x02\x94\x09\xa0\x00\x3a\x00\xc0\x00\x3a\x01\x00\x15\xaf\x64\xac\xbd\x00\x18\x39\xc1\xfc\xe2\x00\x18\x39\xc1\xfc\xe2\x20\x3b\x0f\x00' self.radiotap_decoder = RadioTapDecoder() radiotap=self.radiotap_decoder.decode(self.rawframe) self.assertEqual(str(radiotap.__class__), "impacket.dot11.RadioTap") self.dot11=radiotap.child() self.assertEqual(str(self.dot11.__class__), "impacket.dot11.Dot11") type = self.dot11.get_type() self.assertEqual(type,Dot11Types.DOT11_TYPE_MANAGEMENT) subtype = self.dot11.get_subtype() self.assertEqual(subtype,Dot11Types.DOT11_SUBTYPE_MANAGEMENT_DEAUTHENTICATION) typesubtype = self.dot11.get_type_n_subtype() self.assertEqual(typesubtype,Dot11Types.DOT11_TYPE_MANAGEMENT_SUBTYPE_DEAUTHENTICATION) self.management_base=self.dot11.child() self.assertEqual(str(self.management_base.__class__), "impacket.dot11.Dot11ManagementFrame") self.management_deauthentication=self.management_base.child() self.assertEqual(str(self.management_deauthentication.__class__), "impacket.dot11.Dot11ManagementDeauthentication")
def setUp(self): # 802.11 Management Frame # self.rawframe = "\x00\x00\x1c\x00\xef\x18\x00\x00\x9aK\x87\xae;\x00\x00\x00\x10\x02\x85\t\xa0\x00\xb5\x9d`\x00\x00\x18 \x00:\x01\x00\x18\xf8lvBp\x1a\x04T\xe3\x86\x00\x18\xf8lvB\x00\x081\x04\n\x00\x00\x18\xf8lvB\x00\x05ddwrt\x01\x08\x82\x84\x8b\x96$0Hl!\x02\n\x11$\x02\x01\x0e0\x14\x01\x00\x00\x0f\xac\x04\x01\x00\x00\x0f\xac\x04\x01\x00\x00\x0f\xac\x02\x08\x002\x04\x0c\x12\x18`\xdd\t\x00\x10\x18\x02\x00\x10\x00\x00\x00p\x97\x1cA" self.radiotap_decoder = RadioTapDecoder() radiotap = self.radiotap_decoder.decode(self.rawframe) self.assertEqual(str(radiotap.__class__), "impacket.dot11.RadioTap") self.dot11 = radiotap.child() self.assertEqual(str(self.dot11.__class__), "impacket.dot11.Dot11") type = self.dot11.get_type() self.assertEqual(type, Dot11Types.DOT11_TYPE_MANAGEMENT) subtype = self.dot11.get_subtype() self.assertEqual( subtype, Dot11Types.DOT11_SUBTYPE_MANAGEMENT_REASSOCIATION_REQUEST) typesubtype = self.dot11.get_type_n_subtype() self.assertEqual( typesubtype, Dot11Types.DOT11_TYPE_MANAGEMENT_SUBTYPE_REASSOCIATION_REQUEST) self.management_base = self.dot11.child() self.assertEqual(str(self.management_base.__class__), "impacket.dot11.Dot11ManagementFrame") self.management_reassociation_request = self.management_base.child() self.assertEqual(str(self.management_reassociation_request.__class__), "impacket.dot11.Dot11ManagementReassociationRequest")
def setUp(self): # 802.11 Management Frame # self.rawframe = '\x00\x00\x20\x00\x67\x08\x04\x00\x54\xc6\xb8\x24\x00\x00\x00\x00\x22\x0c\xda\xa0\x02\x00\x00\x00\x40\x01\x00\x00\x3c\x14\x24\x11\x80\x00\x00\x00\xff\xff\xff\xff\xff\xff\x06\x03\x7f\x07\xa0\x16\x06\x03\x7f\x07\xa0\x16\xb0\x77\x3a\x40\xcb\x26\x00\x00\x00\x00\x64\x00\x01\x05\x00\x0a\x66\x72\x65\x65\x62\x73\x64\x2d\x61\x70\x01\x08\x8c\x12\x98\x24\xb0\x48\x60\x6c\x03\x01\x24\x05\x04\x00\x01\x00\x00\x07\x2a\x55\x53\x20\x24\x01\x11\x28\x01\x11\x2c\x01\x11\x30\x01\x11\x34\x01\x17\x38\x01\x17\x3c\x01\x17\x40\x01\x17\x95\x01\x1e\x99\x01\x1e\x9d\x01\x1e\xa1\x01\x1e\xa5\x01\x1e\x20\x01\x00\xdd\x18\x00\x50\xf2\x02\x01\x01\x00\x00\x03\xa4\x00\x00\x27\xa4\x00\x00\x42\x43\x5e\x00\x62\x32\x2f\x00' self.radiotap_decoder = RadioTapDecoder() radiotap = self.radiotap_decoder.decode(self.rawframe) self.assertEqual(str(radiotap.__class__), "impacket.dot11.RadioTap") self.dot11 = radiotap.child() self.assertEqual(str(self.dot11.__class__), "impacket.dot11.Dot11") type = self.dot11.get_type() self.assertEqual(type, Dot11Types.DOT11_TYPE_MANAGEMENT) subtype = self.dot11.get_subtype() self.assertEqual(subtype, Dot11Types.DOT11_SUBTYPE_MANAGEMENT_BEACON) typesubtype = self.dot11.get_type_n_subtype() self.assertEqual(typesubtype, Dot11Types.DOT11_TYPE_MANAGEMENT_SUBTYPE_BEACON) self.management_base = self.dot11.child() self.assertEqual(str(self.management_base.__class__), "impacket.dot11.Dot11ManagementFrame") self.management_beacon = self.management_base.child() self.assertEqual(str(self.management_beacon.__class__), "impacket.dot11.Dot11ManagementBeacon")
def setUp(self): # 802.11 Management Frame # self.rawframe = "\x00\x00\x1c\x00\xef\x18\x00\x00\xc0\xbb\xbc\xae;\x00\x00\x00\x10\x02\x85\t\xa0\x00\xba\x9ca\x00\x00\x1e0\x08:\x01p\x1a\x04T\xe3\x86\x00\x18\xf8lvB\x00\x18\xf8lvB\xe0g\x11\x04\x00\x00\x04\xc0\x01\x08\x82\x84\x8b\x96$0Hl2\x04\x0c\x12\x18`\xdd\t\x00\x10\x18\x02\x02\xf0\x00\x00\x00\xb3\xff\n\\" self.radiotap_decoder = RadioTapDecoder() radiotap = self.radiotap_decoder.decode(self.rawframe) self.assertEqual(str(radiotap.__class__), "impacket.dot11.RadioTap") self.dot11 = radiotap.child() self.assertEqual(str(self.dot11.__class__), "impacket.dot11.Dot11") type = self.dot11.get_type() self.assertEqual(type, Dot11Types.DOT11_TYPE_MANAGEMENT) subtype = self.dot11.get_subtype() self.assertEqual( subtype, Dot11Types.DOT11_SUBTYPE_MANAGEMENT_REASSOCIATION_RESPONSE) typesubtype = self.dot11.get_type_n_subtype() self.assertEqual( typesubtype, Dot11Types.DOT11_TYPE_MANAGEMENT_SUBTYPE_REASSOCIATION_RESPONSE) self.management_base = self.dot11.child() self.assertEqual(str(self.management_base.__class__), "impacket.dot11.Dot11ManagementFrame") self.management_reassociation_response = self.management_base.child() self.assertEqual( str(self.management_reassociation_response.__class__), "impacket.dot11.Dot11ManagementReassociationResponse")
def setUp(self): # 802.11 Management Frame # self.rawframe = "\x00\x00\x1c\x00\xef\x18\x00\x00\xe7\x8a\xec\xb8\x3b\x00\x00\x00\x10\x02\x85\x09\xa0\x00\xb5\x9d\x60\x00\x00\x18\xa0\x00\x3a\x01\x00\x18\xf8\x6c\x76\x42\x70\x1a\x04\x54\xe3\x86\x00\x18\xf8\x6c\x76\x42\x70\x92\x08\x00\xbf\x1b\xa3\xa8" self.radiotap_decoder = RadioTapDecoder() radiotap = self.radiotap_decoder.decode(self.rawframe) self.assertEqual(str(radiotap.__class__), "impacket.dot11.RadioTap") self.dot11 = radiotap.child() self.assertEqual(str(self.dot11.__class__), "impacket.dot11.Dot11") type = self.dot11.get_type() self.assertEqual(type, Dot11Types.DOT11_TYPE_MANAGEMENT) subtype = self.dot11.get_subtype() self.assertEqual(subtype, Dot11Types.DOT11_SUBTYPE_MANAGEMENT_DISASSOCIATION) typesubtype = self.dot11.get_type_n_subtype() self.assertEqual( typesubtype, Dot11Types.DOT11_TYPE_MANAGEMENT_SUBTYPE_DISASSOCIATION) self.management_base = self.dot11.child() self.assertEqual(str(self.management_base.__class__), "impacket.dot11.Dot11ManagementFrame") self.management_disassociation = self.management_base.child() self.assertEqual(str(self.management_disassociation.__class__), "impacket.dot11.Dot11ManagementDisassociation")
def setUp(self): self.RadioTapData=b'\x00\x00\x20\x00\x67\x08\x04\x00\x30\x03\x1a\x25\x00\x00\x00\x00\x22\x0c\xd9\xa0\x02\x00\x00\x00\x40\x01\x00\x00\x3c\x14\x24\x11\x08\x02\x00\x00\xff\xff\xff\xff\xff\xff\x06\x03\x7f\x07\xa0\x16\x00\x19\xe3\xd3\x53\x52\x90\x7f\xaa\xaa\x03\x00\x00\x00\x08\x06\x00\x01\x08\x00\x06\x04\x00\x01\x00\x19\xe3\xd3\x53\x52\xa9\xfe\xf7\x00\x00\x00\x00\x00\x00\x00\x43\x08\x0e\x36' self.radiotap_decoder = RadioTapDecoder() self.in0=self.radiotap_decoder.decode(self.RadioTapData) self.in1=self.in0.child() self.in2=self.in1.child() self.in3=self.in2.child() self.in4=self.in3.child() self.in5=self.in4.child() self.in6=self.in5.child()
def frame_handler(self, manager, worker_addr, frame_data): """ Inject probe response frames for every probe request frame. """ decoder = RadioTapDecoder() decoder.decode(frame_data) management_frame = decoder.get_protocol(dot11.Dot11ManagementFrame) probe_req_frame = decoder.get_protocol( dot11.Dot11ManagementProbeRequest) if not probe_req_frame: return ssid = probe_req_frame.get_ssid() if not ssid: # Ignore broadcast SSID return station_address = management_frame.get_source_address() print "Station: %s" % ":".join( map(lambda i: "%02X" % i, station_address)) print "SSID: %s" % ssid frame = str() # Radiotap frame += "\x00\x00" # Version frame += "\x0b\x00" # Header Length frame += "\x04\x0c\x00\x00" # Presence Flags frame += "\x6c" # Rate frame += "\x0c" # TX Power frame += "\x01" # Antenna # Management Frame frame += "\x50\x00" # Frame Control frame += "\x31\x01" # Duration frame += "".join(chr(i) for i in station_address) # Destination Address frame += "\x00\xde\xad\xbe\xef\x00" # Source Address frame += "\x00\xde\xad\xbe\xef\x00" # BSSID Address frame += "\x00\x00" # Sequence Control frame += "\x00\x00\x00\x00\x00\x00\x00\x00" # Timestamp frame += "\x64\x00" # Beacon Interval frame += "\x01\x04" # Capabilities frame += "\x00%s%s" % (struct.pack("B", len(ssid)), ssid) # SSID frame += "\x01\x08\x82\x84\x8b\x96\x24\x30\x48\x6c" # Supported Rates frame += "\x03\x01\x0e" # DS parameter set frame += "\xdd\x06\xfa\xfa\xfa\x00\xde\xad" # Vendor Specific workers = manager.get_workers() for worker in workers: if worker.raw_mac_address() == worker_addr: break for iface in worker.interfaces_list(): manager.inject_data_from_worker_interface(worker.raw_mac_address(), iface.name(), frame)
def setUp(self): # 802.11 Management Frame # self.rawframe = b"\x00\x00\x1c\x00\xef\x18\x00\x00jH\xfa\x00<\x00\x00\x00\x10\x02\x85\t\xa0\x00\xb9\x9e_\x00\x00" \ b"\x1b\x00\x00:\x01\x00\x18\xf8lvBp\x1a\x04T\xe3\x86\x00\x18\xf8lvBP\x8e1\x04\n\x00\x00\x05ddwrt" \ b"\x01\x08\x82\x84\x8b\x96$0Hl!\x02\n\x11$\x02\x01\x0e0\x14\x01\x00\x00\x0f\xac\x04\x01\x00\x00" \ b"\x0f\xac\x04\x01\x00\x00\x0f\xac\x02\x08\x002\x04\x0c\x12\x18`\xdd\t\x00\x10\x18\x02\x00\x10" \ b"\x00\x00\x00\xbf]o\xce" self.radiotap_decoder = RadioTapDecoder() radiotap = self.radiotap_decoder.decode(self.rawframe) if PY2: self.assertEqual(str(radiotap.__class__), "impacket.dot11.RadioTap") else: self.assertEqual(str(radiotap.__class__), "<class 'impacket.dot11.RadioTap'>") self.dot11 = radiotap.child() if PY2: self.assertEqual(str(self.dot11.__class__), "impacket.dot11.Dot11") else: self.assertEqual(str(self.dot11.__class__), "<class 'impacket.dot11.Dot11'>") type = self.dot11.get_type() self.assertEqual(type, Dot11Types.DOT11_TYPE_MANAGEMENT) subtype = self.dot11.get_subtype() self.assertEqual( subtype, Dot11Types.DOT11_SUBTYPE_MANAGEMENT_ASSOCIATION_REQUEST) typesubtype = self.dot11.get_type_n_subtype() self.assertEqual( typesubtype, Dot11Types.DOT11_TYPE_MANAGEMENT_SUBTYPE_ASSOCIATION_REQUEST) self.management_base = self.dot11.child() if PY2: self.assertEqual(str(self.management_base.__class__), "impacket.dot11.Dot11ManagementFrame") else: self.assertEqual(str(self.management_base.__class__), "<class 'impacket.dot11.Dot11ManagementFrame'>") self.management_association_request = self.management_base.child() if PY2: self.assertEqual( str(self.management_association_request.__class__), "impacket.dot11.Dot11ManagementAssociationRequest") else: self.assertEqual( str(self.management_association_request.__class__), "<class 'impacket.dot11.Dot11ManagementAssociationRequest'>")
def setUp(self): # 802.11 Management Frame # self.rawframe = b"\x00\x00\x1c\x00\xef\x18\x00\x00\xc2L\xfa\x00<\x00\x00\x00\x10\x02\x85\t\xa0\x00\xb4\x9e_\x00\x00\x16\x10\x00:\x01p\x1a\x04T\xe3\x86\x00\x18\xf8lvB\x00\x18\xf8lvB\xf0\x02\x11\x04\x00\x00\x04\xc0\x01\x08\x82\x84\x8b\x96$0Hl2\x04\x0c\x12\x18`\xdd\t\x00\x10\x18\x02\x02\xf0\x00\x00\x00f%\xdf7" self.radiotap_decoder = RadioTapDecoder() radiotap = self.radiotap_decoder.decode(self.rawframe) if PY2: self.assertEqual(str(radiotap.__class__), "impacket.dot11.RadioTap") else: self.assertEqual(str(radiotap.__class__), "<class 'impacket.dot11.RadioTap'>") self.dot11 = radiotap.child() if PY2: self.assertEqual(str(self.dot11.__class__), "impacket.dot11.Dot11") else: self.assertEqual(str(self.dot11.__class__), "<class 'impacket.dot11.Dot11'>") type = self.dot11.get_type() self.assertEqual(type, Dot11Types.DOT11_TYPE_MANAGEMENT) subtype = self.dot11.get_subtype() self.assertEqual( subtype, Dot11Types.DOT11_SUBTYPE_MANAGEMENT_ASSOCIATION_RESPONSE) typesubtype = self.dot11.get_type_n_subtype() self.assertEqual( typesubtype, Dot11Types.DOT11_TYPE_MANAGEMENT_SUBTYPE_ASSOCIATION_RESPONSE) self.management_base = self.dot11.child() if PY2: self.assertEqual(str(self.management_base.__class__), "impacket.dot11.Dot11ManagementFrame") else: self.assertEqual(str(self.management_base.__class__), "<class 'impacket.dot11.Dot11ManagementFrame'>") self.management_association_response = self.management_base.child() if PY2: self.assertEqual( str(self.management_association_response.__class__), "impacket.dot11.Dot11ManagementAssociationResponse") else: self.assertEqual( str(self.management_association_response.__class__), "<class 'impacket.dot11.Dot11ManagementAssociationResponse'>")
def setUp(self): # 802.11 Management Frame # self.rawProbeRequestframe = b'\x00\x00\x18\x00\x2e\x48\x00\x00\x00\x02\x85\x09\xa0\x00\xda\x01\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\xff\xff\xff\xff\xff\xff\x00\x23\x4d\x13\xf9\x1b\xff\xff\xff\xff\xff\xff\x90\x45\x00\x05\x64\x6c\x69\x6e\x6b\x01\x08\x02\x04\x0b\x16\x0c\x12\x18\x24\x32\x04\x30\x48\x60\x6c' self.radiotap_decoder = RadioTapDecoder() radiotap = self.radiotap_decoder.decode(self.rawProbeRequestframe) if PY2: self.assertEqual(str(radiotap.__class__), "impacket.dot11.RadioTap") else: self.assertEqual(str(radiotap.__class__), "<class 'impacket.dot11.RadioTap'>") self.dot11 = radiotap.child() if PY2: self.assertEqual(str(self.dot11.__class__), "impacket.dot11.Dot11") else: self.assertEqual(str(self.dot11.__class__), "<class 'impacket.dot11.Dot11'>") type = self.dot11.get_type() self.assertEqual(type, Dot11Types.DOT11_TYPE_MANAGEMENT) subtype = self.dot11.get_subtype() self.assertEqual(subtype, Dot11Types.DOT11_SUBTYPE_MANAGEMENT_PROBE_REQUEST) typesubtype = self.dot11.get_type_n_subtype() self.assertEqual( typesubtype, Dot11Types.DOT11_TYPE_MANAGEMENT_SUBTYPE_PROBE_REQUEST) self.management_base = self.dot11.child() if PY2: self.assertEqual(str(self.management_base.__class__), "impacket.dot11.Dot11ManagementFrame") else: self.assertEqual(str(self.management_base.__class__), "<class 'impacket.dot11.Dot11ManagementFrame'>") self.management_probe_request = self.management_base.child() if PY2: self.assertEqual(str(self.management_probe_request.__class__), "impacket.dot11.Dot11ManagementProbeRequest") else: self.assertEqual( str(self.management_probe_request.__class__), "<class 'impacket.dot11.Dot11ManagementProbeRequest'>")
def __init__(self, args): self.args = args self.accessPoints = [] self.interface = args.interface self.macAddress = args.source if is_valid_mac_address( args.source) else None self.filename = args.write # self.captured = [] self.channel = None self.ap_dict = {} self.clients_dict = {} # self.rtDecoder = RadioTapDecoder() self.wps_parser = WPSParser()
def __init__(self, interface, channel=None, timeout=5, output=None, passive=False, mac=None, logfile=None): self.interface = interface self.channel = channel self.timeout = timeout self.output = output self.passive = passive self.mac = mac if is_valid_mac_address(mac) else None self.logfile = logfile # self.aps = {} self.wps_aps = {} self.captured = [] self.probes_sent = [] self._stop = False # self.wps_parser = WPSParser() self.rtDecoder = RadioTapDecoder() # Initialize logger self.logger = logging.getLogger('airlog') self.logger.setLevel(logging.INFO) # Console logging ch = logging.StreamHandler() ch.setLevel(logging.INFO) formatter = coloredlogs.ColoredFormatter( '[%(asctime)s] - %(levelname)s - %(message)s', datefmt='%d.%m.%Y %H:%M:%S') ch.setFormatter(formatter) self.logger.addHandler(ch) # Logging to file if logfile is None: return fh = logging.FileHandler(logfile) fh.setLevel(logging.DEBUG) formatter = logging.Formatter('[%(asctime)s] - %(message)s', datefmt='%d.%m.%Y %H:%M:%S') fh.setFormatter(formatter) self.logger.addHandler(fh)
def recv_pkts(hdr, data): global lastexport global ha global pacchetticatturati try: #decodifica del pacchetto radio = RadioTapDecoder().decode(data) datadown = radio.get_body_as_string() ethe = Dot11ControlDecoder().decode(datadown) datadowndown = ethe.get_body_as_string() decodedDataDownDown = DataDecoder().decode(datadowndown) macS = (addressDecode(decodedDataDownDown)) s = type(radio.get_dBm_ant_signal()) time = datetime.datetime.now() #aggiunta al dizionario #controllo se il segnale ha un valore consistente, in caso contrario scarto if (s is int): signal = str(-(256 - radio.get_dBm_ant_signal())) + " dB" t = (time, signal) if (ha.has_key(macS)): ha.get(macS).append(t) else: l = [t] ha[macS] = l pacchetticatturati = pacchetticatturati + 1 #esporta su file (thread in parallelo) if ((time - lastexport).seconds > delay) & len(ha.keys()): haexport = ha ha = {} lastexport = time thread.start_new_thread(exporter, (haexport, )) except KeyboardInterrupt: raise except struct.error: pass #perche non lanciano eccezioni custom quelli di Impacket except: #per evitare che crashi qual'ora ci siano errori imprevisti, ne tengo traccia per il debug global imprexc _, exc_obj, exc_tb = sys.exc_info() imprexc = (exc_obj, exc_tb.tb_lineno) thread.start_new_thread(exporterException, (imprexc, ))
def recv_pkts(hdr, data): global lastexport global ha try: #decodifica del pacchetto radio = RadioTapDecoder().decode(data) datadown = radio.get_body_as_string() ethe = Dot11ControlDecoder().decode(datadown) datadowndown = ethe.get_body_as_string() decodedDataDownDown = DataDecoder().decode(datadowndown) ethMacS = [None] * 6 for i in range(0, 6): #salto i primi 8 byte per ottenere il mac trasmittente ethMacS[i] = hex(decodedDataDownDown.get_byte(8 + i)) macS = ':'.join(map(str, ethMacS)) s = type(radio.get_dBm_ant_signal()) time = datetime.datetime.now() #aggiunta al dizionario #controllo se il segnale ha un valore consistente, in caso contrario scarto if (s is int): signal = hex(radio.get_dBm_ant_signal()) t = (time, signal) if (ha.has_key(macS)): ha.get(macS).append(t) else: l = [t] ha[macS] = l #esporta su file (thread in parallelo) if ((time - lastexport).seconds > delay) & len(ha.keys()): haexport = ha ha = {} lastexport = time thread.start_new_thread(exporter, (haexport, )) except KeyboardInterrupt: raise except: pass
#self._get_field(11, 1, 'ant, '<B') #self._get_field(12, 1, 'dbantsignal, '<B') #self._get_field(13, 1, 'dbantnoise, '<B') #self._get_field(14, 2, 'rxflags, '<H') ret = self.data self.present = None self.data = None self.pkt = None self.pos = None return ret parse_radiotap = RadioTapParser() decoder = RadioTapDecoder() headerSize = struct.calcsize(FMT_HEADER_80211) def handler2(hdr, pkt): #try: rtmeta = parse_radiotap(pkt) #print json.dumps(rtmeta) # Don't try to process packets with bad checksum if rtmeta['flags'] & FLAG_BAD_FCS: return rtap = pkt[:rtmeta['len']] frame = pkt[rtmeta['len']:] header = frame[:headerSize] body = frame[headerSize:] # FCS is last 4 bytes, but may be missing frameControl, dur, addr1, addr2, addr3, seq = struct.unpack(FMT_HEADER_80211, header)