Root check. And attacks can be stopped/skipped

This commit is contained in:
derv82
2015-06-13 13:58:19 -07:00
parent 491854ddb0
commit c32462a045

View File

@@ -16,6 +16,12 @@ class Wifite(object):
def main(self): def main(self):
''' Either performs action based on arguments, or starts attack scanning ''' ''' Either performs action based on arguments, or starts attack scanning '''
if os.getuid() != 0:
Color.pl('{!} {R}error: {O}wifite{R} must be run as {O}root{W}')
Color.pl('{!} {O}re-run as: sudo ./Wifite.py{W}')
return
Configuration.initialize(load_interface=False) Configuration.initialize(load_interface=False)
if Configuration.show_cracked: if Configuration.show_cracked:
@@ -78,34 +84,48 @@ class Wifite(object):
else: else:
targets = s.select_targets() targets = s.select_targets()
for t in targets: targets_remaining = len(targets)
Color.pl('{+} starting attacks against {C}%s{W} ({C}%s{W})' 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)) % (t.bssid, t.essid))
if 'WEP' in t.encryption: if 'WEP' in t.encryption:
attack = AttackWEP(t) attack = AttackWEP(t)
attack.run()
elif 'WPA' in t.encryption: elif 'WPA' in t.encryption:
if t.wps: if t.wps:
attack = AttackWPS(t) attack = AttackWPS(t)
if attack.run(): result = False
# We cracked it. try:
result = attack.run()
except KeyboardInterrupt:
if not self.user_wants_to_continue(targets_remaining, 1):
break break
if result and attack.success:
# We cracked it.
attack.crack_result.save()
continue
else: else:
# WPS failed, try WPA handshake. # WPS failed, try WPA handshake.
attack = AttackWPA(t) attack = AttackWPA(t)
attack.run()
else: else:
# Not using WPS, try WPA handshake. # Not using WPS, try WPA handshake.
attack = AttackWPA(t) attack = AttackWPA(t)
attack.run()
else: else:
Color.pl("{!} {R}Error: {O}unable to attack: encryption not WEP or WPA") Color.pl("{!} {R}Error: {O}unable to attack: encryption not WEP or WPA")
continue continue
pass
try:
attack.run()
except KeyboardInterrupt:
if not self.user_wants_to_continue(targets_remaining):
break
if attack.success: if attack.success:
attack.crack_result.save() attack.crack_result.save()
pass
def print_banner(self): def print_banner(self):
""" Displays ASCII art of the highest caliber. """ """ Displays ASCII art of the highest caliber. """
@@ -124,6 +144,30 @@ class Wifite(object):
Color.pl("{W}") Color.pl("{W}")
def user_wants_to_continue(self, targets_remaining, attacks_remaining=0):
''' Asks user if attacks should continue onto other targets '''
Color.pl('\n{!} {O}interrupted{W}\n')
if attacks_remaining == 0 and targets_remaining == 0:
# No targets or attacksleft, drop out
return
prompt_list = []
if attacks_remaining > 0:
prompt_list.append(Color.s('{C}%d{W} attack(s)' % attacks_remaining))
if targets_remaining > 0:
prompt_list.append(Color.s('{C}%d{W} target(s)' % targets_remaining))
prompt = ' and '.join(prompt_list)
Color.pl('{+} %s remain, do you want to continue?' % prompt)
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:
return True
if __name__ == '__main__': if __name__ == '__main__':
w = Wifite() w = Wifite()
try: try: