def run(self): ''' Main program. 1) Scans for targets, asks user to select targets 2) Attacks each target ''' s = Scanner() if s.target: # We found the target we want targets = [s.target] else: targets = s.select_targets() attacked_targets = 0 targets_remaining = len(targets) for idx, t in enumerate(targets, start=1): attacked_targets += 1 targets_remaining -= 1 Color.pl( '\n{+} ({G}%d{W}/{G}%d{W})' % (idx, len(targets)) + ' starting attacks against {C}%s{W} ({C}%s{W})' % (t.bssid, t.essid if t.essid_known else "{O}ESSID unknown")) if 'WEP' in t.encryption: attack = AttackWEP(t) elif 'WPA' in t.encryption: if t.wps: attack = AttackWPS(t) result = False try: result = attack.run() except Exception, e: Color.pl("\n{!} {R}Error: {O}%s" % str(e)) if Configuration.verbose > 0 or True: Color.pl('\n{!} {O}Full stack trace below') from traceback import format_exc Color.p('\n{!} ') err = format_exc().strip() err = err.replace('\n', '\n{!} {C} ') err = err.replace(' File', '{W}File') err = err.replace(' Exception: ', '{R}Exception: {O}') Color.pl(err) except KeyboardInterrupt: Color.pl('\n{!} {O}interrupted{W}\n') if not self.user_wants_to_continue( targets_remaining, 1): break if result and attack.success: # We cracked it. attack.crack_result.save() continue else: # WPS failed, try WPA handshake. attack = AttackWPA(t) else: # Not using WPS, try WPA handshake. attack = AttackWPA(t)
def run(self): ''' Main program. 1) Scans for targets, asks user to select targets 2) Attacks each target ''' s = Scanner() if s.target: # We found the target we want targets = [s.target] else: targets = s.select_targets() targets_remaining = len(targets) for index, t in enumerate(targets): targets_remaining -= 1 Color.pl('\n{+} ({G}%d{W}/{G}%d{W})' % (index + 1, len(targets)) + ' starting attacks against {C}%s{W} ({C}%s{W})' % (t.bssid, t.essid)) if 'WEP' in t.encryption: attack = AttackWEP(t) elif 'WPA' in t.encryption: if t.wps: attack = AttackWPS(t) result = False try: result = attack.run() except KeyboardInterrupt: if not self.user_wants_to_continue( targets_remaining, 1): break if result and attack.success: # We cracked it. attack.crack_result.save() continue else: # WPS failed, try WPA handshake. attack = AttackWPA(t) else: # Not using WPS, try WPA handshake. attack = AttackWPA(t) else: Color.pl( "{!} {R}Error: {O}unable to attack: encryption not WEP or WPA" ) continue try: attack.run() except KeyboardInterrupt: if not self.user_wants_to_continue(targets_remaining): break if attack.success: attack.crack_result.save()