Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
derv82
GitHub Repository: derv82/wifite2
Path: blob/master/wifite/__main__.py
410 views
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
try:
5
from .config import Configuration
6
except (ValueError, ImportError) as e:
7
raise Exception('You may need to run wifite from the root directory (which includes README.md)', e)
8
9
from .util.color import Color
10
11
import os
12
import sys
13
14
15
class Wifite(object):
16
17
def __init__(self):
18
'''
19
Initializes Wifite. Checks for root permissions and ensures dependencies are installed.
20
'''
21
22
self.print_banner()
23
24
Configuration.initialize(load_interface=False)
25
26
if os.getuid() != 0:
27
Color.pl('{!} {R}error: {O}wifite{R} must be run as {O}root{W}')
28
Color.pl('{!} {R}re-run with {O}sudo{W}')
29
Configuration.exit_gracefully(0)
30
31
from .tools.dependency import Dependency
32
Dependency.run_dependency_check()
33
34
35
def start(self):
36
'''
37
Starts target-scan + attack loop, or launches utilities dpeending on user input.
38
'''
39
from .model.result import CrackResult
40
from .model.handshake import Handshake
41
from .util.crack import CrackHelper
42
43
if Configuration.show_cracked:
44
CrackResult.display()
45
46
elif Configuration.check_handshake:
47
Handshake.check()
48
49
elif Configuration.crack_handshake:
50
CrackHelper.run()
51
52
else:
53
Configuration.get_monitor_mode_interface()
54
self.scan_and_attack()
55
56
57
def print_banner(self):
58
'''Displays ASCII art of the highest caliber.'''
59
Color.pl(r' {G} . {GR}{D} {W}{G} . {W}')
60
Color.pl(r' {G}.´ · .{GR}{D} {W}{G}. · `. {G}wifite {D}%s{W}' % Configuration.version)
61
Color.pl(r' {G}: : : {GR}{D} (¯) {W}{G} : : : {W}{D}automated wireless auditor{W}')
62
Color.pl(r' {G}`. · `{GR}{D} /¯\ {W}{G}´ · .´ {C}{D}https://github.com/derv82/wifite2{W}')
63
Color.pl(r' {G} ` {GR}{D}/¯¯¯\{W}{G} ´ {W}')
64
Color.pl('')
65
66
67
def scan_and_attack(self):
68
'''
69
1) Scans for targets, asks user to select targets
70
2) Attacks each target
71
'''
72
from .util.scanner import Scanner
73
from .attack.all import AttackAll
74
75
Color.pl('')
76
77
# Scan
78
s = Scanner()
79
targets = s.select_targets()
80
81
# Attack
82
attacked_targets = AttackAll.attack_multiple(targets)
83
84
Color.pl('{+} Finished attacking {C}%d{W} target(s), exiting' % attacked_targets)
85
86
87
##############################################################
88
89
90
def entry_point():
91
try:
92
wifite = Wifite()
93
wifite.start()
94
except Exception as e:
95
Color.pexception(e)
96
Color.pl('\n{!} {R}Exiting{W}\n')
97
98
except KeyboardInterrupt:
99
Color.pl('\n{!} {O}Interrupted, Shutting down...{W}')
100
101
Configuration.exit_gracefully(0)
102
103
104
if __name__ == '__main__':
105
entry_point()
106
107