Restart aireplay and aircrack after X seconds

This commit is contained in:
derv82
2015-05-31 11:12:17 -07:00
parent 5528fbfbac
commit 1d6d0aedb3
4 changed files with 31 additions and 29 deletions

View File

@@ -6,7 +6,8 @@ from Configuration import Configuration
import os
class Aircrack(object):
def __init__(self, ivs_file):
def __init__(self, ivs_file=None):
self.cracked_file = Configuration.temp() + 'wepkey.txt'
# Delete previous cracked files
@@ -26,10 +27,13 @@ class Aircrack(object):
def is_running(self):
return self.pid.poll() == None
def is_cracked(self):
return os.path.exists(self.cracked_file)
def stop(self):
''' Stops aircrack process '''
if self.pid.poll() == None:
self.pid.interrupt()
def get_key_hex_ascii(self):
if not self.is_cracked():

View File

@@ -105,37 +105,30 @@ class AttackWEP(Attack):
# Check number of IVs, crack if necessary
if airodump_target.ivs > Configuration.wep_crack_at_ivs:
if not aircrack:
# Aircrack hasn't started yet.
# Find the .ivs file.
ivs_file = None
for fil in airodump.find_files(endswith='.ivs'):
ivs_file = fil
break
if not ivs_file:
Color.pl('{!} {O}no .ivs file found, stopping{W}')
break
else:
Color.pl('\n{+} started {C}cracking{W}')
aircrack = Aircrack(ivs_file)
# Aircrack hasn't started yet. Start it.
ivs_file = airodump.find_files(endswith='.ivs')[0]
Color.pl('\n{+} started {C}cracking{W}')
aircrack = Aircrack(ivs_file)
elif not aircrack.is_running():
# Aircrack stopped running.
Color.pl('\n{!} {O}aircrack stopped running!{W}')
ivs_file = None
for fil in airodump.find_files(endswith='.ivs'):
ivs_file = fil
break
if ivs_file:
Color.pl('{+} restarting {C}aircrack{W}')
ivs_file = airodump.find_files(endswith='.ivs')[0]
Color.pl('{+} {C}aircrack{W} stopped,' +
' restarting {C}aircrack{W}')
aircrack = Aircrack(ivs_file)
elif aircrack.is_running() and \
Configuration.wep_restart_aircrack > 0:
# Restart aircrack after X seconds
if aircrack.pid.running_time() > Configuration.wep_restart_aircrack:
aircrack.stop()
ivs_file = airodump.find_files(endswith='.ivs')[0]
Color.pl('{+} {C}aircrack{W} running more than' +
' {C}%d{W} seconds, restarting'
% Configuration.wep_restart_aircrack)
aircrack = Aircrack(ivs_file)
else:
# No .ivs file and aircrack stopped, error?
Color.pl('{!} {O}no .ivs file found, stopping{W}')
break
elif aircrack.is_running():
# TODO: Restart aircrack after X seconds
pass
if not aireplay.is_running():
# Some Aireplay attacks loop infinitely
@@ -168,6 +161,9 @@ class AttackWEP(Attack):
if stale_seconds > Configuration.wep_restart_stale_ivs:
# No new IVs within threshold, restart aireplay
aireplay.stop()
Color.pl('{!} restarting {C}aireplay{W} after' +
' {C}%d{W} seconds of no new IVs'
% stale_seconds)
aireplay = Aireplay(self.target, \
wep_attack_type, \
client_mac=client_mac)

View File

@@ -37,6 +37,8 @@ class Configuration(object):
Configuration.wep_restart_stale_ivs = 30 # Seconds to wait before restarting
# Aireplay if IVs don't increaes.
# "0" means never restart.
Configuration.wep_restart_aircrack = 180 # Seconds to give aircrack to crack
# before restarting the process.
# WEP-specific attacks
Configuration.wep_fragment = True
Configuration.wep_caffelatte = True

View File

@@ -86,7 +86,7 @@ class Process(object):
''' Returns exit code if process is dead, otherwise "None" '''
return self.pid.poll()
def time_running(self):
def running_time(self):
''' Returns number of seconds since process was started '''
return int(time.time() - self.start_time)