Spaces:
Sleeping
Sleeping
Update uabe_packer.py
Browse files- uabe_packer.py +63 -64
uabe_packer.py
CHANGED
|
@@ -1,72 +1,71 @@
|
|
| 1 |
-
import UnityPy
|
| 2 |
-
import sys
|
| 3 |
import os
|
| 4 |
-
import
|
|
|
|
| 5 |
|
| 6 |
-
def extract_and_inject(dummy_dir,
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
hp_meshes = [obj for obj in env_hp.objects if obj.type.name == "Mesh"]
|
| 20 |
-
hp_tex = [obj for obj in env_hp.objects if obj.type.name == "Texture2D"]
|
| 21 |
-
|
| 22 |
-
if not hp_meshes and not hp_tex:
|
| 23 |
-
continue
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
for i, d_mesh in enumerate(d_meshes):
|
| 31 |
-
if i < len(hp_meshes):
|
| 32 |
-
d_mesh.set_raw_data(hp_meshes[i].get_raw_data())
|
| 33 |
-
modified = True
|
| 34 |
-
|
| 35 |
-
# Packing Texture
|
| 36 |
-
d_texs = [obj for obj in env_dummy.objects if obj.type.name == "Texture2D"]
|
| 37 |
-
for i, d_tex in enumerate(d_texs):
|
| 38 |
-
if i < len(hp_tex):
|
| 39 |
-
d_tex.set_raw_data(hp_tex[i].get_raw_data())
|
| 40 |
-
modified = True
|
| 41 |
-
|
| 42 |
-
if modified:
|
| 43 |
-
# SIMPAN DENGAN KOMPRESI ASLI (LZ4)
|
| 44 |
-
packer_type = env_dummy.file.packer
|
| 45 |
-
with open(dummy_path, "wb") as f:
|
| 46 |
-
f.write(env_dummy.file.save(packer=packer_type))
|
| 47 |
-
print(f"[UABE] 🎯 Berhasil Packing: {file_name}")
|
| 48 |
-
processed_count += 1
|
| 49 |
-
except Exception:
|
| 50 |
-
print(f"[UABE ERROR] Gagal pada file {file_name}:")
|
| 51 |
-
traceback.print_exc()
|
| 52 |
-
continue
|
| 53 |
-
return processed_count > 0
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
| 71 |
traceback.print_exc()
|
| 72 |
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
import sys
|
| 3 |
+
import UnityPy
|
| 4 |
|
| 5 |
+
def extract_and_inject(dummy_dir, target_dir):
|
| 6 |
+
print("🚀 [UABE PACKER] Memulai proses Injeksi Biner...")
|
| 7 |
+
|
| 8 |
+
# 1. Menangani Path (Hugging Face Node.js biasanya memberikan path folder)
|
| 9 |
+
dummy_path = dummy_dir
|
| 10 |
+
if os.path.isdir(dummy_dir):
|
| 11 |
+
files = os.listdir(dummy_dir)
|
| 12 |
+
if files: dummy_path = os.path.join(dummy_dir, files[0])
|
| 13 |
+
|
| 14 |
+
target_path = target_dir
|
| 15 |
+
if os.path.isdir(target_dir):
|
| 16 |
+
files = os.listdir(target_dir)
|
| 17 |
+
if files: target_path = os.path.join(target_dir, files[0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
print(f"📦 Load Dummy : {dummy_path}")
|
| 20 |
+
env_dummy = UnityPy.load(dummy_path)
|
| 21 |
+
|
| 22 |
+
print(f"🎯 Load Target: {target_path}")
|
| 23 |
+
env_target = UnityPy.load(target_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
# ====================================================================
|
| 26 |
+
# --- LOGIKA INJEKSI ZEPETO ---
|
| 27 |
+
# Memindahkan isi Target ke dalam Wadah Dummy untuk mengelabui server
|
| 28 |
+
# ====================================================================
|
| 29 |
+
|
| 30 |
+
# Mengambil nama internal (CAB) asli dari dummy
|
| 31 |
+
dummy_cab = list(env_dummy.cabs.keys())[0] if env_dummy.cabs else None
|
| 32 |
+
target_cab = list(env_target.cabs.keys())[0] if env_target.cabs else None
|
| 33 |
|
| 34 |
+
# Mengubah identitas biner target agar persis seperti dummy
|
| 35 |
+
if dummy_cab and target_cab and dummy_cab != target_cab:
|
| 36 |
+
env_target.cabs[dummy_cab] = env_target.cabs.pop(target_cab)
|
| 37 |
+
for obj in env_target.objects:
|
| 38 |
+
if hasattr(obj, "assets_file"):
|
| 39 |
+
obj.assets_file.name = dummy_cab
|
| 40 |
+
|
| 41 |
+
# ====================================================================
|
| 42 |
+
# --- KUNCI PENYELESAIAN FATAL ERROR (LINE 44) ---
|
| 43 |
+
# Membuang sistem pendeteksi kompresi lama yang memicu AttributeError
|
| 44 |
+
# dan memaksa sistem menggunakan kompresi LZ4 standar modern mutlak.
|
| 45 |
+
# ====================================================================
|
| 46 |
+
print("⚙️ [UABE PACKER] Mengeksekusi kompresi LZ4 modern...")
|
| 47 |
+
|
| 48 |
+
packed_data = env_target.file.save(packer="lz4")
|
| 49 |
+
|
| 50 |
+
# Menimpa file dummy asli dengan biner yang sudah diinjeksi
|
| 51 |
+
with open(dummy_path, "wb") as f:
|
| 52 |
+
f.write(packed_data)
|
| 53 |
+
|
| 54 |
+
print("✅ [UABE PACKER] Injeksi selesai 100%! Bundle siap di-packing.")
|
| 55 |
+
|
| 56 |
+
if __name__ == "__main__":
|
| 57 |
+
# Verifikasi Argumen Terminal
|
| 58 |
+
if len(sys.argv) < 3:
|
| 59 |
+
print("❌ Error: Parameter kurang. Gunakan: python3 uabe_packer.py <dummy_dir> <target_dir>")
|
| 60 |
+
sys.exit(1)
|
| 61 |
|
| 62 |
+
dummy_arg = sys.argv[1]
|
| 63 |
+
target_arg = sys.argv[2]
|
| 64 |
+
|
| 65 |
+
try:
|
| 66 |
+
extract_and_inject(dummy_arg, target_arg)
|
| 67 |
+
except Exception as e:
|
| 68 |
+
print(f"🔥 [FATAL ERROR] UABE Packer Crash: {str(e)}")
|
| 69 |
+
import traceback
|
| 70 |
traceback.print_exc()
|
| 71 |
sys.exit(1)
|