From fa9f20c41c39d2bdb88a0b66450168e25db605e4 Mon Sep 17 00:00:00 2001 From: xaoyo Date: Fri, 6 Oct 2023 10:52:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E8=A7=A3?= =?UTF-8?q?=E5=AF=86=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9A=84=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E8=A1=8C=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- decrypted/decrypt.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/decrypted/decrypt.py b/decrypted/decrypt.py index c14ac99..b5fad8c 100644 --- a/decrypted/decrypt.py +++ b/decrypted/decrypt.py @@ -12,9 +12,9 @@ DEFAULT_ITER = 64000 # 通过密钥解密数据库 -def decrypt(key, filePath, decryptedPath): - password = bytes.fromhex(key.replace(" ", "")) - with open(filePath, "rb") as file: +def decrypt(key, db_path, out_path): + password = bytes.fromhex(key.strip()) + with open(db_path, "rb") as file: blist = file.read() salt = blist[:16] @@ -27,14 +27,14 @@ def decrypt(key, filePath, decryptedPath): hash_mac.update(b'\x01\x00\x00\x00') if hash_mac.digest() == first[-32:-12]: - print("Decryption Success") + print("[+] Decryption Success") else: - print("Password Error") + print("[-] Password Error") return False newblist = [blist[i:i + DEFAULT_PAGESIZE] for i in range(DEFAULT_PAGESIZE, len(blist), DEFAULT_PAGESIZE)] - with open(decryptedPath, "wb") as deFile: + with open(out_path, "wb") as deFile: deFile.write(SQLITE_FILE_HEADER.encode()) t = AES.new(byteKey, AES.MODE_CBC, first[-48:-32]) decrypted = t.decrypt(first[:-48]) @@ -46,7 +46,6 @@ def decrypt(key, filePath, decryptedPath): decrypted = t.decrypt(i[:-48]) deFile.write(decrypted) deFile.write(i[-48:]) - return True @@ -70,5 +69,5 @@ if __name__ == '__main__': out_path = args.out_path # 调用 decrypt 函数,并传入参数 - decrypt(key, db_path, out_path) - print("done!") + result = decrypt(key, db_path, out_path) + print(f"{result} done!")