希望能对大家有用。
[Python] 纯文本查看 复制代码import binascii
import hashlib
from Crypto.Cipher import AES, Blowfish
from Crypto.Util.Padding import pad, unpad
from Crypto.Util.strxor import strxor
class NavicatPassword:
def __init__(self, version=12):
self.version = version
self.aes_key = b'libcckeylibcckey'
self.aes_iv = b'libcciv libcciv '
self.blow_string = '3DC5CA39'
self.blow_key = hashlib.sha1(self.blow_string.encode()).digest()
self.blow_iv = binascii.unhexlify('d9c7c3c8870d64bd')
def encrypt(self, string):
if self.version == 11:
return self._encrypt_eleven(string)
elif self.version == 12:
return self._encrypt_twelve(string)
else:
return False
def decrypt(self, string):
if self.version == 11:
return self._decrypt_eleven(string)
elif self.version == 12:
return self._decrypt_twelve(string)
else:
return False
def _encrypt_eleven(self, string):
string = string.encode()
round_count = len(string) // 8
left_length = len(string) % 8
result = b''
current_vector = self.blow_iv
for i in range(round_count):
block = string[8 * i: 8 * (i + 1)]
temp = self._encrypt_block(strxor(block, current_vector))
current_vector = strxor(current_vector, temp)
result += temp
if left_length:
current_vector = self._encrypt_block(current_vector)
last_block = string[8 * round_count:]
result += strxor(last_block, current_vector[:len(last_block)])
return result.hex().upper()
def _encrypt_twelve(self, string):
string = string.encode()
cipher = AES.new(self.aes_key, AES.MODE_CBC, self.aes_iv)
padded = pad(string, AES.block_size)
encrypted = cipher.encrypt(padded)
return encrypted.hex().upper()
def _decrypt_eleven(self, upper_string):
string = binascii.unhexlify(upper_string.lower())
round_count = len(string) // 8
left_length = len(string) % 8
result = b''
current_vector = self.blow_iv
for i in range(round_count):
encrypted_block = string[8 * i: 8 * (i + 1)]
temp = strxor(self._decrypt_block(encrypted_block), current_vector)
current_vector = strxor(current_vector, encrypted_block)
result += temp
if left_length:
current_vector = self._encrypt_block(current_vector)
last_block = string[8 * round_count:]
result += strxor(last_block, current_vector[:len(last_block)])
return result.decode()
def _decrypt_twelve(self, upper_string):
string = binascii.unhexlify(upper_string.lower())
cipher = AES.new(self.aes_key, AES.MODE_CBC, self.aes_iv)
decrypted = cipher.decrypt(string)
return unpad(decrypted, AES.block_size).decode()
def _encrypt_block(self, block):
cipher = Blowfish.new(self.blow_key, Blowfish.MODE_ECB)
return cipher.encrypt(block)
def _decrypt_block(self, block):
cipher = Blowfish.new(self.blow_key, Blowfish.MODE_ECB)
return cipher.decrypt(block)
navicat_password = NavicatPassword(version=12)
decrypted = navicat_password.decrypt('15057D7BA390')
print(decrypted)
更改自己导出的密码:

image.png (11.21 KB, 下载次数: 1)
下载附件
2025-8-15 15:53 上传
运行后直接输出密码:

image.png (2.61 KB, 下载次数: 2)
下载附件
2025-8-15 15:52 上传
如报错: ModuleNotFoundError: No module named 'Crypto'
则安装库: pip install pycryptodome

image.png (45.63 KB, 下载次数: 2)
下载附件
2025-8-15 15:51 上传