其他资料都是用php写的,但是运行起来好像有点问题,提供python代码,首先注册表获取加密后的密码,然后运行下述代码解密。
参考:获取navicat密码
python">import hashlib
from Crypto.Cipher import AES, Blowfish
from Crypto.Util.Padding import pad, unpad
from binascii import unhexlify, hexlifyclass NavicatPassword:def __init__(self, version=12):self.version = versionself.aes_key = b'libcckeylibcckey'self.aes_iv = b'libcciv libcciv 'self.blow_string = '3DC5CA39'self.blow_key = hashlib.sha1(b'3DC5CA39').digest()self.blow_iv = bytes.fromhex('d9c7c3c8870d64bd')def xor_bytes(self, str1, str2):return bytes([a ^ b for a, b in zip(str1, str2)])def encrypt(self, string):if self.version == 11:return self.encrypt_eleven(string)elif self.version == 12:return self.encrypt_twelve(string)else:return Nonedef encrypt_eleven(self, string):string = pad(string.encode(), Blowfish.block_size)rounds = len(string) // 8left_length = len(string) % 8result = b''current_vector = self.blow_ivfor i in range(rounds):block = string[i * 8:(i + 1) * 8]temp = self.encrypt_block(self.xor_bytes(block, current_vector))current_vector = self.xor_bytes(current_vector, temp)result += tempif left_length:current_vector = self.encrypt_block(current_vector)result += self.xor_bytes(string[rounds * 8:], current_vector)return hexlify(result).upper().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)def encrypt_twelve(self, string):cipher = AES.new(self.aes_key, AES.MODE_CBC, self.aes_iv)result = cipher.encrypt(pad(string.encode(), AES.block_size))return hexlify(result).upper().decode()def decrypt(self, string):if self.version == 11:return self.decrypt_eleven(string)elif self.version == 12:return self.decrypt_twelve(string)else:return Nonedef decrypt_eleven(self, upper_string):string = unhexlify(upper_string.lower())rounds = len(string) // 8left_length = len(string) % 8result = b''current_vector = self.blow_ivfor i in range(rounds):encrypted_block = string[i * 8:(i + 1) * 8]temp = self.xor_bytes(self.decrypt_block(encrypted_block), current_vector)current_vector = self.xor_bytes(current_vector, encrypted_block)result += tempif left_length:current_vector = self.encrypt_block(current_vector)result += self.xor_bytes(string[rounds * 8:], current_vector)return result.decode(errors='ignore')def decrypt_twelve(self, upper_string):string = unhexlify(upper_string.lower())cipher = AES.new(self.aes_key, AES.MODE_CBC, self.aes_iv)return unpad(cipher.decrypt(string), AES.block_size).decode()# Example usage
navicat_password = NavicatPassword(11)
decoded = navicat_password.decrypt('7EAA549760822DA9A89CBBE9')
print(decoded)