欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 产业 > navicat密码解密python

navicat密码解密python

2025/6/30 10:54:25 来源:https://blog.csdn.net/sinat_34233802/article/details/143965837  浏览:    关键词:navicat密码解密python

其他资料都是用php写的,但是运行起来好像有点问题,提供python代码,首先注册表获取加密后的密码,然后运行下述代码解密。
参考:获取navicat密码

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)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词