Navicat For Mysql 1112 导出密码破解 python
-
导出连接;
2.选择需要导出的连接,勾选导出密码;
3.查看导出的connections.ncx文件,找到Password字段值;
Password="FDBA203EE85CA9D242EFD22B4AEBCE47"
4.替换代码中位置:
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
import hashlib
import binascii
class NavicatPassword:
def __init__(self, version=12):
self.version = version
self.aes_key = b'libcckeylibcckey'
self.aes_iv = b'libcciv libcciv '
self.blow_string = b'3DC5CA39'
self.blow_key = hashlib.sha1(self.blow_string).digest()
self.blow_iv = bytes.fromhex('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 None
def decrypt(self, string):
if self.version == 11:
return self.decrypt_eleven(string)
elif self.version == 12:
return self.decrypt_twelve(string)
else:
return None
def encrypt_eleven(self, string):
string = string.encode('utf-8')
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[i * 8:(i + 1) * 8]
temp = self.encrypt_block(self.xor_bytes(block, current_vector))
current_vector = self.xor_bytes(current_vector, temp)
result += temp
if left_length:
current_vector = self.encrypt_block(current_vector)
result += self.xor_bytes(string[round_count * 8:], current_vector)
return binascii.hexlify(result).upper().decode('utf-8')
def encrypt_twelve(self, string):
cipher = Cipher(algorithms.AES(self.aes_key), modes.CBC(self.aes_iv), backend=default_backend())
encryptor = cipher.encryptor()
padded_string = self.pad(string.encode('utf-8'))
encrypted = encryptor.update(padded_string) + encryptor.finalize()
return binascii.hexlify(encrypted).upper().decode('utf-8')
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[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 += temp
if left_length:
current_vector = self.encrypt_block(current_vector)
result += self.xor_bytes(string[round_count * 8:], current_vector)
return result.decode('utf-8')
def decrypt_twelve(self, upper_string):
string = binascii.unhexlify(upper_string.lower())
cipher = Cipher(algorithms.AES(self.aes_key), modes.CBC(self.aes_iv), backend=default_backend())
decryptor = cipher.decryptor()
decrypted = decryptor.update(string) + decryptor.finalize()
return self.unpad(decrypted).decode('utf-8')
def encrypt_block(self, block):
cipher = Cipher(algorithms.Blowfish(self.blow_key), modes.ECB(), backend=default_backend())
encryptor = cipher.encryptor()
return encryptor.update(block) + encryptor.finalize()
def decrypt_block(self, block):
cipher = Cipher(algorithms.Blowfish(self.blow_key), modes.ECB(), backend=default_backend())
decryptor = cipher.decryptor()
return decryptor.update(block) + decryptor.finalize()
def xor_bytes(self, str1, str2):
return bytes(a ^ b for a, b in zip(str1, str2))
def pad(self, data):
pad_length = 16 - (len(data) % 16)
return data + bytes([pad_length] * pad_length)
def unpad(self, data):
pad_length = data[-1]
return data[:-pad_length]
# 使用示例
navicat_password = NavicatPassword(11)
#navicat_password = NavicatPassword(12)
# 解密示例
decrypted = navicat_password.decrypt('FDBA203EE85CA9D242EFD22B4AEBCE47')
print(decrypted)
输出: