diff --git a/Fern-Wifi-Cracker/core/fern.py b/Fern-Wifi-Cracker/core/fern.py index c3a5a48..63f792f 100644 --- a/Fern-Wifi-Cracker/core/fern.py +++ b/Fern-Wifi-Cracker/core/fern.py @@ -7,6 +7,7 @@ import sqlite3 import subprocess from urllib import request +from xml.etree import ElementTree from core import variables from PyQt5 import QtCore, QtGui, QtWidgets @@ -21,7 +22,7 @@ from gui.main_window import * -__version__ = 3.11 +__version__ = 3.12 # @@ -686,92 +687,61 @@ def wpa_button_false(self): ################### 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 + error_catch = variables.exec_command("airodump-ng --write /tmp/fern-log/zfern --output-format netxml \ + %s" % (self.monitor_interface)) # FOR WEP - def scan_process1_thread1(self): - global error_catch - error_catch = variables.exec_command("airodump-ng --write /tmp/fern-log/WPA/zfern-wpa --output-format csv \ - --encrypt wpa %s" % (self.monitor_interface)) # FOR WPA ################### 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 + display_mode = 'xterm -T "FERN (SCAN)" -geometry 100 -e' # if True or if xterm contains valid ascii characters else: - wep_display_mode = '' + 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 + error_catch = variables.exec_command("%s 'airodump-ng -a --write /tmp/fern-log/zfern --output-format netxml\ + %s'" % (display_mode, self.monitor_interface)) # FOR WEP - def scan_process2_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 --write /tmp/fern-log/WPA/zfern-wpa \ - --output-format csv --encrypt wpa %s'" % ( - wpa_display_mode, self.monitor_interface)) # FOR WPA ########################### def scan_process3_thread(self): global error_catch - error_catch = variables.exec_command("airodump-ng --channel %s --write /tmp/fern-log/zfern-wep \ - --output-format csv --encrypt wep %s" % ( - variables.static_channel, self.monitor_interface)) # FOR WEP - - 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 + error_catch = variables.exec_command("airodump-ng --channel %s --write /tmp/fern-log/zfern \ + --output-format netxml %s" % ( + variables.static_channel, self.monitor_interface)) ####################### def scan_process4_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 + display_mode = 'xterm -T "FERN (SCAN)" -geometry 100 -e' # if True or if xterm contains valid ascii characters else: - wep_display_mode = '' + display_mode = '' - error_catch = variables.exec_command("%s 'airodump-ng -a --channel %s --write /tmp/fern-log/zfern-wep \ - --output-format csv --encrypt wep %s'" % ( - wep_display_mode, variables.static_channel, self.monitor_interface)) # FOR WEP + error_catch = variables.exec_command("%s 'airodump-ng -a --channel %s --write /tmp/fern-log/zfern \ + --output-format netxml %s'" % ( + display_mode, variables.static_channel, self.monitor_interface)) - 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 scan_wep(self): global xterm_setting - variables.exec_command('rm -r /tmp/fern-log/*.csv') + variables.exec_command('rm -r /tmp/fern-log/*.netxml') 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/*.netxml') 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: threading.Thread(target=self.scan_process1_thread).start() - threading.Thread(target=self.scan_process1_thread1).start() else: threading.Thread(target=self.scan_process2_thread).start() - threading.Thread(target=self.scan_process2_thread1).start() else: if len(variables.xterm_setting) == 0: threading.Thread(target=self.scan_process3_thread).start() - threading.Thread(target=self.scan_process3_thread1).start() else: threading.Thread(target=self.scan_process4_thread).start() threading.Thread(target=self.scan_process4_thread1).start() @@ -784,22 +754,36 @@ def scan_wep(self): 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 + scan_tree = ElementTree.parse('/tmp/fern-log/zfern-01.kismet.netxml').getroot() # + + for access_point_info in scan_tree: + ssid_info = access_point_info.find("SSID") + is_essid_hidden = ssid_info.find("essid").attrib['cloaked'] + + if is_essid_hidden == "false": + + # is_beacon = ssid_info.find("type").text == "Beacon" + access_point = ssid_info.find("essid").text + encryption = ssid_info.find("encryption").text + + mac_address = access_point_info.find("BSSID").text + channel = access_point_info.find("channel").text + power = access_point_info.find("snr-info").find("last_signal_dbm").text + speed = access_point_info.find("maxseenrate").text + if speed: + speed = "%d" % (int(speed) / 1000) - 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() + if str(encryption).upper().startswith("WPA"): + if access_point not in wpa_details.keys(): + self.wpa_count += 1 + wpa_details[access_point] = [mac_address, channel, speed, power] - # Display number of WEP access points detected - wep_devices = 0; - for line in wpa_access_file.splitlines(): - if "WEP" in line: - wep_devices += 1 + if str(encryption).upper().startswith("WEP"): + if access_point not in wep_details.keys(): + self.wep_count += 1 + wep_details[access_point] = [mac_address, channel, speed, power] - self.wep_count = str(wep_devices) # number of access points wep detected if int(self.wep_count) > 0: self.wep_number_changed_signal.emit() @@ -807,61 +791,15 @@ def scan_wep(self): else: self.wep_button_false_signal.emit() - 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 - - # Display number of WEP access points detected - self.wpa_count = str(wpa_access_file.count('WPA')) # number of access points wep detected - - wpa_devices = 0; - for line in wpa_access_file.splitlines(): - if "WPA" in line or "WPA2" in line: - wpa_devices += 1 - - self.wpa_count = str(wpa_devices) - - - if int(self.wpa_count) == 0: - self.wpa_button_false_signal.emit() - elif int(self.wpa_count) >= 1: + if int(self.wpa_count) > 0: self.wpa_button_true_signal.emit() self.wpa_number_changed_signal.emit() else: self.wpa_button_false_signal.emit() - 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 + except Exception as e: + print("Error occurred during scan: ", e) def showEvent(self, event): self.timer.start() diff --git a/Fern-Wifi-Cracker/core/variables.py b/Fern-Wifi-Cracker/core/variables.py index 40a329a..eb88d18 100644 --- a/Fern-Wifi-Cracker/core/variables.py +++ b/Fern-Wifi-Cracker/core/variables.py @@ -55,15 +55,15 @@ log_direc = 'fern-log' tmp_direc = os.listdir(direc) # list/tmp/ directory = os.getcwd() +temp_log_path = direc + log_direc # # Create temporary log directory # -if 'fern-log' in tmp_direc: - shutil.rmtree(direc + log_direc,ignore_errors=True) # Delete directory in /fern-log if it already exists in /tmp/ - os.mkdir(direc + log_direc) -else: - os.mkdir(direc + log_direc) # Create /tmp/fern-log/ +if os.path.exists(temp_log_path): + shutil.rmtree(temp_log_path,ignore_errors=True) # Delete directory in /fern-log if it already exists in /tmp/ + +os.mkdir(temp_log_path) # Create /tmp/fern-log/ # # Create Sub Temporary directory in /tmp/fern-log diff --git a/Fern-Wifi-Cracker/core/wpa.py b/Fern-Wifi-Cracker/core/wpa.py index 7b8ec9a..8fbf1c3 100644 --- a/Fern-Wifi-Cracker/core/wpa.py +++ b/Fern-Wifi-Cracker/core/wpa.py @@ -2,6 +2,7 @@ import time import subprocess import threading +from xml.etree import ElementTree from core.fern import * from gui.attack_panel import * from core.functions import * @@ -516,18 +517,23 @@ def auto_add_clients(self): def probe_for_Client_Mac(self): variables.exec_command("airodump-ng -a --channel %s --write /tmp/fern-log/WPA/zfern-wpa \ - --output-format csv --encrypt wpa %s"%(variables.victim_channel,variables.monitor_interface)) + --output-format netxml --encrypt wpa %s"%(variables.victim_channel,variables.monitor_interface)) def client_update(self): - wpa_clients_str = reader('/tmp/fern-log/WPA/zfern-wpa-01.csv') - wpa_clients_sort = wpa_clients_str[wpa_clients_str.index('Probed ESSIDs'):-1] + try: + wpa_tree = ElementTree.parse('/tmp/fern-log/WPA/zfern-wpa-01.kismet.netxml').getroot() + + for access_point_info in wpa_tree: + bssid = access_point_info.find("BSSID").text + for client in access_point_info.iter("wireless-client"): + client_mac = client.find("client-mac").text + + if bssid == variables.victim_mac: + self.client_list.append(client_mac) + except Exception: + pass - for line in wpa_clients_sort.splitlines(): - result = re.findall("(([0-9A-F]{2}:){5}[0-9A-F]{2})",line) - if(len(result) == 2): - if(result[1][0] == variables.victim_mac): - self.client_list.append(result[0][0]) def launch_brutefore(self): @@ -764,19 +770,19 @@ def find_dictionary_length(self,filename): self.progress_bar_max = line_count(filename) self.wordlist_lines_counted_signal.emit(filename) - def set_progress_bar(self,filename): int_max = 2147483630 # Avoid a C based interger overflow - if(self.progress_bar_max > int_max): + if self.progress_bar_max > int_max: self.progress_bar_max = int_max self.progressBar.setMaximum(self.progress_bar_max) - self.settings.create_settings(filename,str(self.progress_bar_max)) + self.settings.create_settings(filename, str(self.progress_bar_max)) def dictionary_setting(self): filename = QtWidgets.QFileDialog.getOpenFileName(self,"Select Wordlist","")[0] if(filename): + self.settings.create_settings("wordlist",filename) get_temp_name = self.settings.read_last_settings("wordlist") diff --git a/Fern-Wifi-Cracker/version b/Fern-Wifi-Cracker/version index a19e934..57dddf2 100644 --- a/Fern-Wifi-Cracker/version +++ b/Fern-Wifi-Cracker/version @@ -1,2 +1,2 @@ -version = 3.11 +version = 3.12 total_files = 81