ReFirmLabs / binwalk

Firmware Analysis Tool
MIT License
10.38k stars 1.49k forks source link

Regression. Extraction of ubifs image fails with latest version #593

Open frakman1 opened 2 years ago

frakman1 commented 2 years ago

I can no longer extract ubifs images on the version built from this repo:

Build steps: git clone https://github.com/ReFirmLabs/binwalk.git sudo python setup.py install

Previously, it worked on the version installed via apt-get install on Ubuntu 18:

as well as versions in the recent past. I'm not sure when exactly it failed and on what version but sometime in the last few months.

Extraction was performed on the exact same file.

Working (v2.1.1) log:

$ binwalk -v --signature -e ubifs-256k-4096-3390b0-RG.img --directory=binwalk_ubifs

Scan Time:     2022-02-02 11:27:23
Target File:   /home/frak/Downloads/binwalk/cga4336/ubifs-256k-4096-3390b0-RG.img
MD5 Checksum:  1cbb5bcc30ae643a55a521e7243ba3eb
Signatures:    344

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             UBI erase count header, version: 1, EC: 0x0, VID header offset: 0x1000, data offset: 0x2000

$ tree -L 5 binwalk_ubifs/
binwalk_ubifs/
├── _ubifs-256k-4096-3390b0-RG.img-0.extracted
│   ├── 0.ubi
│   └── ubifs-root
│       └── 1302997359
│           └── rootfs
│               ├── bin
│               ├── boot
<cut>

└── _ubifs-256k-4096-3390b0-RG.img.extracted
    ├── 0.ubi
    └── ubifs-root
        └── 1302997359
            └── rootfs
                ├── bin
                ├── boot
<cut>

54 directories, 8 files

Failing (latest version) log:

$ binwalk -v --signature -e ubifs-256k-4096-3390b0-RG.img --directory=binwalk

Scan Time:     2022-02-02 16:26:16
Target File:   /host_dir/cga4336vfs/ubifs-256k-4096-3390b0-RG.img
MD5 Checksum:  1cbb5bcc30ae643a55a521e7243ba3eb
Signatures:    411

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------

WARNING: Extractor.execute failed to run external extractor 'ubireader_extract_files -o 'ubifs-root' '%e'': 'module' object has no attribute 'DEVNULL', 'ubireader_extract_files -o 'ubifs-root' '%e'' might not be installed correctly
0             0x0             UBI erase count header, version: 1, EC: 0x0, VID header offset: 0x1000, data offset: 0x2000

$ tree binwalk
binwalk
|-- _ubifs-256k-4096-3390b0-RG.img-0.extracted
|   `-- 0.ubi
`-- _ubifs-256k-4096-3390b0-RG.img.extracted
    `-- 0.ubi
frakman1 commented 2 years ago

Update:

When I did a git checkout v2.3.0 and re-installed via sudo python setup.py install, I was able to get it to work. Strangely, the version returned in the help page shows the version as:

$ binwalk --help

Binwalk v2.2.1+80a519b

but the commit ID checks out.

Then I tried git checkout v2.3.2, reinstalled and that works too.

$ binwalk --help

Binwalk v2.3.2+499019

So it failed somewhere between v2.3.2 and v2.3.3:

image

mzpqnxow commented 5 months ago

See #596