Massive refactor/renaming. No more upper-case filenames.
This commit is contained in:
240
Wifite.py
240
Wifite.py
@@ -1,239 +1 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from py.Configuration import Configuration
|
||||
from py.Scanner import Scanner
|
||||
from py.Color import Color
|
||||
from py.AttackWEP import AttackWEP
|
||||
from py.AttackWPA import AttackWPA
|
||||
from py.AttackWPS import AttackWPS
|
||||
from py.CrackResult import CrackResult
|
||||
from py.Handshake import Handshake
|
||||
from py.CrackHandshake import CrackHandshake
|
||||
from py.Process import Process
|
||||
|
||||
from json import loads
|
||||
import os
|
||||
from sys import exit
|
||||
|
||||
class Wifite(object):
|
||||
|
||||
def main(self):
|
||||
''' Either performs action based on arguments, or starts attack scanning '''
|
||||
|
||||
if os.getuid() != 0:
|
||||
Color.pl('{!} {R}error: {O}wifite{R} must be run as {O}root{W}')
|
||||
Color.pl('{!} {O}re-run as: sudo ./Wifite.py{W}')
|
||||
Configuration.exit_gracefully(0)
|
||||
|
||||
self.dependency_check()
|
||||
|
||||
Configuration.initialize(load_interface=False)
|
||||
|
||||
if Configuration.show_cracked:
|
||||
self.display_cracked()
|
||||
|
||||
elif Configuration.check_handshake:
|
||||
self.check_handshake(Configuration.check_handshake)
|
||||
elif Configuration.crack_handshake:
|
||||
CrackHandshake()
|
||||
else:
|
||||
Configuration.get_interface()
|
||||
self.run()
|
||||
|
||||
def dependency_check(self):
|
||||
''' Check that required programs are installed '''
|
||||
required_apps = ['airmon-ng', 'iwconfig', 'ifconfig', 'aircrack-ng', 'aireplay-ng', 'airodump-ng', 'tshark']
|
||||
optional_apps = ['packetforge-ng', 'reaver', 'bully', 'cowpatty', 'pyrit', 'stdbuf', 'macchanger']
|
||||
missing_required = False
|
||||
missing_optional = False
|
||||
|
||||
for app in required_apps:
|
||||
if not Process.exists(app):
|
||||
missing_required = True
|
||||
Color.pl('{!} {R}error: required app {O}%s{R} was not found' % app)
|
||||
|
||||
for app in optional_apps:
|
||||
if not Process.exists(app):
|
||||
missing_optional = True
|
||||
Color.pl('{!} {O}warning: recommended app {R}%s{O} was not found' % app)
|
||||
|
||||
if missing_required:
|
||||
Color.pl('{!} {R}required app(s) were not found, exiting.{W}')
|
||||
exit(-1)
|
||||
|
||||
if missing_optional:
|
||||
Color.pl('{!} {O}recommended app(s) were not found')
|
||||
Color.pl('{!} {O}wifite may not work as expected{W}')
|
||||
|
||||
def display_cracked(self):
|
||||
''' Show cracked targets from cracked.txt '''
|
||||
Color.pl('{+} displaying {C}cracked target(s){W}')
|
||||
name = CrackResult.cracked_file
|
||||
if not os.path.exists(name):
|
||||
Color.pl('{!} {O}file {C}%s{O} not found{W}' % name)
|
||||
return
|
||||
with open(name, 'r') as fid:
|
||||
json = loads(fid.read())
|
||||
for idx, item in enumerate(json, start=1):
|
||||
Color.pl('\n{+} Cracked target #%d:' % (idx))
|
||||
cr = CrackResult.load(item)
|
||||
cr.dump()
|
||||
|
||||
def check_handshake(self, capfile):
|
||||
''' Analyzes .cap file for handshake '''
|
||||
if capfile == '<all>':
|
||||
Color.pl('{+} checking all handshakes in {G}"./hs"{W} directory\n')
|
||||
try:
|
||||
capfiles = [os.path.join('hs', x) for x in os.listdir('hs') if x.endswith('.cap')]
|
||||
except OSError, e:
|
||||
capfiles = []
|
||||
if len(capfiles) == 0:
|
||||
Color.pl('{!} {R}no .cap files found in {O}"./hs"{W}\n')
|
||||
else:
|
||||
capfiles = [capfile]
|
||||
for capfile in capfiles:
|
||||
Color.pl('{+} checking for handshake in .cap file {C}%s{W}' % capfile)
|
||||
if not os.path.exists(capfile):
|
||||
Color.pl('{!} {O}.cap file {C}%s{O} not found{W}' % capfile)
|
||||
return
|
||||
hs = Handshake(capfile, bssid=Configuration.target_bssid, essid=Configuration.target_essid)
|
||||
hs.analyze()
|
||||
Color.pl('')
|
||||
|
||||
def run(self):
|
||||
'''
|
||||
Main program.
|
||||
1) Scans for targets, asks user to select targets
|
||||
2) Attacks each target
|
||||
'''
|
||||
s = Scanner()
|
||||
if s.target:
|
||||
# We found the target we want
|
||||
targets = [s.target]
|
||||
else:
|
||||
targets = s.select_targets()
|
||||
|
||||
attacked_targets = 0
|
||||
targets_remaining = len(targets)
|
||||
for idx, t in enumerate(targets, start=1):
|
||||
attacked_targets += 1
|
||||
targets_remaining -= 1
|
||||
|
||||
Color.pl('\n{+} ({G}%d{W}/{G}%d{W})' % (idx, len(targets)) +
|
||||
' starting attacks against {C}%s{W} ({C}%s{W})'
|
||||
% (t.bssid, t.essid if t.essid_known else "{O}ESSID unknown"))
|
||||
if 'WEP' in t.encryption:
|
||||
attack = AttackWEP(t)
|
||||
elif 'WPA' in t.encryption:
|
||||
if t.wps:
|
||||
attack = AttackWPS(t)
|
||||
result = False
|
||||
try:
|
||||
result = attack.run()
|
||||
except Exception as e:
|
||||
Color.pl("\n{!} {R}Error: {O}%s" % str(e))
|
||||
if Configuration.verbose > 0 or Configuration.print_stack_traces:
|
||||
Color.pl('\n{!} {O}Full stack trace below')
|
||||
from traceback import format_exc
|
||||
Color.p('\n{!} ')
|
||||
err = format_exc().strip()
|
||||
err = err.replace('\n', '\n{!} {C} ')
|
||||
err = err.replace(' File', '{W}File')
|
||||
err = err.replace(' Exception: ', '{R}Exception: {O}')
|
||||
Color.pl(err)
|
||||
except KeyboardInterrupt:
|
||||
Color.pl('\n{!} {O}interrupted{W}\n')
|
||||
if not self.user_wants_to_continue(targets_remaining, 1):
|
||||
break
|
||||
|
||||
if result and attack.success:
|
||||
# We cracked it.
|
||||
attack.crack_result.save()
|
||||
continue
|
||||
else:
|
||||
# WPS failed, try WPA handshake.
|
||||
attack = AttackWPA(t)
|
||||
else:
|
||||
# Not using WPS, try WPA handshake.
|
||||
attack = AttackWPA(t)
|
||||
else:
|
||||
Color.pl("{!} {R}Error: {O}unable to attack: encryption not WEP or WPA")
|
||||
continue
|
||||
|
||||
try:
|
||||
attack.run()
|
||||
except Exception, e:
|
||||
Color.pl("\n{!} {R}Error: {O}%s" % str(e))
|
||||
if Configuration.verbose > 0 or True:
|
||||
Color.pl('\n{!} {O}Full stack trace below')
|
||||
from traceback import format_exc
|
||||
Color.p('\n{!} ')
|
||||
err = format_exc().strip()
|
||||
err = err.replace('\n', '\n{!} {C} ')
|
||||
err = err.replace(' File', '{W}File')
|
||||
err = err.replace(' Exception: ', '{R}Exception: {O}')
|
||||
Color.pl(err)
|
||||
except KeyboardInterrupt:
|
||||
Color.pl('\n{!} {O}interrupted{W}\n')
|
||||
if not self.user_wants_to_continue(targets_remaining):
|
||||
break
|
||||
|
||||
if attack.success:
|
||||
attack.crack_result.save()
|
||||
Color.pl("{+} Finished attacking {C}%d{W} target(s), exiting" % attacked_targets)
|
||||
|
||||
|
||||
def print_banner(self):
|
||||
""" Displays ASCII art of the highest caliber. """
|
||||
Color.pl(r'''
|
||||
{G} . {GR}{D} {W}{G} . {W}
|
||||
{G}.´ · .{GR}{D} {W}{G}. · `. {G}wifite {D}%s{W}
|
||||
{G}: : : {GR}{D} (¯) {W}{G} : : : {W}{D}automated wireless auditor
|
||||
{G}`. · `{GR}{D} /¯\ {W}{G}´ · .´ {C}{D}https://github.com/derv82/wifite2
|
||||
{G} ` {GR}{D}/¯¯¯\{W}{G} ´ {W}
|
||||
''' % Configuration.version)
|
||||
|
||||
def user_wants_to_continue(self, targets_remaining, attacks_remaining=0):
|
||||
''' Asks user if attacks should continue onto other targets '''
|
||||
if attacks_remaining == 0 and targets_remaining == 0:
|
||||
# No targets or attacksleft, drop out
|
||||
return
|
||||
|
||||
prompt_list = []
|
||||
if attacks_remaining > 0:
|
||||
prompt_list.append(Color.s('{C}%d{W} attack(s)' % attacks_remaining))
|
||||
if targets_remaining > 0:
|
||||
prompt_list.append(Color.s('{C}%d{W} target(s)' % targets_remaining))
|
||||
prompt = ' and '.join(prompt_list)
|
||||
Color.pl('{+} %s remain, do you want to continue?' % prompt)
|
||||
|
||||
prompt = Color.s('{+} type {G}c{W} to {G}continue{W}' +
|
||||
' or {R}s{W} to {R}stop{W}: ')
|
||||
|
||||
if raw_input(prompt).lower().startswith('s'):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
w = Wifite()
|
||||
try:
|
||||
w.print_banner()
|
||||
w.main()
|
||||
except Exception, e:
|
||||
Color.pl('\n{!} {R}Error:{O} %s{W}' % str(e))
|
||||
if Configuration.verbose > 0 or True:
|
||||
Color.pl('\n{!} {O}Full stack trace below')
|
||||
from traceback import format_exc
|
||||
Color.p('\n{!} ')
|
||||
err = format_exc().strip()
|
||||
err = err.replace('\n', '\n{!} {C} ')
|
||||
err = err.replace(' File', '{W}File')
|
||||
err = err.replace(' Exception: ', '{R}Exception: {O}')
|
||||
Color.pl(err)
|
||||
Color.pl('\n{!} {R}Exiting{W}\n')
|
||||
except KeyboardInterrupt:
|
||||
Color.pl('\n{!} {O}interrupted, shutting down...{W}')
|
||||
Configuration.exit_gracefully(0)
|
||||
python -m wifite.wifite
|
||||
|
||||
3
py/Arguments.py → wifite/args.py
Normal file → Executable file
3
py/Arguments.py → wifite/args.py
Normal file → Executable file
@@ -1,8 +1,9 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from util.color import Color
|
||||
|
||||
import argparse
|
||||
from Color import Color
|
||||
|
||||
class Arguments(object):
|
||||
''' Holds arguments used by the Wifite '''
|
||||
0
wifite/attack/__init__.py
Normal file
0
wifite/attack/__init__.py
Normal file
16
py/AttackWEP.py → wifite/attack/wep.py
Normal file → Executable file
16
py/AttackWEP.py → wifite/attack/wep.py
Normal file → Executable file
@@ -1,14 +1,14 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Attack import Attack
|
||||
from Airodump import Airodump
|
||||
from Aireplay import Aireplay, WEPAttackType
|
||||
from Aircrack import Aircrack
|
||||
from Configuration import Configuration
|
||||
from Interface import Interface
|
||||
from Color import Color
|
||||
from CrackResultWEP import CrackResultWEP
|
||||
from ..model.attack import Attack
|
||||
from ..tools.airodump import Airodump
|
||||
from ..tools.aireplay import Aireplay, WEPAttackType
|
||||
from ..tools.aircrack import Aircrack
|
||||
from ..config import Configuration
|
||||
from ..model.interface import Interface
|
||||
from ..util.color import Color
|
||||
from ..model.wep_result import CrackResultWEP
|
||||
|
||||
import time
|
||||
|
||||
18
py/AttackWPA.py → wifite/attack/wpa.py
Normal file → Executable file
18
py/AttackWPA.py → wifite/attack/wpa.py
Normal file → Executable file
@@ -1,15 +1,15 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Attack import Attack
|
||||
from Airodump import Airodump
|
||||
from Aireplay import Aireplay
|
||||
from Color import Color
|
||||
from Configuration import Configuration
|
||||
from Handshake import Handshake
|
||||
from Process import Process
|
||||
from CrackResultWPA import CrackResultWPA
|
||||
from Timer import Timer
|
||||
from ..model.attack import Attack
|
||||
from ..tools.airodump import Airodump
|
||||
from ..tools.aireplay import Aireplay
|
||||
from ..config import Configuration
|
||||
from ..util.color import Color
|
||||
from ..util.process import Process
|
||||
from ..util.timer import Timer
|
||||
from ..model.handshake import Handshake
|
||||
from ..model.wpa_result import CrackResultWPA
|
||||
|
||||
import time
|
||||
import os
|
||||
10
py/AttackWPS.py → wifite/attack/wps.py
Normal file → Executable file
10
py/AttackWPS.py → wifite/attack/wps.py
Normal file → Executable file
@@ -1,11 +1,11 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Attack import Attack
|
||||
from Color import Color
|
||||
from Configuration import Configuration
|
||||
from Bully import Bully
|
||||
from Reaver import Reaver
|
||||
from ..model.attack import Attack
|
||||
from ..util.color import Color
|
||||
from ..config import Configuration
|
||||
from ..tools.bully import Bully
|
||||
from ..tools.reaver import Reaver
|
||||
|
||||
class AttackWPS(Attack):
|
||||
def __init__(self, target):
|
||||
12
py/Configuration.py → wifite/config.py
Normal file → Executable file
12
py/Configuration.py → wifite/config.py
Normal file → Executable file
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Color import Color
|
||||
from Macchanger import Macchanger
|
||||
from util.color import Color
|
||||
from tools.macchanger import Macchanger
|
||||
|
||||
import os
|
||||
|
||||
@@ -107,7 +107,7 @@ class Configuration(object):
|
||||
def get_interface():
|
||||
if Configuration.interface is None:
|
||||
# Interface wasn't defined, select it!
|
||||
from Airmon import Airmon
|
||||
from tools.airmon import Airmon
|
||||
Configuration.interface = Airmon.ask()
|
||||
if Configuration.random_mac:
|
||||
Macchanger.random()
|
||||
@@ -116,7 +116,7 @@ class Configuration(object):
|
||||
@staticmethod
|
||||
def load_from_arguments():
|
||||
''' Sets configuration values based on Argument.args object '''
|
||||
from Arguments import Arguments
|
||||
from args import Arguments
|
||||
|
||||
args = Arguments(Configuration).args
|
||||
if args.random_mac:
|
||||
@@ -311,7 +311,7 @@ class Configuration(object):
|
||||
''' Deletes temp and exist with the given code '''
|
||||
Configuration.delete_temp()
|
||||
Macchanger.reset_if_changed()
|
||||
from Airmon import Airmon
|
||||
from tools.airmon import Airmon
|
||||
if hasattr(Configuration, "interface") and Configuration.interface is not None and Airmon.base_interface is not None:
|
||||
Airmon.stop(Configuration.interface)
|
||||
Airmon.put_interface_up(Airmon.base_interface)
|
||||
@@ -324,7 +324,7 @@ class Configuration(object):
|
||||
@staticmethod
|
||||
def dump():
|
||||
''' (Colorful) string representation of the configuration '''
|
||||
from Color import Color
|
||||
from util.color import Color
|
||||
|
||||
max_len = 20
|
||||
for key in Configuration.__dict__.keys():
|
||||
9
py/CrackHandshake.py → wifite/crack.py
Normal file → Executable file
9
py/CrackHandshake.py → wifite/crack.py
Normal file → Executable file
@@ -1,10 +1,11 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Process import Process
|
||||
from Color import Color
|
||||
from Configuration import Configuration
|
||||
from CrackResult import CrackResult
|
||||
from util.process import Process
|
||||
from util.color import Color
|
||||
from config import Configuration
|
||||
from model.result import CrackResult
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
import os
|
||||
0
wifite/model/__init__.py
Normal file
0
wifite/model/__init__.py
Normal file
0
py/Attack.py → wifite/model/attack.py
Normal file → Executable file
0
py/Attack.py → wifite/model/attack.py
Normal file → Executable file
0
py/Client.py → wifite/model/client.py
Normal file → Executable file
0
py/Client.py → wifite/model/client.py
Normal file → Executable file
4
py/Handshake.py → wifite/model/handshake.py
Normal file → Executable file
4
py/Handshake.py → wifite/model/handshake.py
Normal file → Executable file
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Process import Process
|
||||
from Color import Color
|
||||
from ..util.process import Process
|
||||
from ..util.color import Color
|
||||
|
||||
import re
|
||||
import os
|
||||
2
py/Interface.py → wifite/model/interface.py
Normal file → Executable file
2
py/Interface.py → wifite/model/interface.py
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Color import Color
|
||||
from wifite.util.color import Color
|
||||
|
||||
import re
|
||||
|
||||
2
py/CrackResult.py → wifite/model/result.py
Normal file → Executable file
2
py/CrackResult.py → wifite/model/result.py
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Color import Color
|
||||
from ..util.color import Color
|
||||
|
||||
import os
|
||||
import time
|
||||
2
py/Target.py → wifite/model/target.py
Normal file → Executable file
2
py/Target.py → wifite/model/target.py
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Color import Color
|
||||
from wifite.util.color import Color
|
||||
|
||||
import re
|
||||
|
||||
4
py/CrackResultWEP.py → wifite/model/wep_result.py
Normal file → Executable file
4
py/CrackResultWEP.py → wifite/model/wep_result.py
Normal file → Executable file
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Color import Color
|
||||
from CrackResult import CrackResult
|
||||
from ..util.color import Color
|
||||
from .result import CrackResult
|
||||
|
||||
import time
|
||||
|
||||
4
py/CrackResultWPA.py → wifite/model/wpa_result.py
Normal file → Executable file
4
py/CrackResultWPA.py → wifite/model/wpa_result.py
Normal file → Executable file
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Color import Color
|
||||
from CrackResult import CrackResult
|
||||
from ..util.color import Color
|
||||
from .result import CrackResult
|
||||
|
||||
class CrackResultWPA(CrackResult):
|
||||
def __init__(self, bssid, essid, handshake_file, key):
|
||||
4
py/CrackResultWPS.py → wifite/model/wps_result.py
Normal file → Executable file
4
py/CrackResultWPS.py → wifite/model/wps_result.py
Normal file → Executable file
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Color import Color
|
||||
from CrackResult import CrackResult
|
||||
from ..util.color import Color
|
||||
from ..model.result import CrackResult
|
||||
|
||||
import time
|
||||
|
||||
0
wifite/tools/__init__.py
Normal file
0
wifite/tools/__init__.py
Normal file
4
py/Aircrack.py → wifite/tools/aircrack.py
Normal file → Executable file
4
py/Aircrack.py → wifite/tools/aircrack.py
Normal file → Executable file
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Process import Process
|
||||
from Configuration import Configuration
|
||||
from ..util.process import Process
|
||||
from ..config import Configuration
|
||||
|
||||
import os
|
||||
|
||||
6
py/Aireplay.py → wifite/tools/aireplay.py
Normal file → Executable file
6
py/Aireplay.py → wifite/tools/aireplay.py
Normal file → Executable file
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Configuration import Configuration
|
||||
from Process import Process
|
||||
from Timer import Timer
|
||||
from ..config import Configuration
|
||||
from ..util.process import Process
|
||||
from ..util.timer import Timer
|
||||
|
||||
import os, time, re
|
||||
from threading import Thread
|
||||
8
py/Airmon.py → wifite/tools/airmon.py
Normal file → Executable file
8
py/Airmon.py → wifite/tools/airmon.py
Normal file → Executable file
@@ -1,10 +1,10 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Interface import Interface
|
||||
from Process import Process
|
||||
from Color import Color
|
||||
from Configuration import Configuration
|
||||
from ..model.interface import Interface
|
||||
from ..util.process import Process
|
||||
from ..util.color import Color
|
||||
from ..config import Configuration
|
||||
|
||||
import re
|
||||
import os
|
||||
10
py/Airodump.py → wifite/tools/airodump.py
Normal file → Executable file
10
py/Airodump.py → wifite/tools/airodump.py
Normal file → Executable file
@@ -1,11 +1,11 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Process import Process
|
||||
from Configuration import Configuration
|
||||
from Target import Target
|
||||
from Client import Client
|
||||
from Tshark import Tshark
|
||||
from wifite.util.process import Process
|
||||
from wifite.config import Configuration
|
||||
from wifite.model.target import Target
|
||||
from wifite.model.client import Client
|
||||
from wifite.tools.tshark import Tshark
|
||||
|
||||
import os, time
|
||||
|
||||
14
py/Bully.py → wifite/tools/bully.py
Normal file → Executable file
14
py/Bully.py → wifite/tools/bully.py
Normal file → Executable file
@@ -1,13 +1,13 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Attack import Attack
|
||||
from Airodump import Airodump
|
||||
from Color import Color
|
||||
from Timer import Timer
|
||||
from Process import Process
|
||||
from Configuration import Configuration
|
||||
from CrackResultWPS import CrackResultWPS
|
||||
from ..model.attack import Attack
|
||||
from ..tools.airodump import Airodump
|
||||
from ..util.color import Color
|
||||
from ..util.timer import Timer
|
||||
from ..util.process import Process
|
||||
from ..config import Configuration
|
||||
from ..model.wps_result import CrackResultWPS
|
||||
|
||||
import os, time, re
|
||||
from threading import Thread
|
||||
4
py/Macchanger.py → wifite/tools/macchanger.py
Normal file → Executable file
4
py/Macchanger.py → wifite/tools/macchanger.py
Normal file → Executable file
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Interface import Interface
|
||||
from Color import Color
|
||||
from wifite.model.interface import Interface
|
||||
from wifite.util.color import Color
|
||||
|
||||
class Macchanger(object):
|
||||
is_init = False
|
||||
12
py/Reaver.py → wifite/tools/reaver.py
Normal file → Executable file
12
py/Reaver.py → wifite/tools/reaver.py
Normal file → Executable file
@@ -1,12 +1,12 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Attack import Attack
|
||||
from Airodump import Airodump
|
||||
from Color import Color
|
||||
from Configuration import Configuration
|
||||
from CrackResultWPS import CrackResultWPS
|
||||
from Process import Process
|
||||
from ..model.attack import Attack
|
||||
from ..config import Configuration
|
||||
from ..util.color import Color
|
||||
from ..util.process import Process
|
||||
from ..tools.airodump import Airodump
|
||||
from ..model.wps_result import CrackResultWPS
|
||||
|
||||
import os, time, re
|
||||
|
||||
2
py/Tshark.py → wifite/tools/tshark.py
Normal file → Executable file
2
py/Tshark.py → wifite/tools/tshark.py
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Process import Process
|
||||
from wifite.util.process import Process
|
||||
import re
|
||||
|
||||
class Tshark(object):
|
||||
0
wifite/util/__init__.py
Normal file
0
wifite/util/__init__.py
Normal file
0
py/Color.py → wifite/util/color.py
Normal file → Executable file
0
py/Color.py → wifite/util/color.py
Normal file → Executable file
4
py/Process.py → wifite/util/process.py
Normal file → Executable file
4
py/Process.py → wifite/util/process.py
Normal file → Executable file
@@ -4,8 +4,8 @@
|
||||
import time
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
from Color import Color
|
||||
from Configuration import Configuration
|
||||
from wifite.util.color import Color
|
||||
from wifite.config import Configuration
|
||||
|
||||
|
||||
class Process(object):
|
||||
8
py/Scanner.py → wifite/util/scanner.py
Normal file → Executable file
8
py/Scanner.py → wifite/util/scanner.py
Normal file → Executable file
@@ -1,10 +1,10 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Airodump import Airodump
|
||||
from Color import Color
|
||||
from Target import Target
|
||||
from Configuration import Configuration
|
||||
from wifite.tools.airodump import Airodump
|
||||
from wifite.util.color import Color
|
||||
from wifite.model.target import Target
|
||||
from wifite.config import Configuration
|
||||
|
||||
from time import sleep, time
|
||||
|
||||
0
py/Timer.py → wifite/util/timer.py
Normal file → Executable file
0
py/Timer.py → wifite/util/timer.py
Normal file → Executable file
239
wifite/wifite.py
Executable file
239
wifite/wifite.py
Executable file
@@ -0,0 +1,239 @@
|
||||
#!/usr/bin/python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from config import Configuration
|
||||
from util.scanner import Scanner
|
||||
from util.color import Color
|
||||
from attack.wep import AttackWEP
|
||||
from attack.wpa import AttackWPA
|
||||
from attack.wps import AttackWPS
|
||||
from model.result import CrackResult
|
||||
from model.handshake import Handshake
|
||||
from crack import CrackHandshake
|
||||
from util.process import Process
|
||||
|
||||
from json import loads
|
||||
import os
|
||||
from sys import exit
|
||||
|
||||
class Wifite(object):
|
||||
|
||||
def main(self):
|
||||
''' Either performs action based on arguments, or starts attack scanning '''
|
||||
|
||||
if os.getuid() != 0:
|
||||
Color.pl('{!} {R}error: {O}wifite{R} must be run as {O}root{W}')
|
||||
Color.pl('{!} {O}re-run as: sudo ./Wifite.py{W}')
|
||||
Configuration.exit_gracefully(0)
|
||||
|
||||
self.dependency_check()
|
||||
|
||||
Configuration.initialize(load_interface=False)
|
||||
|
||||
if Configuration.show_cracked:
|
||||
self.display_cracked()
|
||||
|
||||
elif Configuration.check_handshake:
|
||||
self.check_handshake(Configuration.check_handshake)
|
||||
elif Configuration.crack_handshake:
|
||||
CrackHandshake()
|
||||
else:
|
||||
Configuration.get_interface()
|
||||
self.run()
|
||||
|
||||
def dependency_check(self):
|
||||
''' Check that required programs are installed '''
|
||||
required_apps = ['airmon-ng', 'iwconfig', 'ifconfig', 'aircrack-ng', 'aireplay-ng', 'airodump-ng', 'tshark']
|
||||
optional_apps = ['packetforge-ng', 'reaver', 'bully', 'cowpatty', 'pyrit', 'stdbuf', 'macchanger']
|
||||
missing_required = False
|
||||
missing_optional = False
|
||||
|
||||
for app in required_apps:
|
||||
if not Process.exists(app):
|
||||
missing_required = True
|
||||
Color.pl('{!} {R}error: required app {O}%s{R} was not found' % app)
|
||||
|
||||
for app in optional_apps:
|
||||
if not Process.exists(app):
|
||||
missing_optional = True
|
||||
Color.pl('{!} {O}warning: recommended app {R}%s{O} was not found' % app)
|
||||
|
||||
if missing_required:
|
||||
Color.pl('{!} {R}required app(s) were not found, exiting.{W}')
|
||||
exit(-1)
|
||||
|
||||
if missing_optional:
|
||||
Color.pl('{!} {O}recommended app(s) were not found')
|
||||
Color.pl('{!} {O}wifite may not work as expected{W}')
|
||||
|
||||
def display_cracked(self):
|
||||
''' Show cracked targets from cracked.txt '''
|
||||
Color.pl('{+} displaying {C}cracked target(s){W}')
|
||||
name = CrackResult.cracked_file
|
||||
if not os.path.exists(name):
|
||||
Color.pl('{!} {O}file {C}%s{O} not found{W}' % name)
|
||||
return
|
||||
with open(name, 'r') as fid:
|
||||
json = loads(fid.read())
|
||||
for idx, item in enumerate(json, start=1):
|
||||
Color.pl('\n{+} Cracked target #%d:' % (idx))
|
||||
cr = CrackResult.load(item)
|
||||
cr.dump()
|
||||
|
||||
def check_handshake(self, capfile):
|
||||
''' Analyzes .cap file for handshake '''
|
||||
if capfile == '<all>':
|
||||
Color.pl('{+} checking all handshakes in {G}"./hs"{W} directory\n')
|
||||
try:
|
||||
capfiles = [os.path.join('hs', x) for x in os.listdir('hs') if x.endswith('.cap')]
|
||||
except OSError, e:
|
||||
capfiles = []
|
||||
if len(capfiles) == 0:
|
||||
Color.pl('{!} {R}no .cap files found in {O}"./hs"{W}\n')
|
||||
else:
|
||||
capfiles = [capfile]
|
||||
for capfile in capfiles:
|
||||
Color.pl('{+} checking for handshake in .cap file {C}%s{W}' % capfile)
|
||||
if not os.path.exists(capfile):
|
||||
Color.pl('{!} {O}.cap file {C}%s{O} not found{W}' % capfile)
|
||||
return
|
||||
hs = Handshake(capfile, bssid=Configuration.target_bssid, essid=Configuration.target_essid)
|
||||
hs.analyze()
|
||||
Color.pl('')
|
||||
|
||||
def run(self):
|
||||
'''
|
||||
Main program.
|
||||
1) Scans for targets, asks user to select targets
|
||||
2) Attacks each target
|
||||
'''
|
||||
s = Scanner()
|
||||
if s.target:
|
||||
# We found the target we want
|
||||
targets = [s.target]
|
||||
else:
|
||||
targets = s.select_targets()
|
||||
|
||||
attacked_targets = 0
|
||||
targets_remaining = len(targets)
|
||||
for idx, t in enumerate(targets, start=1):
|
||||
attacked_targets += 1
|
||||
targets_remaining -= 1
|
||||
|
||||
Color.pl('\n{+} ({G}%d{W}/{G}%d{W})' % (idx, len(targets)) +
|
||||
' starting attacks against {C}%s{W} ({C}%s{W})'
|
||||
% (t.bssid, t.essid if t.essid_known else "{O}ESSID unknown"))
|
||||
if 'WEP' in t.encryption:
|
||||
attack = AttackWEP(t)
|
||||
elif 'WPA' in t.encryption:
|
||||
if t.wps:
|
||||
attack = AttackWPS(t)
|
||||
result = False
|
||||
try:
|
||||
result = attack.run()
|
||||
except Exception as e:
|
||||
Color.pl("\n{!} {R}Error: {O}%s" % str(e))
|
||||
if Configuration.verbose > 0 or Configuration.print_stack_traces:
|
||||
Color.pl('\n{!} {O}Full stack trace below')
|
||||
from traceback import format_exc
|
||||
Color.p('\n{!} ')
|
||||
err = format_exc().strip()
|
||||
err = err.replace('\n', '\n{!} {C} ')
|
||||
err = err.replace(' File', '{W}File')
|
||||
err = err.replace(' Exception: ', '{R}Exception: {O}')
|
||||
Color.pl(err)
|
||||
except KeyboardInterrupt:
|
||||
Color.pl('\n{!} {O}interrupted{W}\n')
|
||||
if not self.user_wants_to_continue(targets_remaining, 1):
|
||||
break
|
||||
|
||||
if result and attack.success:
|
||||
# We cracked it.
|
||||
attack.crack_result.save()
|
||||
continue
|
||||
else:
|
||||
# WPS failed, try WPA handshake.
|
||||
attack = AttackWPA(t)
|
||||
else:
|
||||
# Not using WPS, try WPA handshake.
|
||||
attack = AttackWPA(t)
|
||||
else:
|
||||
Color.pl("{!} {R}Error: {O}unable to attack: encryption not WEP or WPA")
|
||||
continue
|
||||
|
||||
try:
|
||||
attack.run()
|
||||
except Exception, e:
|
||||
Color.pl("\n{!} {R}Error: {O}%s" % str(e))
|
||||
if Configuration.verbose > 0 or True:
|
||||
Color.pl('\n{!} {O}Full stack trace below')
|
||||
from traceback import format_exc
|
||||
Color.p('\n{!} ')
|
||||
err = format_exc().strip()
|
||||
err = err.replace('\n', '\n{!} {C} ')
|
||||
err = err.replace(' File', '{W}File')
|
||||
err = err.replace(' Exception: ', '{R}Exception: {O}')
|
||||
Color.pl(err)
|
||||
except KeyboardInterrupt:
|
||||
Color.pl('\n{!} {O}interrupted{W}\n')
|
||||
if not self.user_wants_to_continue(targets_remaining):
|
||||
break
|
||||
|
||||
if attack.success:
|
||||
attack.crack_result.save()
|
||||
Color.pl("{+} Finished attacking {C}%d{W} target(s), exiting" % attacked_targets)
|
||||
|
||||
|
||||
def print_banner(self):
|
||||
""" Displays ASCII art of the highest caliber. """
|
||||
Color.pl(r'''
|
||||
{G} . {GR}{D} {W}{G} . {W}
|
||||
{G}.´ · .{GR}{D} {W}{G}. · `. {G}wifite {D}%s{W}
|
||||
{G}: : : {GR}{D} (¯) {W}{G} : : : {W}{D}automated wireless auditor
|
||||
{G}`. · `{GR}{D} /¯\ {W}{G}´ · .´ {C}{D}https://github.com/derv82/wifite2
|
||||
{G} ` {GR}{D}/¯¯¯\{W}{G} ´ {W}
|
||||
''' % Configuration.version)
|
||||
|
||||
def user_wants_to_continue(self, targets_remaining, attacks_remaining=0):
|
||||
''' Asks user if attacks should continue onto other targets '''
|
||||
if attacks_remaining == 0 and targets_remaining == 0:
|
||||
# No targets or attacksleft, drop out
|
||||
return
|
||||
|
||||
prompt_list = []
|
||||
if attacks_remaining > 0:
|
||||
prompt_list.append(Color.s('{C}%d{W} attack(s)' % attacks_remaining))
|
||||
if targets_remaining > 0:
|
||||
prompt_list.append(Color.s('{C}%d{W} target(s)' % targets_remaining))
|
||||
prompt = ' and '.join(prompt_list)
|
||||
Color.pl('{+} %s remain, do you want to continue?' % prompt)
|
||||
|
||||
prompt = Color.s('{+} type {G}c{W} to {G}continue{W}' +
|
||||
' or {R}s{W} to {R}stop{W}: ')
|
||||
|
||||
if raw_input(prompt).lower().startswith('s'):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
w = Wifite()
|
||||
try:
|
||||
w.print_banner()
|
||||
w.main()
|
||||
except Exception, e:
|
||||
Color.pl('\n{!} {R}Error:{O} %s{W}' % str(e))
|
||||
if Configuration.verbose > 0 or True:
|
||||
Color.pl('\n{!} {O}Full stack trace below')
|
||||
from traceback import format_exc
|
||||
Color.p('\n{!} ')
|
||||
err = format_exc().strip()
|
||||
err = err.replace('\n', '\n{!} {C} ')
|
||||
err = err.replace(' File', '{W}File')
|
||||
err = err.replace(' Exception: ', '{R}Exception: {O}')
|
||||
Color.pl(err)
|
||||
Color.pl('\n{!} {R}Exiting{W}\n')
|
||||
except KeyboardInterrupt:
|
||||
Color.pl('\n{!} {O}interrupted, shutting down...{W}')
|
||||
Configuration.exit_gracefully(0)
|
||||
Reference in New Issue
Block a user