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
|
result = False
|
||||||
try:
|
try:
|
||||||
result = attack.run()
|
result = attack.run()
|
||||||
|
except Exception, e:
|
||||||
|
Color.pl("\n{!} {R}Error: {O}%s" % str(e))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
Color.pl('\n{!} {O}interrupted{W}\n')
|
||||||
if not self.user_wants_to_continue(targets_remaining, 1):
|
if not self.user_wants_to_continue(targets_remaining, 1):
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -121,7 +124,10 @@ class Wifite(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
attack.run()
|
attack.run()
|
||||||
|
except Exception, e:
|
||||||
|
Color.pl("\n{!} {R}Error: {O}%s" % str(e))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
Color.pl('\n{!} {O}interrupted{W}\n')
|
||||||
if not self.user_wants_to_continue(targets_remaining):
|
if not self.user_wants_to_continue(targets_remaining):
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -145,7 +151,6 @@ class Wifite(object):
|
|||||||
|
|
||||||
def user_wants_to_continue(self, targets_remaining, attacks_remaining=0):
|
def user_wants_to_continue(self, targets_remaining, attacks_remaining=0):
|
||||||
''' Asks user if attacks should continue onto other targets '''
|
''' Asks user if attacks should continue onto other targets '''
|
||||||
Color.pl('\n{!} {O}interrupted{W}\n')
|
|
||||||
if attacks_remaining == 0 and targets_remaining == 0:
|
if attacks_remaining == 0 and targets_remaining == 0:
|
||||||
# No targets or attacksleft, drop out
|
# No targets or attacksleft, drop out
|
||||||
return
|
return
|
||||||
|
|||||||
12
py/Airmon.py
12
py/Airmon.py
@@ -12,6 +12,7 @@ import signal
|
|||||||
|
|
||||||
class Airmon(object):
|
class Airmon(object):
|
||||||
''' Wrapper around the 'airmon-ng' program '''
|
''' Wrapper around the 'airmon-ng' program '''
|
||||||
|
base_interface = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.refresh()
|
self.refresh()
|
||||||
@@ -71,6 +72,7 @@ class Airmon(object):
|
|||||||
# Get interface name from input
|
# Get interface name from input
|
||||||
if type(iface) == Interface:
|
if type(iface) == Interface:
|
||||||
iface = iface.name
|
iface = iface.name
|
||||||
|
Airmon.base_interface = iface
|
||||||
|
|
||||||
# Call airmon-ng
|
# Call airmon-ng
|
||||||
Color.p("{+} enabling {G}monitor mode{W} on {C}%s{W}... " % iface)
|
Color.p("{+} enabling {G}monitor mode{W} on {C}%s{W}... " % iface)
|
||||||
@@ -178,6 +180,7 @@ class Airmon(object):
|
|||||||
iface = mon_ifaces[0]
|
iface = mon_ifaces[0]
|
||||||
Color.pl('{+} using interface {G}%s{W} which is already in monitor mode'
|
Color.pl('{+} using interface {G}%s{W} which is already in monitor mode'
|
||||||
% iface);
|
% iface);
|
||||||
|
Airmon.base_interface = None
|
||||||
return iface
|
return iface
|
||||||
|
|
||||||
a = Airmon()
|
a = Airmon()
|
||||||
@@ -251,15 +254,14 @@ class Airmon(object):
|
|||||||
os.kill(int(pid), signal.SIGTERM)
|
os.kill(int(pid), signal.SIGTERM)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def put_interfaces_up():
|
def put_interface_up(iface):
|
||||||
for interface in Airmon.get_interfaces():
|
Color.p("{!} {O}putting interface {R}%s up{O}..." % (iface))
|
||||||
Color.p("{!} {O}putting interface {R}%s up{O}..." %(interface.name))
|
(out,err) = Process.call('ifconfig %s up' % (iface))
|
||||||
(out,err) = Process.call('ifconfig %s up' %(interface.name))
|
|
||||||
Color.pl(" {R}done{W}")
|
Color.pl(" {R}done{W}")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def start_network_manager():
|
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')
|
(out,err) = Process.call('systemctl start NetworkManager')
|
||||||
Color.pl(" {R}restarted{W}")
|
Color.pl(" {R}restarted{W}")
|
||||||
|
|
||||||
|
|||||||
@@ -289,9 +289,9 @@ class Configuration(object):
|
|||||||
Configuration.delete_temp()
|
Configuration.delete_temp()
|
||||||
Macchanger.reset_if_changed()
|
Macchanger.reset_if_changed()
|
||||||
from Airmon import Airmon
|
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.stop(Configuration.interface)
|
||||||
Airmon.put_interfaces_up()
|
Airmon.put_interface_up(Airmon.base_interface)
|
||||||
Airmon.start_network_manager()
|
Airmon.start_network_manager()
|
||||||
exit(code)
|
exit(code)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user