Hi, I've written a script in python to sniff packets on an MR-3020 running OpenWRT. Since there is only one radio I hop through channels 1 - 11 and then every 10 minutes get out of monitor mode, connect to the internet, and send the data up to my server.
I can see lots of packets in the area, but when I filter for probe requests the amount of activity becomes MUCH more sparse. Every now and then I'll pick something up, but I'm sitting here with like 5 phones, an iPad, Sonos, a couple computers, etc. and would think that I should be picking up a probe request every couple seconds / minutes.
I'm wondering if I'm jumping channels or calling the sniff method too fast or slow and I'm just missing them all? Is there something else that I may be doing wrong? Thanks in advance!
class Main():
while run:
logger.debug("Starting Sensor Run Loop.")
sniffer.stop()
hopper.stop()
time.sleep(2)
execute_command("wifi up")
time.sleep(10)
logger.debug("Do Internet Things.")
try:
logger.debug("Calling Saver.")
Saver.save()
logger.debug("Done with Saver.")
except e:
logger.error("There was a different error: %r" % e)
pass
start_monitor_mode()
time.sleep(2)
hopper_thread = Thread(target=hopper.start, name="hopper_thread")
hopper_thread.start()
sniffer_thread = Thread(target=sniffer.start, name="sniffer_thread")
sniffer_thread.start()
time.sleep(60*10)
class Sniffer(Thread):
def start(self):
self.run = True
logger.info("Starting Sniffer Loop.")
while self.run:
try:
sniff(iface=self.monitor, prn=self.process_packet, timeout=1)
logger.debug("Sniffing")
except:
e = sys.exc_info()[0]
logger.error(e)
time.sleep(2)
def process_packet(self, pkt):
logger.debug(str(pkt.addr2))
if pkt.haslayer(Dot11ProbeReq):
PacketQueue.add_packet(self._process_probe_request(pkt))
class Hopper(Thread):
def start(self):
logger.info("Starting Hopper Loop.")
self.run = True
max_channel = 11
while self.run:
try:
self.channel += 1
if self.channel > max_channel:
self.channel = 1
self.execute_command('iw ' + self.monitor + ' set self.channel ' + str(self.channel))
logger.debug("Channel: " + str(self.channel))
time.sleep(1)
except:
e = sys.exc_info()[0]
logger.error(e)