def process(self, event): #print "Path =", event.src_path #debug #print event.src_path, event.event_type #debug time.sleep(0.1) w_xml = xml_machine('%s' % event.src_path) crackable_list = w_xml.crackables() #print "crackable_list:", crackable_list #debug if crackable_list == '0': print "no luck buddy, keep trying" else: print "Potential target WIFI AP(s) detected..." for cracker in crackable_list: #print "cracker:", cracker #debug w_xml.parse_deets(cracker) print "BSSD!!!!!!!", w_xml.bssid #create/check list of APs that have already been cracked/timed-out and also add any manual exceptions #manual exceptions should be able to be cmd line variables ignore_aps = create_ignore_list() if w_xml.name != 'none': if w_xml.name not in ignore_aps: ##ignore this AP if w_xml.client_count != 0: #print "client_count:", deets["client_count"] #debug lat, lng, acc = geo_locate(w_xml.bssid, "0", "0") #power and snr to be added in future..... #print 'lat:', lat #print 'lng:', lng #print 'acc:', acc w_xml.geo_lat = lat w_xml.geo_long = lng w_xml.geo_accuracy = acc w_xml.xml_tree() w_xml.xml_write(target_dir+cracker+'.xml') else: print "No suitable WIFI AP(s) detected, continuing to scan..."
def create_ignore_list(): ignore_list = ['petonehappinessclub', ignore_arg] for ignore in glob.iglob(target_dir+"*.xml"): ignore_xml = xml_machine(ignore) ignore_xml.parse_deets() if str(ignore_xml.cracked) != 'False': ignore_list.append(ignore_xml.name) print "ignore_list:", ignore_list return ignore_list
def create_ignore_list(): ignore_list = ['petonehappinessclub', 'SETUP', ignore_arg] for ignore in glob.iglob(target_dir + "*.xml"): ignore_xml = xml_machine(ignore) ignore_xml.parse_deets() if str(ignore_xml.cracked) == 'True': ignore_list.append(ignore_xml.name) else: if per_arg == False: if str(ignore_xml.cracked) == 'Timeout': ignore_list.append(ignore_xml.name) #print "ignore_list:", ignore_list return ignore_list
def create_ignore_list(): ignore_list = ['petonehappinessclub', 'SETUP', ignore_arg] for ignore in glob.iglob(target_dir+"*.xml"): ignore_xml = xml_machine(ignore) ignore_xml.parse_deets() if str(ignore_xml.cracked) == 'True': ignore_list.append(ignore_xml.name) else: if per_arg == False: if str(ignore_xml.cracked) == 'Timeout': ignore_list.append(ignore_xml.name) #print "ignore_list:", ignore_list return ignore_list
def sort_by_power(location): #looks at folder of xmls and sorts APs based on "last_max_signal" RF power value sort_dict = {} for sort_me in glob.iglob(location): #print "file:", sort_me #debug sorted_xml = xml_machine(sort_me) sorted_xml.parse_deets() #print "name:", sorted_xml.name #debug #print "power:", sorted_xml.power sort_dict[sorted_xml.name] = str(sorted_xml.power) #print "sort_dict:", sort_dict #debug _sorted = sorted(sort_dict.items(), key=operator.itemgetter(1)) #print "sorted result:", _sorted #debug return _sorted
def tidy_targets(): if (tidy_arg != 'n'): print "Housekeeping...targets" files_targets = os.listdir(target_dir) for file in files_targets: remove_xml = xml_machine(target_dir + file) remove_xml.parse_deets() print "remove_xml.cracked:", remove_xml.cracked if str(remove_xml.cracked) in 'False': try: print "Removing target xml file:", (target_dir + file) os.remove(target_dir + file) except OSError: pass else: print "No housekeeping..."
def tidy_targets(): if (tidy_arg != 'n'): print "Housekeeping...targets" files_targets = os.listdir(target_dir) for file in files_targets: remove_xml = xml_machine(target_dir+file) remove_xml.parse_deets() print "remove_xml.cracked:", remove_xml.cracked if str(remove_xml.cracked) in 'False': try: print "Removing target xml file:", (target_dir+file) os.remove(target_dir+file) except OSError: pass else: print "No housekeeping..."
def process(self, event): #print event.src_path, event.event_type #debug w_xml = xml_machine('%s' % event.src_path) crackable_list = w_xml.crackables() #print("crackable_list:", crackable_list) #debug if crackable_list == '0': print "no luck buddy, keep trying" else: geo_list = [] for cracker in crackable_list: w_xml.parse_deets(cracker) geo_list.append(w_xml.bssid) #create/check list of APs that have already been cracked/timed-out and also add any manual exceptions #manual exceptions should be able to be cmd line variables ignore_aps = create_ignore_list() if w_xml.name != 'none': if w_xml.name not in ignore_aps: ##ignore this AP print "Potential target WIFI AP(s) detected..." if w_xml.client_count != 0: #geo_locate Wifi AP of interest. Requires at least two APs detected. #first, get another close WIFI AP if geo_arg != False: if len(geo_list) >= 2: get_index = geo_list.index(w_xml.bssid) if get_index == 0: closest_AP = geo_list[1] if get_index >= 1: closest_AP = geo_list[(get_index - 1)] print "OTHER AP:", closest_AP location_data = buildJson( w_xml.bssid, w_xml.power, w_xml.snr, closest_AP, 0, 0) print "LOCATION DATA", location_data lat, lng, acc = geolocate(location_data) w_xml.geo_lat = lat w_xml.geo_long = lng w_xml.geo_accuracy = acc w_xml.xml_tree() w_xml.xml_write(target_dir + cracker + '.xml') else: print "No WIFI AP clients detected, continuing to scan..."
def process(self, event): #print event.src_path, event.event_type #debug w_xml = xml_machine('%s' % event.src_path) crackable_list = w_xml.crackables() #print("crackable_list:", crackable_list) #debug if crackable_list == '0': print "no luck buddy, keep trying" else: geo_list = [] for cracker in crackable_list: w_xml.parse_deets(cracker) geo_list.append(w_xml.bssid) #create/check list of APs that have already been cracked/timed-out and also add any manual exceptions #manual exceptions should be able to be cmd line variables ignore_aps = create_ignore_list() if w_xml.name != 'none': if w_xml.name not in ignore_aps: ##ignore this AP print "Potential target WIFI AP(s) detected..." if w_xml.client_count != 0: #geo_locate Wifi AP of interest. Requires at least two APs detected. #first, get another close WIFI AP if geo_arg != False: if len(geo_list) >= 2: get_index = geo_list.index(w_xml.bssid) if get_index == 0: closest_AP = geo_list[1] if get_index >= 1: closest_AP = geo_list[(get_index-1)] print "OTHER AP:", closest_AP location_data = buildJson(w_xml.bssid, w_xml.power, w_xml.snr, closest_AP, 0, 0) print"LOCATION DATA", location_data lat, lng, acc = geolocate(location_data) w_xml.geo_lat = lat w_xml.geo_long = lng w_xml.geo_accuracy = acc w_xml.xml_tree() w_xml.xml_write(target_dir+cracker+'.xml') else: print "No WIFI AP clients detected, continuing to scan..."
def tidy(): #Housekeeping function to remove old files #check that command line arguments hasnt disabled tidy function (for dev/testing) if (tidy_arg != 'n'): print "Housekeeping..." files_xml = os.listdir(output_dir) print "removing existing xml files:", files_xml for file in files_xml: try: os.remove(output_dir+file) except OSError: pass files_targets = os.listdir(target_dir) for file in files_targets: #test for "self.cracked == False" remove_xml = xml_machine(target_dir+file) remove_xml.parse_deets() #print "remove_xml.cracked:", remove_xml.cracked #debug if str(remove_xml.cracked) == 'False': try: print "Removing target xml file:", (target_dir+file) os.remove(target_dir+file) except OSError: pass files_handshake = os.listdir(handshake_dir) for file in files_handshake: #test for filename without word "strip" in it file_string = str(file) strip_test = file_string.find("strip") if strip_test == -1: try: print "removing useless handshake file:", (handshake_dir+file) os.remove(handshake_dir+file) except OSError: pass else: print "No housekeeping..."
time_started = time.time() #print "time_started:%.0f" % time_started #debug print "Starting folder watchdog..." observer.start() while scanning == True: time.sleep(1) airodump_parent_conn.send(scanning) print "General scan now running for: %.0f seconds" % (time.time() - time_started) file_list = os.listdir(target_dir) if time.time() - time_started >= 60: print "Times up, aborting general scan..." scanning = False if file_list != []: #test for APs that havent previously been cracked/timed-out for _file in file_list: _xml = xml_machine(target_dir+_file) _xml.parse_deets() if str(_xml.cracked) == 'False': print "Targets detected, aborting general scan..." scanning = False break observer.stop() airodump_parent_conn.send(scanning) airodump_parent_conn.close() if file_list != []: #parse xml exported previously with target deets sort_list = sort_by_power(target_dir+"*.xml") #print "sort_list:", sort_list ignore_aps = create_ignore_list() print "Ignoring previously scanned networks:", ignore_aps scan_list = [x for x in sort_list if x not in ignore_aps]