Support for Python3

That was fun.
This commit is contained in:
derv82
2018-03-31 23:02:00 -04:00
parent 1ad17472b2
commit 3eddcaa59f
23 changed files with 103 additions and 63 deletions

View File

@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
from ..util.process import Process
from ..util.input import xrange
from ..config import Configuration
import os
@@ -80,17 +81,17 @@ if __name__ == '__main__':
Configuration.initialize(False)
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)
while aircrack.is_running():
sleep(1)
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()
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 asciikey == 'uncle', 'asciikey was "%s", expected "uncle"' % asciikey

View File

@@ -29,7 +29,7 @@ class WEPAttackType(object):
self.value = None
self.name = None
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 value == var:
self.name = name
@@ -37,7 +37,7 @@ class WEPAttackType(object):
return
raise Exception("Attack number %d not found" % var)
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 name == var:
self.name = name
@@ -438,12 +438,12 @@ class Aireplay(Thread):
if __name__ == '__main__':
t = WEPAttackType(4)
print t.name, type(t.name), t.value
print(t.name, type(t.name), t.value)
t = WEPAttackType('caffelatte')
print t.name, type(t.name), t.value
print(t.name, type(t.name), t.value)
t = WEPAttackType(t)
print t.name, type(t.name), t.value
print(t.name, type(t.name), t.value)
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(',')
@@ -455,13 +455,13 @@ if __name__ == '__main__':
from time import sleep
sleep(0.1)
stdout, stderr = aireplay.get_output()
print "STDOUT>", stdout
print "STDERR>", stderr
print("STDOUT>", stdout)
print("STDERR>", stderr)
'''
'''
forge = Aireplay.forge_packet('/tmp/replay_dec-0605-060243.xor', \
'A4:2B:8C:16:6B:3A', \
'00:C0:CA:4E:CA:E0')
print forge
print(forge)
'''

View File

@@ -4,6 +4,7 @@
from ..model.interface import Interface
from ..util.process import Process
from ..util.color import Color
from ..util.input import raw_input
from ..config import Configuration
import re
@@ -28,7 +29,7 @@ class Airmon(object):
def print_menu(self):
''' Prints menu '''
print Interface.menu_header()
print(Interface.menu_header())
for idx, iface in enumerate(self.interfaces, start=1):
Color.pl(" {G}%d{W}. %s" % (idx, iface))

View File

@@ -145,7 +145,7 @@ class Airodump(object):
capfile = csv_filename[:-3] + 'cap'
try:
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
Wash.check_for_wps_and_update_targets(capfile, targets)
@@ -180,8 +180,13 @@ class Airodump(object):
targets = []
import csv
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=',')
hit_clients = False
for row in csv_reader:
# Each "row" is a list of fields for a target/client

View File

@@ -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(',')
target = Target(fields)
psk = Bully.get_psk_from_pin(target, '01030365')
print "psk", psk
print("psk", psk)
'''
stdout = " [*] Pin is '11867722', key is '9a6f7997'"

View File

@@ -268,7 +268,7 @@ executing pixiewps -e d0141b15656e96b85fcead2e8e76330d2b1ac1576bb026e7a328c0e1ba
result = CrackResultWPS('AA:BB:CC:DD:EE:FF', ssid, pin, psk)
result.dump()
print ""
print("")
(pin, psk, ssid) = Reaver.get_pin_psk_ssid(new_stdout)
assert pin == '11867722', 'pin was "%s", should have been "11867722"' % pin

View File

@@ -82,6 +82,6 @@ if __name__ == '__main__':
# Should update 'wps' field of a target
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

View File

@@ -69,6 +69,7 @@ if __name__ == '__main__':
# Should update 'wps' field of a target
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