mirror of
https://github.com/azaion/loader.git
synced 2026-04-22 09:36:32 +00:00
Quality cleanup refactoring
Made-with: Cursor
This commit is contained in:
+7
-13
@@ -1,9 +1,9 @@
|
||||
import hashlib
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import requests
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives import padding
|
||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||
|
||||
API_SERVICES = [
|
||||
@@ -33,24 +33,18 @@ def decrypt_archive(encrypted_path: str, key_fragment: bytes, output_path: str):
|
||||
iv = f_in.read(16)
|
||||
cipher = Cipher(algorithms.AES(aes_key), modes.CBC(iv), backend=default_backend())
|
||||
decryptor = cipher.decryptor()
|
||||
unpadder = padding.PKCS7(128).unpadder()
|
||||
|
||||
with open(output_path, "wb") as f_out:
|
||||
while True:
|
||||
chunk = f_in.read(64 * 1024)
|
||||
if not chunk:
|
||||
break
|
||||
f_out.write(decryptor.update(chunk))
|
||||
final = decryptor.finalize()
|
||||
f_out.write(final)
|
||||
|
||||
with open(output_path, "rb") as f:
|
||||
f.seek(-1, 2)
|
||||
padding_len = f.read(1)[0]
|
||||
|
||||
if 1 <= padding_len <= 16:
|
||||
size = os.path.getsize(output_path) - padding_len
|
||||
with open(output_path, "r+b") as f:
|
||||
f.truncate(size)
|
||||
decrypted = decryptor.update(chunk)
|
||||
if decrypted:
|
||||
f_out.write(unpadder.update(decrypted))
|
||||
final_decrypted = decryptor.finalize()
|
||||
f_out.write(unpadder.update(final_decrypted) + unpadder.finalize())
|
||||
|
||||
|
||||
def docker_load(tar_path: str):
|
||||
|
||||
Reference in New Issue
Block a user