Spaces:
Sleeping
Sleeping
| import os | |
| import sys | |
| import UnityPy | |
| import datetime | |
| def get_timestamp(): | |
| return datetime.datetime.now().strftime("%H:%M:%S") | |
| def ultimate_surgical_patch(dummy_bundle_dir, hp_bundle_dir, output_bundle_dir): | |
| print(f"[{get_timestamp()}] [PYTHON] Memulai audit biner mendalam...") | |
| # 1. EKSTRAKSI IDENTITAS DUMMY (KTP TARGET) | |
| dummy_cab = None | |
| if not os.path.exists(dummy_bundle_dir): | |
| print(f"[{get_timestamp()}] [PYTHON] [ERROR] Folder Dummy tidak ada: {dummy_bundle_dir}") | |
| sys.exit(1) | |
| print(f"[{get_timestamp()}] [PYTHON] Melakukan scan identitas pada folder Dummy...") | |
| dummy_files = [f for f in os.listdir(dummy_bundle_dir) if os.path.isfile(os.path.join(dummy_bundle_dir, f))] | |
| for rf in dummy_files: | |
| try: | |
| full_path = os.path.join(dummy_bundle_dir, rf) | |
| env = UnityPy.load(full_path) | |
| if env.cabs: | |
| dummy_cab = list(env.cabs.keys())[0] | |
| print(f"[{get_timestamp()}] [PYTHON] [INFO] CAB Dummy ditemukan di {rf}: {dummy_cab}") | |
| break | |
| except Exception as e: | |
| print(f"[{get_timestamp()}] [PYTHON] [WARN] Gagal membaca {rf}: {str(e)}") | |
| if not dummy_cab: | |
| print(f"[{get_timestamp()}] [PYTHON] [FATAL] Tidak ada CAB valid di Dummy. Patching dibatalkan.") | |
| sys.exit(1) | |
| # 2. PROSES PATCHING BADAN (RAKSASA) | |
| if not os.path.exists(output_bundle_dir): | |
| os.makedirs(output_bundle_dir, exist_ok=True) | |
| hp_platforms = [f for f in os.listdir(hp_bundle_dir) if os.path.isfile(os.path.join(hp_bundle_dir, f))] | |
| print(f"[{get_timestamp()}] [PYTHON] Ditemukan {len(hp_platforms)} platform untuk diproses.") | |
| for platform in hp_platforms: | |
| hp_path = os.path.join(hp_bundle_dir, platform) | |
| out_path = os.path.join(output_bundle_dir, platform) | |
| print(f"[{get_timestamp()}] [PYTHON] [PROCESS] Platform: {platform}") | |
| try: | |
| # Cari CAB asli milik Baju Raksasa | |
| env_hp = UnityPy.load(hp_path) | |
| hp_cab = list(env_hp.cabs.keys())[0] if env_hp.cabs else None | |
| if not hp_cab: | |
| print(f"[{get_timestamp()}] [PYTHON] [SKIP] Tidak ada CAB di {platform}") | |
| continue | |
| print(f"[{get_timestamp()}] [PYTHON] [DATA] CAB Asli Raksasa: {hp_cab}") | |
| print(f"[{get_timestamp()}] [PYTHON] [DATA] Target Injeksi : {dummy_cab}") | |
| with open(hp_path, "rb") as f: | |
| raw_data = f.read() | |
| old_bytes = hp_cab.encode('utf-8') | |
| new_bytes = dummy_cab.encode('utf-8') | |
| # Hitung jumlah kemunculan untuk validasi log | |
| occurences = raw_data.count(old_bytes) | |
| print(f"[{get_timestamp()}] [PYTHON] [PATCH] Menemukan {occurences} string target di biner.") | |
| # Eksekusi Patching | |
| patched_data = raw_data.replace(old_bytes, new_bytes) | |
| with open(out_path, "wb") as f: | |
| f.write(patched_data) | |
| print(f"[{get_timestamp()}] [PYTHON] [SUCCESS] {platform} berhasil di-patch. Ukuran: {len(patched_data)} bytes.") | |
| # 3. PATCHING PREFAB (KERTAS BLUEPRINT) | |
| stage_root = os.path.dirname(output_bundle_dir) | |
| for file in os.listdir(stage_root): | |
| if file.lower().endswith(".prefab"): | |
| pf_path = os.path.join(stage_root, file) | |
| with open(pf_path, "rb") as pf: | |
| p_data = pf.read() | |
| if old_bytes in p_data: | |
| p_patched = p_data.replace(old_bytes, new_bytes) | |
| with open(pf_path, "wb") as pf: | |
| pf.write(p_patched) | |
| print(f"[{get_timestamp()}] [PYTHON] [PREFAB] ID CAB di {file} telah disinkronkan.") | |
| except Exception as e: | |
| print(f"[{get_timestamp()}] [PYTHON] [ERROR] Platform {platform} gagal: {str(e)}") | |
| print(f"[{get_timestamp()}] [PYTHON] Operasi selesai. Semua identitas telah dipalsukan.") | |
| print("KONFIRMASI: Injeksi selesai 100%") | |
| if __name__ == "__main__": | |
| if len(sys.argv) < 4: | |
| print("Usage: python3 uabe_packer.py <dummy_bundle_dir> <hp_bundle_dir> <output_bundle_dir>") | |
| sys.exit(1) | |
| ultimate_surgical_patch(sys.argv[1], sys.argv[2], sys.argv[3]) |