Toolbox for analyzing and editing pkg application files for psp,ps3, ps4 and ps5, includes the most useful functions you might need.
| 1 | """ |
| 2 | Extract tab widget for PKG extraction functionality |
| 3 | """ |
| 4 | from PyQt5.QtWidgets import (QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, |
| 5 | QPushButton, QTextEdit, QFileDialog, QMessageBox, |
| 6 | QGroupBox) |
| 7 | from PyQt5.QtCore import Qt |
| 8 | from .base_tab import BaseTab |
| 9 | from packages import PackagePS4 |
| 10 | from Utilities import Logger |
| 11 | |
| 12 | class ExtractTab(BaseTab): |
| 13 | """Tab for PKG extraction operations""" |
| 14 | |
| 15 | def setup_ui(self): |
| 16 | """Setup the extract tab UI""" |
| 17 | # Output directory selection |
| 18 | output_group = QGroupBox("Output Directory") |
| 19 | output_layout = QVBoxLayout() |
| 20 | |
| 21 | dir_layout = QHBoxLayout() |
| 22 | self.extract_out_entry = QLineEdit() |
| 23 | self.extract_out_entry.setPlaceholderText("Select output directory") |
| 24 | browse_button = QPushButton("Browse") |
| 25 | browse_button.clicked.connect(self.browse_output_directory) |
| 26 | |
| 27 | dir_layout.addWidget(self.extract_out_entry) |
| 28 | dir_layout.addWidget(browse_button) |
| 29 | output_layout.addLayout(dir_layout) |
| 30 | output_group.setLayout(output_layout) |
| 31 | |
| 32 | # Extract button |
| 33 | self.extract_button = QPushButton("Extract PKG") |
| 34 | self.extract_button.clicked.connect(self.extract_pkg) |
| 35 | self.extract_button.setStyleSheet(""" |
| 36 | QPushButton { |
| 37 | background-color: #27ae60; |
| 38 | color: white; |
| 39 | font-weight: bold; |
| 40 | padding: 12px; |
| 41 | border-radius: 6px; |
| 42 | font-size: 14px; |
| 43 | } |
| 44 | QPushButton:hover { |
| 45 | background-color: #2ecc71; |
| 46 | } |
| 47 | QPushButton:disabled { |
| 48 | background-color: #95a5a6; |
| 49 | } |
| 50 | """) |
| 51 | |
| 52 | # Log display |
| 53 | log_group = QGroupBox("Extraction Log") |
| 54 | log_layout = QVBoxLayout() |
| 55 | self.extract_log = QTextEdit() |
| 56 | self.extract_log.setReadOnly(True) |
| 57 | self.extract_log.setMaximumHeight(200) |
| 58 | log_layout.addWidget(self.extract_log) |
| 59 | log_group.setLayout(log_layout) |
| 60 | |
| 61 | # Add to main layout |
| 62 | self.layout.addWidget(output_group) |
| 63 | self.layout.addWidget(self.extract_button) |
| 64 | self.layout.addWidget(log_group) |
| 65 | self.layout.addStretch() |
| 66 | |
| 67 | def browse_output_directory(self): |
| 68 | """Browse for output directory""" |
| 69 | directory = QFileDialog.getExistingDirectory( |
| 70 | self, |
| 71 | "Select Output Directory" |
| 72 | ) |
| 73 | if directory: |
| 74 | self.extract_out_entry.setText(directory) |
| 75 | |
| 76 | def extract_pkg(self): |
| 77 | """Extract PKG contents""" |
| 78 | package = self.get_package() |
| 79 | if not package: |
| 80 | QMessageBox.warning(self, "Warning", "Please load a PKG file first") |
| 81 | return |
| 82 | |
| 83 | output_dir = self.extract_out_entry.text() |
| 84 | if not output_dir: |
| 85 | QMessageBox.warning(self, "Warning", "Please select an output directory") |
| 86 | return |
| 87 | |
| 88 | try: |
| 89 | self.extract_button.setEnabled(False) |
| 90 | self.extract_log.append(f"[+] Starting extraction to: {output_dir}") |
| 91 | |
| 92 | # Force use shadPKG for PS4; fallback to internal dump on error |
| 93 | if isinstance(package, PackagePS4): |
| 94 | try: |
| 95 | result = package.extract_via_shadpkg(output_dir) |
| 96 | self.extract_log.append(f"[+] shadPKG extraction: {result}") |
| 97 | except Exception as e: |
| 98 | Logger.log_warning(f"shadPKG failed from UI extract, fallback to dump: {e}") |
| 99 | self.extract_log.append(f"[-] shadPKG failed, using internal extraction: {e}") |
| 100 | result = package.dump(output_dir) |
| 101 | self.extract_log.append(f"[+] Internal extraction: {result}") |
| 102 | else: |
| 103 | result = package.dump(output_dir) |
| 104 | self.extract_log.append(f"[+] Extraction completed: {result}") |
| 105 | |
| 106 | QMessageBox.information(self, "Success", "PKG extracted successfully") |
| 107 | |
| 108 | except Exception as e: |
| 109 | error_msg = f"Failed to extract PKG: {str(e)}" |
| 110 | self.extract_log.append(f"[-] {error_msg}") |
| 111 | QMessageBox.critical(self, "Error", error_msg) |
| 112 | finally: |
| 113 | self.extract_button.setEnabled(True) |
| 114 | |
| 115 |