A tool for deriving PKG packet encryption keys for ps4 written in c++
| 1 | #!/usr/bin/env python3 |
| 2 | """ |
| 3 | Build a patched Minecraft PKG from extracted and patched files. |
| 4 | This script uses Patch Builder or orbis-pub-cmd to create a valid PS4 PKG. |
| 5 | """ |
| 6 | |
| 7 | import os |
| 8 | import sys |
| 9 | import subprocess |
| 10 | import shutil |
| 11 | from pathlib import Path |
| 12 | |
| 13 | def build_with_orbis_pub_cmd(extract_dir, output_pkg): |
| 14 | """Build PKG using orbis-pub-cmd (LibOrbisPkg)""" |
| 15 | try: |
| 16 | cmd = [ |
| 17 | "orbis-pub-cmd", |
| 18 | "image_build", |
| 19 | "--image_type", "pkg", |
| 20 | "--image_path", str(extract_dir), |
| 21 | "--output_path", str(output_pkg) |
| 22 | ] |
| 23 | print(f"[*] Building PKG with orbis-pub-cmd...") |
| 24 | print(f" Command: {' '.join(cmd)}") |
| 25 | result = subprocess.run(cmd, capture_output=True, text=True) |
| 26 | |
| 27 | if result.returncode == 0: |
| 28 | print(f"[+] PKG built successfully: {output_pkg}") |
| 29 | return True |
| 30 | else: |
| 31 | print(f"[-] orbis-pub-cmd failed:") |
| 32 | print(result.stderr) |
| 33 | return False |
| 34 | except FileNotFoundError: |
| 35 | print("[-] orbis-pub-cmd not found") |
| 36 | return False |
| 37 | |
| 38 | def build_with_patch_builder(extract_dir): |
| 39 | """Provide instructions for building with Patch Builder GUI""" |
| 40 | print("\n" + "="*70) |
| 41 | print("PATCH BUILDER GUI METHOD") |
| 42 | print("="*70) |
| 43 | print(f"\nExtracted files are ready at:\n {extract_dir}\n") |
| 44 | print("To build the PKG using Patch Builder GUI:") |
| 45 | print("1. Download Patch Builder: https://www.mediafire.com/file/xw0zn2e0rjaf5k7/Patch_Builder_v1.3.3.zip/") |
| 46 | print("2. Extract and run Patch Builder") |
| 47 | print("3. Select 'New Project' -> 'Patch'") |
| 48 | print("4. Set the project folder to:") |
| 49 | print(f" {extract_dir}") |
| 50 | print("5. Click 'Build' to create the PKG") |
| 51 | print("6. The PKG will be saved in the project folder") |
| 52 | print("\n" + "="*70 + "\n") |
| 53 | |
| 54 | def main(): |
| 55 | if len(sys.argv) < 2: |
| 56 | print("Usage: python3 build_patched_pkg.py <extract_dir> [output_pkg]") |
| 57 | print("Example: python3 build_patched_pkg.py /tmp/shadpkg_patch /tmp/minecraft_patched.pkg") |
| 58 | sys.exit(1) |
| 59 | |
| 60 | extract_dir = Path(sys.argv[1]) |
| 61 | |
| 62 | if not extract_dir.exists(): |
| 63 | print(f"[-] Extract directory not found: {extract_dir}") |
| 64 | sys.exit(1) |
| 65 | |
| 66 | # Default output path |
| 67 | if len(sys.argv) > 2: |
| 68 | output_pkg = Path(sys.argv[2]) |
| 69 | else: |
| 70 | output_pkg = extract_dir.parent / "minecraft_patched.pkg" |
| 71 | |
| 72 | print(f"[*] Building patched Minecraft PKG") |
| 73 | print(f" Extract dir: {extract_dir}") |
| 74 | print(f" Output PKG: {output_pkg}") |
| 75 | |
| 76 | # Try orbis-pub-cmd first |
| 77 | if build_with_orbis_pub_cmd(extract_dir, output_pkg): |
| 78 | print(f"\n[+] PKG ready for installation: {output_pkg}") |
| 79 | sys.exit(0) |
| 80 | |
| 81 | # Fall back to Patch Builder instructions |
| 82 | build_with_patch_builder(extract_dir) |
| 83 | print("[!] Please use Patch Builder GUI to complete the PKG build") |
| 84 | sys.exit(1) |
| 85 | |
| 86 | if __name__ == "__main__": |
| 87 | main() |
| 88 |