7
7
import sqlite3
8
8
import subprocess
9
9
from urllib import request
10
+ from xml .etree import ElementTree
10
11
11
12
from core import variables
12
13
from PyQt5 import QtCore , QtGui , QtWidgets
21
22
22
23
from gui .main_window import *
23
24
24
- __version__ = 3.11
25
+ __version__ = 3.12
25
26
26
27
27
28
#
@@ -686,92 +687,61 @@ def wpa_button_false(self):
686
687
###################
687
688
def scan_process1_thread (self ):
688
689
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
691
692
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
696
693
697
694
###################
698
695
def scan_process2_thread (self ):
699
696
global error_catch
700
697
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
702
699
else :
703
- wep_display_mode = ''
700
+ display_mode = ''
704
701
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
707
704
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 = ''
714
705
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
718
706
719
707
###########################
720
708
def scan_process3_thread (self ):
721
709
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 ))
731
713
732
714
#######################
733
715
def scan_process4_thread (self ):
734
716
global error_catch
735
717
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
737
719
else :
738
- wep_display_mode = ''
720
+ display_mode = ''
739
721
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 ))
743
725
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 ))
754
726
755
727
def scan_wep (self ):
756
728
global xterm_setting
757
- variables .exec_command ('rm -r /tmp/fern-log/*.csv ' )
729
+ variables .exec_command ('rm -r /tmp/fern-log/*.netxml ' )
758
730
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 ' )
760
732
variables .exec_command ('rm -r /tmp/fern-log/WPA/*.cap' )
761
733
734
+
762
735
# Channel desision block
763
736
if scan_control == 0 :
764
737
if not variables .static_channel :
765
738
if len (variables .xterm_setting ) == 0 :
766
739
threading .Thread (target = self .scan_process1_thread ).start ()
767
- threading .Thread (target = self .scan_process1_thread1 ).start ()
768
740
else :
769
741
threading .Thread (target = self .scan_process2_thread ).start ()
770
- threading .Thread (target = self .scan_process2_thread1 ).start ()
771
742
else :
772
743
if len (variables .xterm_setting ) == 0 :
773
744
threading .Thread (target = self .scan_process3_thread ).start ()
774
- threading .Thread (target = self .scan_process3_thread1 ).start ()
775
745
else :
776
746
threading .Thread (target = self .scan_process4_thread ).start ()
777
747
threading .Thread (target = self .scan_process4_thread1 ).start ()
@@ -784,84 +754,52 @@ def scan_wep(self):
784
754
try :
785
755
time .sleep (2 )
786
756
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
789
773
774
+ if speed :
775
+ speed = "%d" % (int (speed ) / 1000 )
790
776
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 ]
795
781
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 ]
801
786
802
- self .wep_count = str (wep_devices ) # number of access points wep detected
803
787
804
788
if int (self .wep_count ) > 0 :
805
789
self .wep_number_changed_signal .emit ()
806
790
self .wep_button_true_signal .emit ()
807
791
else :
808
792
self .wep_button_false_signal .emit ()
809
793
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 :
839
795
self .wpa_button_true_signal .emit ()
840
796
self .wpa_number_changed_signal .emit ()
841
797
else :
842
798
self .wpa_button_false_signal .emit ()
843
799
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
-
862
800
863
- except ( ValueError , IndexError ) :
864
- pass
801
+ except Exception as e :
802
+ print ( "Error occurred during scan: " , e )
865
803
866
804
def showEvent (self , event ):
867
805
self .timer .start ()
0 commit comments