From 62503b0d0c8aa7603093674b02b11869d5a12d35 Mon Sep 17 00:00:00 2001 From: derv82 Date: Sun, 14 May 2017 09:34:09 -0400 Subject: [PATCH] Various small fixes + tweaks --- py/AttackWEP.py | 7 +++---- py/AttackWPS.py | 7 ++++--- py/Color.py | 13 ++++++++++++- py/Interface.py | 2 +- py/Scanner.py | 1 + py/Target.py | 6 ++++-- py/Wash.py | 23 +++++++++++------------ 7 files changed, 36 insertions(+), 23 deletions(-) diff --git a/py/AttackWEP.py b/py/AttackWEP.py index 074c7ee..dcf301d 100644 --- a/py/AttackWEP.py +++ b/py/AttackWEP.py @@ -77,8 +77,8 @@ class AttackWEP(Attack): while True: airodump_target = self.wait_for_target(airodump) - Color.p('\r{+} running {C}%s{W} WEP attack ({G}%d IVs{W}) ' - % (attack_name, airodump_target.ivs)) + Color.pattack("WEP", airodump_target, "%s attack" % attack_name, "%d IVs" % airodump_target.ivs) + #Color.p('\r{+} running {C}%s{W} WEP attack ({G}%d IVs{W}) ' % (attack_name, airodump_target.ivs)) # Check if we cracked it. if aircrack and aircrack.is_cracked(): @@ -219,8 +219,7 @@ class AttackWEP(Attack): attacks_remaining = Configuration.wep_attacks[attack_index + 1:] Color.pl("{+} {G}%d{W} attacks remain ({C}%s{W})" % (len(attacks_remaining), ', '.join(attacks_remaining))) - prompt = Color.s('{+} type {G}c{W} to {G}continue{W}' + - ' or {R}s{W} to {R}stop{W}: ') + prompt = Color.s('{+} type {G}c{W} to {G}continue{W} or {R}s{W} to {R}stop{W}: ') if raw_input(prompt).lower().startswith('s'): return False else: diff --git a/py/AttackWPS.py b/py/AttackWPS.py index c24342e..ce37762 100644 --- a/py/AttackWPS.py +++ b/py/AttackWPS.py @@ -62,6 +62,7 @@ class AttackWPS(Attack): '-b', self.target.bssid, '-c', self.target.channel, '-K', '1', # pixie-dust attack + '--session', '/dev/null', # Don't restart session '-vv' # (very) verbose ] @@ -126,7 +127,7 @@ class AttackWPS(Attack): elif 'Detected AP rate limiting,' in stdout_last_line: if Configuration.wps_skip_rate_limit: Color.pl('{R}failed: {O}hit WPS rate-limit{W}') - Color.pl('{!} {O}use {R}--skip-rate-limit{O} to ignore' + + Color.pl('{!} {O}use {R}--ignore-ratelimit{O} to ignore' + ' this kind of failure in the future{W}') break step = '({C}step -/8{W}) waiting for AP rate limit' @@ -184,7 +185,7 @@ class AttackWPS(Attack): '-i', Configuration.interface, '-b', self.target.bssid, '-c', self.target.channel, - '-a', # Automatically restart session + '--session', '/dev/null', # Don't restart session '-vv' # verbose ] reaver = Process(command, stdout=stdout_write, stderr=Process.devnull()) @@ -273,7 +274,7 @@ class AttackWPS(Attack): if Configuration.wps_skip_rate_limit: Color.pl(state) Color.pl('{!} {R}hit rate limit, stopping{W}\n') - Color.pl('{!} {O}use {R}--skip-rate-limit{O} to ignore' + + Color.pl('{!} {O}use {R}--ignore-ratelimit{O} to ignore' + ' this kind of failure in the future{W}') break diff --git a/py/Color.py b/py/Color.py index 0fac0ef..54d534a 100644 --- a/py/Color.py +++ b/py/Color.py @@ -21,7 +21,7 @@ class Color(object): # Helper string replacements replacements = { '{+}': ' {W}[{G}+{W}]', - '{!}': ' {W}[{R}!{W}]' + '{!}': ' {O}[{R}!{O}]{W}' } last_sameline_length = 0 @@ -74,6 +74,17 @@ class Color(object): sys.stdout.flush() Color.last_sameline_length = 0 + @staticmethod + def pattack(attack_type, target, attack_name, progress): + ''' + Prints a one-liner for an attack + Includes attack type (WEP/WPA), target BSSID/ESSID & power, attack type, and progress + [name] ESSID (MAC @ Pwr) Attack_Type: Progress + e.g.: [WEP] Router2G (00:11:22 @ 23db) replay attack: 102 IVs + ''' + Color.p("\r{+} {G}%s{W} ({C}%s @ %sdb{W}) {G}%s {C}%s{W}: %s " % ( + target.essid, target.bssid, target.power, attack_type, attack_name, progress)) + if __name__ == '__main__': Color.pl("{R}Testing{G}One{C}Two{P}Three{W}Done") print Color.s("{C}Testing{P}String{W}") diff --git a/py/Interface.py b/py/Interface.py index 8bf1cb0..19aa9ba 100644 --- a/py/Interface.py +++ b/py/Interface.py @@ -90,7 +90,7 @@ class Interface(object): output = Process(['ifconfig', iface]).stdout() mac_regex = ('[a-zA-Z0-9]{2}-' * 6)[:-1] - match = re.search('HWaddr (%s)' % mac_regex, output) + match = re.search(' (%s)' % mac_regex, output) if not match: raise Exception('Could not find the mac address for %s' % iface) return match.groups()[0].replace('-', ':') diff --git a/py/Scanner.py b/py/Scanner.py index 0d3c47c..319e52a 100644 --- a/py/Scanner.py +++ b/py/Scanner.py @@ -23,6 +23,7 @@ class Scanner(object): self.targets = [] self.target = None # Specific target (based on ESSID/BSSID) + Color.pl("") # Loads airodump with interface/channel/etc from Configuration with Airodump() as airodump: try: diff --git a/py/Target.py b/py/Target.py index 2a09d81..f26bcc9 100644 --- a/py/Target.py +++ b/py/Target.py @@ -103,10 +103,12 @@ class Target(object): power = Color.s('{%s}%s' % (color, power)) wps = Color.s('{O} n/a') - if self.wps: + if self.wps == True: wps = Color.s('{G} yes') - else: + elif self.wps == False: wps = Color.s('{R} no') + else: + wps = Color.s('{O} n/a') clients = ' ' if len(self.clients) == 1: diff --git a/py/Wash.py b/py/Wash.py index 80c6dcd..6fbdbaa 100644 --- a/py/Wash.py +++ b/py/Wash.py @@ -2,9 +2,11 @@ # -*- coding: utf-8 -*- from Process import Process +import re class Wash(object): ''' Wrapper for Wash program. ''' + BSSID_REGEX = re.compile("([A-F0-9\:]{17})", re.IGNORECASE) def __init__(self): pass @@ -33,20 +35,17 @@ class Wash(object): '-f', capfile # Path to cap file ] p = Process(command) - for line in p.stdout().split('\n'): - # Ignore irrelevant lines - if line.strip() == '' or line.startswith('Scanning for'): - continue - bssid = line.split(' ')[0] - for t in targets: - if t.bssid.lower() == bssid.lower(): - # Update the WPS flag - t.wps = True - # Mark other targets as "no" wps support + p.wait() + if p.poll() != 0: + return + + bssids = [bssid.upper() for bssid in Wash.BSSID_REGEX.findall(p.stdout())] for t in targets: - if t.wps: continue - t.wps = False + t.wps = t.bssid.upper() in bssids + if t.bssid.lower() == bssid.lower(): + # Update the WPS flag + t.wps = True if __name__ == '__main__':