ReFirmLabs / binwalk

Firmware Analysis Tool
MIT License
10.54k stars 1.51k forks source link

Option --dd for single file signature does not result in any extraction #538

Open stef204 opened 3 years ago

stef204 commented 3 years ago

I have a 1.5G tar archive file with a tree structure of nested directories (each containing files of various types) and am trying to extract only the files with type `database' and extension 'db'. 1) test signature of file type:

% binwalk -B somefilename.db                        

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             SQLite 3.x database,, user version 3
22538         0x580A          Executable script, shebang: "/bin/env bash COMMAND='dd if=$IMAGE of=$DEVICE bs=$BSIZE oflag=sync status=progress' echo "execute: \$ $COMMAND" echo -n "type \"

2) check that binwalk can detect those signatures

 % binwalk -y 'database' data.myarchive.tar 
DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
3414016       0x341800        SQLite 3.x database,, user version 4
3691008       0x385200        SQLite 3.x database,
10327552      0x9D9600        SQLite 3.x database,, user version 1
12805120      0xC36400        SQLite 3.x database,, user version 12
14270008      0xD9BE38        SQLite 3.x database,
14286488      0xD9FE98        SQLite 3.x database,, user version 1
[snip]

Full output here.

3) try to extract files with above signature using option -D:

% binwalk -D 'database:db' data.ext4.win000.tar

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             POSIX tar archive (GNU), owner user name: "c/"

Result = nothing extracted.

What am I doing wrong?

binwalk 2.3.0 on Linux

EDIT: Other commands I have tried.

binwalk -Me -a='\.db$' data.ext4.win000.tar

Result = nothing extracted.

after creating directory `extract-db'

% cd extract-db/
% binwalk -D 'database:db:cp %e' ../data.ext4.win000.tar

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             POSIX tar archive (GNU), owner user name: "c/"

Result = nothing extracted.