-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsorted_pwn.py
More file actions
248 lines (211 loc) · 8.29 KB
/
sorted_pwn.py
File metadata and controls
248 lines (211 loc) · 8.29 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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
import logging
import json
import os
import glob
import pwnagotchi.plugins as plugins
from flask import abort
from flask import send_from_directory
from flask import render_template_string
TEMPLATE = """
{% extends "base.html" %}
{% set active_page = "passwordsList" %}
{% block title %}
{{ title }}
{% endblock %}
{% block meta %}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=0" />
{% endblock %}
{% block styles %}
{{ super() }}
<style>
#searchText {
width: 100%;
}
table {
table-layout: auto;
width: 100%;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 15px;
text-align: left;
}
table tr:nth-child(even) {
background-color: #eee;
}
table tr:nth-child(odd) {
background-color: #fff;
}
table th {
background-color: black;
color: white;
}
@media screen and (max-width:700px) {
table, tr, td {
padding:0;
border:1px solid black;
}
table {
border:none;
}
tr:first-child, thead, th {
display:none;
border:none;
}
tr {
float: left;
width: 100%;
margin-bottom: 2em;
}
table tr:nth-child(odd) {
background-color: #eee;
}
td {
float: left;
width: 100%;
padding:1em;
}
td::before {
content:attr(data-label);
word-wrap: break-word;
background-color: black;
color: white;
border-right:2px solid black;
width: 20%;
float:left;
padding:1em;
font-weight: bold;
margin:-1em 1em -1em -1em;
}
}
</style>
{% endblock %}
{% block script %}
var searchInput = document.getElementById("searchText");
searchInput.onkeyup = function() {
var filter, table, tr, td, i, j, txtValue, rowContainsFilter;
filter = searchInput.value.toUpperCase();
table = document.getElementById("tableOptions");
if (table) {
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
// Skip header rows if they exist and you don't want to filter them
// For example, if your header is in a <thead>, you could get rows from <tbody> instead
// Or check if tr[i].parentNode.tagName === 'THEAD' and continue
rowContainsFilter = false; // Flag to check if any td in the current row matches
tds = tr[i].getElementsByTagName("td");
for (j = 0; j < tds.length; j++) {
let currentTd = tds[j];
if (currentTd) {
txtValue = currentTd.textContent || currentTd.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
rowContainsFilter = true;
break; // Found a match in this row, no need to check other tds
}
}
}
if (rowContainsFilter) {
tr[i].style.display = "";
} else {
// Only hide if it's not a header row (th)
// This check is basic, if you have th in tbody, you might need a more specific check
if (tr[i].getElementsByTagName("th").length === 0) {
tr[i].style.display = "none";
}
}
}
}
}
{% endblock %}
{% block content %}
<input type="text" id="searchText" placeholder="Search for ..." title="Type in a filter">
<table id="tableOptions">
<tr>
<th>SSID</th>
<th>Password</th>
<th>Other</th>
</tr>
{% for p in passwords %}
<tr>
<td data-label="SSID">{{p["ssid"]}}</td>
<td data-label="Password">{{p["password"]}}</td>
<td data-label="Other">
{% set other = p.get("other_fields") %}
{% if other %}
{% if other is iterable and other is not string %}
{{ other | join(", ") }}
{% else %}
{{ other }}
{% endif %}
{% else %}
<span>None</span>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% endblock %}
"""
class sorted_pwn(plugins.Plugin):
__author__ = '37124354+dbukovac@users.noreply.github.com'
__editor__ = 'avipars'
__version__ = '0.0.2.2'
__license__ = 'GPL3'
__description__ = 'List cracked passwords from any potfile found in the handshakes directory'
__github__ = 'https://github.com/evilsocket/pwnagotchi-plugins-contrib/blob/df9758065bd672354b3fa2a3299f4a8d80c8fd6a/wpa-sec-list.py'
def __init__(self):
self.ready = False
def on_loaded(self):
logging.info("[sorted_pwn] plugin loaded")
def on_config_changed(self, config):
self.config = config
self.ready = True
def on_webhook(self, path, request):
if not self.ready:
return "Plugin not ready"
if path == "/" or not path:
try:
base_dir = self.config['bettercap']['handshakes']
potfile_paths = glob.glob(os.path.join(base_dir, "*.potfile"))
unique_entries = {}
for pf_path in potfile_paths:
logging.info("[sorted_pwn] trying to open %s" % pf_path)
with open(pf_path, "r", encoding="utf-8", errors="ignore") as f:
for line in f:
line = line.strip()
if not line or ":" not in line:
continue
fields = line.split(":")
if len(fields) < 2:
continue
# to deal with both pwncrack and wpa-sec format
ssid = fields[-2].strip() # 2nd to last
password = fields[-1].strip() # last one
other_fields = fields[:-2] # everything before ssid/password
key = (ssid, password)
if key not in unique_entries:
unique_entries[key] = {
"ssid": ssid,
"password": password,
"other_fields": other_fields, # list has mac info
"raw_line": line
}
else:
# keep additional occurrences if you want
unique_entries[key].setdefault("duplicates", []).append({
"other_fields": other_fields,
"raw_line": line
})
# Convert to sorted list
sorted_passwords = sorted(unique_entries.values(), key=lambda x: (x["ssid"].lower(), x["password"]))
return render_template_string(TEMPLATE,
title="Unique Passwords List",
passwords=sorted_passwords)
except Exception as e:
logging.error("[sorted_pwn] error while loading potfiles: %s" % e)
logging.debug(e, exc_info=True)
abort(500)