Initial commit, basic helper classes created
This commit is contained in:
110
py/Configuration.py
Normal file
110
py/Configuration.py
Normal file
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
|
||||
class Configuration(object):
|
||||
''' Stores configuration variables for Wifite. '''
|
||||
|
||||
def __init__(self):
|
||||
''' Sets up default initial configuration values '''
|
||||
self.temp_dir = None # Temporary directory
|
||||
|
||||
self.version = 2.00 # Program version
|
||||
self.tx_power = 0 # Wifi transmit power (0 is default)
|
||||
self.interface = None
|
||||
self.target_channel = None # User-defined channel to scan
|
||||
self.target_essid = None # User-defined AP name
|
||||
self.target_bssid = None # User-defined AP BSSID
|
||||
self.pillage = False # "Pillage" mode to attack everything
|
||||
|
||||
# WEP variables
|
||||
self.wep_only = False # Only attack WEP networks
|
||||
self.wep_pps = 6000 # Packets per second
|
||||
self.wep_timeout = 600 # Seconds to wait before failing
|
||||
# WEP-specific attacks
|
||||
self.wep_fragment = True
|
||||
self.wep_caffelatte = True
|
||||
self.wep_p0841 = True
|
||||
self.wep_hirte = True
|
||||
# Number of IVS at which we start cracking
|
||||
self.wep_crack_at_ivs = 10000
|
||||
|
||||
# WPA variables
|
||||
self.wpa_only = False # Only attack WPA networks
|
||||
self.wpa_deauth_timeout = 10 # Seconds to wait between deauths
|
||||
self.wpa_attack_timeout = 500 # Seconds to wait before failing
|
||||
self.wpa_handshake_dir = "hs" # Directory to store handshakes
|
||||
|
||||
# Default dictionary for cracking
|
||||
self.wordlist = None
|
||||
wordlists = [
|
||||
'/usr/share/wfuzz/wordlist/fuzzdb/wordlists-user-passwd/passwds/phpbb.txt',
|
||||
'/usr/share/fuzzdb/wordlists-user-passwd/passwds/phpbb.txt'
|
||||
]
|
||||
for wlist in wordlists:
|
||||
if os.path.exists(wlist):
|
||||
self.wordlist = wlist
|
||||
break
|
||||
|
||||
# WPS variables
|
||||
self.wps_only = False # Only attack WPS networks
|
||||
self.pixie_only = False # Only use Pixie attack on WPS
|
||||
self.wps_timeout = 600 # Seconds to wait before failing
|
||||
self.wps_max_retries = 20 # Retries before failing
|
||||
|
||||
|
||||
def load_from_arguments(self, args):
|
||||
''' Sets configuration values based on Argument.args object '''
|
||||
if args.channel: self.target_channel = args.channel
|
||||
if args.interface: self.interface = args.interface
|
||||
if args.wep_only: self.wep_only = args.wep_only
|
||||
if args.wpa_only: self.wpa_only = args.wpa_only
|
||||
if args.wps_only: self.wps_only = args.wps_only
|
||||
if args.pixie_only: self.pixie_only = args.pixie_only
|
||||
if args.wordlist: self.wordlist = args.wordlist
|
||||
|
||||
|
||||
def temp(self):
|
||||
''' Creates and/or returns the temporary directory '''
|
||||
if self.temp_dir == None:
|
||||
self.temp_dir = self.create_temp()
|
||||
return self.temp_dir
|
||||
|
||||
def create_temp(self):
|
||||
''' Creates and returns a temporary directory '''
|
||||
from tempfile import mkdtemp
|
||||
tmp = mkdtemp(prefix='wifite')
|
||||
if not tmp.endswith(os.sep):
|
||||
tmp += os.sep
|
||||
return tmp
|
||||
|
||||
def delete_temp(self):
|
||||
''' Remove temp files and folder '''
|
||||
if self.temp_dir == None: return
|
||||
if os.path.exists(self.temp_dir):
|
||||
for f in os.listdir(self.temp_dir):
|
||||
os.remove(self.temp_dir + f)
|
||||
os.rmdir(self.temp_dir)
|
||||
|
||||
|
||||
def exit_gracefully(self, code=0):
|
||||
''' Deletes temp and exist with the given code '''
|
||||
self.delete_temp()
|
||||
exit(code)
|
||||
|
||||
def __str__(self):
|
||||
''' (Colorful) string representation of the configuration '''
|
||||
from Color import Color
|
||||
result = Color.s('{W}Wifite Configuration{W}\n')
|
||||
result += Color.s('{W}--------------------{W}\n')
|
||||
for (key,val) in sorted(c.__dict__.iteritems()):
|
||||
result += Color.s("{G}%s{W}:\t{C}%s{W}\n" % (key,val))
|
||||
return result
|
||||
|
||||
if __name__ == '__main__':
|
||||
c = Configuration()
|
||||
from Arguments import Arguments
|
||||
a = Arguments()
|
||||
c.load_from_arguments(a.args)
|
||||
print c
|
||||
|
||||
Reference in New Issue
Block a user