Restart aireplay and aircrack after X seconds
This commit is contained in:
@@ -6,7 +6,8 @@ from Configuration import Configuration
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
class Aircrack(object):
|
class Aircrack(object):
|
||||||
def __init__(self, ivs_file):
|
def __init__(self, ivs_file=None):
|
||||||
|
|
||||||
self.cracked_file = Configuration.temp() + 'wepkey.txt'
|
self.cracked_file = Configuration.temp() + 'wepkey.txt'
|
||||||
|
|
||||||
# Delete previous cracked files
|
# Delete previous cracked files
|
||||||
@@ -26,10 +27,13 @@ class Aircrack(object):
|
|||||||
def is_running(self):
|
def is_running(self):
|
||||||
return self.pid.poll() == None
|
return self.pid.poll() == None
|
||||||
|
|
||||||
|
|
||||||
def is_cracked(self):
|
def is_cracked(self):
|
||||||
return os.path.exists(self.cracked_file)
|
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):
|
def get_key_hex_ascii(self):
|
||||||
if not self.is_cracked():
|
if not self.is_cracked():
|
||||||
|
|||||||
@@ -105,37 +105,30 @@ class AttackWEP(Attack):
|
|||||||
# Check number of IVs, crack if necessary
|
# Check number of IVs, crack if necessary
|
||||||
if airodump_target.ivs > Configuration.wep_crack_at_ivs:
|
if airodump_target.ivs > Configuration.wep_crack_at_ivs:
|
||||||
if not aircrack:
|
if not aircrack:
|
||||||
# Aircrack hasn't started yet.
|
# Aircrack hasn't started yet. Start it.
|
||||||
# Find the .ivs file.
|
ivs_file = airodump.find_files(endswith='.ivs')[0]
|
||||||
ivs_file = None
|
Color.pl('\n{+} started {C}cracking{W}')
|
||||||
for fil in airodump.find_files(endswith='.ivs'):
|
aircrack = Aircrack(ivs_file)
|
||||||
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)
|
|
||||||
|
|
||||||
elif not aircrack.is_running():
|
elif not aircrack.is_running():
|
||||||
# Aircrack stopped running.
|
# Aircrack stopped running.
|
||||||
Color.pl('\n{!} {O}aircrack stopped running!{W}')
|
Color.pl('\n{!} {O}aircrack stopped running!{W}')
|
||||||
ivs_file = None
|
ivs_file = airodump.find_files(endswith='.ivs')[0]
|
||||||
for fil in airodump.find_files(endswith='.ivs'):
|
Color.pl('{+} {C}aircrack{W} stopped,' +
|
||||||
ivs_file = fil
|
' restarting {C}aircrack{W}')
|
||||||
break
|
aircrack = Aircrack(ivs_file)
|
||||||
if ivs_file:
|
|
||||||
Color.pl('{+} restarting {C}aircrack{W}')
|
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)
|
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():
|
if not aireplay.is_running():
|
||||||
# Some Aireplay attacks loop infinitely
|
# Some Aireplay attacks loop infinitely
|
||||||
@@ -168,6 +161,9 @@ class AttackWEP(Attack):
|
|||||||
if stale_seconds > Configuration.wep_restart_stale_ivs:
|
if stale_seconds > Configuration.wep_restart_stale_ivs:
|
||||||
# No new IVs within threshold, restart aireplay
|
# No new IVs within threshold, restart aireplay
|
||||||
aireplay.stop()
|
aireplay.stop()
|
||||||
|
Color.pl('{!} restarting {C}aireplay{W} after' +
|
||||||
|
' {C}%d{W} seconds of no new IVs'
|
||||||
|
% stale_seconds)
|
||||||
aireplay = Aireplay(self.target, \
|
aireplay = Aireplay(self.target, \
|
||||||
wep_attack_type, \
|
wep_attack_type, \
|
||||||
client_mac=client_mac)
|
client_mac=client_mac)
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ class Configuration(object):
|
|||||||
Configuration.wep_restart_stale_ivs = 30 # Seconds to wait before restarting
|
Configuration.wep_restart_stale_ivs = 30 # Seconds to wait before restarting
|
||||||
# Aireplay if IVs don't increaes.
|
# Aireplay if IVs don't increaes.
|
||||||
# "0" means never restart.
|
# "0" means never restart.
|
||||||
|
Configuration.wep_restart_aircrack = 180 # Seconds to give aircrack to crack
|
||||||
|
# before restarting the process.
|
||||||
# WEP-specific attacks
|
# WEP-specific attacks
|
||||||
Configuration.wep_fragment = True
|
Configuration.wep_fragment = True
|
||||||
Configuration.wep_caffelatte = True
|
Configuration.wep_caffelatte = True
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class Process(object):
|
|||||||
''' Returns exit code if process is dead, otherwise "None" '''
|
''' Returns exit code if process is dead, otherwise "None" '''
|
||||||
return self.pid.poll()
|
return self.pid.poll()
|
||||||
|
|
||||||
def time_running(self):
|
def running_time(self):
|
||||||
''' Returns number of seconds since process was started '''
|
''' Returns number of seconds since process was started '''
|
||||||
return int(time.time() - self.start_time)
|
return int(time.time() - self.start_time)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user