Don't kill+restart aircrack after 30s, wait 60s for target,

Also detect enabled/disabled interfaces when putting in/out of monitor mode.
This commit is contained in:
derv82
2018-04-19 12:59:11 -04:00
parent 1bbc7fefaf
commit adc7d37318
5 changed files with 23 additions and 8 deletions

View File

@@ -137,6 +137,7 @@ class AttackWEP(Attack):
self.fake_auth() self.fake_auth()
aircrack = Aircrack(ivs_file) aircrack = Aircrack(ivs_file)
'''
elif Configuration.wep_restart_aircrack > 0 and \ elif Configuration.wep_restart_aircrack > 0 and \
aircrack.pid.running_time() > Configuration.wep_restart_aircrack: aircrack.pid.running_time() > Configuration.wep_restart_aircrack:
# Restart aircrack after X seconds # Restart aircrack after X seconds
@@ -144,6 +145,7 @@ class AttackWEP(Attack):
ivs_file = airodump.find_files(endswith='.ivs')[0] ivs_file = airodump.find_files(endswith='.ivs')[0]
Color.pl('\n{+} {C}aircrack{W} ran for more than {C}%d{W} seconds, restarting' % Configuration.wep_restart_aircrack) Color.pl('\n{+} {C}aircrack{W} ran for more than {C}%d{W} seconds, restarting' % Configuration.wep_restart_aircrack)
aircrack = Aircrack(ivs_file) aircrack = Aircrack(ivs_file)
'''
if not aireplay.is_running(): if not aireplay.is_running():

View File

@@ -6,7 +6,7 @@ import time
class Attack(object): class Attack(object):
'''Contains functionality common to all attacks.''' '''Contains functionality common to all attacks.'''
target_wait = 20 target_wait = 60
def __init__(self, target): def __init__(self, target):
self.target = target self.target = target

View File

@@ -222,7 +222,7 @@ class Aireplay(Thread):
if pps == "0": if pps == "0":
self.status = "Waiting for packet..." self.status = "Waiting for packet..."
else: else:
self.status = "Replaying packet @ %s/sec" % pps self.status = "Replaying @ %s/sec" % pps
pass pass
def __del__(self): def __del__(self):

View File

@@ -213,7 +213,7 @@ class Airmon(object):
airmon_output = Process(['airmon-ng', 'stop', iface]).stdout() airmon_output = Process(['airmon-ng', 'stop', iface]).stdout()
disabled_iface = Airmon._parse_airmon_stop(airmon_output) (disabled_iface, enabled_iface) = Airmon._parse_airmon_stop(airmon_output)
if not disabled_iface and iface in Airmon.BAD_DRIVERS: if not disabled_iface and iface in Airmon.BAD_DRIVERS:
Color.p('{O}"bad driver" detected{W} ') Color.p('{O}"bad driver" detected{W} ')
@@ -224,6 +224,8 @@ class Airmon(object):
else: else:
Color.pl('{O}could not disable on {R}%s{W}' % iface) Color.pl('{O}could not disable on {R}%s{W}' % iface)
return (disabled_iface, enabled_iface)
@staticmethod @staticmethod
def _parse_airmon_stop(airmon_output): def _parse_airmon_stop(airmon_output):
@@ -235,17 +237,25 @@ class Airmon(object):
# airmon-ng 1.2rc1 output: wlan0mon (removed) # airmon-ng 1.2rc1 output: wlan0mon (removed)
removed_re = re.compile(r'([a-zA-Z0-9]+).*\(removed\)') removed_re = re.compile(r'([a-zA-Z0-9]+).*\(removed\)')
# Enabled interface: (mac80211 station mode vif enabled on [phy4]wlan0)
enabled_re = re.compile(r'\s*\(mac80211 station mode (?:vif )?enabled on (?:\[\w+\])?(\w+)\)\s*')
disabled_iface = None disabled_iface = None
enabled_iface = None
for line in airmon_output.split('\n'): for line in airmon_output.split('\n'):
matches = disabled_re.match(line) matches = disabled_re.match(line)
if matches: if matches:
return matches.group(1) disabled_iface = matches.group(1)
matches = removed_re.match(line) matches = removed_re.match(line)
if matches: if matches:
return matches.group(1) disabled_iface = matches.group(1)
return None matches = enabled_re.match(line)
if matches:
enabled_iface = matches.group(1)
return (disabled_iface, enabled_iface)
@staticmethod @staticmethod
@@ -386,4 +396,6 @@ class Airmon(object):
if __name__ == '__main__': if __name__ == '__main__':
Airmon.terminate_conflicting_processes() Airmon.terminate_conflicting_processes()
iface = Airmon.ask() iface = Airmon.ask()
Airmon.stop(iface) (disabled_iface, enabled_iface) = Airmon.stop(iface)
print("Disabled:", disabled_iface)
print("Enabled:", enabled_iface)

View File

@@ -10,11 +10,12 @@ class Ifconfig(object):
'''Put interface up''' '''Put interface up'''
from ..util.process import Process from ..util.process import Process
command = ['ifconfig', interface, 'up'] command = ['ifconfig', interface]
if type(args) is list: if type(args) is list:
command.extend(args) command.extend(args)
elif type(args) is 'str': elif type(args) is 'str':
command.append(args) command.append(args)
command.append('up')
pid = Process(command) pid = Process(command)
pid.wait() pid.wait()