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
cfedd0ff
Commit
cfedd0ff
authored
Dec 19, 2013
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial port of extract.py to a module. Currently extraction is broken.
parent
5ab25d16
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
17 deletions
+38
-17
module.py
src/binwalk/module.py
+31
-13
__init__.py
src/binwalk/modules/__init__.py
+1
-0
configuration.py
src/binwalk/modules/configuration.py
+3
-1
hexdiff.py
src/binwalk/modules/hexdiff.py
+3
-3
No files found.
src/binwalk/module.py
View file @
cfedd0ff
...
@@ -8,10 +8,6 @@ import binwalk.config
...
@@ -8,10 +8,6 @@ import binwalk.config
import
binwalk.plugin
import
binwalk.plugin
from
binwalk.compat
import
*
from
binwalk.compat
import
*
class
Type
(
object
):
Primary
=
1
Support
=
2
class
ModuleOption
(
object
):
class
ModuleOption
(
object
):
'''
'''
A container class that allows modules to declare command line options.
A container class that allows modules to declare command line options.
...
@@ -118,9 +114,6 @@ class Module(object):
...
@@ -118,9 +114,6 @@ class Module(object):
# The module title, as displayed in help output
# The module title, as displayed in help output
TITLE
=
""
TITLE
=
""
# Default type is primary
TYPE
=
Types
.
Primary
# A list of binwalk.module.ModuleOption command line options
# A list of binwalk.module.ModuleOption command line options
CLI
=
[]
CLI
=
[]
...
@@ -128,7 +121,7 @@ class Module(object):
...
@@ -128,7 +121,7 @@ class Module(object):
KWARGS
=
[]
KWARGS
=
[]
# A dictionary of module dependencies; all modules depend on binwalk.modules.configuration.Configuration
# A dictionary of module dependencies; all modules depend on binwalk.modules.configuration.Configuration
DEPENDS
=
{
'config'
:
'Configuration'
}
DEPENDS
=
{
'config'
:
'Configuration'
,
'extractor'
:
'Extractor'
}
# Format string for printing the header during a scan
# Format string for printing the header during a scan
HEADER_FORMAT
=
"
%
s
\n
"
HEADER_FORMAT
=
"
%
s
\n
"
...
@@ -194,6 +187,16 @@ class Module(object):
...
@@ -194,6 +187,16 @@ class Module(object):
'''
'''
return
False
return
False
def
process_result
(
self
,
r
):
'''
Processes the result. Passed to all dependency modules when a valid result is found.
@r - The result, an instance of binwalk.module.Result.
Returns None.
'''
return
None
def
validate
(
self
,
r
):
def
validate
(
self
,
r
):
'''
'''
Validates the result.
Validates the result.
...
@@ -245,6 +248,10 @@ class Module(object):
...
@@ -245,6 +248,10 @@ class Module(object):
self
.
_plugins_result
(
r
)
self
.
_plugins_result
(
r
)
if
r
.
valid
:
if
r
.
valid
:
for
(
attribute
,
module
)
in
iterator
(
self
.
DEPENDS
):
dependency
=
getattr
(
self
,
attribute
)
dependency
.
process_result
(
r
)
self
.
results
.
append
(
r
)
self
.
results
.
append
(
r
)
# Update the progress status automatically if it is not being done manually by the module
# Update the progress status automatically if it is not being done manually by the module
...
@@ -421,13 +428,22 @@ class Modules(object):
...
@@ -421,13 +428,22 @@ class Modules(object):
def
execute
(
self
,
*
args
,
**
kwargs
):
def
execute
(
self
,
*
args
,
**
kwargs
):
run_modules
=
[]
run_modules
=
[]
self
.
_set_arguments
(
list
(
args
),
kwargs
)
orig_arguments
=
self
.
arguments
if
args
or
kwargs
:
self
.
_set_arguments
(
list
(
args
),
kwargs
)
# Run all modules
for
module
in
self
.
list
():
for
module
in
self
.
list
():
if
module
.
TYPE
==
Type
.
Primary
:
obj
=
self
.
run
(
module
)
obj
=
self
.
run
(
module
)
if
obj
.
enabled
:
# Add all loaded modules that marked themselves as enabled to the run_modules list
run_modules
.
append
(
obj
)
for
(
module
,
obj
)
in
iterator
(
self
.
loaded_modules
):
if
obj
.
enabled
:
run_modules
.
append
(
obj
)
self
.
arguments
=
orig_arguments
return
run_modules
return
run_modules
def
run
(
self
,
module
):
def
run
(
self
,
module
):
...
@@ -446,12 +462,14 @@ class Modules(object):
...
@@ -446,12 +462,14 @@ class Modules(object):
def
load
(
self
,
module
):
def
load
(
self
,
module
):
kwargs
=
self
.
argv
(
module
,
argv
=
self
.
arguments
)
kwargs
=
self
.
argv
(
module
,
argv
=
self
.
arguments
)
kwargs
.
update
(
self
.
dependencies
(
module
))
kwargs
.
update
(
self
.
dependencies
(
module
))
print
"Loading"
,
module
return
module
(
**
kwargs
)
return
module
(
**
kwargs
)
def
dependencies
(
self
,
module
):
def
dependencies
(
self
,
module
):
import
binwalk.modules
import
binwalk.modules
kwargs
=
{}
kwargs
=
{}
print
"Loading dependency:"
,
module
if
hasattr
(
module
,
"DEPENDS"
):
if
hasattr
(
module
,
"DEPENDS"
):
for
(
kwarg
,
dependency
)
in
iterator
(
module
.
DEPENDS
):
for
(
kwarg
,
dependency
)
in
iterator
(
module
.
DEPENDS
):
...
...
src/binwalk/modules/__init__.py
View file @
cfedd0ff
...
@@ -3,3 +3,4 @@ from binvis import Plotter
...
@@ -3,3 +3,4 @@ from binvis import Plotter
from
hexdiff
import
HexDiff
from
hexdiff
import
HexDiff
from
hashmatch
import
HashMatch
from
hashmatch
import
HashMatch
from
configuration
import
Configuration
from
configuration
import
Configuration
from
extractor
import
Extractor
src/binwalk/modules/configuration.py
View file @
cfedd0ff
...
@@ -11,7 +11,9 @@ from binwalk.compat import *
...
@@ -11,7 +11,9 @@ from binwalk.compat import *
class
Configuration
(
binwalk
.
module
.
Module
):
class
Configuration
(
binwalk
.
module
.
Module
):
TITLE
=
"General"
TITLE
=
"General"
DEPENDS
=
{}
CLI
=
[
CLI
=
[
binwalk
.
module
.
ModuleOption
(
long
=
'length'
,
binwalk
.
module
.
ModuleOption
(
long
=
'length'
,
short
=
'l'
,
short
=
'l'
,
...
...
src/binwalk/modules/hexdiff.py
View file @
cfedd0ff
...
@@ -106,7 +106,7 @@ class HexDiff(binwalk.module.Module):
...
@@ -106,7 +106,7 @@ class HexDiff(binwalk.module.Module):
self
.
block_hex
+=
c
self
.
block_hex
+=
c
def
_build_header
(
self
,
files
,
block_size
):
def
_build_header
(
self
,
files
,
block_size
):
header
=
"OFFSET"
+
(
" "
*
4
)
+
files
[
0
]
.
name
header
=
"OFFSET"
+
(
" "
*
6
)
+
files
[
0
]
.
name
for
i
in
range
(
1
,
len
(
files
)):
for
i
in
range
(
1
,
len
(
files
)):
header
+=
" "
*
((
block_size
*
3
)
+
2
+
block_size
+
8
-
len
(
files
[
i
-
1
]
.
name
))
header
+=
" "
*
((
block_size
*
3
)
+
2
+
block_size
+
8
-
len
(
files
[
i
-
1
]
.
name
))
...
@@ -178,9 +178,9 @@ class HexDiff(binwalk.module.Module):
...
@@ -178,9 +178,9 @@ class HexDiff(binwalk.module.Module):
while
i
<
read_block_size
and
(
total
+
i
)
<
size
:
while
i
<
read_block_size
and
(
total
+
i
)
<
size
:
diff_same
=
{}
diff_same
=
{}
alt_text
=
"*"
+
" "
*
6
alt_text
=
"*"
+
" "
*
8
self
.
_build_block
(
"
%.08
X "
%
(
total
+
i
+
offset
))
self
.
_build_block
(
"
%.08
X
"
%
(
total
+
i
+
offset
))
# For each byte in this block, is the byte the same in all files, the same in some files, or different in all files?
# For each byte in this block, is the byte the same in all files, the same in some files, or different in all files?
for
j
in
range
(
0
,
block
):
for
j
in
range
(
0
,
block
):
...
...
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