Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
derv82
GitHub Repository: derv82/wifite2
Path: blob/master/wifite/attack/wps.py
412 views
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
from ..model.attack import Attack
5
from ..util.color import Color
6
from ..util.process import Process
7
from ..config import Configuration
8
from ..tools.bully import Bully
9
from ..tools.reaver import Reaver
10
11
class AttackWPS(Attack):
12
13
@staticmethod
14
def can_attack_wps():
15
return Reaver.exists() or Bully.exists()
16
17
def __init__(self, target, pixie_dust=False):
18
super(AttackWPS, self).__init__(target)
19
self.success = False
20
self.crack_result = None
21
self.pixie_dust = pixie_dust
22
23
def run(self):
24
''' Run all WPS-related attacks '''
25
26
# Drop out if user specified to not use Reaver/Bully
27
if Configuration.use_pmkid_only:
28
self.success = False
29
return False
30
31
if Configuration.no_wps:
32
self.success = False
33
return False
34
35
if not Configuration.wps_pixie and self.pixie_dust:
36
Color.pl('\r{!} {O}--no-pixie{R} was given, ignoring WPS PIN Attack on ' +
37
'{O}%s{W}' % self.target.essid)
38
self.success = False
39
return False
40
41
if not Configuration.wps_pin and not self.pixie_dust:
42
Color.pl('\r{!} {O}--no-pin{R} was given, ignoring WPS Pixie-Dust Attack ' +
43
'on {O}%s{W}' % self.target.essid)
44
self.success = False
45
return False
46
47
if not Reaver.exists() and Bully.exists():
48
# Use bully if reaver isn't available
49
return self.run_bully()
50
elif self.pixie_dust and not Reaver.is_pixiedust_supported() and Bully.exists():
51
# Use bully if reaver can't do pixie-dust
52
return self.run_bully()
53
elif Configuration.use_bully:
54
# Use bully if asked by user
55
return self.run_bully()
56
elif not Reaver.exists():
57
# Print error if reaver isn't found (bully not available)
58
if self.pixie_dust:
59
Color.pl('\r{!} {R}Skipping WPS Pixie-Dust attack: {O}reaver{R} not found.{W}')
60
else:
61
Color.pl('\r{!} {R}Skipping WPS PIN attack: {O}reaver{R} not found.{W}')
62
return False
63
elif self.pixie_dust and not Reaver.is_pixiedust_supported():
64
# Print error if reaver can't support pixie-dust (bully not available)
65
Color.pl('\r{!} {R}Skipping WPS attack: {O}reaver{R} does not support {O}--pixie-dust{W}')
66
return False
67
else:
68
return self.run_reaver()
69
70
71
def run_bully(self):
72
bully = Bully(self.target, pixie_dust=self.pixie_dust)
73
bully.run()
74
bully.stop()
75
self.crack_result = bully.crack_result
76
self.success = self.crack_result is not None
77
return self.success
78
79
80
def run_reaver(self):
81
reaver = Reaver(self.target, pixie_dust=self.pixie_dust)
82
reaver.run()
83
self.crack_result = reaver.crack_result
84
self.success = self.crack_result is not None
85
return self.success
86
87
88