Airodump uses static methods for parsing Targets
This commit is contained in:
@@ -81,7 +81,7 @@ class Airodump(object):
|
|||||||
if fil.startswith(self.output_file_prefix):
|
if fil.startswith(self.output_file_prefix):
|
||||||
os.remove(Configuration.temp() + fil)
|
os.remove(Configuration.temp() + fil)
|
||||||
|
|
||||||
def get_targets(self, wpa_wep_only=True):
|
def get_targets(self):
|
||||||
''' Parses airodump's CSV file, returns list of Targets '''
|
''' Parses airodump's CSV file, returns list of Targets '''
|
||||||
# Find the .CSV file
|
# Find the .CSV file
|
||||||
csv_filename = None
|
csv_filename = None
|
||||||
@@ -94,9 +94,28 @@ class Airodump(object):
|
|||||||
# No file found
|
# No file found
|
||||||
return self.targets
|
return self.targets
|
||||||
|
|
||||||
targets = []
|
|
||||||
|
|
||||||
# Parse the .CSV file
|
# Parse the .CSV file
|
||||||
|
targets = Airodump.get_targets_from_csv(csv_filename)
|
||||||
|
targets = Airodump.filter_targets(targets, wep=True, wpa=True, opn=False)
|
||||||
|
|
||||||
|
# Check targets for WPS
|
||||||
|
capfile = csv_filename[:-3] + 'cap'
|
||||||
|
Wash.check_for_wps_and_update_targets(capfile, targets)
|
||||||
|
|
||||||
|
# Sort by power
|
||||||
|
targets.sort(key=lambda x: x.power, reverse=True)
|
||||||
|
|
||||||
|
self.targets = targets
|
||||||
|
|
||||||
|
return self.targets
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_targets_from_csv(csv_filename):
|
||||||
|
'''
|
||||||
|
Returns list of Target objects parsed from CSV file
|
||||||
|
'''
|
||||||
|
targets = []
|
||||||
import csv
|
import csv
|
||||||
with open(csv_filename, 'rb') as csvopen:
|
with open(csv_filename, 'rb') as csvopen:
|
||||||
csv_reader = csv.reader(csvopen, delimiter=',')
|
csv_reader = csv.reader(csvopen, delimiter=',')
|
||||||
@@ -138,26 +157,21 @@ class Airodump(object):
|
|||||||
# Ignore empty/blank ESSIDs
|
# Ignore empty/blank ESSIDs
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if wpa_wep_only and 'WPA' not in target.encryption and 'WEP' not in target.encryption:
|
|
||||||
# Ignore non-WPA and non-WEP encrypted networks
|
|
||||||
continue
|
|
||||||
|
|
||||||
if self.encryption and self.encryption not in target.encryption:
|
|
||||||
# We're looking for a specific type of encryption
|
|
||||||
continue
|
|
||||||
|
|
||||||
targets.append(target)
|
targets.append(target)
|
||||||
|
return targets
|
||||||
|
|
||||||
# Check targets for WPS
|
@staticmethod
|
||||||
capfile = csv_filename[:-3] + 'cap'
|
def filter_targets(targets, wep=True, wpa=True, opn=False):
|
||||||
Wash.check_for_wps_and_update_targets(capfile, targets)
|
''' Filters targets based on encryption '''
|
||||||
|
result = []
|
||||||
# Sort by power
|
for target in targets:
|
||||||
targets.sort(key=lambda x: x.power, reverse=True)
|
if wep and 'WEP' in target.encryption:
|
||||||
|
result.append(target)
|
||||||
self.targets = targets
|
elif wpa and 'WPA' in target.encryption:
|
||||||
|
result.append(target)
|
||||||
return self.targets
|
elif opn and 'OPN' in target.encryption:
|
||||||
|
result.append(target)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user