SFO Extract

Introduction

Beginning with the PlayStation Portable and PlayStation 3, Sony has included a file named param.sfo with their games that provided metadata about the game itself, such as the game's name, ID, version, minimum required firmware, etc.  The format of the file studied and well documented (the PS3 version in particular is well documented), and there are many different SFO utilities available.  (My referred reader is sfo by hippie68 since it's cross-platform, open source, CLI-based, and still being actively developed.)

While viewing param.sfo contents is easy enough, extracting it from the original game or package is a bit trickier.  It's pretty straightforward to extract param.sfo from PS3 and PSP ISOs, but PS4 and Vita games, plus PS3 and PSP PSN packages, require jumping through more hoops.

SFO Extract aims to make extracting param.sfo from any supported game or package format as easy as possible.  It was developed with the following goals in mind:

  • Support all PlayStation media formats that include param.sfo
  • Extract the file as quickly and easily as possible
  • Minimize external dependencies

SFO Extract has been tested with and supports the following formats:

  • PS3 ISOs and App, Update, and DLC PKGs
  • PS4 ISOs and Update PKGs
  • PSP ISOs and DLC PKGs
  • Vita PSVs and App, Update, and DLC PKGs

SFO Extract currently has the following limitations:

  • PS4 ISOs that contain multiple games or app packages (like Life Is Strange: Before the Storm) are not fully supported as there's no predictable way to determine which SFO should be extracted.  As a result, if this type of ISO is detected, SFO Extract will instead extract the BD SFO instead of the App SFO, which describes the contents of the disc rather than the contents of the game.  The BD SFO contains a subset of information from the App SFO.

Return to top

Download  Current Version: 1.0, Released: 09/21/2021

sfo-extract.sh (11.95 KB) - The SFO Extract BASH shell script

The SFO Extract changelog is included in the beginning of the script.

Return to top

Installation

SFO Extract installation simply requires downloading the script, enabling the execute bit (eg., chmod a+x sfo-extract.sh, and moving to a directory in your ${PATH}. In order to support encrypted PS3 and PSP PKG files, the following utility is also necessary:

Return to top

Usage

Execute sfo-extract.sh -h to display help information.  This will describe the syntax for running the program and list all available options.

You may provide pass one or more ISO/PKG files; if multiple files passed (such as *.iso), it'll extract from multiple files in parallel up to your number of CPU threads in order to speed up the process.

By default, sfo-extract.sh outputs param.sfo to the same directory and base name as the source file; use the -d option to change the location of the output file.

Note:  sfo-extract.sh includes a -q quick extract option for PS4 games.  Unpacking the main (App) SFO can take quite a while on PS4 games, so this option exists to extract an alternate disc (BD) SFO that contains a subset of information from the main SFO.  Extracting this BD SFO is much faster, and is useful when you only need basic info about the game, like Title ID, version, or minimum firmware requirement.

Return to top

Technical Details

SFO Extract primarily works as follows:

  1. Search the file for a pattern matching the param.sfo (hereafter referred to as "SFO") header
  2. Calculate the length of the SFO by examining the header
  3. Extract the bytes containing SFO and write to the new file

SFO Extract will perform each of those steps in parallel up to the number of logical CPUs in your computer (use the -t option to control this).  Below is a breakdown of each step.

Search for SFO header

Per reverse-engineered specifications, the SFO begins with the hex string 00 50 53 46 01 01 00 00 xx xx 00 00 xx xx 00 00 (the Xs are variable).  SFO Extract uses grep to search the binary file for this matching pattern and determine the offset of where the header begins.

While searching for the header is relatively straightforward, there are a couple complicating factors:

  1. Some formats, like PSP ISOs, may contain multiple SFO files, with the desired SFO not stored first.  SFO Extract identifies the file format and, when appropriate, extracts the second matching SFO to produce the desired result.
  2. PS4 ISOs also include multiple SFOs, and because the second SFO is randomly located on what can be very large ISO images, grep will either crash or run out of memory when searching files that large.  As a result, instead of directly grepping files, SFO Extract will use dd to read a 1 GB chunk of the file at a time, search that for the SFO header, and repeat as many times as necessary to find the desired SFO file.

Calculate SFO length

SFO files vary in size between systems and games.  To determine the SFO size, SFO Extract does the following:
  1. Get the data table offset from the header
  2. Get the number of index entries from the header
  3. For each entry, determine the size if it's corresponding description
  4. Perform the following calculations:
    • Header = 20 bytes
    • Index table = number of entries * 16 bytes
    • Data table = sum of sizes defined for each entry in index
    • Key table = Data table offset - index table size - header size
    • Total SFO size = header + index table + key table + data table

Extract and save SFO

This step is the most straightforward: using hexdump, read the bytes beginning at the offset found in step 1 for the size determined in step 2, then write the results to the new SFO file.  This step largely reuses commands and logic developed for the prior steps.

Exceptions

The above process covers the process used by SFO Extract to find and extract SFO files, but I have not been able to figure out a good way to do the same for encrypted PSP and PS3 PKG files.  Since the SFO is encrypted, the data must first be decrypted before it can be found and extracted.  SFO Extract calls PSN_get_pkg_info.py to handle this job.

Return to top