def start_sniffer(self, interface, hop_channels=True, fixed_channel=7): self.running_interface = interface try: card = NetworkCard(interface) if card.get_mode().lower() != 'monitor': card.set_mode('monitor') except: print "[-] Could not set card to monitor mode. Card might be busy." return for plugin in self.plugins: plugin.pre_scanning() self.sniffer_running = True self.sniffing_thread = Thread( target=self.sniff_packets) self.sniffing_thread.start() if hop_channels: hopper_thread = Thread( target=self.hop_channels) hopper_thread.start() else: try: card = NetworkCard(interface) card.set_channel(fixed_channel) if card.get_channel() == fixed_channel: print "[+] Set fixed channel to {}".format(fixed_channel) else: print "[-] Could not change channel, try unplugging your interface." print "[/] Channel is on {}".format(card.get_channel()) except: print "[-] Cannot set channel at the moment."
def hop_channels(self): # Hop through channels to get find more beacons try: card = NetworkCard(self.running_interface) while self.sniffer_running: current_channel = card.get_channel() if current_channel <= 12: card.set_channel(current_channel + 1) else: card.set_channel(1) sleep(1) except Exception as e: pass # The sniffer has already been aborted