A Python script for extracting files from BMW SWFL (Software Flash) binary files based on XML manifest files.
- ✅ Parses XML manifest files with FLASH-SEGMENTS information
- ✅ Extracts individual files from binary containers
- ✅ Supports multiple compression methods (gzip, NRV/UCL)
- ✅ Handles both compressed and uncompressed segments
- ✅ Creates detailed extraction manifest
- ✅ Cross-platform support (Linux, Windows)
python3 extract.py -i <input_bin> -x <input_xml> -o <output_dir>-i, --input: Input binary file (required)-x, --xml: XML manifest file (optional, auto-detected if not provided)-o, --output: Output directory (optional, defaults to<input>_extracted)
# Basic usage with auto-detection
python3 extract.py -i samples/swfl_00009ff7.bin.006_012_003
# Specify all parameters
python3 extract.py -i samples/swfl_00009ff7.bin.006_012_003 -x samples/swfl_00009ff7.xml.006_012_003 -o extracted_files
# Extract to current directory
python3 extract.py -i samples/swfl_00009ff7.bin.006_012_003 -o .The script creates:
- Individual extracted files - Each segment is extracted as a separate file with its original name
- Extraction manifest -
extraction_manifest.jsoncontaining metadata about all extracted files - Detailed logging - Progress information and decompression status
- gzip/gz: Standard gzip compression (using Python's built-in gzip module)
- nrv/ucl: NRV/UCL compression (using unucl tool)
- none: Uncompressed data
- Python 3.6+
unuclexecutable (included inunucl/directory)- Linux:
unucl.linux.x86-64 - Windows:
unucl.exe
- Linux:
SWFLExtractor/
├── extract.py # Main extraction script
├── unucl/ # Decompression tools
│ ├── unucl.linux.x86-64 # Linux executable
│ └── unucl.exe # Windows executable
├── samples/ # Sample files
│ ├── swfl_00009ff7.bin.006_012_003 # Example binary file
│ ├── swfl_00009ff7.xml.006_012_003 # Example XML manifest
│ └── swfl_00009ff7_006_012_003.json # Example manifest JSON
├── test_extraction/ # Example output directory
└── README.md # This file
input: samples/swfl_00009ff7.bin.006_012_003
xml: samples/swfl_00009ff7.xml.006_012_003
output: test_extraction
Using unucl: ./unucl/unucl.linux.x86-64
Found 24 flash segments
Processing segment: MANIFEST (swfl_00009ff7_006_012_003.json)
Source: 0x00000200 - 0x00001EB2 (size: 7347)
Target: 0x00000000 - 0x00001CB2 (size: 7347)
Compression: UNCOMPRESSED (none)
Extracted to: test_extraction/swfl_00009ff7_006_012_003.json
Processing segment: BIN_1 (abl-sa8155.elf.bin)
Source: 0x00002600 - 0x00032DB9 (size: 198586)
Target: 0x0000000A - 0x000307C3 (size: 198586)
Compression: COMPRESSED (gz)
Decompressing...
Decompressed: 221184 bytes
Extracted to: test_extraction/abl-sa8155.elf.bin
...
Extraction complete! 24 files extracted to: test_extraction
If decompression fails for some files, the script will:
- Try alternative decompression methods
- Fall back to using the original compressed data
- Continue processing other files
- Log the failure in the output
If no XML file is specified and auto-detection fails:
- Check that the XML file exists in the same directory as the binary
- Ensure the XML filename follows the pattern:
<binary_name>.xml - Use the
-xparameter to specify the XML file explicitly
If you encounter permission issues:
- Ensure the script has read access to the input files
- Ensure the script has write access to the output directory
- On Linux, you may need to make the unucl executable:
chmod +x unucl/unucl.linux.x86-64