Gracefully handle airodump crashing.

Apparently Airodump is capturing the SIGINT on some Ctrl+C presses.
Wifite will print out that airodump crashed w/ the return code & command executed.
Wifite will not change the list of targets if airodump crashes (to avoid wps:n/a).
This commit is contained in:
derv82
2018-02-27 04:54:15 -05:00
parent af5e3aaca9
commit a8f05d31d4
2 changed files with 20 additions and 9 deletions

View File

@@ -125,6 +125,7 @@ class Airodump(object):
def get_targets(self, apply_filter=True):
''' Parses airodump's CSV file, returns list of Targets '''
# Find the .CSV file
csv_filename = None
for fil in self.find_files(endswith='-01.csv'):
@@ -157,6 +158,9 @@ class Airodump(object):
# We decloaked a target!
self.decloaked_targets.append(new_target)
if self.pid.poll() is not None:
raise Exception('Airodump has stopped')
self.targets = targets
self.deauth_hidden_targets()

View File

@@ -23,19 +23,19 @@ class Scanner(object):
self.targets = []
self.target = None # Specific target (based on ESSID/BSSID)
self.err_msg = None
Color.pl("")
# Loads airodump with interface/channel/etc from Configuration
with Airodump() as airodump:
try:
with Airodump() as airodump:
# Loop until interrupted (Ctrl+C)
while True:
if airodump.pid.poll() is not None:
# Airodump process died!
raise Exception(
"Airodump exited unexpectedly! " +
"Command ran: %s"
% ' '.join(airodump.pid.command))
# Airodump process died
self.err_msg = '\r{!} {R}Airodump exited unexpectedly (Code: %d){O} Command: {W}%s' % (airodump.pid.poll(), " ".join(airodump.pid.command))
raise KeyboardInterrupt
self.targets = airodump.get_targets()
@@ -145,6 +145,9 @@ class Scanner(object):
''' Asks user to select target(s) '''
if len(self.targets) == 0:
if self.err_msg is not None:
Color.pl(self.err_msg)
# TODO Print a more-helpful reason for failure.
# 1. Link to wireless drivers wiki,
# 2. How to check if your device supporst monitor mode,
@@ -155,6 +158,10 @@ class Scanner(object):
self.print_targets()
Color.clear_entire_line()
if self.err_msg is not None:
Color.pl(self.err_msg)
input_str = '{+} select target(s)'
input_str += ' ({G}1-%d{W})' % len(self.targets)
input_str += ' separated by commas, dashes'