-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhcx-wifi-genpasslst
executable file
·57 lines (47 loc) · 1.5 KB
/
hcx-wifi-genpasslst
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
#!/usr/bin/env python3
import sys
import subprocess
if len(sys.argv) < 2:
print("ABOUT: generate password.csv for hcx-wifi")
print("USAGE: " + sys.argv[0] + " <hash(es)File> > wifipasslst.csv")
exit()
def hex2str(hex_string):
try:
return bytes.fromhex(hex_string).decode('utf-8')
except ValueError:
return "HEX ERROR"
# Open and read the hash file
hashes_file_path = sys.argv[1]
try:
with open(hashes_file_path, 'r') as file:
hashes_file_lines = file.readlines()
except FileNotFoundError:
print(f"Error: File '{hashes_file_path}' not found.")
sys.exit(1)
# Run hashcat and parse output
hashcat_items = {}
try:
result = subprocess.run(['hashcat', '-m', '22000', '--show', hashes_file_path],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
for line in result.stdout.splitlines():
if not line:
continue
clms = line.split(":")
if len(clms) >= 5:
hashcat_items[clms[0]] = clms[4]
except subprocess.SubprocessError as e:
print(f"Error running hashcat: {e}")
sys.exit(1)
# Process each hash line and output results
for line in hashes_file_lines:
hash_line = line.strip()
if not hash_line:
continue
split = hash_line.split("*")
if len(split) < 6:
print("Invalid format")
continue
bssid = split[3].upper()
essid = hex2str(split[5])
passwd = hashcat_items.get(split[2], "...")
print(f"{bssid}|||{essid}|||{passwd}")