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
d89eb06b
Commit
d89eb06b
authored
11 years ago
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extraction working with recursion.
parent
c488f7f1
fix-entropy-graph-legend
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
11 deletions
+38
-11
binwalk
src/bin/binwalk
+4
-2
__init__.py
src/binwalk/__init__.py
+1
-1
module.py
src/binwalk/core/module.py
+10
-4
configuration.py
src/binwalk/modules/configuration.py
+14
-2
signature.py
src/binwalk/modules/signature.py
+7
-1
lzmamod.py
src/binwalk/plugins/lzmamod.py
+2
-1
No files found.
src/bin/binwalk
View file @
d89eb06b
...
...
@@ -31,8 +31,10 @@ def main():
if
len
(
sys
.
argv
)
==
1
:
usage
(
modules
)
elif
not
modules
.
execute
():
modules
.
execute
(
*
sys
.
argv
[
1
:],
signature
=
True
)
except
binwalk
.
DependencyError
as
e
:
for
module
in
modules
.
execute
(
*
sys
.
argv
[
1
:],
signature
=
True
):
for
result
in
module
.
results
:
print
result
.
description
except
binwalk
.
ModuleException
as
e
:
sys
.
exit
(
1
)
if
__name__
==
'__main__'
:
...
...
This diff is collapsed.
Click to expand it.
src/binwalk/__init__.py
View file @
d89eb06b
from
binwalk.core.module
import
Modules
,
DependencyError
from
binwalk.core.module
import
Modules
,
ModuleException
This diff is collapsed.
Click to expand it.
src/binwalk/core/module.py
View file @
d89eb06b
...
...
@@ -245,13 +245,19 @@ class Module(object):
if
r
is
None
:
r
=
Result
(
**
kwargs
)
# Any module that is reporting results, valid or not, should be marked as enabled
if
not
self
.
enabled
:
self
.
enabled
=
True
self
.
validate
(
r
)
self
.
_plugins_result
(
r
)
for
(
attribute
,
module
)
in
iterator
(
self
.
DEPENDS
):
try
:
dependency
=
getattr
(
self
,
attribute
)
dependency
.
callback
(
r
)
self
.
_plugins_result
(
r
)
except
AttributeError
:
continue
if
r
.
valid
:
self
.
results
.
append
(
r
)
...
...
@@ -350,7 +356,7 @@ class Status(object):
for
(
k
,
v
)
in
iterator
(
self
.
kwargs
):
setattr
(
self
,
k
,
v
)
class
DependencyError
(
Exception
):
class
ModuleException
(
Exception
):
pass
class
Modules
(
object
):
...
...
@@ -500,7 +506,7 @@ class Modules(object):
self
.
run
(
dependency
)
if
self
.
loaded_modules
[
dependency
]
.
errors
:
raise
DependencyError
(
"Failed to load "
+
str
(
dependency
))
raise
ModuleException
(
"Failed to load "
+
str
(
dependency
))
else
:
kwargs
[
kwarg
]
=
self
.
loaded_modules
[
dependency
]
...
...
This diff is collapsed.
Click to expand it.
src/binwalk/modules/configuration.py
View file @
d89eb06b
...
...
@@ -121,6 +121,19 @@ class Configuration(Module):
if
len
(
self
.
target_files
)
>
1
and
self
.
verbose
==
0
:
self
.
verbose
=
1
def
open_file
(
self
,
fname
,
length
=
None
,
offset
=
None
,
swap
=
None
):
'''
Opens the specified file with all pertinent configuration settings.
'''
if
length
is
None
:
length
=
self
.
length
if
offset
is
None
:
offset
=
self
.
offset
if
swap
is
None
:
swap
=
self
.
swap_size
return
binwalk
.
core
.
common
.
BlockFile
(
fname
,
length
=
length
,
offset
=
offset
,
swap
=
swap
)
def
_open_target_files
(
self
):
'''
Checks if the target files can be opened.
...
...
@@ -132,8 +145,7 @@ class Configuration(Module):
if
not
os
.
path
.
isdir
(
tfile
):
# Make sure we can open the target files
try
:
fp
=
binwalk
.
core
.
common
.
BlockFile
(
tfile
,
length
=
self
.
length
,
offset
=
self
.
offset
,
swap
=
self
.
swap_size
)
self
.
target_files
.
append
(
fp
)
self
.
target_files
.
append
(
self
.
open_file
(
tfile
))
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
...
...
This diff is collapsed.
Click to expand it.
src/binwalk/modules/signature.py
View file @
d89eb06b
...
...
@@ -146,7 +146,10 @@ class Signature(Module):
current_block_offset
=
r
.
jump
def
run
(
self
):
for
fp
in
self
.
config
.
target_files
:
target_files
=
self
.
config
.
target_files
while
target_files
:
for
fp
in
target_files
:
self
.
header
()
self
.
status
.
clear
()
...
...
@@ -157,3 +160,6 @@ class Signature(Module):
self
.
footer
()
target_files
=
[
self
.
config
.
open_file
(
f
)
for
f
in
self
.
extractor
.
pending
]
self
.
extractor
.
pending
=
[]
This diff is collapsed.
Click to expand it.
src/binwalk/plugins/lzmamod.py
View file @
d89eb06b
...
...
@@ -31,7 +31,8 @@ class Plugin:
if
not
self
.
module
.
extractor
.
execute
(
self
.
original_cmd
,
fname
):
out_name
=
os
.
path
.
splitext
(
fname
)[
0
]
+
'-patched'
+
os
.
path
.
splitext
(
fname
)[
1
]
fp_out
=
BlockFile
(
out_name
,
'w'
)
fp_in
=
BlockFile
(
fname
,
swap
=
self
.
module
.
config
.
swap_size
)
# Use self.module.config.open_file here to ensure that other config settings (such as byte-swapping) are honored
fp_in
=
self
.
module
.
config
.
open_file
(
fname
,
offset
=
0
,
length
=
0
)
fp_in
.
MAX_TRAILING_SIZE
=
0
i
=
0
...
...
This diff is collapsed.
Click to expand it.
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