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
Dec 20, 2013
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extraction working with recursion.
parent
c488f7f1
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():
...
@@ -31,8 +31,10 @@ def main():
if
len
(
sys
.
argv
)
==
1
:
if
len
(
sys
.
argv
)
==
1
:
usage
(
modules
)
usage
(
modules
)
elif
not
modules
.
execute
():
elif
not
modules
.
execute
():
modules
.
execute
(
*
sys
.
argv
[
1
:],
signature
=
True
)
for
module
in
modules
.
execute
(
*
sys
.
argv
[
1
:],
signature
=
True
):
except
binwalk
.
DependencyError
as
e
:
for
result
in
module
.
results
:
print
result
.
description
except
binwalk
.
ModuleException
as
e
:
sys
.
exit
(
1
)
sys
.
exit
(
1
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
src/binwalk/__init__.py
View file @
d89eb06b
from
binwalk.core.module
import
Modules
,
DependencyError
from
binwalk.core.module
import
Modules
,
ModuleException
src/binwalk/core/module.py
View file @
d89eb06b
...
@@ -245,13 +245,19 @@ class Module(object):
...
@@ -245,13 +245,19 @@ class Module(object):
if
r
is
None
:
if
r
is
None
:
r
=
Result
(
**
kwargs
)
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
.
validate
(
r
)
self
.
_plugins_result
(
r
)
for
(
attribute
,
module
)
in
iterator
(
self
.
DEPENDS
):
for
(
attribute
,
module
)
in
iterator
(
self
.
DEPENDS
):
try
:
dependency
=
getattr
(
self
,
attribute
)
dependency
=
getattr
(
self
,
attribute
)
dependency
.
callback
(
r
)
dependency
.
callback
(
r
)
except
AttributeError
:
self
.
_plugins_result
(
r
)
continue
if
r
.
valid
:
if
r
.
valid
:
self
.
results
.
append
(
r
)
self
.
results
.
append
(
r
)
...
@@ -350,7 +356,7 @@ class Status(object):
...
@@ -350,7 +356,7 @@ class Status(object):
for
(
k
,
v
)
in
iterator
(
self
.
kwargs
):
for
(
k
,
v
)
in
iterator
(
self
.
kwargs
):
setattr
(
self
,
k
,
v
)
setattr
(
self
,
k
,
v
)
class
DependencyError
(
Exception
):
class
ModuleException
(
Exception
):
pass
pass
class
Modules
(
object
):
class
Modules
(
object
):
...
@@ -500,7 +506,7 @@ class Modules(object):
...
@@ -500,7 +506,7 @@ class Modules(object):
self
.
run
(
dependency
)
self
.
run
(
dependency
)
if
self
.
loaded_modules
[
dependency
]
.
errors
:
if
self
.
loaded_modules
[
dependency
]
.
errors
:
raise
DependencyError
(
"Failed to load "
+
str
(
dependency
))
raise
ModuleException
(
"Failed to load "
+
str
(
dependency
))
else
:
else
:
kwargs
[
kwarg
]
=
self
.
loaded_modules
[
dependency
]
kwargs
[
kwarg
]
=
self
.
loaded_modules
[
dependency
]
...
...
src/binwalk/modules/configuration.py
View file @
d89eb06b
...
@@ -121,6 +121,19 @@ class Configuration(Module):
...
@@ -121,6 +121,19 @@ class Configuration(Module):
if
len
(
self
.
target_files
)
>
1
and
self
.
verbose
==
0
:
if
len
(
self
.
target_files
)
>
1
and
self
.
verbose
==
0
:
self
.
verbose
=
1
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
):
def
_open_target_files
(
self
):
'''
'''
Checks if the target files can be opened.
Checks if the target files can be opened.
...
@@ -132,8 +145,7 @@ class Configuration(Module):
...
@@ -132,8 +145,7 @@ class Configuration(Module):
if
not
os
.
path
.
isdir
(
tfile
):
if
not
os
.
path
.
isdir
(
tfile
):
# Make sure we can open the target files
# Make sure we can open the target files
try
:
try
:
fp
=
binwalk
.
core
.
common
.
BlockFile
(
tfile
,
length
=
self
.
length
,
offset
=
self
.
offset
,
swap
=
self
.
swap_size
)
self
.
target_files
.
append
(
self
.
open_file
(
tfile
))
self
.
target_files
.
append
(
fp
)
except
KeyboardInterrupt
as
e
:
except
KeyboardInterrupt
as
e
:
raise
e
raise
e
except
Exception
as
e
:
except
Exception
as
e
:
...
...
src/binwalk/modules/signature.py
View file @
d89eb06b
...
@@ -146,7 +146,10 @@ class Signature(Module):
...
@@ -146,7 +146,10 @@ class Signature(Module):
current_block_offset
=
r
.
jump
current_block_offset
=
r
.
jump
def
run
(
self
):
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
.
header
()
self
.
status
.
clear
()
self
.
status
.
clear
()
...
@@ -157,3 +160,6 @@ class Signature(Module):
...
@@ -157,3 +160,6 @@ class Signature(Module):
self
.
footer
()
self
.
footer
()
target_files
=
[
self
.
config
.
open_file
(
f
)
for
f
in
self
.
extractor
.
pending
]
self
.
extractor
.
pending
=
[]
src/binwalk/plugins/lzmamod.py
View file @
d89eb06b
...
@@ -31,7 +31,8 @@ class Plugin:
...
@@ -31,7 +31,8 @@ class Plugin:
if
not
self
.
module
.
extractor
.
execute
(
self
.
original_cmd
,
fname
):
if
not
self
.
module
.
extractor
.
execute
(
self
.
original_cmd
,
fname
):
out_name
=
os
.
path
.
splitext
(
fname
)[
0
]
+
'-patched'
+
os
.
path
.
splitext
(
fname
)[
1
]
out_name
=
os
.
path
.
splitext
(
fname
)[
0
]
+
'-patched'
+
os
.
path
.
splitext
(
fname
)[
1
]
fp_out
=
BlockFile
(
out_name
,
'w'
)
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
fp_in
.
MAX_TRAILING_SIZE
=
0
i
=
0
i
=
0
...
...
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