Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 31 additions & 24 deletions decrypt.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
import os
import multiprocessing

def xorhead(data):
result = bytearray(data)
for i in range(0, 32):
result[i] ^= (len(data) + i).to_bytes(4, 'big')[3]
return bytes(result)
def get_ab_encrypt_key(md5_name: str) -> int:
sv = 0
for char in md5_name:
sv += ord(char)
sv &= 0xFF

def xordata(data):
result = bytearray(data)
for i in range(0, len(data) - 32):
result[i + 32] ^= (i + 32).to_bytes(4, 'big')[3]
if i + 32 >= 4096:
return bytes(result)
return bytes(result)
if (sv & 1) != 0:
key = sv + 4
else:
key = sv + 2
return key & 0xFF

def decrypt(file):
print(file)
path = "bundles/" + file
data = open(path,'rb').read()
with open("bundles-decrypt/" + file, "wb") as f:
f.write(xordata(xorhead(data)))
def xor_decrypt_data(data: bytes, key: int) -> bytes:
dec = bytearray(data)
for i in range(len(dec)):
dec[i] ^= key
return bytes(dec)


def decrypt(file: str):
print(f"{file}")
key_str, _ = os.path.splitext(file)
key = get_ab_encrypt_key(key_str)
with open(os.path.join("bundles", file), 'rb') as f:
enc = f.read()
dec = xor_decrypt_data(enc, key)
with open(os.path.join("bundles-decrypt", file), "wb") as f:
f.write(dec)

if __name__ == "__main__":
if not os.path.isdir("bundles"):
print("copy bundle folders here")
print("请将需要解密的 'bundles' 文件夹放在此脚本旁边。")
exit()

if not os.path.isdir("bundles-decrypt"):
os.mkdir("bundles-decrypt")

os.system("mkdir -p bundles-decrypt")
pool = multiprocessing.Pool()
pool.map(decrypt, os.listdir("bundles"))
pool.close()
pool.join()
with multiprocessing.Pool() as pool:
pool.map(decrypt, os.listdir("bundles"))