Comparisons to singletons like None should always be done with is or is not, never the equality operators.
This commit is contained in:
@@ -26,14 +26,14 @@ class Aircrack(object):
|
|||||||
|
|
||||||
|
|
||||||
def is_running(self):
|
def is_running(self):
|
||||||
return self.pid.poll() == None
|
return self.pid.poll() is None
|
||||||
|
|
||||||
def is_cracked(self):
|
def is_cracked(self):
|
||||||
return os.path.exists(self.cracked_file)
|
return os.path.exists(self.cracked_file)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
''' Stops aircrack process '''
|
''' Stops aircrack process '''
|
||||||
if self.pid.poll() == None:
|
if self.pid.poll() is None:
|
||||||
self.pid.interrupt()
|
self.pid.interrupt()
|
||||||
|
|
||||||
def get_key_hex_ascii(self):
|
def get_key_hex_ascii(self):
|
||||||
@@ -56,7 +56,7 @@ class Aircrack(object):
|
|||||||
# Hex key is non-printable in ascii
|
# Hex key is non-printable in ascii
|
||||||
ascii_key = None
|
ascii_key = None
|
||||||
continue
|
continue
|
||||||
elif ascii_key == None:
|
elif ascii_key is None:
|
||||||
# We can't generate an Ascii key
|
# We can't generate an Ascii key
|
||||||
continue
|
continue
|
||||||
# Convert decimal to char
|
# Convert decimal to char
|
||||||
|
|||||||
@@ -81,11 +81,11 @@ class Aireplay(Thread):
|
|||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
def is_running(self):
|
def is_running(self):
|
||||||
return self.pid.poll() == None
|
return self.pid.poll() is None
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
''' Stops aireplay process '''
|
''' Stops aireplay process '''
|
||||||
if hasattr(self, "pid") and self.pid and self.pid.poll() == None:
|
if hasattr(self, "pid") and self.pid and self.pid.poll() is None:
|
||||||
self.pid.interrupt()
|
self.pid.interrupt()
|
||||||
|
|
||||||
def get_output(self):
|
def get_output(self):
|
||||||
@@ -182,7 +182,7 @@ class Aireplay(Thread):
|
|||||||
|
|
||||||
# Interface is required at this point
|
# Interface is required at this point
|
||||||
Configuration.initialize()
|
Configuration.initialize()
|
||||||
if Configuration.interface == None:
|
if Configuration.interface is None:
|
||||||
raise Exception("Wireless interface must be defined (-i)")
|
raise Exception("Wireless interface must be defined (-i)")
|
||||||
|
|
||||||
cmd = ["aireplay-ng"]
|
cmd = ["aireplay-ng"]
|
||||||
@@ -259,7 +259,7 @@ class Aireplay(Thread):
|
|||||||
cmd.extend(["-h", client_mac])
|
cmd.extend(["-h", client_mac])
|
||||||
|
|
||||||
elif attack_type == WEPAttackType.hirte:
|
elif attack_type == WEPAttackType.hirte:
|
||||||
if client_mac == None:
|
if client_mac is None:
|
||||||
# Unable to carry out hirte attack
|
# Unable to carry out hirte attack
|
||||||
raise Exception("Client is required for hirte attack")
|
raise Exception("Client is required for hirte attack")
|
||||||
cmd.extend([
|
cmd.extend([
|
||||||
@@ -267,7 +267,7 @@ class Aireplay(Thread):
|
|||||||
"-h", client_mac
|
"-h", client_mac
|
||||||
])
|
])
|
||||||
elif attack_type == WEPAttackType.forgedreplay:
|
elif attack_type == WEPAttackType.forgedreplay:
|
||||||
if client_mac == None or replay_file == None:
|
if client_mac is None or replay_file is None:
|
||||||
raise Exception("Client_mac and Replay_File are required for arp replay")
|
raise Exception("Client_mac and Replay_File are required for arp replay")
|
||||||
cmd.extend([
|
cmd.extend([
|
||||||
"--arpreplay",
|
"--arpreplay",
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class Airmon(object):
|
|||||||
mon_iface = mon_iface.split(')')[0]
|
mon_iface = mon_iface.split(')')[0]
|
||||||
break
|
break
|
||||||
|
|
||||||
if mon_iface == None:
|
if mon_iface is None:
|
||||||
# Airmon did not enable monitor mode on an interface
|
# Airmon did not enable monitor mode on an interface
|
||||||
Color.pl("{R}failed{W}")
|
Color.pl("{R}failed{W}")
|
||||||
|
|
||||||
|
|||||||
@@ -21,15 +21,15 @@ class Airodump(object):
|
|||||||
|
|
||||||
Configuration.initialize()
|
Configuration.initialize()
|
||||||
|
|
||||||
if interface == None:
|
if interface is None:
|
||||||
interface = Configuration.interface
|
interface = Configuration.interface
|
||||||
if interface == None:
|
if interface is None:
|
||||||
raise Exception("Wireless interface must be defined (-i)")
|
raise Exception("Wireless interface must be defined (-i)")
|
||||||
self.interface = interface
|
self.interface = interface
|
||||||
|
|
||||||
self.targets = []
|
self.targets = []
|
||||||
|
|
||||||
if channel == None:
|
if channel is None:
|
||||||
channel = Configuration.target_channel
|
channel = Configuration.target_channel
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
self.five_ghz = Configuration.five_ghz
|
self.five_ghz = Configuration.five_ghz
|
||||||
@@ -133,7 +133,7 @@ class Airodump(object):
|
|||||||
# Found the file
|
# Found the file
|
||||||
csv_filename = fil
|
csv_filename = fil
|
||||||
break
|
break
|
||||||
if csv_filename == None or not os.path.exists(csv_filename):
|
if csv_filename is None or not os.path.exists(csv_filename):
|
||||||
# No file found
|
# No file found
|
||||||
return self.targets
|
return self.targets
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class Attack(object):
|
|||||||
airodump_target = t
|
airodump_target = t
|
||||||
break
|
break
|
||||||
|
|
||||||
if airodump_target == None:
|
if airodump_target is None:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'Could not find target (%s) in airodump' % self.target.bssid)
|
'Could not find target (%s) in airodump' % self.target.bssid)
|
||||||
|
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class Bully(Attack):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if hasattr(self, "pid") and self.pid and self.pid.poll() == None:
|
if hasattr(self, "pid") and self.pid and self.pid.poll() is None:
|
||||||
self.pid.interrupt()
|
self.pid.interrupt()
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class Configuration(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_interface():
|
def get_interface():
|
||||||
if Configuration.interface == None:
|
if Configuration.interface is None:
|
||||||
# Interface wasn't defined, select it!
|
# Interface wasn't defined, select it!
|
||||||
from Airmon import Airmon
|
from Airmon import Airmon
|
||||||
Configuration.interface = Airmon.ask()
|
Configuration.interface = Airmon.ask()
|
||||||
@@ -273,7 +273,7 @@ class Configuration(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def temp(subfile=''):
|
def temp(subfile=''):
|
||||||
''' Creates and/or returns the temporary directory '''
|
''' Creates and/or returns the temporary directory '''
|
||||||
if Configuration.temp_dir == None:
|
if Configuration.temp_dir is None:
|
||||||
Configuration.temp_dir = Configuration.create_temp()
|
Configuration.temp_dir = Configuration.create_temp()
|
||||||
return Configuration.temp_dir + subfile
|
return Configuration.temp_dir + subfile
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ class Configuration(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def delete_temp():
|
def delete_temp():
|
||||||
''' Remove temp files and folder '''
|
''' Remove temp files and folder '''
|
||||||
if Configuration.temp_dir == None: return
|
if Configuration.temp_dir is None: return
|
||||||
if os.path.exists(Configuration.temp_dir):
|
if os.path.exists(Configuration.temp_dir):
|
||||||
for f in os.listdir(Configuration.temp_dir):
|
for f in os.listdir(Configuration.temp_dir):
|
||||||
os.remove(Configuration.temp_dir + f)
|
os.remove(Configuration.temp_dir + f)
|
||||||
@@ -323,7 +323,7 @@ class Configuration(object):
|
|||||||
for (key,val) in sorted(Configuration.__dict__.iteritems()):
|
for (key,val) in sorted(Configuration.__dict__.iteritems()):
|
||||||
if key.startswith('__'): continue
|
if key.startswith('__'): continue
|
||||||
if type(val) == staticmethod: continue
|
if type(val) == staticmethod: continue
|
||||||
if val == None: continue
|
if val is None: continue
|
||||||
result += Color.s("{G}%s {W} {C}%s{W}\n" % (key.ljust(max_len),val))
|
result += Color.s("{G}%s {W} {C}%s{W}\n" % (key.ljust(max_len),val))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class Handshake(object):
|
|||||||
mac_regex = ('[a-zA-Z0-9]{2}:' * 6)[:-1]
|
mac_regex = ('[a-zA-Z0-9]{2}:' * 6)[:-1]
|
||||||
match = re.search('(%s) [^ ]* (%s).*.*SSID=(.*)$'
|
match = re.search('(%s) [^ ]* (%s).*.*SSID=(.*)$'
|
||||||
% (mac_regex, mac_regex), line)
|
% (mac_regex, mac_regex), line)
|
||||||
if match == None:
|
if match is None:
|
||||||
# Line doesn't contain src, dst, ssid
|
# Line doesn't contain src, dst, ssid
|
||||||
continue
|
continue
|
||||||
(src, dst, essid) = match.groups()
|
(src, dst, essid) = match.groups()
|
||||||
@@ -139,7 +139,7 @@ class Handshake(object):
|
|||||||
mac_regex = ('[a-zA-Z0-9]{2}:' * 6)[:-1]
|
mac_regex = ('[a-zA-Z0-9]{2}:' * 6)[:-1]
|
||||||
match = re.search('(%s) (?:->|→) (%s).*Message.*(\d).*(\d)'
|
match = re.search('(%s) (?:->|→) (%s).*Message.*(\d).*(\d)'
|
||||||
% (mac_regex, mac_regex), line)
|
% (mac_regex, mac_regex), line)
|
||||||
if match == None:
|
if match is None:
|
||||||
# Line doesn't contain src, dst, Message numbers
|
# Line doesn't contain src, dst, Message numbers
|
||||||
continue
|
continue
|
||||||
(src, dst, index, ttl) = match.groups()
|
(src, dst, index, ttl) = match.groups()
|
||||||
|
|||||||
@@ -82,10 +82,10 @@ class Interface(object):
|
|||||||
from Process import Process
|
from Process import Process
|
||||||
import re
|
import re
|
||||||
|
|
||||||
if iface == None:
|
if iface is None:
|
||||||
Configuration.initialize()
|
Configuration.initialize()
|
||||||
iface = Configuration.interface
|
iface = Configuration.interface
|
||||||
if iface == None:
|
if iface is None:
|
||||||
raise Exception('Interface must be defined (-i)')
|
raise Exception('Interface must be defined (-i)')
|
||||||
|
|
||||||
output = Process(['ifconfig', iface]).stdout()
|
output = Process(['ifconfig', iface]).stdout()
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class Process(object):
|
|||||||
Ran when object is GC'd.
|
Ran when object is GC'd.
|
||||||
If process is still running at this point, it should die.
|
If process is still running at this point, it should die.
|
||||||
'''
|
'''
|
||||||
if self.pid and self.pid.poll() == None:
|
if self.pid and self.pid.poll() is None:
|
||||||
self.interrupt()
|
self.interrupt()
|
||||||
|
|
||||||
def stdout(self):
|
def stdout(self):
|
||||||
@@ -110,9 +110,9 @@ class Process(object):
|
|||||||
|
|
||||||
def get_output(self):
|
def get_output(self):
|
||||||
''' Waits for process to finish, sets stdout & stderr '''
|
''' Waits for process to finish, sets stdout & stderr '''
|
||||||
if self.pid.poll() == None:
|
if self.pid.poll() is None:
|
||||||
self.pid.wait()
|
self.pid.wait()
|
||||||
if self.out == None:
|
if self.out is None:
|
||||||
(self.out, self.err) = self.pid.communicate()
|
(self.out, self.err) = self.pid.communicate()
|
||||||
|
|
||||||
def poll(self):
|
def poll(self):
|
||||||
@@ -139,7 +139,7 @@ class Process(object):
|
|||||||
kill(pid, SIGINT)
|
kill(pid, SIGINT)
|
||||||
|
|
||||||
wait_time = 0 # Time since Interrupt was sent
|
wait_time = 0 # Time since Interrupt was sent
|
||||||
while self.pid.poll() == None:
|
while self.pid.poll() is None:
|
||||||
# Process is still running
|
# Process is still running
|
||||||
wait_time += 0.1
|
wait_time += 0.1
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class Reaver(Attack):
|
|||||||
(pin, psk, ssid) = self.get_pin_psk_ssid(stdout)
|
(pin, psk, ssid) = self.get_pin_psk_ssid(stdout)
|
||||||
|
|
||||||
# Check if we cracked it, or if process stopped.
|
# Check if we cracked it, or if process stopped.
|
||||||
if (pin and psk and ssid) or reaver.poll() != None:
|
if (pin and psk and ssid) or reaver.poll() is not None:
|
||||||
reaver.interrupt()
|
reaver.interrupt()
|
||||||
|
|
||||||
# Check one-last-time for PIN/PSK/SSID, in case of race condition.
|
# Check one-last-time for PIN/PSK/SSID, in case of race condition.
|
||||||
@@ -321,7 +321,7 @@ class Reaver(Attack):
|
|||||||
pin_current = 11000 - pins_left
|
pin_current = 11000 - pins_left
|
||||||
|
|
||||||
# Check if process is still running
|
# Check if process is still running
|
||||||
if reaver.pid.poll() != None:
|
if reaver.pid.poll() is not None:
|
||||||
Color.pl('{R}failed{W}')
|
Color.pl('{R}failed{W}')
|
||||||
Color.pl('{!} {R}reaver{O} quit unexpectedly{W}')
|
Color.pl('{!} {R}reaver{O} quit unexpectedly{W}')
|
||||||
self.success = False
|
self.success = False
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class Scanner(object):
|
|||||||
# Loop until interrupted (Ctrl+C)
|
# Loop until interrupted (Ctrl+C)
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
if airodump.pid.poll() != None:
|
if airodump.pid.poll() is not None:
|
||||||
# Airodump process died!
|
# Airodump process died!
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Airodump exited unexpectedly! " +
|
"Airodump exited unexpectedly! " +
|
||||||
@@ -76,7 +76,7 @@ class Scanner(object):
|
|||||||
bssid = Configuration.target_bssid
|
bssid = Configuration.target_bssid
|
||||||
essid = Configuration.target_essid
|
essid = Configuration.target_essid
|
||||||
|
|
||||||
if bssid == None and essid == None:
|
if bssid is None and essid is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for target in self.targets:
|
for target in self.targets:
|
||||||
|
|||||||
Reference in New Issue
Block a user