def __init__(self, iface, mac_address): self.devices = dict() self.pd = pcapy.open_live(iface, helpers.PCAP_SNAPLEN, helpers.PCAP_PROMISCOUS, helpers.PCAP_TIMEOUT) bpf_filter = "(type mgt subtype probe-resp) and (wlan addr1 %s)" % mac_address self.pd.setfilter(bpf_filter) datalink = self.pd.datalink() if datalink == helpers.PCAP_DLT_IEEE802_11: self.decoder = ImpactDecoder.Dot11Decoder() elif datalink == helpers.PCAP_DLT_IEEE802_11_RADIOTAP: self.decoder = ImpactDecoder.RadioTapDecoder() else: raise Exception("Invalid datalink.") self.run()
def __init__(self, iface): self.devices = dict() self.pd = pcapy.open_live(iface, helpers.PCAP_SNAPLEN, helpers.PCAP_PROMISCOUS, helpers.PCAP_TIMEOUT) # Filter Action frames with an specific BSSID Address bpf_filter = "wlan[0] = 0xd0 and wlan addr3 00:25:00:ff:94:73" self.pd.setfilter(bpf_filter) datalink = self.pd.datalink() if datalink == helpers.PCAP_DLT_IEEE802_11: self.decoder = ImpactDecoder.Dot11Decoder() elif datalink == helpers.PCAP_DLT_IEEE802_11_RADIOTAP: self.decoder = ImpactDecoder.RadioTapDecoder() else: raise Exception("Invalid datalink.") self.run()
def __init__(self, iface, mac_address): self.devices = dict() self.iface = iface self.pd = pcapy.open_live(iface, helpers.PCAP_SNAPLEN, helpers.PCAP_PROMISCOUS, helpers.PCAP_TIMEOUT) self.mac_address = helpers.get_buffer_from_string_mac_address( mac_address) # We need to capture beacon and probe response frames to get BSSID, SSID and CCX 85 IE. # But we also need to get reassociation response frames with CCX 95 IE. bpf_filter = "(type mgt subtype beacon) or (type mgt subtype probe-resp) or (type mgt subtype reassoc-resp)" self.pd.setfilter(bpf_filter) datalink = self.pd.datalink() if datalink == helpers.PCAP_DLT_IEEE802_11: self.decoder = ImpactDecoder.Dot11Decoder() elif datalink == helpers.PCAP_DLT_IEEE802_11_RADIOTAP: self.decoder = ImpactDecoder.RadioTapDecoder() else: raise Exception("Invalid datalink.") self.run()
'essid': data['essid'] }, '$push': { 'locates': data['locate'] } }, upsert=True): print 'save to mongodb successful' except Exception, e: print 'save to mongodb failed' print e def sniff_AP(): sniff(iface='mon0', prn=parse, filter='wlan[0]==0x80 or wlan[0]==0x50') def change_channel(): for ch in cycle([1, 3, 5, 7, 9, 11, 13]): os.system('sudo iwconfig wlan1mon channel ' + str(ch)) time.sleep(0.2) if __name__ == '__main__': RTD = ImpactDecoder.RadioTapDecoder() gpsp = GpsPoller() gpsp.start() threading.Thread(target=sniff_AP).start() threading.Thread(target=change_channel).start() threading.Thread(target=save_to_mongo).start()