163545
This commit is contained in:
@@ -9,29 +9,52 @@ class NavicatPassword:
|
||||
self.aes_iv = b'libcciv libcciv '
|
||||
|
||||
def decrypt(self, encrypted_str):
|
||||
data = binascii.unhexlify(encrypted_str.lower())
|
||||
cipher = AES.new(self.aes_key, AES.MODE_CBC, self.aes_iv)
|
||||
return cipher.decrypt(data).decode('utf-8').rstrip('\x00')
|
||||
try:
|
||||
data = binascii.unhexlify(encrypted_str.lower())
|
||||
cipher = AES.new(self.aes_key, AES.MODE_CBC, self.aes_iv)
|
||||
decrypted = cipher.decrypt(data)
|
||||
# 处理可能的填充字符
|
||||
decrypted = decrypted.rstrip(b'\x00')
|
||||
# 尝试UTF-8解码,失败则使用latin1
|
||||
try:
|
||||
return decrypted.decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
return decrypted.decode('latin1')
|
||||
except Exception as e:
|
||||
raise ValueError(f"解密失败: {str(e)}")
|
||||
|
||||
class App:
|
||||
def __init__(self, root):
|
||||
self.root = root
|
||||
self.root.title("Navicat密码解密工具")
|
||||
|
||||
self.version = tk.IntVar(value=12)
|
||||
self.password = tk.StringVar()
|
||||
|
||||
self.create_widgets()
|
||||
|
||||
def create_widgets(self):
|
||||
tk.Label(self.root, text="Navicat版本:").grid(row=0, column=0, padx=5, pady=5)
|
||||
tk.Radiobutton(self.root, text="11", variable=self.version, value=11).grid(row=0, column=1, sticky="w")
|
||||
tk.Radiobutton(self.root, text="12", variable=self.version, value=12).grid(row=0, column=2, sticky="w")
|
||||
tk.Label(self.root, text="加密密码:").grid(row=0, column=0, padx=5, pady=5)
|
||||
tk.Entry(self.root, textvariable=self.password, width=30).grid(row=0, column=1)
|
||||
|
||||
tk.Label(self.root, text="加密密码:").grid(row=1, column=0, padx=5, pady=5)
|
||||
tk.Entry(self.root, textvariable=self.password, width=30).grid(row=1, column=1, columnspan=2)
|
||||
tk.Button(self.root, text="解密", command=self.decrypt_password).grid(row=1, column=1, pady=10)
|
||||
|
||||
tk.Button(self.root, text="解密", command=self.decrypt_password).grid(row=2, column=1, pady=10)
|
||||
def show_result(self, result):
|
||||
top = tk.Toplevel(self.root)
|
||||
top.title("解密结果")
|
||||
|
||||
tk.Label(top, text="解密后的密码:").pack(padx=20, pady=5)
|
||||
|
||||
# 使用支持更多字符的字体
|
||||
font = ('Courier New', 12)
|
||||
result_text = tk.Text(top, height=1, width=30, font=font)
|
||||
result_text.insert(tk.END, result)
|
||||
result_text.config(state=tk.DISABLED)
|
||||
result_text.pack(padx=20, pady=5)
|
||||
|
||||
def copy_to_clipboard():
|
||||
self.root.clipboard_clear()
|
||||
self.root.clipboard_append(result)
|
||||
|
||||
tk.Button(top, text="复制密码", command=copy_to_clipboard).pack(pady=10)
|
||||
|
||||
def decrypt_password(self):
|
||||
password = self.password.get().strip()
|
||||
@@ -40,9 +63,9 @@ class App:
|
||||
return
|
||||
|
||||
try:
|
||||
navicat = NavicatPassword(self.version.get())
|
||||
navicat = NavicatPassword()
|
||||
result = navicat.decrypt(password)
|
||||
messagebox.showinfo("解密结果", f"解密后的密码是:\n{result}")
|
||||
self.show_result(result)
|
||||
except Exception as e:
|
||||
messagebox.showerror("错误", f"解密失败:{str(e)}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user