Skip to content

Commit 0da03ab

Browse files
committed
Fixed bug that prevents program from displaying networks while scannning and other issues
1 parent 781f914 commit 0da03ab

File tree

4 files changed

+71
-127
lines changed

4 files changed

+71
-127
lines changed

Fern-Wifi-Cracker/core/fern.py

Lines changed: 48 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import sqlite3
88
import subprocess
99
from urllib import request
10+
from xml.etree import ElementTree
1011

1112
from core import variables
1213
from PyQt5 import QtCore, QtGui, QtWidgets
@@ -21,7 +22,7 @@
2122

2223
from gui.main_window import *
2324

24-
__version__ = 3.11
25+
__version__ = 3.12
2526

2627

2728
#
@@ -686,92 +687,61 @@ def wpa_button_false(self):
686687
###################
687688
def scan_process1_thread(self):
688689
global error_catch
689-
error_catch = variables.exec_command("airodump-ng --write /tmp/fern-log/zfern-wep --output-format csv \
690-
--encrypt wep %s" % (self.monitor_interface)) # FOR WEP
690+
error_catch = variables.exec_command("airodump-ng --write /tmp/fern-log/zfern --output-format netxml \
691+
%s" % (self.monitor_interface)) # FOR WEP
691692

692-
def scan_process1_thread1(self):
693-
global error_catch
694-
error_catch = variables.exec_command("airodump-ng --write /tmp/fern-log/WPA/zfern-wpa --output-format csv \
695-
--encrypt wpa %s" % (self.monitor_interface)) # FOR WPA
696693

697694
###################
698695
def scan_process2_thread(self):
699696
global error_catch
700697
if bool(variables.xterm_setting):
701-
wep_display_mode = 'xterm -T "FERN (WEP SCAN)" -geometry 100 -e' # if True or if xterm contains valid ascii characters
698+
display_mode = 'xterm -T "FERN (SCAN)" -geometry 100 -e' # if True or if xterm contains valid ascii characters
702699
else:
703-
wep_display_mode = ''
700+
display_mode = ''
704701

705-
error_catch = variables.exec_command("%s 'airodump-ng -a --write /tmp/fern-log/zfern-wep --output-format csv\
706-
--encrypt wep %s'" % (wep_display_mode, self.monitor_interface)) # FOR WEP
702+
error_catch = variables.exec_command("%s 'airodump-ng -a --write /tmp/fern-log/zfern --output-format netxml\
703+
%s'" % (display_mode, self.monitor_interface)) # FOR WEP
707704

708-
def scan_process2_thread1(self):
709-
global error_catch
710-
if bool(variables.xterm_setting): # if True or if xterm contains valid ascii characters
711-
wpa_display_mode = 'xterm -T "FERN (WPA SCAN)" -geometry 100 -e'
712-
else:
713-
wpa_display_mode = ''
714705

715-
error_catch = variables.exec_command("%s 'airodump-ng -a --write /tmp/fern-log/WPA/zfern-wpa \
716-
--output-format csv --encrypt wpa %s'" % (
717-
wpa_display_mode, self.monitor_interface)) # FOR WPA
718706

719707
###########################
720708
def scan_process3_thread(self):
721709
global error_catch
722-
error_catch = variables.exec_command("airodump-ng --channel %s --write /tmp/fern-log/zfern-wep \
723-
--output-format csv --encrypt wep %s" % (
724-
variables.static_channel, self.monitor_interface)) # FOR WEP
725-
726-
def scan_process3_thread1(self):
727-
global error_catch
728-
error_catch = variables.exec_command("airodump-ng --channel %s --write /tmp/fern-log/WPA/zfern-wpa \
729-
--output-format csv --encrypt wpa %s" % (
730-
variables.static_channel, self.monitor_interface)) # FOR WPA
710+
error_catch = variables.exec_command("airodump-ng --channel %s --write /tmp/fern-log/zfern \
711+
--output-format netxml %s" % (
712+
variables.static_channel, self.monitor_interface))
731713

732714
#######################
733715
def scan_process4_thread(self):
734716
global error_catch
735717
if bool(variables.xterm_setting):
736-
wep_display_mode = 'xterm -T "FERN (WEP SCAN)" -geometry 100 -e' # if True or if xterm contains valid ascii characters
718+
display_mode = 'xterm -T "FERN (SCAN)" -geometry 100 -e' # if True or if xterm contains valid ascii characters
737719
else:
738-
wep_display_mode = ''
720+
display_mode = ''
739721

740-
error_catch = variables.exec_command("%s 'airodump-ng -a --channel %s --write /tmp/fern-log/zfern-wep \
741-
--output-format csv --encrypt wep %s'" % (
742-
wep_display_mode, variables.static_channel, self.monitor_interface)) # FOR WEP
722+
error_catch = variables.exec_command("%s 'airodump-ng -a --channel %s --write /tmp/fern-log/zfern \
723+
--output-format netxml %s'" % (
724+
display_mode, variables.static_channel, self.monitor_interface))
743725

744-
def scan_process4_thread1(self):
745-
global error_catch
746-
if bool(variables.xterm_setting): # if True or if xterm contains valid ascii characters
747-
wpa_display_mode = 'xterm -T "FERN (WPA SCAN)" -geometry 100 -e'
748-
else:
749-
wpa_display_mode = ''
750-
751-
error_catch = variables.exec_command("%s 'airodump-ng -a --channel %s --write /tmp/fern-log/WPA/zfern-wpa \
752-
--output-format csv --encrypt wpa %s'" % (
753-
wpa_display_mode, variables.static_channel, self.monitor_interface))
754726

755727
def scan_wep(self):
756728
global xterm_setting
757-
variables.exec_command('rm -r /tmp/fern-log/*.csv')
729+
variables.exec_command('rm -r /tmp/fern-log/*.netxml')
758730
variables.exec_command('rm -r /tmp/fern-log/*.cap')
759-
variables.exec_command('rm -r /tmp/fern-log/WPA/*.csv')
731+
variables.exec_command('rm -r /tmp/fern-log/WPA/*.netxml')
760732
variables.exec_command('rm -r /tmp/fern-log/WPA/*.cap')
761733

734+
762735
# Channel desision block
763736
if scan_control == 0:
764737
if not variables.static_channel:
765738
if len(variables.xterm_setting) == 0:
766739
threading.Thread(target=self.scan_process1_thread).start()
767-
threading.Thread(target=self.scan_process1_thread1).start()
768740
else:
769741
threading.Thread(target=self.scan_process2_thread).start()
770-
threading.Thread(target=self.scan_process2_thread1).start()
771742
else:
772743
if len(variables.xterm_setting) == 0:
773744
threading.Thread(target=self.scan_process3_thread).start()
774-
threading.Thread(target=self.scan_process3_thread1).start()
775745
else:
776746
threading.Thread(target=self.scan_process4_thread).start()
777747
threading.Thread(target=self.scan_process4_thread1).start()
@@ -784,84 +754,52 @@ def scan_wep(self):
784754
try:
785755
time.sleep(2)
786756

787-
wep_access_file = str(reader('/tmp/fern-log/zfern-wep-01.csv')) # WEP access point log file
788-
wpa_access_file = str(reader('/tmp/fern-log/WPA/zfern-wpa-01.csv')) # WPA access point log file
757+
scan_tree = ElementTree.parse('/tmp/fern-log/zfern-01.kismet.netxml').getroot() #
758+
759+
for access_point_info in scan_tree:
760+
ssid_info = access_point_info.find("SSID")
761+
is_essid_hidden = ssid_info.find("essid").attrib['cloaked']
762+
763+
if is_essid_hidden == "false":
764+
765+
# is_beacon = ssid_info.find("type").text == "Beacon"
766+
access_point = ssid_info.find("essid").text
767+
encryption = ssid_info.find("encryption").text
768+
769+
mac_address = access_point_info.find("BSSID").text
770+
channel = access_point_info.find("channel").text
771+
power = access_point_info.find("snr-info").find("last_signal_dbm").text
772+
speed = access_point_info.find("maxseenrate").text
789773

774+
if speed:
775+
speed = "%d" % (int(speed) / 1000)
790776

791-
wep_access_convert = wep_access_file[0:wep_access_file.index('Station MAC')]
792-
wep_access_process = wep_access_convert[wep_access_convert.index('Key'):-1]
793-
wep_access_process1 = wep_access_process.strip('Key\r\n')
794-
process = wep_access_process1.splitlines()
777+
if str(encryption).upper().startswith("WPA"):
778+
if access_point not in wpa_details.keys():
779+
self.wpa_count += 1
780+
wpa_details[access_point] = [mac_address, channel, speed, power]
795781

796-
# Display number of WEP access points detected
797-
wep_devices = 0;
798-
for line in wpa_access_file.splitlines():
799-
if "WEP" in line:
800-
wep_devices += 1
782+
if str(encryption).upper().startswith("WEP"):
783+
if access_point not in wep_details.keys():
784+
self.wep_count += 1
785+
wep_details[access_point] = [mac_address, channel, speed, power]
801786

802-
self.wep_count = str(wep_devices) # number of access points wep detected
803787

804788
if int(self.wep_count) > 0:
805789
self.wep_number_changed_signal.emit()
806790
self.wep_button_true_signal.emit()
807791
else:
808792
self.wep_button_false_signal.emit()
809793

810-
for iterate in range(len(process)):
811-
detail_process1 = process[iterate]
812-
wep_access = detail_process1.split(',')
813-
814-
mac_address = wep_access[0].strip(' ') # Mac address
815-
channel = wep_access[3].strip(' ') # Channel
816-
speed = wep_access[4].strip(' ') # Speed
817-
power = wep_access[8].strip(' ') # Power
818-
access_point = wep_access[13].strip(' ') # Access point Name
819-
820-
if access_point not in wep_details.keys():
821-
wep_details[access_point] = [mac_address, channel, speed, power]
822-
823-
# WPA Access point sort starts here
824-
825-
# Display number of WEP access points detected
826-
self.wpa_count = str(wpa_access_file.count('WPA')) # number of access points wep detected
827-
828-
wpa_devices = 0;
829-
for line in wpa_access_file.splitlines():
830-
if "WPA" in line or "WPA2" in line:
831-
wpa_devices += 1
832-
833-
self.wpa_count = str(wpa_devices)
834-
835-
836-
if int(self.wpa_count) == 0:
837-
self.wpa_button_false_signal.emit()
838-
elif int(self.wpa_count) >= 1:
794+
if int(self.wpa_count) > 0:
839795
self.wpa_button_true_signal.emit()
840796
self.wpa_number_changed_signal.emit()
841797
else:
842798
self.wpa_button_false_signal.emit()
843799

844-
wpa_access_convert = wpa_access_file[0:wpa_access_file.index('Station MAC')]
845-
wpa_access_process = wpa_access_convert[wpa_access_convert.index('Key'):-1]
846-
wpa_access_process1 = wpa_access_process.strip('Key\r\n')
847-
process = wpa_access_process1.splitlines()
848-
849-
for iterate in range(len(process)):
850-
detail_process1 = process[iterate]
851-
wpa_access = detail_process1.split(',')
852-
853-
mac_address = wpa_access[0].strip(' ') # Mac address
854-
channel = wpa_access[3].strip(' ') # Channel
855-
speed = wpa_access[4].strip(' ') # Speed
856-
power = wpa_access[8].strip(' ') # Power
857-
access_point = wpa_access[13].strip(' ') # Access point Name
858-
859-
if access_point not in wpa_details.keys():
860-
wpa_details[access_point] = [mac_address, channel, speed, power]
861-
862800

863-
except(ValueError, IndexError):
864-
pass
801+
except Exception as e:
802+
print("Error occurred during scan: ", e)
865803

866804
def showEvent(self, event):
867805
self.timer.start()

Fern-Wifi-Cracker/core/variables.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@
5555
log_direc = 'fern-log'
5656
tmp_direc = os.listdir(direc) # list/tmp/
5757
directory = os.getcwd()
58+
temp_log_path = direc + log_direc
5859

5960
#
6061
# Create temporary log directory
6162
#
62-
if 'fern-log' in tmp_direc:
63-
shutil.rmtree(direc + log_direc,ignore_errors=True) # Delete directory in /fern-log if it already exists in /tmp/
64-
os.mkdir(direc + log_direc)
65-
else:
66-
os.mkdir(direc + log_direc) # Create /tmp/fern-log/
63+
if os.path.exists(temp_log_path):
64+
shutil.rmtree(temp_log_path,ignore_errors=True) # Delete directory in /fern-log if it already exists in /tmp/
65+
66+
os.mkdir(temp_log_path) # Create /tmp/fern-log/
6767

6868
#
6969
# Create Sub Temporary directory in /tmp/fern-log

Fern-Wifi-Cracker/core/wpa.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import time
33
import subprocess
44
import threading
5+
from xml.etree import ElementTree
56
from core.fern import *
67
from gui.attack_panel import *
78
from core.functions import *
@@ -516,18 +517,23 @@ def auto_add_clients(self):
516517

517518
def probe_for_Client_Mac(self):
518519
variables.exec_command("airodump-ng -a --channel %s --write /tmp/fern-log/WPA/zfern-wpa \
519-
--output-format csv --encrypt wpa %s"%(variables.victim_channel,variables.monitor_interface))
520+
--output-format netxml --encrypt wpa %s"%(variables.victim_channel,variables.monitor_interface))
520521

521522

522523
def client_update(self):
523-
wpa_clients_str = reader('/tmp/fern-log/WPA/zfern-wpa-01.csv')
524-
wpa_clients_sort = wpa_clients_str[wpa_clients_str.index('Probed ESSIDs'):-1]
524+
try:
525+
wpa_tree = ElementTree.parse('/tmp/fern-log/WPA/zfern-wpa-01.kismet.netxml').getroot()
526+
527+
for access_point_info in wpa_tree:
528+
bssid = access_point_info.find("BSSID").text
529+
for client in access_point_info.iter("wireless-client"):
530+
client_mac = client.find("client-mac").text
531+
532+
if bssid == variables.victim_mac:
533+
self.client_list.append(client_mac)
534+
except Exception:
535+
pass
525536

526-
for line in wpa_clients_sort.splitlines():
527-
result = re.findall("(([0-9A-F]{2}:){5}[0-9A-F]{2})",line)
528-
if(len(result) == 2):
529-
if(result[1][0] == variables.victim_mac):
530-
self.client_list.append(result[0][0])
531537

532538

533539
def launch_brutefore(self):
@@ -764,19 +770,19 @@ def find_dictionary_length(self,filename):
764770
self.progress_bar_max = line_count(filename)
765771
self.wordlist_lines_counted_signal.emit(filename)
766772

767-
768773
def set_progress_bar(self,filename):
769774
int_max = 2147483630 # Avoid a C based interger overflow
770-
if(self.progress_bar_max > int_max):
775+
if self.progress_bar_max > int_max:
771776
self.progress_bar_max = int_max
772777
self.progressBar.setMaximum(self.progress_bar_max)
773-
self.settings.create_settings(filename,str(self.progress_bar_max))
778+
self.settings.create_settings(filename, str(self.progress_bar_max))
774779

775780

776781

777782
def dictionary_setting(self):
778783
filename = QtWidgets.QFileDialog.getOpenFileName(self,"Select Wordlist","")[0]
779784
if(filename):
785+
780786
self.settings.create_settings("wordlist",filename)
781787

782788
get_temp_name = self.settings.read_last_settings("wordlist")

Fern-Wifi-Cracker/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = 3.11
1+
version = 3.12
22
total_files = 81

0 commit comments

Comments
 (0)