forked from itsdarklikehell/pwnagotchi-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbetter_quickdic.py
170 lines (154 loc) · 6.33 KB
/
better_quickdic.py
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
from pwnagotchi import plugins
import logging
import subprocess
import string
import re
import pwnagotchi.plugins as plugins
import qrcode
import io
import os
class BetterQuickDic(plugins.Plugin):
__GitHub__ = ""
__author__ = "(edited by: itsdarklikehell [email protected]), silentree12th"
__version__ = "1.4.5"
__license__ = "GPL3"
__description__ = "Run a quick dictionary scan against captured handshakes. Optionally send found passwords as qrcode and plain text over to telegram bot."
__name__ = "BetterQuickDic"
__help__ = "Run a small aircrack scan against captured handshakes and PMKID"
__dependencies__ = {
"pip": ["qrcode"],
"apt": ["aircrack-ng"],
}
__defaults__ = {
"enabled": False,
"wordlist_folder": "/etc/pwnagotchi/wordlists/passwords/",
"face": "(·ω·)",
"api": None,
"id": None,
}
def __init__(self):
self.ready = False
self.text_to_set = ""
logging.debug(f"[{self.__class__.__name__}] plugin init")
def on_loaded(self):
logging.info(f"[{self.__class__.__name__}] plugin loaded")
if "face" not in self.options:
self.options["face"] = "(·ω·)"
if "wordlist_folder" not in self.options:
self.options["wordlist_folder"] = "/etc/pwnagotchi/wordlists/passwords/"
if "enabled" not in self.options:
self.options["enabled"] = False
if "api" not in self.options:
self.options["api"] = None
if "id" not in self.options:
self.options["id"] = None
check = subprocess.run(
("/usr/bin/dpkg -l aircrack-ng | grep aircrack-ng | awk '{print $2, $3}'"),
shell=True,
stdout=subprocess.PIPE,
)
check = check.stdout.decode("utf-8").strip()
if check != "aircrack-ng <none>":
logging.info(f"[{self.__class__.__name__}] Found %s" % check)
else:
logging.warn(
f"[{self.__class__.__name__}] aircrack-ng is not installed!")
# if self.options['id'] != None and self.options['api'] != None:
# self._send_message(filename='Android AP', pwd='12345678')
def on_handshake(self, agent, filename, access_point, client_station):
display = agent.view()
result = subprocess.run(
(
"/usr/bin/aircrack-ng "
+ filename
+ " | grep \"1 handshake\" | awk '{print $2}'"
),
shell=True,
stdout=subprocess.PIPE,
)
result = result.stdout.decode("utf-8").translate(
{ord(c): None for c in string.whitespace}
)
if not result:
logging.info(f"[{self.__class__.__name__}] No handshake")
else:
logging.info(f"[{self.__class__.__name__}] Handshake confirmed")
result2 = subprocess.run(
(
"aircrack-ng -w `echo "
+ self.options["wordlist_folder"]
+ "*.txt | sed 's/ /,/g'` -l "
+ filename
+ ".cracked -q -b "
+ result
+ " "
+ filename
+ " | grep KEY"
),
shell=True,
stdout=subprocess.PIPE,
)
result2 = result2.stdout.decode("utf-8").strip()
logging.info(f"[{self.__class__.__name__}] %s" % result2)
if result2 != "KEY NOT FOUND":
key = re.search(r"\[(.*)\]", result2)
pwd = str(key.group(1))
self.text_to_set = "Cracked password: " + pwd
# logging.warn('!!! [quickdic] !!! %s' % self.text_to_set)
display.set("face", self.options["face"])
display.set("status", self.text_to_set)
self.text_to_set = ""
display.update(force=True)
# plugins.on('cracked', access_point, pwd)
if self.options["id"] != None and self.options["api"] != None:
self._send_message(filename, pwd)
def _send_message(self, filename, pwd):
try:
security = "WPA"
filename = filename
base_filename = os.path.splitext(os.path.basename(filename))[0]
ssid = base_filename.split("_")[0:-2]
password = pwd
wifi_config = "WIFI:S:" + ssid + ";T:" + security + ";P:" + password + ";;"
# bot = Bot(token=self.options["api"])
chat_id = int(self.options["id"])
qr = qrcode.QRCode(
version=None,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data(wifi_config)
qr.make(fit=True)
# Create an image from the QR code instance
# img = qr.make_image(fill_color="black", back_color="white")
q = io.StringIO()
qr.print_ascii(out=q)
q.seek(0)
# Convert the image to bytes
# image_bytes = io.BytesIO()
# img.save(image_bytes)
# image_bytes.seek(0)
# Send the image directly as bytes
# message_text = 'ssid: ' + ssid + ' password: ' + password
# bot.send_photo(chat_id=chat_id, photo=InputFile(image_bytes, filename=ssid+'-'+password+'.txt'), caption=message_text)
message_text = f"\nSSID: {ssid}\nPassword: {password}\n```\n{q.read()}\n```"
# bot.send_message(chat_id=chat_id, text=message_text, parse_mode="Markdown")
logging.info(message_text)
logging.info(
f"[{self.__class__.__name__}] QR code content sent to Telegram."
)
except Exception as e:
logging.error(
f"[{self.__class__.__name__}] Error sending QR code content to Telegram: {str(e)}"
)
def on_ui_update(self, ui):
if self.text_to_set:
ui.set("face", self.options["face"])
ui.set("status", self.text_to_set)
self.text_to_set = ""
def on_unload(self, ui):
with ui._lock:
logging.info(f"[{self.__class__.__name__}] plugin unloaded")
def on_webhook(self, path, request):
logging.info(f"[{self.__class__.__name__}] webhook pressed")