Support for Python3
That was fun.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python2.7
|
#!/usr/bin/python2.7
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from util.color import Color
|
from .util.color import Color
|
||||||
|
|
||||||
import argparse, sys
|
import argparse, sys
|
||||||
|
|
||||||
@@ -366,11 +366,11 @@ class Arguments(object):
|
|||||||
help=Color.s('Show commands to crack a captured handshake'))
|
help=Color.s('Show commands to crack a captured handshake'))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from util.color import Color
|
from .util.color import Color
|
||||||
from config import Configuration
|
from config import Configuration
|
||||||
Configuration.initialize(False)
|
Configuration.initialize(False)
|
||||||
a = Arguments(Configuration)
|
a = Arguments(Configuration)
|
||||||
args = a.args
|
args = a.args
|
||||||
for (key,value) in sorted(args.__dict__.iteritems()):
|
for (key,value) in sorted(args.__dict__.items()):
|
||||||
Color.pl('{C}%s: {G}%s{W}' % (key.ljust(21),value))
|
Color.pl('{C}%s: {G}%s{W}' % (key.ljust(21),value))
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from ..tools.aircrack import Aircrack
|
|||||||
from ..config import Configuration
|
from ..config import Configuration
|
||||||
from ..model.interface import Interface
|
from ..model.interface import Interface
|
||||||
from ..util.color import Color
|
from ..util.color import Color
|
||||||
|
from ..util.input import raw_input
|
||||||
from ..model.wep_result import CrackResultWEP
|
from ..model.wep_result import CrackResultWEP
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/python2.7
|
#!/usr/bin/python2.7
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from util.color import Color
|
from .util.color import Color
|
||||||
from tools.macchanger import Macchanger
|
from .tools.macchanger import Macchanger
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ class Configuration(object):
|
|||||||
def get_interface():
|
def get_interface():
|
||||||
if Configuration.interface is None:
|
if Configuration.interface is None:
|
||||||
# Interface wasn't defined, select it!
|
# Interface wasn't defined, select it!
|
||||||
from tools.airmon import Airmon
|
from .tools.airmon import Airmon
|
||||||
Configuration.interface = Airmon.ask()
|
Configuration.interface = Airmon.ask()
|
||||||
if Configuration.random_mac:
|
if Configuration.random_mac:
|
||||||
Macchanger.random()
|
Macchanger.random()
|
||||||
@@ -117,7 +117,7 @@ class Configuration(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def load_from_arguments():
|
def load_from_arguments():
|
||||||
''' Sets configuration values based on Argument.args object '''
|
''' Sets configuration values based on Argument.args object '''
|
||||||
from args import Arguments
|
from .args import Arguments
|
||||||
|
|
||||||
args = Arguments(Configuration).args
|
args = Arguments(Configuration).args
|
||||||
if args.random_mac:
|
if args.random_mac:
|
||||||
@@ -315,7 +315,7 @@ class Configuration(object):
|
|||||||
''' Deletes temp and exist with the given code '''
|
''' Deletes temp and exist with the given code '''
|
||||||
Configuration.delete_temp()
|
Configuration.delete_temp()
|
||||||
Macchanger.reset_if_changed()
|
Macchanger.reset_if_changed()
|
||||||
from tools.airmon import Airmon
|
from .tools.airmon import Airmon
|
||||||
if hasattr(Configuration, "interface") and Configuration.interface is not None and Airmon.base_interface is not None:
|
if hasattr(Configuration, "interface") and Configuration.interface is not None and Airmon.base_interface is not None:
|
||||||
Airmon.stop(Configuration.interface)
|
Airmon.stop(Configuration.interface)
|
||||||
Airmon.put_interface_up(Airmon.base_interface)
|
Airmon.put_interface_up(Airmon.base_interface)
|
||||||
@@ -328,7 +328,7 @@ class Configuration(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def dump():
|
def dump():
|
||||||
''' (Colorful) string representation of the configuration '''
|
''' (Colorful) string representation of the configuration '''
|
||||||
from util.color import Color
|
from .util.color import Color
|
||||||
|
|
||||||
max_len = 20
|
max_len = 20
|
||||||
for key in Configuration.__dict__.keys():
|
for key in Configuration.__dict__.keys():
|
||||||
@@ -337,7 +337,7 @@ class Configuration(object):
|
|||||||
result = Color.s('{W}%s Value{W}\n' % 'Configuration Key'.ljust(max_len))
|
result = Color.s('{W}%s Value{W}\n' % 'Configuration Key'.ljust(max_len))
|
||||||
result += Color.s('{W}%s------------------{W}\n' % ('-' * max_len))
|
result += Color.s('{W}%s------------------{W}\n' % ('-' * max_len))
|
||||||
|
|
||||||
for (key,val) in sorted(Configuration.__dict__.iteritems()):
|
for (key,val) in sorted(Configuration.__dict__.items()):
|
||||||
if key.startswith('__') or type(val) == staticmethod or val is None:
|
if key.startswith('__') or type(val) == staticmethod or val is None:
|
||||||
continue
|
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))
|
||||||
@@ -345,4 +345,4 @@ class Configuration(object):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
Configuration.initialize(False)
|
Configuration.initialize(False)
|
||||||
print Configuration.dump()
|
print(Configuration.dump())
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class Client(object):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
''' String representation of a Client '''
|
''' String representation of a Client '''
|
||||||
result = ''
|
result = ''
|
||||||
for (key,value) in self.__dict__.iteritems():
|
for (key,value) in self.__dict__.items():
|
||||||
result += key + ': ' + str(value)
|
result += key + ': ' + str(value)
|
||||||
result += ', '
|
result += ', '
|
||||||
return result
|
return result
|
||||||
@@ -39,4 +39,4 @@ class Client(object):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
fields = 'AA:BB:CC:DD:EE:FF, 2015-05-27 19:43:47, 2015-05-27 19:43:47, -67, 2, (not associated) ,HOME-ABCD'.split(',')
|
fields = 'AA:BB:CC:DD:EE:FF, 2015-05-27 19:43:47, 2015-05-27 19:43:47, -67, 2, (not associated) ,HOME-ABCD'.split(',')
|
||||||
c = Client(fields)
|
c = Client(fields)
|
||||||
print c
|
print('Client', c)
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ class Handshake(object):
|
|||||||
|
|
||||||
bssids = set()
|
bssids = set()
|
||||||
# Check if we have all 4 messages for the handshake between the same MACs
|
# Check if we have all 4 messages for the handshake between the same MACs
|
||||||
for (client_target, num) in target_client_msg_nums.iteritems():
|
for (client_target, num) in target_client_msg_nums.items():
|
||||||
if num == 4:
|
if num == 4:
|
||||||
# We got a handshake!
|
# We got a handshake!
|
||||||
bssid = client_target.split(',')[0]
|
bssid = client_target.split(',')[0]
|
||||||
@@ -358,7 +358,6 @@ class Handshake(object):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
hs = Handshake('./tests/files/handshake_exists.cap', bssid='A4:2B:8C:16:6B:3A')
|
hs = Handshake('./tests/files/handshake_exists.cap', bssid='A4:2B:8C:16:6B:3A')
|
||||||
|
|
||||||
hs.analyze()
|
hs.analyze()
|
||||||
print "has_hanshake() =", hs.has_handshake()
|
print("has_hanshake() =", hs.has_handshake())
|
||||||
|
|
||||||
|
|||||||
@@ -98,4 +98,4 @@ class Interface(object):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
mac = Interface.get_mac()
|
mac = Interface.get_mac()
|
||||||
print 'wlan0mon mac address:', mac
|
print('wlan0mon mac address:', mac)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class CrackResult(object):
|
|||||||
text = fid.read()
|
text = fid.read()
|
||||||
try:
|
try:
|
||||||
json = loads(text)
|
json = loads(text)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
Color.pl('{!} error while loading %s: %s' % (name, str(e)))
|
Color.pl('{!} error while loading %s: %s' % (name, str(e)))
|
||||||
json.append(self.to_dict())
|
json.append(self.to_dict())
|
||||||
with open(name, 'w') as fid:
|
with open(name, 'w') as fid:
|
||||||
|
|||||||
@@ -147,5 +147,5 @@ if __name__ == '__main__':
|
|||||||
t = Target(fields)
|
t = Target(fields)
|
||||||
t.clients.append("asdf")
|
t.clients.append("asdf")
|
||||||
t.clients.append("asdf")
|
t.clients.append("asdf")
|
||||||
print t.to_str()
|
print(t.to_str())
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ if __name__ == '__main__':
|
|||||||
w.dump()
|
w.dump()
|
||||||
|
|
||||||
w = CrackResultWPA('AA:BB:CC:DD:EE:FF', 'Test Router', 'hs/capfile.cap', 'Key')
|
w = CrackResultWPA('AA:BB:CC:DD:EE:FF', 'Test Router', 'hs/capfile.cap', 'Key')
|
||||||
print '\n'
|
print('\n')
|
||||||
w.dump()
|
w.dump()
|
||||||
w.save()
|
w.save()
|
||||||
print w.__dict__['bssid']
|
print(w.__dict__['bssid'])
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from ..util.process import Process
|
from ..util.process import Process
|
||||||
|
from ..util.input import xrange
|
||||||
from ..config import Configuration
|
from ..config import Configuration
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@@ -80,17 +81,17 @@ if __name__ == '__main__':
|
|||||||
Configuration.initialize(False)
|
Configuration.initialize(False)
|
||||||
|
|
||||||
ivs_file = 'tests/files/wep-crackable.ivs'
|
ivs_file = 'tests/files/wep-crackable.ivs'
|
||||||
print "Running aircrack on %s ..." % ivs_file
|
print("Running aircrack on %s ..." % ivs_file)
|
||||||
|
|
||||||
aircrack = Aircrack(ivs_file)
|
aircrack = Aircrack(ivs_file)
|
||||||
while aircrack.is_running():
|
while aircrack.is_running():
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
assert aircrack.is_cracked(), "Aircrack should have cracked %s" % ivs_file
|
assert aircrack.is_cracked(), "Aircrack should have cracked %s" % ivs_file
|
||||||
print "aircrack process completed."
|
print("aircrack process completed.")
|
||||||
|
|
||||||
(hexkey, asciikey) = aircrack.get_key_hex_ascii()
|
(hexkey, asciikey) = aircrack.get_key_hex_ascii()
|
||||||
print "aircrack found HEX key: (%s) and ASCII key: (%s)" % (hexkey, asciikey)
|
print("aircrack found HEX key: (%s) and ASCII key: (%s)" % (hexkey, asciikey))
|
||||||
assert hexkey == '75:6E:63:6C:65', 'hexkey was "%s", expected "75:6E:63:6C:65"' % hexkey
|
assert hexkey == '75:6E:63:6C:65', 'hexkey was "%s", expected "75:6E:63:6C:65"' % hexkey
|
||||||
assert asciikey == 'uncle', 'asciikey was "%s", expected "uncle"' % asciikey
|
assert asciikey == 'uncle', 'asciikey was "%s", expected "uncle"' % asciikey
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class WEPAttackType(object):
|
|||||||
self.value = None
|
self.value = None
|
||||||
self.name = None
|
self.name = None
|
||||||
if type(var) is int:
|
if type(var) is int:
|
||||||
for (name,value) in WEPAttackType.__dict__.iteritems():
|
for (name,value) in WEPAttackType.__dict__.items():
|
||||||
if type(value) is int:
|
if type(value) is int:
|
||||||
if value == var:
|
if value == var:
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -37,7 +37,7 @@ class WEPAttackType(object):
|
|||||||
return
|
return
|
||||||
raise Exception("Attack number %d not found" % var)
|
raise Exception("Attack number %d not found" % var)
|
||||||
elif type(var) is str:
|
elif type(var) is str:
|
||||||
for (name,value) in WEPAttackType.__dict__.iteritems():
|
for (name,value) in WEPAttackType.__dict__.items():
|
||||||
if type(value) is int:
|
if type(value) is int:
|
||||||
if name == var:
|
if name == var:
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -438,12 +438,12 @@ class Aireplay(Thread):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
t = WEPAttackType(4)
|
t = WEPAttackType(4)
|
||||||
print t.name, type(t.name), t.value
|
print(t.name, type(t.name), t.value)
|
||||||
t = WEPAttackType('caffelatte')
|
t = WEPAttackType('caffelatte')
|
||||||
print t.name, type(t.name), t.value
|
print(t.name, type(t.name), t.value)
|
||||||
|
|
||||||
t = WEPAttackType(t)
|
t = WEPAttackType(t)
|
||||||
print t.name, type(t.name), t.value
|
print(t.name, type(t.name), t.value)
|
||||||
|
|
||||||
from ..model.target import Target
|
from ..model.target import Target
|
||||||
fields = 'A4:2B:8C:16:6B:3A, 2015-05-27 19:28:44, 2015-05-27 19:28:46, 6, 54e, WEP, WEP, , -58, 2, 0, 0. 0. 0. 0, 9, Test Router Please Ignore, '.split(',')
|
fields = 'A4:2B:8C:16:6B:3A, 2015-05-27 19:28:44, 2015-05-27 19:28:46, 6, 54e, WEP, WEP, , -58, 2, 0, 0. 0. 0. 0, 9, Test Router Please Ignore, '.split(',')
|
||||||
@@ -455,13 +455,13 @@ if __name__ == '__main__':
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
stdout, stderr = aireplay.get_output()
|
stdout, stderr = aireplay.get_output()
|
||||||
print "STDOUT>", stdout
|
print("STDOUT>", stdout)
|
||||||
print "STDERR>", stderr
|
print("STDERR>", stderr)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
'''
|
'''
|
||||||
forge = Aireplay.forge_packet('/tmp/replay_dec-0605-060243.xor', \
|
forge = Aireplay.forge_packet('/tmp/replay_dec-0605-060243.xor', \
|
||||||
'A4:2B:8C:16:6B:3A', \
|
'A4:2B:8C:16:6B:3A', \
|
||||||
'00:C0:CA:4E:CA:E0')
|
'00:C0:CA:4E:CA:E0')
|
||||||
print forge
|
print(forge)
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
from ..model.interface import Interface
|
from ..model.interface import Interface
|
||||||
from ..util.process import Process
|
from ..util.process import Process
|
||||||
from ..util.color import Color
|
from ..util.color import Color
|
||||||
|
from ..util.input import raw_input
|
||||||
from ..config import Configuration
|
from ..config import Configuration
|
||||||
|
|
||||||
import re
|
import re
|
||||||
@@ -28,7 +29,7 @@ class Airmon(object):
|
|||||||
|
|
||||||
def print_menu(self):
|
def print_menu(self):
|
||||||
''' Prints menu '''
|
''' Prints menu '''
|
||||||
print Interface.menu_header()
|
print(Interface.menu_header())
|
||||||
for idx, iface in enumerate(self.interfaces, start=1):
|
for idx, iface in enumerate(self.interfaces, start=1):
|
||||||
Color.pl(" {G}%d{W}. %s" % (idx, iface))
|
Color.pl(" {G}%d{W}. %s" % (idx, iface))
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class Airodump(object):
|
|||||||
capfile = csv_filename[:-3] + 'cap'
|
capfile = csv_filename[:-3] + 'cap'
|
||||||
try:
|
try:
|
||||||
Tshark.check_for_wps_and_update_targets(capfile, targets)
|
Tshark.check_for_wps_and_update_targets(capfile, targets)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# No tshark, or it failed. Fall-back to wash
|
# No tshark, or it failed. Fall-back to wash
|
||||||
Wash.check_for_wps_and_update_targets(capfile, targets)
|
Wash.check_for_wps_and_update_targets(capfile, targets)
|
||||||
|
|
||||||
@@ -180,8 +180,13 @@ class Airodump(object):
|
|||||||
targets = []
|
targets = []
|
||||||
import csv
|
import csv
|
||||||
with open(csv_filename, 'rb') as csvopen:
|
with open(csv_filename, 'rb') as csvopen:
|
||||||
lines = (line.replace('\0', '') for line in csvopen)
|
lines = []
|
||||||
|
for line in csvopen:
|
||||||
|
if type(line) is bytes: line = line.decode('utf-8')
|
||||||
|
line = line.replace('\0', '')
|
||||||
|
lines.append(line)
|
||||||
csv_reader = csv.reader(lines, delimiter=',')
|
csv_reader = csv.reader(lines, delimiter=',')
|
||||||
|
|
||||||
hit_clients = False
|
hit_clients = False
|
||||||
for row in csv_reader:
|
for row in csv_reader:
|
||||||
# Each "row" is a list of fields for a target/client
|
# Each "row" is a list of fields for a target/client
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ if __name__ == '__main__':
|
|||||||
fields = '34:21:09:01:92:7C,2015-05-27 19:28:44,2015-05-27 19:28:46,1,54,WPA2,CCMP TKIP,PSK,-58,2,0,0.0.0.0,9,AirLink89300,'.split(',')
|
fields = '34:21:09:01:92:7C,2015-05-27 19:28:44,2015-05-27 19:28:46,1,54,WPA2,CCMP TKIP,PSK,-58,2,0,0.0.0.0,9,AirLink89300,'.split(',')
|
||||||
target = Target(fields)
|
target = Target(fields)
|
||||||
psk = Bully.get_psk_from_pin(target, '01030365')
|
psk = Bully.get_psk_from_pin(target, '01030365')
|
||||||
print "psk", psk
|
print("psk", psk)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
stdout = " [*] Pin is '11867722', key is '9a6f7997'"
|
stdout = " [*] Pin is '11867722', key is '9a6f7997'"
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ executing pixiewps -e d0141b15656e96b85fcead2e8e76330d2b1ac1576bb026e7a328c0e1ba
|
|||||||
result = CrackResultWPS('AA:BB:CC:DD:EE:FF', ssid, pin, psk)
|
result = CrackResultWPS('AA:BB:CC:DD:EE:FF', ssid, pin, psk)
|
||||||
result.dump()
|
result.dump()
|
||||||
|
|
||||||
print ""
|
print("")
|
||||||
|
|
||||||
(pin, psk, ssid) = Reaver.get_pin_psk_ssid(new_stdout)
|
(pin, psk, ssid) = Reaver.get_pin_psk_ssid(new_stdout)
|
||||||
assert pin == '11867722', 'pin was "%s", should have been "11867722"' % pin
|
assert pin == '11867722', 'pin was "%s", should have been "11867722"' % pin
|
||||||
|
|||||||
@@ -82,6 +82,6 @@ if __name__ == '__main__':
|
|||||||
# Should update 'wps' field of a target
|
# Should update 'wps' field of a target
|
||||||
Tshark.check_for_wps_and_update_targets(test_file, targets)
|
Tshark.check_for_wps_and_update_targets(test_file, targets)
|
||||||
|
|
||||||
print 'Target(BSSID={}).wps = {} (Expected: True)'.format(targets[0].bssid, targets[0].wps)
|
print('Target(BSSID={}).wps = {} (Expected: True)'.format(targets[0].bssid, targets[0].wps))
|
||||||
assert targets[0].wps == True
|
assert targets[0].wps == True
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ if __name__ == '__main__':
|
|||||||
# Should update 'wps' field of a target
|
# Should update 'wps' field of a target
|
||||||
Wash.check_for_wps_and_update_targets(test_file, targets)
|
Wash.check_for_wps_and_update_targets(test_file, targets)
|
||||||
|
|
||||||
print 'Target(BSSID={}).wps = {} (Expected: True)'.format(targets[0].bssid, targets[0].wps)
|
print('Target(BSSID={}).wps = {} (Expected: True)'.format(targets[0].bssid, targets[0].wps))
|
||||||
|
|
||||||
assert targets[0].wps == True
|
assert targets[0].wps == True
|
||||||
|
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ class Color(object):
|
|||||||
def s(text):
|
def s(text):
|
||||||
''' Returns colored string '''
|
''' Returns colored string '''
|
||||||
output = text
|
output = text
|
||||||
for (key,value) in Color.replacements.iteritems():
|
for (key,value) in Color.replacements.items():
|
||||||
output = output.replace(key, value)
|
output = output.replace(key, value)
|
||||||
for (key,value) in Color.colors.iteritems():
|
for (key,value) in Color.colors.items():
|
||||||
output = output.replace("{%s}" % key, value)
|
output = output.replace("{%s}" % key, value)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ class Color(object):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
Color.pl("{R}Testing{G}One{C}Two{P}Three{W}Done")
|
Color.pl("{R}Testing{G}One{C}Two{P}Three{W}Done")
|
||||||
print Color.s("{C}Testing{P}String{W}")
|
print(Color.s("{C}Testing{P}String{W}"))
|
||||||
Color.pl("{+} Good line")
|
Color.pl("{+} Good line")
|
||||||
Color.pl("{!} Danger")
|
Color.pl("{!} Danger")
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
from ..util.process import Process
|
from ..util.process import Process
|
||||||
from ..util.color import Color
|
from ..util.color import Color
|
||||||
|
from ..util.input import raw_input
|
||||||
from ..config import Configuration
|
from ..config import Configuration
|
||||||
from ..model.result import CrackResult
|
from ..model.result import CrackResult
|
||||||
|
|
||||||
|
|||||||
17
wifite/util/input.py
Normal file
17
wifite/util/input.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/python2.7
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Fix for raw_input on python3: https://stackoverflow.com/a/7321970
|
||||||
|
try:
|
||||||
|
input = raw_input
|
||||||
|
except NameError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
raw_input = input
|
||||||
|
|
||||||
|
try:
|
||||||
|
range = xrange
|
||||||
|
except NameError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
xrange = range
|
||||||
@@ -36,6 +36,11 @@ class Process(object):
|
|||||||
pid.wait()
|
pid.wait()
|
||||||
(stdout, stderr) = pid.communicate()
|
(stdout, stderr) = pid.communicate()
|
||||||
|
|
||||||
|
# Python 3 compatibility
|
||||||
|
if type(stdout) is bytes: stdout = stdout.decode('utf-8')
|
||||||
|
if type(stderr) is bytes: stderr = stderr.decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
if Configuration.verbose > 1 and stdout is not None and stdout.strip() != '':
|
if Configuration.verbose > 1 and stdout is not None and stdout.strip() != '':
|
||||||
Color.pe("{P} [stdout] %s{W}" % '\n [stdout] '.join(stdout.strip().split('\n')))
|
Color.pe("{P} [stdout] %s{W}" % '\n [stdout] '.join(stdout.strip().split('\n')))
|
||||||
if Configuration.verbose > 1 and stderr is not None and stderr.strip() != '':
|
if Configuration.verbose > 1 and stderr is not None and stderr.strip() != '':
|
||||||
@@ -114,6 +119,13 @@ class Process(object):
|
|||||||
self.pid.wait()
|
self.pid.wait()
|
||||||
if self.out is None:
|
if self.out is None:
|
||||||
(self.out, self.err) = self.pid.communicate()
|
(self.out, self.err) = self.pid.communicate()
|
||||||
|
|
||||||
|
if type(self.out) is bytes:
|
||||||
|
self.out = self.out.decode('utf-8')
|
||||||
|
|
||||||
|
if type(self.err) is bytes:
|
||||||
|
self.err = self.err.decode('utf-8')
|
||||||
|
|
||||||
return (self.out, self.err)
|
return (self.out, self.err)
|
||||||
|
|
||||||
def poll(self):
|
def poll(self):
|
||||||
@@ -151,7 +163,7 @@ class Process(object):
|
|||||||
self.pid.terminate()
|
self.pid.terminate()
|
||||||
break
|
break
|
||||||
|
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
if 'No such process' in e.__str__():
|
if 'No such process' in e.__str__():
|
||||||
return
|
return
|
||||||
raise e # process cannot be killed
|
raise e # process cannot be killed
|
||||||
@@ -159,20 +171,20 @@ class Process(object):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
p = Process('ls')
|
p = Process('ls')
|
||||||
print p.stdout(), p.stderr()
|
print(p.stdout(), p.stderr())
|
||||||
p.interrupt()
|
p.interrupt()
|
||||||
|
|
||||||
# Calling as list of arguments
|
# Calling as list of arguments
|
||||||
(out, err) = Process.call(['ls', '-lah'])
|
(out, err) = Process.call(['ls', '-lah'])
|
||||||
print out, err
|
print(out, err)
|
||||||
|
|
||||||
print '\n---------------------\n'
|
print('\n---------------------\n')
|
||||||
|
|
||||||
# Calling as string
|
# Calling as string
|
||||||
(out, err) = Process.call('ls -l | head -2')
|
(out, err) = Process.call('ls -l | head -2')
|
||||||
print out, err
|
print(out, err)
|
||||||
|
|
||||||
print '"reaver" exists:', Process.exists('reaver')
|
print('"reaver" exists:', Process.exists('reaver'))
|
||||||
|
|
||||||
# Test on never-ending process
|
# Test on never-ending process
|
||||||
p = Process('yes')
|
p = Process('yes')
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
from ..tools.airodump import Airodump
|
from ..tools.airodump import Airodump
|
||||||
from ..util.color import Color
|
from ..util.color import Color
|
||||||
|
from ..util.input import raw_input, xrange
|
||||||
from ..model.target import Target
|
from ..model.target import Target
|
||||||
from ..config import Configuration
|
from ..config import Configuration
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ class Scanner(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.targets = airodump.get_targets()
|
self.targets = airodump.get_targets()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
break
|
break
|
||||||
|
|
||||||
if self.found_target():
|
if self.found_target():
|
||||||
@@ -219,7 +220,7 @@ if __name__ == '__main__':
|
|||||||
try:
|
try:
|
||||||
s = Scanner()
|
s = Scanner()
|
||||||
targets = s.select_targets()
|
targets = s.select_targets()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
Color.pl('\r {!} {R}Error{W}: %s' % str(e))
|
Color.pl('\r {!} {R}Error{W}: %s' % str(e))
|
||||||
Configuration.exit_gracefully(0)
|
Configuration.exit_gracefully(0)
|
||||||
for t in targets:
|
for t in targets:
|
||||||
|
|||||||
@@ -2,19 +2,20 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from config import Configuration
|
from .config import Configuration
|
||||||
except (ValueError, ImportError) as e:
|
except (ValueError, ImportError) as e:
|
||||||
raise Exception('You may need to run wifite from the root directory (which includes README.md)')
|
raise Exception('You may need to run wifite from the root directory (which includes README.md)')
|
||||||
|
|
||||||
from util.scanner import Scanner
|
from .util.scanner import Scanner
|
||||||
from util.process import Process
|
from .util.process import Process
|
||||||
from util.color import Color
|
from .util.color import Color
|
||||||
from util.crack import CrackHandshake
|
from .util.crack import CrackHandshake
|
||||||
from attack.wep import AttackWEP
|
from .util.input import raw_input
|
||||||
from attack.wpa import AttackWPA
|
from .attack.wep import AttackWEP
|
||||||
from attack.wps import AttackWPS
|
from .attack.wpa import AttackWPA
|
||||||
from model.result import CrackResult
|
from .attack.wps import AttackWPS
|
||||||
from model.handshake import Handshake
|
from .model.result import CrackResult
|
||||||
|
from .model.handshake import Handshake
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
@@ -95,7 +96,7 @@ class Wifite(object):
|
|||||||
Color.pl('{+} checking all handshakes in {G}"./hs"{W} directory\n')
|
Color.pl('{+} checking all handshakes in {G}"./hs"{W} directory\n')
|
||||||
try:
|
try:
|
||||||
capfiles = [os.path.join('hs', x) for x in os.listdir('hs') if x.endswith('.cap')]
|
capfiles = [os.path.join('hs', x) for x in os.listdir('hs') if x.endswith('.cap')]
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
capfiles = []
|
capfiles = []
|
||||||
if len(capfiles) == 0:
|
if len(capfiles) == 0:
|
||||||
Color.pl('{!} {R}no .cap files found in {O}"./hs"{W}\n')
|
Color.pl('{!} {R}no .cap files found in {O}"./hs"{W}\n')
|
||||||
@@ -173,7 +174,7 @@ class Wifite(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
attack.run()
|
attack.run()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
Color.pl("\n{!} {R}Error: {O}%s" % str(e))
|
Color.pl("\n{!} {R}Error: {O}%s" % str(e))
|
||||||
if Configuration.verbose > 0 or True:
|
if Configuration.verbose > 0 or True:
|
||||||
Color.pl('\n{!} {O}Full stack trace below')
|
Color.pl('\n{!} {O}Full stack trace below')
|
||||||
@@ -234,7 +235,7 @@ def run():
|
|||||||
try:
|
try:
|
||||||
w.main()
|
w.main()
|
||||||
|
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
Color.pl('\n{!} {R}Error:{O} %s{W}' % str(e))
|
Color.pl('\n{!} {R}Error:{O} %s{W}' % str(e))
|
||||||
|
|
||||||
if Configuration.verbose > 0 or True:
|
if Configuration.verbose > 0 or True:
|
||||||
|
|||||||
Reference in New Issue
Block a user