Add scan_time argument
This commit is contained in:
@@ -17,6 +17,12 @@ class Arguments(object):
|
|||||||
|
|
||||||
# Global variables
|
# Global variables
|
||||||
glob = parser.add_argument_group('SETTINGS')
|
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',
|
glob.add_argument('-i',
|
||||||
action='store',
|
action='store',
|
||||||
dest='interface',
|
dest='interface',
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ class Configuration(object):
|
|||||||
|
|
||||||
Configuration.verbose = 0 # Verbosity level.
|
Configuration.verbose = 0 # Verbosity level.
|
||||||
|
|
||||||
|
Configuration.scan_time = 0 # Scan time
|
||||||
|
|
||||||
Configuration.tx_power = 0 # Wifi transmit power (0 is default)
|
Configuration.tx_power = 0 # Wifi transmit power (0 is default)
|
||||||
Configuration.interface = None
|
Configuration.interface = None
|
||||||
Configuration.target_channel = None # User-defined channel to scan
|
Configuration.target_channel = None # User-defined channel to scan
|
||||||
@@ -138,6 +140,9 @@ class Configuration(object):
|
|||||||
if args.target_essid:
|
if args.target_essid:
|
||||||
Configuration.target_essid = args.target_essid
|
Configuration.target_essid = args.target_essid
|
||||||
Color.pl('{+} {C}option:{W} targeting ESSID {G}%s{W}' % 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:
|
if args.verbose:
|
||||||
Configuration.verbose = args.verbose
|
Configuration.verbose = args.verbose
|
||||||
Color.pl('{+} {C}option:{W} verbosity level {G}%d{W}' % args.verbose)
|
Color.pl('{+} {C}option:{W} verbosity level {G}%d{W}' % args.verbose)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from Color import Color
|
|||||||
from Target import Target
|
from Target import Target
|
||||||
from Configuration import Configuration
|
from Configuration import Configuration
|
||||||
|
|
||||||
from time import sleep
|
from time import sleep, time
|
||||||
|
|
||||||
class Scanner(object):
|
class Scanner(object):
|
||||||
''' Scans wifi networks & provides menu for selecting targets '''
|
''' Scans wifi networks & provides menu for selecting targets '''
|
||||||
@@ -23,13 +23,15 @@ class Scanner(object):
|
|||||||
self.targets = []
|
self.targets = []
|
||||||
self.target = None # Specific target (based on ESSID/BSSID)
|
self.target = None # Specific target (based on ESSID/BSSID)
|
||||||
|
|
||||||
|
scan_time = Configuration.scan_time # currently in seconds
|
||||||
|
|
||||||
Color.pl("")
|
Color.pl("")
|
||||||
# Loads airodump with interface/channel/etc from Configuration
|
# Loads airodump with interface/channel/etc from Configuration
|
||||||
with Airodump() as airodump:
|
with Airodump() as airodump:
|
||||||
try:
|
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:
|
while True:
|
||||||
|
|
||||||
if airodump.pid.poll() is not None:
|
if airodump.pid.poll() is not None:
|
||||||
# Airodump process died!
|
# Airodump process died!
|
||||||
raise Exception(
|
raise Exception(
|
||||||
@@ -63,6 +65,8 @@ class Scanner(object):
|
|||||||
outline += " {G}%s{W}) " % ", ".join([x.essid for x in decloaked])
|
outline += " {G}%s{W}) " % ", ".join([x.essid for x in decloaked])
|
||||||
Color.clear_entire_line()
|
Color.clear_entire_line()
|
||||||
Color.p(outline)
|
Color.p(outline)
|
||||||
|
if scan_time > 0 and time() > (start_time + scan_time):
|
||||||
|
return
|
||||||
sleep(1)
|
sleep(1)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user