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
f4f0472d
Commit
f4f0472d
authored
Nov 22, 2013
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added --carve option; made delayed extraction the default.
parent
d5eb11e0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
13 deletions
+32
-13
binwalk
src/bin/binwalk
+21
-8
__init__.py
src/binwalk/__init__.py
+3
-2
extractor.py
src/binwalk/extractor.py
+8
-3
No files found.
src/bin/binwalk
View file @
f4f0472d
...
...
@@ -111,7 +111,8 @@ def usage(fd):
fd
.
write
(
"
\t
-e, --extract=[file] Automatically extract known file types; load rules from file, if specified
\n
"
)
fd
.
write
(
"
\t
-M, --matryoshka=[n] Recursively scan extracted files, up to n levels deep (8 levels of recursion is the default)
\n
"
)
fd
.
write
(
"
\t
-r, --rm Cleanup extracted files and zero-size files
\n
"
)
fd
.
write
(
"
\t
-d, --delay Delay file extraction for files with known footers
\n
"
)
fd
.
write
(
"
\t
-j, --ignore-footers Ignore file footers and extract up to EOF
\n
"
)
fd
.
write
(
"
\t
-z, --carve Carve data from files, but don't execute extraction utilities
\n
"
)
fd
.
write
(
"
\n
"
)
fd
.
write
(
"Plugin Options:
\n
"
)
...
...
@@ -165,11 +166,12 @@ def main():
show_legend
=
True
entropy_scan
=
False
enable_plugins
=
True
exec_commands
=
True
show_invalid
=
False
entropy_algorithm
=
None
format_to_terminal
=
False
custom_signature
=
None
delay_extraction
=
Fals
e
delay_extraction
=
Tru
e
ignore_time_skew
=
True
extract_rules_file
=
None
ignore_failed_open
=
False
...
...
@@ -194,7 +196,7 @@ def main():
config
=
binwalk
.
Config
()
short_options
=
"AaBbCcdEeGHhIiJ
kLMNnOPpQqrSTtUuvWw
?D:F:f:g:K:o:l:m:R:s:X:x:Y:y:"
short_options
=
"AaBbCcdEeGHhIiJ
jkLMNnOPpQqrSTtUuvWwz
?D:F:f:g:K:o:l:m:R:s:X:x:Y:y:"
long_options
=
[
"rm"
,
"help"
,
...
...
@@ -212,8 +214,10 @@ def main():
"keep-going"
,
"show-invalid"
,
"ignore-time-skew"
,
"ignore-footers"
,
"carve"
,
"profile"
,
"delay"
,
"delay"
,
# delay is depreciated, but kept for backwards compatability
"skip-unopened"
,
"term"
,
"tim"
,
...
...
@@ -266,6 +270,8 @@ def main():
examples
()
elif
opt
in
(
"-d"
,
"--delay"
):
delay_extraction
=
True
elif
opt
in
(
"-j"
,
"--ignore-footers"
):
delay_extraction
=
False
elif
opt
in
(
"-f"
,
"--file"
):
log_file
=
arg
elif
opt
in
(
"-c"
,
"--csv"
):
...
...
@@ -336,6 +342,8 @@ def main():
plugin_whitelist
.
append
(
arg
)
elif
opt
in
(
"-T"
,
"--ignore-time-skew"
):
ignore_time_skew
=
False
elif
opt
in
(
"-z"
,
"--carve"
):
exec_commands
=
False
elif
opt
in
(
"-H"
,
"--heuristic"
,
"--math"
):
do_comp
=
True
...
...
@@ -453,7 +461,15 @@ def main():
usage
(
sys
.
stderr
)
# Instantiate the Binwalk class
bwalk
=
binwalk
.
Binwalk
(
magic_files
=
magic_files
,
flags
=
magic_flags
,
verbose
=
verbose
,
log
=
log_file
,
quiet
=
quiet
,
ignore_smart_keywords
=
ignore_signature_keywords
,
load_plugins
=
enable_plugins
,
ignore_time_skews
=
ignore_time_skew
)
bwalk
=
binwalk
.
Binwalk
(
magic_files
=
magic_files
,
flags
=
magic_flags
,
verbose
=
verbose
,
log
=
log_file
,
quiet
=
quiet
,
ignore_smart_keywords
=
ignore_signature_keywords
,
load_plugins
=
enable_plugins
,
ignore_time_skews
=
ignore_time_skew
,
exec_commands
=
exec_commands
)
# If a custom signature was specified, create a temporary magic file containing the custom signature
# and ensure that it is the only magic file that will be loaded when Binwalk.scan() is called.
...
...
@@ -482,9 +498,6 @@ def main():
# Enable delayed extraction, which will prevent supported file types from having trailing data when extracted
bwalk
.
extractor
.
enable_delayed_extract
(
delay_extraction
)
# Load the magic file(s)
#bwalk.load_signatures(magic_files=magic_files)
# If --term was specified, enable output formatting to terminal
if
format_to_terminal
:
bwalk
.
display
.
enable_formatting
(
True
)
...
...
src/binwalk/__init__.py
View file @
f4f0472d
...
...
@@ -68,7 +68,7 @@ class Binwalk(object):
CUSTOM
=
0x40
ENTROPY
=
0x80
def
__init__
(
self
,
magic_files
=
[],
flags
=
magic
.
MAGIC_NONE
,
log
=
None
,
quiet
=
False
,
verbose
=
0
,
ignore_smart_keywords
=
False
,
ignore_time_skews
=
False
,
load_extractor
=
False
,
load_plugins
=
True
):
def
__init__
(
self
,
magic_files
=
[],
flags
=
magic
.
MAGIC_NONE
,
log
=
None
,
quiet
=
False
,
verbose
=
0
,
ignore_smart_keywords
=
False
,
ignore_time_skews
=
False
,
load_extractor
=
False
,
load_plugins
=
True
,
exec_commands
=
True
):
'''
Class constructor.
...
...
@@ -81,6 +81,7 @@ class Binwalk(object):
@ignore_time_skews - Set to True to ignore file results with timestamps in the future.
@load_extractor - Set to True to load the default extraction rules automatically.
@load_plugins - Set to False to disable plugin support.
@exec_commands - Set to False to disable the execution of external utilities when extracting data from files.
Returns None.
'''
...
...
@@ -134,7 +135,7 @@ class Binwalk(object):
# o Specify file extraction rules to be applied during a scan
#
self
.
filter
=
MagicFilter
()
self
.
extractor
=
Extractor
(
verbose
=
extractor_verbose
)
self
.
extractor
=
Extractor
(
verbose
=
extractor_verbose
,
exec_commands
=
exec_commands
)
if
load_extractor
:
self
.
extractor
.
load_defaults
()
...
...
src/binwalk/extractor.py
View file @
f4f0472d
...
...
@@ -45,18 +45,20 @@ class Extractor:
# Max size of data to read/write at one time when extracting data
MAX_READ_SIZE
=
10
*
1024
*
1024
def
__init__
(
self
,
verbose
=
False
):
def
__init__
(
self
,
verbose
=
False
,
exec_commands
=
True
):
'''
Class constructor.
@verbose - Set to True to display the output from any executed external applications.
@verbose - Set to True to display the output from any executed external applications.
@exec_commands - Set to False to disable the execution of external utilities when extracting data from files.
Returns None.
'''
self
.
config
=
Config
()
self
.
enabled
=
False
self
.
delayed
=
Fals
e
self
.
delayed
=
Tru
e
self
.
verbose
=
verbose
self
.
exec_commands
=
exec_commands
self
.
extract_rules
=
[]
self
.
remove_after_execute
=
False
self
.
extract_path
=
os
.
getcwd
()
...
...
@@ -465,6 +467,9 @@ class Extractor:
tmp
=
None
retval
=
True
if
not
self
.
exec_commands
:
return
retval
try
:
if
callable
(
cmd
):
try
:
...
...
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