Less-invasive interface management, catch Exceptions at the target-level
Exception-handling should resolve #18 (move onto next target instead of crashing). Interface management changes: 1. Interfaces are left in monitor-mode if they were already in monitor mode * Previously *always* put the iface out of monitor mode & restarted network manager 2. Only the interface that was put into monitor mode is brought back up * Previously all interfaces were brought back up
This commit is contained in:
@@ -101,7 +101,10 @@ class Wifite(object):
|
||||
result = False
|
||||
try:
|
||||
result = attack.run()
|
||||
except Exception, e:
|
||||
Color.pl("\n{!} {R}Error: {O}%s" % str(e))
|
||||
except KeyboardInterrupt:
|
||||
Color.pl('\n{!} {O}interrupted{W}\n')
|
||||
if not self.user_wants_to_continue(targets_remaining, 1):
|
||||
break
|
||||
|
||||
@@ -121,7 +124,10 @@ class Wifite(object):
|
||||
|
||||
try:
|
||||
attack.run()
|
||||
except Exception, e:
|
||||
Color.pl("\n{!} {R}Error: {O}%s" % str(e))
|
||||
except KeyboardInterrupt:
|
||||
Color.pl('\n{!} {O}interrupted{W}\n')
|
||||
if not self.user_wants_to_continue(targets_remaining):
|
||||
break
|
||||
|
||||
@@ -145,7 +151,6 @@ class Wifite(object):
|
||||
|
||||
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
|
||||
|
||||
14
py/Airmon.py
14
py/Airmon.py
@@ -12,6 +12,7 @@ import signal
|
||||
|
||||
class Airmon(object):
|
||||
''' Wrapper around the 'airmon-ng' program '''
|
||||
base_interface = None
|
||||
|
||||
def __init__(self):
|
||||
self.refresh()
|
||||
@@ -71,6 +72,7 @@ class Airmon(object):
|
||||
# Get interface name from input
|
||||
if type(iface) == Interface:
|
||||
iface = iface.name
|
||||
Airmon.base_interface = iface
|
||||
|
||||
# Call airmon-ng
|
||||
Color.p("{+} enabling {G}monitor mode{W} on {C}%s{W}... " % iface)
|
||||
@@ -178,6 +180,7 @@ class Airmon(object):
|
||||
iface = mon_ifaces[0]
|
||||
Color.pl('{+} using interface {G}%s{W} which is already in monitor mode'
|
||||
% iface);
|
||||
Airmon.base_interface = None
|
||||
return iface
|
||||
|
||||
a = Airmon()
|
||||
@@ -251,15 +254,14 @@ class Airmon(object):
|
||||
os.kill(int(pid), signal.SIGTERM)
|
||||
|
||||
@staticmethod
|
||||
def put_interfaces_up():
|
||||
for interface in Airmon.get_interfaces():
|
||||
Color.p("{!} {O}putting interface {R}%s up{O}..." %(interface.name))
|
||||
(out,err) = Process.call('ifconfig %s up' %(interface.name))
|
||||
Color.pl(" {R}done{W}")
|
||||
def put_interface_up(iface):
|
||||
Color.p("{!} {O}putting interface {R}%s up{O}..." % (iface))
|
||||
(out,err) = Process.call('ifconfig %s up' % (iface))
|
||||
Color.pl(" {R}done{W}")
|
||||
|
||||
@staticmethod
|
||||
def start_network_manager():
|
||||
Color.p("{!} {O}Restarting {R}NetworkManager{O}...")
|
||||
Color.p("{!} {O}restarting {R}NetworkManager{O}...")
|
||||
(out,err) = Process.call('systemctl start NetworkManager')
|
||||
Color.pl(" {R}restarted{W}")
|
||||
|
||||
|
||||
@@ -289,9 +289,9 @@ class Configuration(object):
|
||||
Configuration.delete_temp()
|
||||
Macchanger.reset_if_changed()
|
||||
from Airmon import Airmon
|
||||
if Configuration.interface is not None:
|
||||
if Configuration.interface is not None and Airmon.base_interface is not None:
|
||||
Airmon.stop(Configuration.interface)
|
||||
Airmon.put_interfaces_up()
|
||||
Airmon.put_interface_up(Airmon.base_interface)
|
||||
Airmon.start_network_manager()
|
||||
exit(code)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user