Giter Site home page Giter Site logo

pkg2zip's Introduction

pkg2zip

Travis CI Build Status AppVeyor Build Status Downloads Release License

Utility that decrypts PlayStation Vita pkg file and creates zip package. Supported pkg files - main application, DLC, patch and PSM files. Also supports PSX and PSP pkg files for use with Adrenaline.

Optionally writes NoNpDrm or NoPsmDrm fake license file from zRIF string. You must provide license key.

Requirements

Features

  • portable, written in cross-platform C code, runs on Windows, GNU/Linux, macOS (system dependent functionality is isolated in sys.c file).
  • small, has no external library dependencies and uses very minimal dynamic memory allocations.
  • fast, uses AESNI hardware accelerated AES decryption if supported by CPU (requires AESNI and SSSE3 instructions).
  • simple, creates zip package with same folder structure that Vita expects (just drag & drop all file from zip archive to ux0:). Zip file is created directly from pkg without any intermediate temporary files.
  • Vita DLC, Vita PATCH and PSM pkg unpacking.
  • PSX and PSP pkg unpacking.

Limitations:

  • no PSP DLC pkg files are supported.
  • no actual title name is extracted for PSM pkg files.

Usage

If you have zRIF fake license, then execute:

pkg2zip package.pkg zRIF_STRING

This will create title [id] [region].zip file. Title, ID and region is automatically detected from pkg file. It will include work.bin file.

If you don't have zRIF fake license, but just want to unpack files, then omit last argument:

pkg2zip package.pkg

Resulting zip file will not include work.bin. This is useful for patch pkg files.

To get output file name of the zip, use -l (must come before pkg file and cannot be used with -x):

pkg2zip -l package.pkg

To avoid zipping process and create individual files, use -x argument (must come before pkg file):

pkg2zip -x package.pkg [zRIF_STRING]

PSX or PSP pkg files do not require zRIF argument. It will be ignored.

For PSP files pkg2zip by default will create .ISO file. To create compressed .CSO file pass -cN argument where N is compression factor. For example, for fastest compression use:

pkg2zip -c1 package.pkg

To create smaller cso file (more compression will require more time) use -c9, or anything inbetween:

pkg2zip -c9 package.pkg

You can combine -cN argument together with -x:

pkg2zip -x -c9 package.pkg

Generating zRIF string

If you have working NoNpDrm license file (work.bin or 6488b73b912a753a492e2714e9b38bc7.rif) you can create zRIF string with rif2zrif.py python script:

$ python rif2zrif.py path/to/work.bin

It will print zRIF string to stdout.

To generate work.bin from zRIF string use zrif2rif.py script:

$ python zrif2rif.py zRIF work.bin

Last argument is optional, it specifies where to save file and defaults to work.bin name.

Download

Get latest Windows binaries here.

ArchLinux users can build binary with pkg2zip package in AUR repository. For example, with pacaur:

$ pacaur -S pkg2zip

openSUSE users can download the package from the Packman repository. If this repository is enabled, just install pkg2zip with zypper.

# zypper install pkg2zip

Building

Execute make if you are on GNU/Linux or macOS.

On Windows you can build either with MinGW (get MinGW-w64) or Visual Studio 2017 Community Edition.

  • for MinGW make sure you have make installed, and then execute mingw32-make
  • for Visual Studio run build.cmd

Alternatives

License

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

pkg2zip's People

Contributors

mmozeiko avatar pseiler avatar theradziu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pkg2zip's Issues

Make build.cmd to work with different types of Visual Studio 2017 (Build Tools, Community, Pro)

Please update build.cmd as following to make it more flexible for different VS setups, e.g. in my case I only use VS build tools which are in "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools"

@echo off

if not "%VSINSTALLDIR%" == "" goto vsdevcmd_present
echo Please run %~0 inside a Visual Studio 2017 Tools Developer Command Prompt
exit /B

:vsdevcmd_present
call "%VSINSTALLDIR%\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64
cd /d "%~dp0"

...

Error on pkg extraction

Allow user to specify an output directory.

Previously I was using pkg_dec with NPS Browser (I also contributed to NPSB) and it had the option to provide an output directroy for extracted files.

I'd like to be able to do the same thing with pkg2zip since it organizes the files in a much cleaner way.

Right now we get a single app and addcont directory where all the games end up. I'd much rather extract games into their own directories like this:

{gameTitle} ({region}) [{titleID}]
 |-addcont
 |-app
 \-license

i.e. pkg2zip -x {pkgFile} {zRifKey} -o ".\{gameTitle} ({region}) [{titleID}]"

Thanks!

Doesn't compile on ARM

Some compiling errors when compiling on Raspberry Pi 3 B+. Works perfectly fine on my PC.

$ make
[C] pkg2zip_aes.c
[C] pkg2zip.c
[C] pkg2zip_crc32.c
[C] pkg2zip_aes_x86.c
cc: error: unrecognized command line option ‘-maes’; did you mean ‘-mapcs’?
cc: error: unrecognized command line option ‘-mssse3’
makefile:28: recipe for target 'pkg2zip_aes_x86.o' failed
make: *** [pkg2zip_aes_x86.o] Error 1

Debian Package

I try run make when compile, but make install not work here, i now know how to install this package.

[Request] Add PocketStation proper extraction

Right now PocketStation is recognized and extracted as PSX title (which is most likely wrong, since its PS Vita app) and produce no files.

pkg2zip v1.8
[*] loading...
[*] unpacking PSX
[*] unpacking completed
[*] done!

[Request] Add region & language params for automatic renaming of PSP games

When obtaining a PSP game from NPS Browser, pkg2zip automatically names the file with the naming convention of "Title [Game ID].iso", while using the default params (-x {pkgFile} "{zRifKey}").

This is a request to add a param for the region. Ideally I'd like to have it automatically name the PSP games with a naming convention of "Title (Region) [Game ID].iso".

A param for language(s) may also be helpful.

Thanks in advance!

Add query option to query the file name

It would be nice to add an parameter (f.e. -l) to output only the file name of outputted zip.

like

pkg2zip -l example_game.pkg
Example Game US PCSE001234.zip

So it can easily be scripted like this

#!/bin/bash
MY_FILE=$(pkgzip -l example_game.pkg)
pkg2zip example_game.pkg
mv $MY_FILE /new/destination
...

Compilation issue - "comparison between signed and unsigned integer expressions"

On my Linux system, when I try to compile I get the following:

$ make
[C] pkg2zip_utils.c
[C] pkg2zip_aes.c
[C] pkg2zip.c
[C] pkg2zip_crc32.c
[C] pkg2zip_aes_x86.c
[C] pkg2zip_zip.c
[C] pkg2zip_crc32_x86.c
[C] pkg2zip_sys.c
pkg2zip_sys.c: In function ‘sys_read’:
pkg2zip_sys.c:157:14: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
     if (read != size)
              ^
pkg2zip_sys.c: In function ‘sys_write’:
pkg2zip_sys.c:166:15: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
     if (wrote != size)
               ^
cc1: all warnings being treated as errors
makefile:36: recipe for target 'pkg2zip_sys.o' failed
make: *** [pkg2zip_sys.o] Error 1

issues on extraction patch

pkg2zip v1.6 error seems to only on patch extraction (no zip file). without -x arg extraction working fine

pkg2zip.exe -x mypkgfile.pkg (same with added zrif)

...
[23/24] sce_pfs/pflist
[24/24] sce_sys/package/digs.bin
ERROR: cannot create 'patch/PCSE00680/sce_sys/package/digs.bin' file

http://gs.ww.np.dl.playstation.net/ppkg/np/PCSE00680/PCSE00680_T0/ee26b55db65c4b41/UP4403-PCSE00680_00-SPARKLEUNLEASHED-A0101-V0101-1274bf4b92dce125081c8ee295d999fe51a96887-PE.pkg
or
http://gs.ww.np.dl.playstation.net/ppkg/np/PCSE00339/PCSE00339_T2/f75debdfce6af542/UP3643-PCSE00339_00-DUKE3DHDUSVITA00-A0101-V0102-8f63a6108a67372a2cf8b55eb78f55ad763c69aa-PE.pkg

PSP CSO feature is broken

Any game created with the CSO feature hangs on Adrenaline, but works fine on PPSSPP.
To confirm it was the feature, I manually uncompressed the file and ran it successfully in Adrenaline. I used a third party tool to compress it to a CSO (level 9 compression) again, and that worked fine as well.

For some reason, any CSO created by this program just hangs on Adrenaline-6 fix (the version that fixed the CSO hang bug.)

[Request] Add option not to unpack PSP eboots

This would treat PSP eboots as PSX eboots are treated now and extract into the same folder structure.. i.e. ../PSP/GAME/{ID}

With currently available tools its not necessary to unpack all the way to ISO. eboots can run in their native format, retain their original compression, along with any associated document.dat.

Issue when retrieving name of PKG using -l command

Whenever I used the -l command to run the program, it always returned this error in the console on Windows :

This version of C:\Users\otega\Downloads\pkg2zip.exe is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.

Error with PSX PKG

I tested the last version with one PSX PKG

https://gyazo.com/a9158c091073586b3f797101b4c94e56

It's a PS3 format not a PSP format, so, how must i installed it ?

Android support

I just want to know if this is possible to build the app for android

[Request] Add folder option

Please add option to create folder as target for extraction. It would be very useful to have "addcont, app, patch" automatically in one folder. Thank you very much.

[Request] Add pkg to pkgs decryption only feature.

I'd work similar to pkg_dec's --raw option, providing decrypted pkgs file.

Such feature is very useful for people that wish to research certain pkg files [examples: pocketstation (see: #21) or PSN_get_pkg_info development]

Consider renaming?

This tool now does much more than outputting to zip, including outputting to an extracted folder, or to ISO/CSO. So maybe it should be renamed pkgtool or similar? Or pspkgtool to make it clear it is PlayStation-specific, as opposed to other types of PKG files.

Errors compiling on gcc 8.1.1

-Werror causes compile to fail on gcc 8.1.1 with -Werror=format-truncation=

Disabling -Werror allows it to compile with warnings.

[Bug/Request] Unable to properly extract PSP DLC

When using pkg2zip with NPS Browser, everything works fantastically with the exception of the DLC for the PSP system. The .pkg file for the DLC will download, but pkg2zip is unable to properly extract that data.

I wasn't sure whether to post this as a bug or a feature request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.