forked from ins1gn1a/Hexcat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hexcat.py
35 lines (28 loc) · 899 Bytes
/
hexcat.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import os
with open(sys.argv[1],'r') as passfile:
passlist = passfile.read().splitlines()
def decode_hex(password):
decoded = []
pwd = password
if "$HEX" in password:
multihex = list(filter(None, password.split("$")))
for x in multihex:
if "HEX[" in x:
endhex = x.find("]")
try:
decoded.append((bytes.fromhex(x[4:endhex]).decode("utf-8")))
except:
decoded.append((bytes.fromhex(x[4:endhex]).decode("cp1252")))
else:
decoded.append(x)
if len(decoded) != 0:
pwd = ''.join(decoded)
return (pwd)
else:
return (pwd)
for line in passlist:
username,password = line.split(":",1)
print (username + ":" + str(decode_hex(password)))