版本选择可用-密码特殊字符待处理

This commit is contained in:
2025-01-14 16:25:44 +08:00
parent 49a935d688
commit ab68de262f
22 changed files with 43134 additions and 34 deletions
+1 -31
View File
@@ -4,45 +4,15 @@ from Crypto.Cipher import AES, Blowfish
import binascii
class NavicatPassword:
def __init__(self, version=12):
self.version = version
def __init__(self):
self.aes_key = b'libcckeylibcckey'
self.aes_iv = b'libcciv libcciv '
self.blow_key = b'\x3D\xC5\xCA\x39'
self.blow_iv = b'\xD9\xC7\xC3\xC8\x87\x0D\x64\xBD'
def decrypt(self, encrypted_str):
if self.version == 11:
return self.decrypt_eleven(encrypted_str)
elif self.version == 12:
return self.decrypt_twelve(encrypted_str)
return None
def decrypt_eleven(self, encrypted_str):
data = binascii.unhexlify(encrypted_str.lower())
result = b''
iv = self.blow_iv
for i in range(0, len(data), 8):
block = data[i:i+8]
decrypted = self.blowfish_decrypt(block)
result += self.xor_bytes(decrypted, iv)
iv = self.xor_bytes(iv, block)
return result.decode('utf-8')
def decrypt_twelve(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')
def blowfish_decrypt(self, data):
cipher = Blowfish.new(self.blow_key, Blowfish.MODE_ECB)
return cipher.decrypt(data)
def xor_bytes(self, a, b):
return bytes([x ^ y for x, y in zip(a, b)])
class App:
def __init__(self, root):
self.root = root