VAIO Packaging Manager Extractor v1.0

Parses VAIO Packaging Manager executables and extracts their contents. If direct extraction fails, it unlocks the executable in order to run at all systems and allow the user to choose the extraction location.
This commit is contained in:
Plato Mavropoulos 2019-02-03 22:28:39 +02:00
parent 9feaefff67
commit 654d9e29cf
2 changed files with 171 additions and 1 deletions

View file

@ -11,7 +11,7 @@ Various BIOS Utilities for Modding/Research
#### **Description**
Extracts and unpacks the SPI/BIOS modules from Dell HDR executables. After extraction, the HDR image is automatically unpacked into individual SPI/BIOS modules via [LongSoft's PFSExtractor-RS](https://github.com/LongSoft/PFSExtractor-RS) tool.
Parses modern icon-less Dell BIOS HDR executables and extracts their SPI/BIOS modules. After extraction, the HDR image is automatically unpacked into individual SPI/BIOS modules via [LongSoft's PFSExtractor-RS](https://github.com/LongSoft/PFSExtractor-RS) tool.
#### **Usage**
@ -264,6 +264,48 @@ PyInstaller can build/freeze/compile the utility at Windows, it is simple to run
At dist folder you should find the final utility executable
## **VAIO Packaging Manager Extractor**
#### **Description**
Parses VAIO Packaging Manager executables and extracts their contents. If direct extraction fails, it unlocks the executable in order to run at all systems and allow the user to choose the extraction location. The utility automatically uses [Igor Pavlov's 7-Zip](https://www.7-zip.org/) tool in order to decompress the initially obfuscated Microsoft CAB compressed contents.
#### **Usage**
You can either Drag & Drop or manually enter the full path of a folder containing VAIO Packaging Manager executables.
#### **Download**
An already built/frozen/compiled binary is provided by me for Windows only. Thus, **you don't need to manually build/freeze/compile it under Windows**. Instead, download the latest version from the [Releases](https://github.com/platomav/BIOSUtilities/releases) tab. To extract the already built/frozen/compiled archive, you need to use programs which support RAR5 compression. Note that you need to manually apply any prerequisites.
#### **Compatibility**
Should work at all Windows, Linux or macOS operating systems which have Python 3.6 support. Windows users who plan to use the already built/frozen/compiled binary must make sure that they have the latest Windows Updates installed which include all required "Universal C Runtime (CRT)" libraries.
#### **Prerequisites**
To run the python script or its built/frozen/compiled binary, you need to have the following 3rd party tool at the same directory:
* [7-Zip Console](https://www.7-zip.org/) (i.e. 7z.exe)
#### **Build/Freeze/Compile with PyInstaller**
PyInstaller can build/freeze/compile the utility at all three supported platforms, it is simple to run and gets updated often.
1. Make sure Python 3.6.0 or newer is installed:
> python --version
2. Use pip to install PyInstaller:
> pip3 install pyinstaller
3. Build/Freeze/Compile:
> pyinstaller --noupx --onefile VAIO_Package_Extract.py
At dist folder you should find the final utility executable
## **Award BIOS Module Extractor**
#### **Description**

View file

@ -0,0 +1,128 @@
#!/usr/bin/env python3
"""
VAIO Package Extractor
VAIO Packaging Manager Extractor
Copyright (C) 2019 Plato Mavropoulos
"""
print('VAIO Packaging Manager Extractor v1.0')
import os
import re
import sys
import subprocess
if len(sys.argv) >= 2 :
# Drag & Drop or CLI
vaio_exec = sys.argv[1:]
else :
# Folder path
vaio_exec = []
in_path = input('\nEnter the full folder path: ')
print('\nWorking...')
for root, dirs, files in os.walk(in_path):
for name in files :
vaio_exec.append(os.path.join(root, name))
# Microsoft CAB Header XOR 0xFF (Tag[4] + Res[4] + Size[4] + Res[4] + Offset[4] + Res[4] + Ver[2]) pattern
mscf_pattern = re.compile(br'\xB2\xAC\xBC\xB9\xFF{4}.{4}\xFF{4}.{4}\xFF{4}\xFC\xFE', re.DOTALL)
# VAIO Packaging Manager Configuration file ("[Setting]" + Windows_new_line) pattern
vaio_pattern = re.compile(br'\x5B\x53\x65\x74\x74\x69\x6E\x67\x5D\x0D\x0A')
# VAIO Packaging Manager Configuration file entry "UseVAIOCheck" pattern
check_pattern = re.compile(br'\x0A\x55\x73\x65\x56\x41\x49\x4F\x43\x68\x65\x63\x6B\x3D')
# VAIO Packaging Manager Configuration file entry "ExtractPathByUser" pattern
path_pattern = re.compile(br'\x0A\x45\x78\x74\x72\x61\x63\x74\x50\x61\x74\x68\x42\x79\x55\x73\x65\x72\x3D')
for input_file in vaio_exec :
file_path = os.path.abspath(input_file)
file_dir = os.path.dirname(file_path)
file_name = os.path.basename(file_path)
print('\nFile: ' + file_name)
# Open Locked VAIO Packaging Manager executable as mutable bytearray
with open(input_file, 'rb') as in_file : vaio_data = bytearray(in_file.read())
match_mscf = mscf_pattern.search(vaio_data) # Search for Microsoft CAB Header XOR 0xFF pattern
match_vaio = vaio_pattern.search(vaio_data) if not match_mscf else None # Search for VAIO Packaging Manager Configuration file
# Check if Microsoft CAB Header XOR 0xFF pattern exists
if match_mscf :
print('\n Detected obfuscated Microsoft CAB image.')
# Determine the Microsoft CAB image Size
cab_size_hex = bytearray(4) # Initialize LE Hex CAB Size as mutable bytearray
cab_size_xor = vaio_data[match_mscf.start() + 0x8:match_mscf.start() + 0xC] # Get LE XOR-ed CAB Size
for idx in range(4) : # Parse each CAB Size byte
cab_size_hex[idx] = cab_size_xor[idx] ^ 0xFF # Perform XOR 0xFF
cab_size = int.from_bytes(cab_size_hex, 'little') # Get BE Actual CAB Size
print('\n Removing Obfuscation...') # May take a while
# Determine the Microsoft CAB image Data
cab_data = bytearray(cab_size) # Initialize CAB Data as mutable bytearray
cab_data_xor = vaio_data[match_mscf.start():match_mscf.start() + cab_size] # Get XOR-ed CAB Data
for idx in range(cab_size) : # Parse each CAB Data byte
cab_data[idx] = cab_data_xor[idx] ^ 0xFF # Perform XOR 0xFF and get Actual CAB Data
print('\n Extracting...')
with open('vaio_temp.cab', 'wb') as cab_file : cab_file.write(cab_data) # Create temporary CAB image
extr_path = os.path.join(file_dir, file_name[:-4], '') # Create CAB image extraction path
try :
decomp = subprocess.run(['7z', 'x', '-aou', '-bso0', '-bse0', '-bsp0', '-o' + extr_path, 'vaio_temp.cab']) # 7-Zip
except :
print('\n Error: Could not decompress Microsoft CAB image!')
print(' Make sure that "7z" executable exists!\n')
os.remove('vaio_temp.cab') # Remove temporary CAB image
print('\n Extracted!')
# Check if VAIO Packaging Manager Configuration file pattern exists
elif match_vaio :
print('\n Error: Failed to Extract, attempting to Unlock instead...')
# Initialize VAIO Package Configuration file variables (assume overkill size of 0x500)
info_start, info_end, val_false, val_true = [match_vaio.start(), match_vaio.start() + 0x500, b'', b'']
# Get VAIO Package Configuration file info, split at new_line and stop at payload DOS header (EOF)
vaio_info = vaio_data[info_start:info_end].split(b'\x0D\x0A\x4D\x5A')[0].replace(b'\x0D',b'').split(b'\x0A')
# Determine VAIO Package Configuration file True & False values
for info in vaio_info :
if info.startswith(b'ExtractPathByUser=') : val_false = bytearray(b'0' if info[18:] in (b'0',b'1') else info[18:]) # Should be 0/No/False
if info.startswith(b'UseVAIOCheck=') : val_true = bytearray(b'1' if info[13:] in (b'0',b'1') else info[13:]) # Should be 1/Yes/True
else :
if val_false == val_true or not val_false or not val_true :
print('\n Error: Could not determine True/False values!')
continue # Next input file
# Find and replace UseVAIOCheck entry from 1/Yes/True to 0/No/False
UseVAIOCheck = check_pattern.search(vaio_data[info_start:])
if UseVAIOCheck : vaio_data[info_start + UseVAIOCheck.end():info_start + UseVAIOCheck.end() + len(val_false)] = val_false
else : print('\n Error: Could not find UseVAIOCheck entry!')
# Find and replace ExtractPathByUser entry from 0/No/False to 1/Yes/True
ExtractPathByUser = path_pattern.search(vaio_data[info_start:])
if ExtractPathByUser : vaio_data[info_start + ExtractPathByUser.end():info_start + ExtractPathByUser.end() + len(val_false)] = val_true
else : print('\n Error: Could not find ExtractPathByUser entry!')
# Store Unlocked VAIO Packaging Manager executable
if UseVAIOCheck and ExtractPathByUser :
with open(os.path.join(file_dir, file_name + '_Unlocked.exe'), 'wb') as unl_file : unl_file.write(vaio_data)
print('\n Unlocked!')
else :
print('\n Error: No VAIO Packaging Manager found!')
continue # Next input file
else :
input('\nDone!')