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:
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}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user