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
27a8a4d6
Commit
27a8a4d6
authored
Dec 13, 2013
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consolidated code into the binwalk.module.Module parent class.
parent
3040e25b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
19 deletions
+52
-19
module.py
src/binwalk/module.py
+33
-7
binvis.py
src/binwalk/modules/binvis.py
+4
-3
configuration.py
src/binwalk/modules/configuration.py
+13
-9
hexdiff.py
src/binwalk/modules/hexdiff.py
+2
-0
No files found.
src/binwalk/module.py
View file @
27a8a4d6
...
...
@@ -86,13 +86,23 @@ class Result(object):
class
Error
(
Result
):
'''
A subclass of binwalk.module.Result.
Accepts all the same kwargs as binwalk.module.Result, but the following are also suggested:
'''
def
__init__
(
self
,
**
kwargs
):
'''
Accepts all the same kwargs as binwalk.module.Result, but the following are also added:
@exception - In case of an exception, this is the exception object.
@exception - In case of an exception, this is the exception object.
__init__ returns None.
'''
pass
Returns None.
'''
self
.
exception
=
None
Result
.
__init__
(
self
,
**
kwargs
)
if
self
.
exception
:
sys
.
stderr
.
write
(
str
(
self
.
exception
)
+
"
\n
"
)
elif
self
.
description
:
sys
.
stderr
.
write
(
self
.
description
+
"
\n
"
)
class
Module
(
object
):
'''
...
...
@@ -215,6 +225,8 @@ class Module(object):
'''
e
=
Error
(
**
kwargs
)
self
.
errors
.
append
(
e
)
if
e
.
exception
:
raise
e
.
exception
def
main
(
self
):
'''
...
...
@@ -222,7 +234,13 @@ class Module(object):
Returns the value returned from self.run.
'''
self
.
init
()
try
:
self
.
init
()
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
self
.
error
(
exception
=
e
)
return
False
self
.
config
.
display
.
format_strings
(
self
.
HEADER_FORMAT
,
self
.
RESULT_FORMAT
)
if
type
(
self
.
HEADER
)
==
type
([]):
...
...
@@ -231,7 +249,15 @@ class Module(object):
self
.
config
.
display
.
header
(
self
.
HEADER
)
self
.
_plugins_pre_scan
()
retval
=
self
.
run
()
try
:
retval
=
self
.
run
()
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
self
.
error
(
exception
=
e
)
return
False
self
.
_plugins_post_scan
()
self
.
config
.
display
.
footer
()
...
...
src/binwalk/modules/binvis.py
View file @
27a8a4d6
...
...
@@ -5,7 +5,7 @@ from binwalk.common import BlockFile
class
Plotter
(
binwalk
.
module
.
Module
):
'''
Base class for
plott
ing binaries in Qt.
Base class for
visualiz
ing binaries in Qt.
Other plotter classes are derived from this.
'''
VIEW_DISTANCE
=
1024
...
...
@@ -41,6 +41,7 @@ class Plotter(binwalk.module.Module):
binwalk
.
module
.
ModuleKwarg
(
name
=
'show_grids'
,
default
=
False
),
]
# There isn't really any useful data to print to console. Disable header and result output.
HEADER
=
None
RESULT
=
None
...
...
@@ -61,7 +62,7 @@ class Plotter(binwalk.module.Module):
self
.
MAX_PLOT_POINTS
=
self
.
MAX_3D_PLOT_POINTS
self
.
_generate_data_point
=
self
.
_generate_3d_data_point
else
:
raise
Exception
(
"Invalid Plotter axis specified:
%
d. Must be one of: [2,
3].
"
%
self
.
axis
)
raise
Exception
(
"Invalid Plotter axis specified:
%
d. Must be one of: [2,
3]
"
%
self
.
axis
)
if
not
self
.
max_points
:
self
.
max_points
=
self
.
MAX_PLOT_POINTS
...
...
@@ -78,7 +79,7 @@ class Plotter(binwalk.module.Module):
Print console messages. For internal use only.
'''
if
self
.
verbose
:
print
(
message
)
print
(
message
)
def
_generate_plot_points
(
self
,
data_points
):
'''
...
...
src/binwalk/modules/configuration.py
View file @
27a8a4d6
...
...
@@ -142,8 +142,10 @@ class Configuration(binwalk.module.Module):
# Make sure we can open the target files
try
:
self
.
target_files
.
append
(
binwalk
.
common
.
BlockFile
(
tfile
,
length
=
self
.
length
,
offset
=
self
.
offset
))
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
s
ys
.
stderr
.
write
(
"Cannot open file :
%
s
\n
"
%
str
(
e
))
s
elf
.
error
(
description
=
"Cannot open file :
%
s
\n
"
%
str
(
e
))
# Unless -O was specified, don't run the scan unless we are able to scan all specified files
if
len
(
self
.
target_files
)
!=
len
(
self
.
files
)
and
not
self
.
skip_unopened
:
...
...
@@ -192,7 +194,7 @@ class Update(object):
self
.
update_zlib
()
self
.
update_compressd
()
def
_do_update_from_
svn
(
self
,
prefix
,
fname
):
def
_do_update_from_
git
(
self
,
prefix
,
fname
):
'''
Updates the specified file to the latest version of that file in SVN.
...
...
@@ -217,8 +219,10 @@ class Update(object):
data
=
urllib2
.
urlopen
(
url
)
.
read
()
open
(
self
.
config
.
paths
[
'system'
][
fname
],
"wb"
)
.
write
(
data
)
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
raise
Exception
(
"Update._do_update_from_
svn
failed to update file '
%
s':
%
s"
%
(
url
,
str
(
e
)))
raise
Exception
(
"Update._do_update_from_
git
failed to update file '
%
s':
%
s"
%
(
url
,
str
(
e
)))
def
update_binwalk
(
self
):
'''
...
...
@@ -226,7 +230,7 @@ class Update(object):
Returns None.
'''
self
.
_do_update_from_
svn
(
self
.
MAGIC_PREFIX
,
self
.
config
.
BINWALK_MAGIC_FILE
)
self
.
_do_update_from_
git
(
self
.
MAGIC_PREFIX
,
self
.
config
.
BINWALK_MAGIC_FILE
)
def
update_bincast
(
self
):
'''
...
...
@@ -234,7 +238,7 @@ class Update(object):
Returns None.
'''
self
.
_do_update_from_
svn
(
self
.
MAGIC_PREFIX
,
self
.
config
.
BINCAST_MAGIC_FILE
)
self
.
_do_update_from_
git
(
self
.
MAGIC_PREFIX
,
self
.
config
.
BINCAST_MAGIC_FILE
)
def
update_binarch
(
self
):
'''
...
...
@@ -242,7 +246,7 @@ class Update(object):
Returns None.
'''
self
.
_do_update_from_
svn
(
self
.
MAGIC_PREFIX
,
self
.
config
.
BINARCH_MAGIC_FILE
)
self
.
_do_update_from_
git
(
self
.
MAGIC_PREFIX
,
self
.
config
.
BINARCH_MAGIC_FILE
)
def
update_zlib
(
self
):
'''
...
...
@@ -250,7 +254,7 @@ class Update(object):
Returns None.
'''
self
.
_do_update_from_
svn
(
self
.
MAGIC_PREFIX
,
self
.
config
.
ZLIB_MAGIC_FILE
)
self
.
_do_update_from_
git
(
self
.
MAGIC_PREFIX
,
self
.
config
.
ZLIB_MAGIC_FILE
)
def
update_compressd
(
self
):
'''
...
...
@@ -258,7 +262,7 @@ class Update(object):
Returns None.
'''
self
.
_do_update_from_
svn
(
self
.
MAGIC_PREFIX
,
self
.
config
.
COMPRESSD_MAGIC_FILE
)
self
.
_do_update_from_
git
(
self
.
MAGIC_PREFIX
,
self
.
config
.
COMPRESSD_MAGIC_FILE
)
def
update_extract
(
self
):
'''
...
...
@@ -266,6 +270,6 @@ class Update(object):
Returns None.
'''
self
.
_do_update_from_
svn
(
self
.
CONFIG_PREFIX
,
self
.
config
.
EXTRACT_FILE
)
self
.
_do_update_from_
git
(
self
.
CONFIG_PREFIX
,
self
.
config
.
EXTRACT_FILE
)
src/binwalk/modules/hexdiff.py
View file @
27a8a4d6
...
...
@@ -216,6 +216,8 @@ class HexDiff(binwalk.module.Module):
for
j
in
range
(
0
,
block
):
try
:
self
.
_build_block
(
"
%.2
X "
%
ord
(
data
[
f
.
name
][
j
+
i
]),
highlight
=
diff_same
[
j
])
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
self
.
_build_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