Advertisement
Sweetening

PS3_ISO.ps

Aug 25th, 2024 (edited)
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.85 KB | None | 0 0
  1. # Define paths and filenames
  2. $pkgPath = ".\Game.pkg"
  3. $extractPath = ".\ExtractedFiles"
  4. $workingDir = ".\WorkingDirectory"
  5. $isoPath = ".\Base.iso"
  6. $repackedIsoPath = ".\Repacked.iso"
  7. $sevenZipUrl = "https://www.7-zip.org/a/7z2201-x64.exe"
  8. $mkisofsUrl = "https://downloads.sourceforge.net/project/cdrtools/cdrtools/3.02a09/cdrtools-3.02a09-win32-bin.zip"
  9. $signingScriptUrl = "https://example.com/signing-script.ps1" # Placeholder URL for signing script
  10.  
  11. # Define tool paths
  12. $sevenZipPath = "C:\Program Files\7-Zip\7z.exe"
  13. $mkisofsPath = "C:\Program Files\mkisofs\mkisofs.exe"
  14. $signingScriptPath = "$env:TEMP\signing-script.ps1"
  15. $ps3InstallPath = "$env:ProgramFiles\PS3ModdingTool"
  16. $ps3ScriptPath = "$ps3InstallPath\ps3.ps1"
  17. $shortcutPath = "$env:Public\Desktop\PS3.lnk"
  18.  
  19. # Function to download a file
  20. function Download-File {
  21. param (
  22. [string]$url,
  23. [string]$outputPath
  24. )
  25. try {
  26. Write-Host "Downloading $url..."
  27. Invoke-WebRequest -Uri $url -OutFile $outputPath -ErrorAction Stop
  28. } catch {
  29. Write-Error "Failed to download $url. $_"
  30. exit 1
  31. }
  32. }
  33.  
  34. # Function to install 7-Zip
  35. function Install-SevenZip {
  36. Write-Host "Installing 7-Zip..."
  37. $zipInstaller = "$env:TEMP\7zInstaller.exe"
  38. Download-File -url $sevenZipUrl -outputPath $zipInstaller
  39. try {
  40. Start-Process -FilePath $zipInstaller -ArgumentList "/S" -Wait -ErrorAction Stop
  41. Remove-Item -Path $zipInstaller -ErrorAction Stop
  42. } catch {
  43. Write-Error "Failed to install 7-Zip. $_"
  44. exit 1
  45. }
  46. }
  47.  
  48. # Function to install mkisofs
  49. function Install-Mkisofs {
  50. Write-Host "Installing mkisofs..."
  51. $zipInstaller = "$env:TEMP\cdrtools.zip"
  52. Download-File -url $mkisofsUrl -outputPath $zipInstaller
  53. try {
  54. Expand-Archive -Path $zipInstaller -DestinationPath "$env:ProgramFiles" -ErrorAction Stop
  55. Remove-Item -Path $zipInstaller -ErrorAction Stop
  56. } catch {
  57. Write-Error "Failed to install mkisofs. $_"
  58. exit 1
  59. }
  60. }
  61.  
  62. # Function to install signing script
  63. function Install-SigningScript {
  64. Write-Host "Installing signing script..."
  65. Download-File -url $signingScriptUrl -outputPath $signingScriptPath
  66. }
  67.  
  68. # Check and install necessary tools
  69. if (-not (Test-Path $sevenZipPath)) {
  70. Install-SevenZip
  71. }
  72. if (-not (Test-Path $mkisofsPath)) {
  73. Install-Mkisofs
  74. }
  75. if (-not (Test-Path $signingScriptPath)) {
  76. Install-SigningScript
  77. }
  78.  
  79. # Ensure necessary directories exist
  80. if (-not (Test-Path $extractPath)) { New-Item -ItemType Directory -Path $extractPath -ErrorAction Stop }
  81. if (-not (Test-Path $workingDir)) { New-Item -ItemType Directory -Path $workingDir -ErrorAction Stop }
  82.  
  83. # Extract PKG file
  84. Write-Host "Extracting PKG file..."
  85. try {
  86. & $sevenZipPath x $pkgPath -o$extractPath -y
  87. if ($LASTEXITCODE -ne 0) { throw "Extraction failed with exit code $LASTEXITCODE." }
  88. } catch {
  89. Write-Error "Extraction failed. $_"
  90. exit 1
  91. }
  92.  
  93. # Allow user to modify files
  94. Write-Host "Please modify the files in $workingDir. Press Enter when done..."
  95. Read-Host
  96.  
  97. # Re-sign files
  98. Write-Host "Re-signing files..."
  99. try {
  100. & powershell -ExecutionPolicy Bypass -File $signingScriptPath -Path $workingDir
  101. if ($LASTEXITCODE -ne 0) { throw "Re-signing failed with exit code $LASTEXITCODE." }
  102. } catch {
  103. Write-Error "Re-signing failed. $_"
  104. exit 1
  105. }
  106.  
  107. # Repack the ISO
  108. Write-Host "Repacking ISO file..."
  109. try {
  110. & $mkisofsPath -o $repackedIsoPath -R -J -V "GameISO" "$workingDir"
  111. if ($LASTEXITCODE -ne 0) { throw "ISO repackaging failed with exit code $LASTEXITCODE." }
  112. } catch {
  113. Write-Error "ISO repackaging failed. $_"
  114. exit 1
  115. }
  116.  
  117. # Calculate checksum
  118. Write-Host "Calculating checksum..."
  119. try {
  120. $hash = Get-FileHash -Path $repackedIsoPath -Algorithm SHA256
  121. Write-Host "Checksum: $($hash.Hash)"
  122. } catch {
  123. Write-Error "Checksum calculation failed. $_"
  124. exit 1
  125. }
  126.  
  127. # Display completion message
  128. function Show-Message {
  129. Write-Host "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣷⣶⣤⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀"
  130. Write-Host "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⠿⣿⣷⣶⣄⠀⠀⠀⠀⠀⠀⠀⠀"
  131. Write-Host "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⡇⠀⢸⣿⣿⣿⣷⡄⠀⠀⠀⠀⠀⠀"
  132. Write-Host "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⡇⠀⢸⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀"
  133. Write-Host "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⡇⠀⢸⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀"
  134. Write-Host "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⡇⠀⠈⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀"
  135. Write-Host "⠀⠀⠀⠀⠀⠀⠀⣀⣤⣴⣿⣿⣿⣿⡇⠀⢠⣶⣿⣿⣿⠿⠿⢿⣶⣦⣤⡀"
  136. Write-Host "⢰⣿⣿⣿⣿⠿⠛⠛⠉⠀⣿⣿⣿⣿⡇⠀⠘⠛⠛⠋⠉⠙⢛⠻⠿⠛⠋⠀"
  137. Write-Host "⠈⠻⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀"
  138. Write-Host " Made By Taylor Christian Newsome"
  139. }
  140.  
  141. Show-Message
  142. Write-Host "Process completed successfully."
  143.  
  144. # Install PS3 command
  145. function Install-PS3Tool {
  146. if (-not (Test-Path $ps3InstallPath)) {
  147. New-Item -ItemType Directory -Path $ps3InstallPath -ErrorAction Stop
  148. }
  149. Copy-Item -Path $MyInvocation.MyCommand.Path -Destination $ps3ScriptPath -ErrorAction Stop
  150.  
  151. # Create executable for easy access
  152. if (-not (Test-Path $shortcutPath)) {
  153. try {
  154. $WshShell = New-Object -ComObject WScript.Shell
  155. $Shortcut = $WshShell.CreateShortcut($shortcutPath)
  156. $Shortcut.TargetPath = "powershell.exe"
  157. $Shortcut.Arguments = "-ExecutionPolicy Bypass -File `"$ps3ScriptPath`""
  158. $Shortcut.WorkingDirectory = $ps3InstallPath
  159. $Shortcut.IconLocation = "powershell.exe,0"
  160. $Shortcut.Save()
  161. } catch {
  162. Write-Error "Failed to create desktop shortcut. $_"
  163. exit 1
  164. }
  165. }
  166. }
  167.  
  168. Install-PS3Tool
  169.  
  170. # Help function
  171. function Show-Help {
  172. Write-Host "PS3 Modding Tool - Command Line Options"
  173. Write-Host ""
  174. Write-Host "Usage:"
  175. Write-Host " ps3 : Start the PS3 Modding Tool"
  176. Write-Host " ps3 -h, --help : Show this help message"
  177. Write-Host ""
  178. Write-Host "Description:"
  179. Write-Host " This tool allows you to mod PS3 games by extracting, modifying, and repacking game files."
  180. Write-Host ""
  181. Write-Host "Installation:"
  182. Write-Host " The tool will install necessary components and create a desktop shortcut for easy access."
  183. Write-Host ""
  184. Write-Host "Examples:"
  185. Write-Host " ps3 : Run the tool"
  186. Write-Host " ps3 -h : Show this help message"
  187. }
  188.  
  189. # Command-line arguments
  190. if ($args.Count -eq 0) {
  191. Show-Help
  192. } elseif ($args[0] -eq '-h' -or $args[0] -eq '--help') {
  193. Show-Help
  194. } else {
  195. Write-Host "Unknown argument: $($args[0])"
  196. Show-Help
  197. }
  198.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement