def refresh_interface(self): variables.exec_command('killall airodump-ng') variables.exec_command('killall airmon-ng') self.animate_monitor_mode(True) self.mon_label.clear() self.interface_combo.clear() self.interface_combo.setEnabled(True) self.interface_cards = list() thread.start_new_thread(self.refresh_card_thread,())
def wep_attack_window(self): if 'WEP-DUMP' not in os.listdir('/tmp/fern-log'): os.mkdir('/tmp/fern-log/WEP-DUMP',0700) else: variables.exec_command('rm -r /tmp/fern-log/WEP-DUMP/*') wep_run = wep_attack_dialog() self.connect(wep_run,QtCore.SIGNAL('update database label'),self.update_database_label) self.connect(wep_run,QtCore.SIGNAL("stop scan"),self.stop_network_scan) wep_run.exec_()
def set_monitor_thread(self,monitor_card,mac_setting_exists,last_settings): self.killConflictProcesses() status = str(commands.getoutput("airmon-ng start %s"%(monitor_card))) messages = ("monitor mode enabled","monitor mode vif enabled","monitor mode already") monitor_created = False; for x in messages: if(x in status): monitor_created = True if (monitor_created): monitor_interface_process = str(commands.getoutput("airmon-ng")) regex = object() if ('monitor mode enabled' in status): regex = re.compile("mon\d",re.IGNORECASE) elif ('monitor mode vif enabled' in status): regex = re.compile("wlan\dmon",re.IGNORECASE) interfaces = regex.findall(monitor_interface_process) if(interfaces): self.monitor_interface = interfaces[0] else: self.monitor_interface = monitor_card variables.monitor_interface = self.monitor_interface self.interface_combo.setEnabled(False) variables.wps_functions.monitor_interface = self.monitor_interface self.emit(QtCore.SIGNAL("monitor mode enabled")) # Create Fake Mac Address and index for use mon_down = commands.getstatusoutput('ifconfig %s down'%(self.monitor_interface)) if mac_setting_exists: variables.exec_command('macchanger -m %s %s'%(last_settings,self.monitor_interface)) else: variables.exec_command('macchanger -A %s'%(self.monitor_interface)) mon_up = commands.getstatusoutput('ifconfig %s up'%(self.monitor_interface)) for iterate in os.listdir('/sys/class/net'): if str(iterate) == str(self.monitor_interface): os.chmod('/sys/class/net/' + self.monitor_interface + '/address',0777) variables.monitor_mac_address = reader('/sys/class/net/' + self.monitor_interface + '/address').strip() variables.wps_functions.monitor_mac_address = variables.monitor_mac_address else: self.emit(QtCore.SIGNAL("monitor_failed()"))
def scan_process2_thread(self): global error_catch if bool(variables.xterm_setting): wep_display_mode = 'xterm -T "FERN (WEP SCAN)" -geometry 100 -e' # if True or if xterm contains valid ascii characters else: wep_display_mode = '' error_catch = variables.exec_command("%s 'airodump-ng -a --write /tmp/fern-log/zfern-wep --output-format csv\ --encrypt wep %s'"%(wep_display_mode,self.monitor_interface)) #FOR WEP
def scan_process4_thread1(self): global error_catch if bool(variables.xterm_setting): # if True or if xterm contains valid ascii characters wpa_display_mode = 'xterm -T "FERN (WPA SCAN)" -geometry 100 -e' else: wpa_display_mode = '' error_catch = variables.exec_command("%s 'airodump-ng -a --channel %s --write /tmp/fern-log/WPA/zfern-wpa \ --output-format csv --encrypt wpa %s'"%(wpa_display_mode,variables.static_channel,self.monitor_interface))
def refresh_card_thread(self): # Disable cards already on monitor modes wireless_interfaces = str(commands.getstatusoutput('airmon-ng')) prev_monitor = os.listdir('/sys/class/net') monitor_interfaces_list = [] for monitors in prev_monitor: if monitors in wireless_interfaces: monitor_interfaces_list.append(monitors) for monitored_interfaces in monitor_interfaces_list: variables.exec_command('airmon-ng stop %s'%(monitored_interfaces)) # List Interface cards compatible_interface = str(commands.getoutput("airmon-ng | egrep -e '^[a-z]{2,4}[0-9]'")) interface_list = os.listdir('/sys/class/net') # Interate over interface output and update combo box if compatible_interface.count('\t') == 0: self.emit(QtCore.SIGNAL("interface cards not found")) else: for interface in interface_list: if interface in compatible_interface: if not interface.startswith('mon'): self.interface_cards.append(interface) self.emit(QtCore.SIGNAL("interface cards found"))
def stop_scan_network(self): global error_catch global scan_control scan_control = 1 variables.exec_command('rm -r /tmp/fern-log/*.cap') variables.exec_command('killall airodump-ng') variables.exec_command('killall airmon-ng') self.label_7.setText("<font Color=red>\t Stopped</font>") variables.wps_functions.stop_WPS_Scanning() # Stops WPS scanning self.wep_clientlabel.setText("None Detected") self.wpa_clientlabel.setText("None Detected") self.disconnect(self.scan_button,QtCore.SIGNAL("clicked()"),self.stop_scan_network) self.connect(self.scan_button,QtCore.SIGNAL("clicked()"),self.scan_network)
def scan_process3_thread1(self): global error_catch error_catch = variables.exec_command("airodump-ng --channel %s --write /tmp/fern-log/WPA/zfern-wpa \ --output-format csv --encrypt wpa %s"%(variables.static_channel,self.monitor_interface))# FOR WPA
def scan_process1_thread(self): global error_catch error_catch = variables.exec_command("airodump-ng --write /tmp/fern-log/zfern-wep --output-format csv \ --encrypt wep %s"%(self.monitor_interface)) #FOR WEP
def stop_network_scan(self): global scan_control scan_control = 1 variables.exec_command('killall airodump-ng') variables.exec_command('killall airmon-ng') self.label_7.setText("<font Color=red>\t Stopped</font>")
def stop_network_scan(self): global scan_control scan_control = 1 variables.exec_command('killall airodump-ng') variables.exec_command('killall airmon-ng') self.label_7.setText("<font Color=red>\t Stopped</font>")
def update_launcher(self): ''' Downloads and installs update files ''' global svn_access global file_total global files_downloaded global fern_directory file_total = int() files_downloaded = int() fern_directory = os.getcwd() update_directory = '/tmp/Fern-Wifi-Cracker/' try: online_response_check = urllib2.urlopen('https://raw.githubusercontent.com/savio-code/fern-wifi-cracker/master/Fern-Wifi-Cracker/version') online_response = online_response_check.read() online_files = re.compile('total_files = \d+',re.IGNORECASE) for online_file_total in online_response.splitlines(): if re.match(online_files,online_file_total): file_total = int(online_file_total.split()[2]) if 'Fern-Wifi-Cracker' in os.listdir('/tmp/'): variables.exec_command('rm -r /tmp/Fern-Wifi-Cracker') svn_access = subprocess.Popen('cd /tmp/ \n svn checkout https://github.com/savio-code/fern-wifi-cracker/trunk/Fern-Wifi-Cracker/',\ shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,stdin=subprocess.PIPE) svn_update = svn_access.stdout thread.start_new_thread(self.update_error,()) while True: response = svn_update.readline() if len(response) > 0: files_downloaded += 1 self.emit(QtCore.SIGNAL('file downloaded')) if str('revision') in str(response): self.emit(QtCore.SIGNAL("finished downloading")) # Delete all old files (*.py,*.py etc) except ".font_setting.dat" file for old_file in os.listdir(os.getcwd()): if os.path.isfile(os.getcwd() + os.sep + old_file) and old_file != '.font_settings.dat': os.remove(os.getcwd() + os.sep + old_file) # Delete all old directories except the "key-database" directory for old_directory in os.listdir(os.getcwd()): if os.path.isdir(os.getcwd() + os.sep + old_directory) and old_directory != 'key-database': shutil.rmtree(os.getcwd() + os.sep + old_directory) for update_file in os.listdir('/tmp/Fern-Wifi-Cracker'): # Copy New update files to working directory if os.path.isfile(update_directory + update_file): shutil.copyfile(update_directory + update_file,os.getcwd() + os.sep + update_file) else: shutil.copytree(update_directory + update_file,os.getcwd() + os.sep + update_file) for new_file in os.listdir(os.getcwd()): # chmod New files to allow permissions os.chmod(os.getcwd() + os.sep + new_file,0777) time.sleep(5) self.emit(QtCore.SIGNAL("restart application")) break if len(svn_failure_message) > 2: self.emit(QtCore.SIGNAL("download failed")) break except(urllib2.URLError,urllib2.HTTPError): self.emit(QtCore.SIGNAL("download failed"))
def update_launcher(self): ''' Downloads and installs update files ''' global svn_access global file_total global files_downloaded global fern_directory file_total = int() files_downloaded = int() fern_directory = os.getcwd() update_directory = '/tmp/Fern-Wifi-Cracker/' try: online_response_check = urllib2.urlopen('https://raw.githubusercontent.com/savio-code/fern-wifi-cracker/master/Fern-Wifi-Cracker/version') online_response = online_response_check.read() online_files = re.compile('total_files = \d+',re.IGNORECASE) for online_file_total in online_response.splitlines(): if re.match(online_files,online_file_total): file_total = int(online_file_total.split()[2]) if 'Fern-Wifi-Cracker' in os.listdir('/tmp/'): variables.exec_command('rm -r /tmp/Fern-Wifi-Cracker') svn_access = subprocess.Popen('cd /tmp/ \n svn checkout https://github.com/savio-code/fern-wifi-cracker/trunk/Fern-Wifi-Cracker/',\ shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,stdin=subprocess.PIPE) svn_update = svn_access.stdout thread.start_new_thread(self.update_error,()) while True: response = svn_update.readline() if len(response) > 0: files_downloaded += 1 self.emit(QtCore.SIGNAL('file downloaded')) if str('revision') in str(response): self.emit(QtCore.SIGNAL("finished downloading")) # Delete all old files (*.py,*.py etc) except ".font_setting.dat" file for old_file in os.listdir(os.getcwd()): if os.path.isfile(os.getcwd() + os.sep + old_file) and old_file != '.font_settings.dat': os.remove(os.getcwd() + os.sep + old_file) # Delete all old directories except the "key-database" directory for old_directory in os.listdir(os.getcwd()): if os.path.isdir(os.getcwd() + os.sep + old_directory) and old_directory != 'key-database': shutil.rmtree(os.getcwd() + os.sep + old_directory) for update_file in os.listdir('/tmp/Fern-Wifi-Cracker'): # Copy New update files to working directory if os.path.isfile(update_directory + update_file): shutil.copyfile(update_directory + update_file,os.getcwd() + os.sep + update_file) else: shutil.copytree(update_directory + update_file,os.getcwd() + os.sep + update_file) for new_file in os.listdir(os.getcwd()): # chmod New files to allow permissions os.chmod(os.getcwd() + os.sep + new_file,0777) time.sleep(5) self.emit(QtCore.SIGNAL("restart application")) break if len(svn_failure_message) > 2: self.emit(QtCore.SIGNAL("download failed")) break except(urllib2.URLError,urllib2.HTTPError): self.emit(QtCore.SIGNAL("download failed"))
def scan_wep(self): global xterm_setting variables.exec_command('rm -r /tmp/fern-log/*.csv') variables.exec_command('rm -r /tmp/fern-log/*.cap') variables.exec_command('rm -r /tmp/fern-log/WPA/*.csv') variables.exec_command('rm -r /tmp/fern-log/WPA/*.cap') # Channel desision block if scan_control == 0: if not variables.static_channel: if len(variables.xterm_setting) == 0: thread.start_new_thread(self.scan_process1_thread, ()) thread.start_new_thread(self.scan_process1_thread1, ()) else: thread.start_new_thread(self.scan_process2_thread, ()) thread.start_new_thread(self.scan_process2_thread1, ()) else: if len(variables.xterm_setting) == 0: thread.start_new_thread(self.scan_process3_thread, ()) thread.start_new_thread(self.scan_process3_thread1, ()) else: thread.start_new_thread(self.scan_process4_thread, ()) thread.start_new_thread(self.scan_process4_thread1, ()) time.sleep(5) if scan_control != 1: self.label_7.setText("<font Color=green>\t Active</font>") while scan_control != 1: try: time.sleep(2) wep_access_file = str(reader('/tmp/fern-log/zfern-wep-01.csv') ) # WEP access point log file wpa_access_file = str( reader('/tmp/fern-log/WPA/zfern-wpa-01.csv') ) # WPA access point log file wep_access_convert = wep_access_file[0:wep_access_file. index('Station MAC')] wep_access_process = wep_access_convert[wep_access_convert. index('Key'):-1] wep_access_process1 = wep_access_process.strip('Key\r\n') process = wep_access_process1.splitlines() # Display number of WEP access points detected self.wep_count = str(wep_access_file.count('WEP') / 2) # number of access points wep detected if int(self.wep_count) > 0: self.emit(QtCore.SIGNAL("wep_number_changed")) self.emit(QtCore.SIGNAL("wep_button_true")) else: self.emit(QtCore.SIGNAL("wep_button_false")) for iterate in range(len(process)): detail_process1 = process[iterate] wep_access = detail_process1.split(',') mac_address = wep_access[0].strip(' ') # Mac address channel = wep_access[3].strip(' ') # Channel speed = wep_access[4].strip(' ') # Speed power = wep_access[8].strip(' ') # Power access_point = wep_access[13].strip( ' ') # Access point Name if access_point not in wep_details.keys(): wep_details[access_point] = [ mac_address, channel, speed, power ] # WPA Access point sort starts here read_wpa = reader('/tmp/fern-log/WPA/zfern-wpa-01.csv') # Display number of WEP access points detected self.wpa_count = str(read_wpa.count( 'WPA')) # number of access points wep detected if int(self.wpa_count) == 0: self.emit(QtCore.SIGNAL("wpa_button_false")) elif int(self.wpa_count >= 1): self.emit(QtCore.SIGNAL("wpa_button_true")) self.emit(QtCore.SIGNAL("wpa_number_changed")) else: self.emit(QtCore.SIGNAL("wpa_button_false")) wpa_access_convert = wpa_access_file[0:wpa_access_file. index('Station MAC')] wpa_access_process = wpa_access_convert[wpa_access_convert. index('Key'):-1] wpa_access_process1 = wpa_access_process.strip('Key\r\n') process = wpa_access_process1.splitlines() for iterate in range(len(process)): detail_process1 = process[iterate] wpa_access = detail_process1.split(',') mac_address = wpa_access[0].strip(' ') # Mac address channel = wpa_access[3].strip(' ') # Channel speed = wpa_access[4].strip(' ') # Speed power = wpa_access[8].strip(' ') # Power access_point = wpa_access[13].strip( ' ') # Access point Name if access_point not in wpa_details.keys(): wpa_details[access_point] = [ mac_address, channel, speed, power ] except (ValueError, IndexError): pass
def scan_process3_thread1(self): global error_catch error_catch = variables.exec_command( "airodump-ng --channel %s --write /tmp/fern-log/WPA/zfern-wpa \ --output-format csv --encrypt wpa %s" % (variables.static_channel, self.monitor_interface)) # FOR WPA
def scan_process1_thread(self): global error_catch error_catch = variables.exec_command( "airodump-ng --write /tmp/fern-log/zfern-wep --output-format csv \ --encrypt wep %s" % (self.monitor_interface)) #FOR WEP
def scan_wep(self): global xterm_setting variables.exec_command('rm -r /tmp/fern-log/*.csv') variables.exec_command('rm -r /tmp/fern-log/*.cap') variables.exec_command('rm -r /tmp/fern-log/WPA/*.csv') variables.exec_command('rm -r /tmp/fern-log/WPA/*.cap') # Channel desision block if scan_control == 0: if not variables.static_channel: if len(variables.xterm_setting) == 0: thread.start_new_thread(self.scan_process1_thread,()) thread.start_new_thread(self.scan_process1_thread1,()) else: thread.start_new_thread(self.scan_process2_thread,()) thread.start_new_thread(self.scan_process2_thread1,()) else: if len(variables.xterm_setting) == 0: thread.start_new_thread(self.scan_process3_thread,()) thread.start_new_thread(self.scan_process3_thread1,()) else: thread.start_new_thread(self.scan_process4_thread,()) thread.start_new_thread(self.scan_process4_thread1,()) time.sleep(5) if scan_control != 1: self.label_7.setText("<font Color=green>\t Active</font>") while scan_control != 1: try: time.sleep(2) wep_access_file = str(reader('/tmp/fern-log/zfern-wep-01.csv')) # WEP access point log file wpa_access_file = str(reader('/tmp/fern-log/WPA/zfern-wpa-01.csv')) # WPA access point log file wep_access_convert = wep_access_file[0:wep_access_file.index('Station MAC')] wep_access_process = wep_access_convert[wep_access_convert.index('Key'):-1] wep_access_process1 = wep_access_process.strip('Key\r\n') process = wep_access_process1.splitlines() # Display number of WEP access points detected self.wep_count = str(wep_access_file.count('WEP')/2) # number of access points wep detected if int(self.wep_count) > 0: self.emit(QtCore.SIGNAL("wep_number_changed")) self.emit(QtCore.SIGNAL("wep_button_true")) else: self.emit(QtCore.SIGNAL("wep_button_false")) for iterate in range(len(process)): detail_process1 = process[iterate] wep_access = detail_process1.split(',') mac_address = wep_access[0].strip(' ') # Mac address channel = wep_access[3].strip(' ') # Channel speed = wep_access[4].strip(' ') # Speed power = wep_access[8].strip(' ') # Power access_point = wep_access[13].strip(' ') # Access point Name if access_point not in wep_details.keys(): wep_details[access_point] = [mac_address,channel,speed,power] # WPA Access point sort starts here read_wpa = reader('/tmp/fern-log/WPA/zfern-wpa-01.csv') # Display number of WEP access points detected self.wpa_count = str(read_wpa.count('WPA')) # number of access points wep detected if int(self.wpa_count) == 0: self.emit(QtCore.SIGNAL("wpa_button_false")) elif int(self.wpa_count >= 1): self.emit(QtCore.SIGNAL("wpa_button_true")) self.emit(QtCore.SIGNAL("wpa_number_changed")) else: self.emit(QtCore.SIGNAL("wpa_button_false")) wpa_access_convert = wpa_access_file[0:wpa_access_file.index('Station MAC')] wpa_access_process = wpa_access_convert[wpa_access_convert.index('Key'):-1] wpa_access_process1 = wpa_access_process.strip('Key\r\n') process = wpa_access_process1.splitlines() for iterate in range(len(process)): detail_process1 = process[iterate] wpa_access = detail_process1.split(',') mac_address = wpa_access[0].strip(' ') # Mac address channel = wpa_access[3].strip(' ') # Channel speed = wpa_access[4].strip(' ') # Speed power = wpa_access[8].strip(' ') # Power access_point = wpa_access[13].strip(' ') # Access point Name if access_point not in wpa_details.keys(): wpa_details[access_point] = [mac_address,channel,speed,power] except(ValueError,IndexError): pass
def set_monitor_thread(self, monitor_card, mac_setting_exists, last_settings): self.killConflictProcesses() commands.getstatusoutput( 'ifconfig %s down' % (self.monitor_interface) ) # Avoid this: "ioctl(SIOCSIWMODE) failed: Device or resource busy" status = str(commands.getoutput("airmon-ng start %s" % (monitor_card))) messages = ("monitor mode enabled", "monitor mode vif enabled", "monitor mode already") monitor_created = False for x in messages: if (x in status): monitor_created = True if (monitor_created): monitor_interface_process = str(commands.getoutput("airmon-ng")) regex = object() if ('monitor mode enabled' in status): regex = re.compile("mon\d", re.IGNORECASE) elif ('monitor mode vif enabled' in status): regex = re.compile("wlan\dmon", re.IGNORECASE) interfaces = regex.findall(monitor_interface_process) if (interfaces): self.monitor_interface = interfaces[0] else: self.monitor_interface = monitor_card variables.monitor_interface = self.monitor_interface self.interface_combo.setEnabled(False) variables.wps_functions.monitor_interface = self.monitor_interface self.emit(QtCore.SIGNAL("monitor mode enabled")) # Create Fake Mac Address and index for use mon_down = commands.getstatusoutput('ifconfig %s down' % (self.monitor_interface)) if mac_setting_exists: variables.exec_command('macchanger -m %s %s' % (last_settings, self.monitor_interface)) else: variables.exec_command('macchanger -A %s' % (self.monitor_interface)) #mon_up = commands.getstatusoutput('ifconfig %s up'%(self.monitor_interface)) # Lets leave interface down to avoid channel looping during channel specific attack commands.getstatusoutput('ifconfig %s down' % (self.monitor_interface)) for iterate in os.listdir('/sys/class/net'): if str(iterate) == str(self.monitor_interface): os.chmod( '/sys/class/net/' + self.monitor_interface + '/address', 0777) variables.monitor_mac_address = reader( '/sys/class/net/' + self.monitor_interface + '/address').strip() variables.wps_functions.monitor_mac_address = variables.monitor_mac_address else: self.emit(QtCore.SIGNAL("monitor_failed()"))