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
ec1917f2
Commit
ec1917f2
authored
Nov 30, 2015
by
Craig Heffner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added --count option
parent
f004d4dd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
8 deletions
+26
-8
common.py
src/binwalk/core/common.py
+1
-0
module.py
src/binwalk/core/module.py
+6
-6
extractor.py
src/binwalk/modules/extractor.py
+12
-1
general.py
src/binwalk/modules/general.py
+7
-1
No files found.
src/binwalk/core/common.py
View file @
ec1917f2
...
...
@@ -483,3 +483,4 @@ def BlockFile(fname, mode='r', subclass=io.FileIO, **kwargs):
return
(
data
,
dlen
)
return
InternalBlockFile
(
fname
,
mode
=
mode
,
**
kwargs
)
src/binwalk/core/module.py
View file @
ec1917f2
...
...
@@ -449,6 +449,12 @@ class Module(object):
self
.
validate
(
r
)
self
.
_plugins_result
(
r
)
# Update the progress status automatically if it is not being done manually by the module
if
r
.
offset
and
r
.
file
and
self
.
AUTO_UPDATE_STATUS
:
self
.
status
.
total
=
r
.
file
.
length
self
.
status
.
completed
=
r
.
offset
self
.
status
.
fp
=
r
.
file
for
dependency
in
self
.
dependencies
:
try
:
getattr
(
self
,
dependency
.
attribute
)
.
callback
(
r
)
...
...
@@ -458,12 +464,6 @@ class Module(object):
if
r
.
valid
:
self
.
results
.
append
(
r
)
# Update the progress status automatically if it is not being done manually by the module
if
r
.
offset
and
r
.
file
and
self
.
AUTO_UPDATE_STATUS
:
self
.
status
.
total
=
r
.
file
.
length
self
.
status
.
completed
=
r
.
offset
self
.
status
.
fp
=
r
.
file
if
r
.
display
:
display_args
=
self
.
_build_display_args
(
r
)
if
display_args
:
...
...
src/binwalk/modules/extractor.py
View file @
ec1917f2
...
...
@@ -72,6 +72,11 @@ class Extractor(Module):
type
=
int
,
kwargs
=
{
'max_size'
:
0
},
description
=
'Limit the size of each extracted file'
),
Option
(
short
=
'n'
,
long
=
'count'
,
type
=
int
,
kwargs
=
{
'max_count'
:
0
},
description
=
'Limit the number of extracted files'
),
Option
(
short
=
'r'
,
long
=
'rm'
,
kwargs
=
{
'remove_after_execute'
:
True
},
...
...
@@ -84,6 +89,7 @@ class Extractor(Module):
KWARGS
=
[
Kwarg
(
name
=
'max_size'
,
default
=
None
),
Kwarg
(
name
=
'max_count'
,
default
=
None
),
Kwarg
(
name
=
'base_directory'
,
default
=
None
),
Kwarg
(
name
=
'remove_after_execute'
,
default
=
False
),
Kwarg
(
name
=
'load_default_rules'
,
default
=
False
),
...
...
@@ -100,6 +106,8 @@ class Extractor(Module):
self
.
directory
=
None
# Key value pairs of input file path and output extraction path
self
.
output
=
{}
# Number of extracted files
self
.
extraction_count
=
0
if
self
.
load_default_rules
:
self
.
load_defaults
()
...
...
@@ -154,7 +162,7 @@ class Extractor(Module):
# Only extract valid results that have been marked for extraction and displayed to the user.
# Note that r.display is still True even if --quiet has been specified; it is False if the result has been
# explicitly excluded via the -y/-x options.
if
r
.
valid
and
r
.
extract
and
r
.
display
:
if
r
.
valid
and
r
.
extract
and
r
.
display
and
(
not
self
.
max_count
or
self
.
extraction_count
<
self
.
max_count
)
:
# Create some extract output for this file, it it doesn't already exist
if
not
binwalk
.
core
.
common
.
has_key
(
self
.
output
,
r
.
file
.
path
):
self
.
output
[
r
.
file
.
path
]
=
ExtractInfo
()
...
...
@@ -165,6 +173,9 @@ class Extractor(Module):
# If the extraction was successful, self.extract will have returned the output directory and name of the dd'd file
if
extraction_directory
and
dd_file
:
# Track the number of extracted files
self
.
extraction_count
+=
1
# Get the full path to the dd'd file and save it in the output info for this file
dd_file_path
=
os
.
path
.
join
(
extraction_directory
,
dd_file
)
self
.
output
[
r
.
file
.
path
]
.
carved
[
r
.
offset
]
=
dd_file_path
...
...
src/binwalk/modules/general.py
View file @
ec1917f2
...
...
@@ -191,7 +191,13 @@ class General(Module):
if
swap
is
None
:
swap
=
self
.
swap_size
return
binwalk
.
core
.
common
.
BlockFile
(
fname
,
subclass
=
self
.
subclass
,
length
=
length
,
offset
=
offset
,
swap
=
swap
,
block
=
block
,
peek
=
peek
)
return
binwalk
.
core
.
common
.
BlockFile
(
fname
,
subclass
=
self
.
subclass
,
length
=
length
,
offset
=
offset
,
swap
=
swap
,
block
=
block
,
peek
=
peek
)
def
_open_target_files
(
self
):
'''
...
...
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