def main(self, parent, iface, canvas, target): self.parent = parent # assign Wireless Interface self.iface = iface # assign scan target self.target = target # initiate a global variable networks to store obtained networks global networks networks = [] # Making sure that our wireless interface isn't down. try: os.system("sudo ifconfig %s up" % self.iface) except OSError: pass # Create the queue self.queue = Queue.Queue() # Set up Gui part self.gui = Gui(parent, self.queue, self.endApplication, canvas) self.running = True self.multiThreader() signal.signal(signal.SIGINT, self.stop_channel_hop) # Start the periodic call in the GUI to check the queue self.periodicCall()
class ThreadedClient(object): #def __init__(self, parent, iface, canvas, target): def main(self, parent, iface, canvas, target): self.parent = parent # assign Wireless Interface self.iface = iface # assign scan target self.target = target # initiate a global variable networks to store obtained networks global networks networks = [] # Making sure that our wireless interface isn't down. try: os.system("sudo ifconfig %s up" % self.iface) except OSError: pass # Create the queue self.queue = Queue.Queue() # Set up Gui part self.gui = Gui(parent, self.queue, self.endApplication, canvas) self.running = True self.multiThreader() signal.signal(signal.SIGINT, self.stop_channel_hop) # Start the periodic call in the GUI to check the queue self.periodicCall() def multiThreader(self): # start a thread to run sniffer self.thread1 = threading.Thread(target=self.workerThread1) self.thread1.start() # start a thread to run channel hopper self.thread2 = threading.Thread(target=self.channel_hopper, args=(self.iface,)) self.thread2.start() def periodicCall(self): """ Check every 200 ms if there is something new in the queue. """ self.parent.after(200, self.periodicCall) self.gui.processIncoming() if not self.running: try: self.thread1.join() self.thread2.join() except e: print e def workerThread1(self): while self.running: t = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) #print "Sniffer started at: %s" %t scan = WifiScanner(self.queue, self.iface, self.target) def endApplication(self): self.running = False t = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) print "Sniffer stopped at: %s" %t def channel_hopper(self, iface): while self.running: try: channel = random.randrange(1,13) os.system("sudo iwconfig %s channel %d" % (iface, channel)) time.sleep(1.5) except KeyboardInterrupt: break def stop_channel_hop(self, signal, frame): # calls endApplication function self.endApplication()
class ThreadedClient(object): #def __init__(self, parent, iface, canvas, target): def main(self, parent, iface, canvas, target): self.parent = parent # assign Wireless Interface self.iface = iface # assign scan target self.target = target # initiate a global variable networks to store obtained networks global networks networks = [] # Making sure that our wireless interface isn't down. try: os.system("sudo ifconfig %s up" % self.iface) except OSError: pass # Create the queue self.queue = Queue.Queue() # Set up Gui part self.gui = Gui(parent, self.queue, self.endApplication, canvas) self.running = True self.multiThreader() signal.signal(signal.SIGINT, self.stop_channel_hop) # Start the periodic call in the GUI to check the queue self.periodicCall() def multiThreader(self): # start a thread to run sniffer self.thread1 = threading.Thread(target=self.workerThread1) self.thread1.start() # start a thread to run channel hopper self.thread2 = threading.Thread(target=self.channel_hopper, args=(self.iface, )) self.thread2.start() def periodicCall(self): """ Check every 200 ms if there is something new in the queue. """ self.parent.after(200, self.periodicCall) self.gui.processIncoming() if not self.running: try: self.thread1.join() self.thread2.join() except e: print e def workerThread1(self): while self.running: t = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) #print "Sniffer started at: %s" %t scan = WifiScanner(self.queue, self.iface, self.target) def endApplication(self): self.running = False t = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) print "Sniffer stopped at: %s" % t def channel_hopper(self, iface): while self.running: try: channel = random.randrange(1, 13) os.system("sudo iwconfig %s channel %d" % (iface, channel)) time.sleep(1.5) except KeyboardInterrupt: break def stop_channel_hop(self, signal, frame): # calls endApplication function self.endApplication()