From f4fc57a407b18dee6c9ccfed27becdbfff5bef79 Mon Sep 17 00:00:00 2001 From: kimocoder Date: Mon, 26 Feb 2018 13:45:50 +0100 Subject: [PATCH] Add scan_time argument --- py/Arguments.py | 6 ++++++ py/Configuration.py | 5 +++++ py/Scanner.py | 10 +++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/py/Arguments.py b/py/Arguments.py index 609d0fe..6560793 100644 --- a/py/Arguments.py +++ b/py/Arguments.py @@ -17,6 +17,12 @@ class Arguments(object): # Global variables glob = parser.add_argument_group('SETTINGS') + glob.add_argument('-s', + action='store', + dest='scan_time', + metavar='[scantime]', + type=int, + help=Color.s('Scan time to (default: {G}ask{W})')) glob.add_argument('-i', action='store', dest='interface', diff --git a/py/Configuration.py b/py/Configuration.py index fc34585..b248e42 100644 --- a/py/Configuration.py +++ b/py/Configuration.py @@ -28,6 +28,8 @@ class Configuration(object): Configuration.verbose = 0 # Verbosity level. + Configuration.scan_time = 0 # Scan time + Configuration.tx_power = 0 # Wifi transmit power (0 is default) Configuration.interface = None Configuration.target_channel = None # User-defined channel to scan @@ -138,6 +140,9 @@ class Configuration(object): if args.target_essid: Configuration.target_essid = args.target_essid Color.pl('{+} {C}option:{W} targeting ESSID {G}%s{W}' % args.target_essid) + if args.scan_time: + Configuration.scan_time = args.scan_time + Color.pl('{+} {C}option:{W} scan time {G}%d{W}' % args.scan_time) if args.verbose: Configuration.verbose = args.verbose Color.pl('{+} {C}option:{W} verbosity level {G}%d{W}' % args.verbose) diff --git a/py/Scanner.py b/py/Scanner.py index 8ecd423..f64baae 100644 --- a/py/Scanner.py +++ b/py/Scanner.py @@ -6,7 +6,7 @@ from Color import Color from Target import Target from Configuration import Configuration -from time import sleep +from time import sleep, time class Scanner(object): ''' Scans wifi networks & provides menu for selecting targets ''' @@ -23,13 +23,15 @@ class Scanner(object): self.targets = [] self.target = None # Specific target (based on ESSID/BSSID) + scan_time = Configuration.scan_time # currently in seconds + Color.pl("") # Loads airodump with interface/channel/etc from Configuration with Airodump() as airodump: try: - # Loop until interrupted (Ctrl+C) + # Loop until interrupted (Ctrl+C) or until scan_time is reached (if scan_time was defined) + start_time = time() while True: - if airodump.pid.poll() is not None: # Airodump process died! raise Exception( @@ -63,6 +65,8 @@ class Scanner(object): outline += " {G}%s{W}) " % ", ".join([x.essid for x in decloaked]) Color.clear_entire_line() Color.p(outline) + if scan_time > 0 and time() > (start_time + scan_time): + return sleep(1) except KeyboardInterrupt: pass