Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
binwalk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-gitdep
binwalk
Commits
d67a78da
Commit
d67a78da
authored
Oct 22, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated extractor to support generating unique output file names for extraction rules
parent
7ab9d0fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
8 deletions
+25
-8
extract.conf
src/binwalk/config/extract.conf
+13
-3
extractor.py
src/binwalk/modules/extractor.py
+12
-5
No files found.
src/binwalk/config/extract.conf
View file @
d67a78da
#################################################################################################################
# Default extract
rules
loaded when --extract is specified.
# Default extract
ion rules,
loaded when --extract is specified.
#
# <lower-case unique string from binwalk output text>:<desired file extension>:<command to execute>
#
# Note that %e is a place holder for the extracted file name.
#
# The %% place holder is used when a unique file path is required.
# For example '%%squashfs-root%%' will be replaced with 'squashfs-root-0'
# if 'squashfs-root' already exists.
#################################################################################################################
# Assumes these utilities are installed in $PATH.
...
...
@@ -22,9 +26,15 @@
^
microsoft
cabinet
archive
:
cab
:
cabextract
'%e'
# Try sasquatch first, or if not installed, the standard unsquashfs
^
squashfs
filesystem
:
squashfs
:
sasquatch
'%e'
^
squashfs
filesystem
:
squashfs
:
unsquashfs
'%e'
^
squashfs
filesystem
:
squashfs
:
sasquatch
-
d
'%%squashfs-root%%'
'%e'
^
squashfs
filesystem
:
squashfs
:
unsquashfs
-
d
'%%squashfs-root%%'
'%e'
# Try cramfsck first; if that fails, swap the file system and try again
^
cramfs
filesystem
:
cramfs
:
cramfsck
-
x
'%%cramfs-root%%'
'%e'
^
cramfs
filesystem
:
cramfs
:
cramfsswap
'%e'
'%e.swap'
&&
cramfsck
-
x
'%%cramfs-root%%'
'%e.swap'
# Try mounting the file system (this requires root privileges)
^
squashfs
filesystem
:
mkdir
squashfs
-
root
&&
mount
-
t
squashfs
'%e'
squashfs
-
root
^
cramfs
filesystem
:
cramfs
:
mkdir
cramfs
-
root
&&
mount
-
t
cramfs
'%e'
cramfs
-
root
^
ext2
filesystem
:
ext2
:
mkdir
ext2
-
root
&&
mount
-
t
ext2
'%e'
ext2
-
root
^
romfs
filesystem
:
romfs
:
mkdir
romfs
-
root
&&
mount
-
t
romfs
'%e'
romfs
-
root
...
...
src/binwalk/modules/extractor.py
View file @
d67a78da
...
...
@@ -27,6 +27,10 @@ class Extractor(Module):
# Place holder for the extracted file name in the command
FILE_NAME_PLACEHOLDER
=
'
%
e'
# Unique path delimiter, used for generating unique output file/directory names.
# Useful when, for example, extracting two squashfs images (squashfs-root, squashfs-root-0).
UNIQUE_PATH_DELIMITER
=
'
%%
'
TITLE
=
'Extraction'
ORDER
=
9
PRIMARY
=
False
...
...
@@ -565,6 +569,13 @@ class Extractor(Module):
# Execute.
for
command
in
cmd
.
split
(
"&&"
):
# Generate unique file paths for all paths in the current command that are surrounded by UNIQUE_PATH_DELIMITER
while
self
.
UNIQUE_PATH_DELIMITER
in
command
:
need_unique_path
=
command
.
split
(
self
.
UNIQUE_PATH_DELIMITER
)[
1
]
.
split
(
self
.
UNIQUE_PATH_DELIMITER
)[
0
]
unique_path
=
binwalk
.
core
.
common
.
unique_file_name
(
need_unique_path
)
command
=
command
.
replace
(
self
.
UNIQUE_PATH_DELIMITER
+
need_unique_path
+
self
.
UNIQUE_PATH_DELIMITER
,
unique_path
)
# Replace all instances of FILE_NAME_PLACEHOLDER in the command with fname
command
=
command
.
strip
()
.
replace
(
self
.
FILE_NAME_PLACEHOLDER
,
fname
)
...
...
@@ -581,11 +592,7 @@ class Extractor(Module):
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
# Silently ignore no such file or directory errors. Why? Because these will inevitably be raised when
# making the switch to the new firmware mod kit directory structure. We handle this elsewhere, but it's
# annoying to see this spammed out to the console every time.
if
binwalk
.
core
.
common
.
DEBUG
or
(
not
hasattr
(
e
,
'errno'
)
or
e
.
errno
!=
2
):
binwalk
.
core
.
common
.
warning
(
"Extractor.execute failed to run external extrator '
%
s':
%
s"
%
(
str
(
cmd
),
str
(
e
)))
binwalk
.
core
.
common
.
warning
(
"Extractor.execute failed to run external extrator '
%
s':
%
s"
%
(
str
(
cmd
),
str
(
e
)))
retval
=
None
if
tmp
is
not
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment