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
54bfff03
Commit
54bfff03
authored
Dec 13, 2013
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial move of hexdiff.py/plotter.py to modules.
parent
ae122ee8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
17 deletions
+19
-17
common.py
src/binwalk/common.py
+4
-1
binvis.py
src/binwalk/modules/binvis.py
+8
-9
configuration.py
src/binwalk/modules/configuration.py
+7
-7
No files found.
src/binwalk/common.py
View file @
54bfff03
...
...
@@ -212,7 +212,7 @@ class BlockFile(io.FileIO):
# limit disk I/O, but small enough to limit the size of processed data blocks.
READ_BLOCK_SIZE
=
1
*
1024
*
1024
def
__init__
(
self
,
fname
,
mode
=
'r'
,
length
=
0
,
offset
=
0
):
def
__init__
(
self
,
fname
,
mode
=
'r'
,
length
=
0
,
offset
=
0
,
block
=
READ_BLOCK_SIZE
):
'''
Class constructor.
...
...
@@ -255,6 +255,9 @@ class BlockFile(io.FileIO):
elif
self
.
length
>
self
.
size
:
self
.
length
=
self
.
size
if
block
>
0
:
self
.
READ_BLOCK_SIZE
=
block
io
.
FileIO
.
__init__
(
self
,
fname
,
mode
)
# Work around for python 2.6 where FileIO._name is not defined
...
...
src/binwalk/modules/binvis.py
View file @
54bfff03
...
...
@@ -57,7 +57,6 @@ class Plotter(object):
binwalk
.
module
.
process_kwargs
(
self
,
kwargs
)
self
.
verbose
=
self
.
config
.
verbose
self
.
files
=
self
.
config
.
target_files
self
.
offset
=
self
.
config
.
offset
self
.
length
=
self
.
config
.
length
self
.
plane_count
=
-
1
...
...
@@ -79,8 +78,8 @@ class Plotter(object):
self
.
window
=
gl
.
GLViewWidget
()
self
.
window
.
opts
[
'distance'
]
=
self
.
VIEW_DISTANCE
if
len
(
self
.
files
)
==
1
:
self
.
window
.
setWindowTitle
(
self
.
files
[
0
]
)
if
len
(
self
.
target_
files
)
==
1
:
self
.
window
.
setWindowTitle
(
self
.
target_files
[
0
]
.
name
)
def
_print
(
self
,
message
):
'''
...
...
@@ -159,20 +158,20 @@ class Plotter(object):
'''
return
(
0
,
0
,
0
)
def
_generate_data_points
(
self
,
f
ile_name
):
def
_generate_data_points
(
self
,
f
p
):
'''
Generates a dictionary of data points and their frequency of occurrance.
@f
ile_name - The file
to generate data points from.
@f
p - The BlockFile object
to generate data points from.
Returns a dictionary.
'''
i
=
0
data_points
=
{}
self
.
_print
(
"Generating data points for
%
s"
%
f
ile_
name
)
self
.
_print
(
"Generating data points for
%
s"
%
f
p
.
name
)
with
BlockFile
(
file_name
,
'r'
,
offset
=
self
.
offset
,
length
=
self
.
length
)
as
fp
:
# We don't need any extra data from BlockFile
fp
.
MAX_TRAILING_SIZE
=
0
while
True
:
...
...
@@ -255,8 +254,8 @@ class Plotter(object):
ygrid
.
scale
(
12.8
,
12.8
,
12.8
)
zgrid
.
scale
(
12.8
,
12.8
,
12.8
)
for
f
ile_name
in
self
.
files
:
data_points
=
self
.
_generate_data_points
(
f
ile_name
)
for
f
d
in
self
.
target_
files
:
data_points
=
self
.
_generate_data_points
(
f
d
)
self
.
_print
(
"Generating plot points from
%
d data points"
%
len
(
data_points
))
...
...
src/binwalk/modules/configuration.py
View file @
54bfff03
...
...
@@ -102,7 +102,7 @@ class Configuration(object):
Update
(
self
.
verbose
)
.
update
()
sys
.
exit
(
0
)
self
.
_
test
_target_files
()
self
.
_
open
_target_files
()
self
.
_set_verbosity
()
self
.
display
=
binwalk
.
display
.
Display
(
log
=
self
.
log_file
,
...
...
@@ -128,7 +128,7 @@ class Configuration(object):
Checks if the target files can be opened.
Any files that cannot be opened are removed from the self.target_files list.
'''
failed_open_count
=
0
open_files
=
[]
# Validate the target files listed in target_files
for
tfile
in
self
.
target_files
:
...
...
@@ -136,20 +136,20 @@ class Configuration(object):
if
not
os
.
path
.
isdir
(
tfile
):
# Make sure we can open the target files
try
:
fd
=
open
(
tfile
,
"rb"
)
fd
.
close
()
open_files
.
append
(
BlockFile
(
tfile
,
length
=
self
.
length
,
offset
=
self
.
offset
))
except
Exception
as
e
:
sys
.
stderr
.
write
(
"Cannot open file :
%
s
\n
"
%
str
(
e
))
self
.
target_files
.
pop
(
self
.
target_files
.
index
(
tfile
))
failed_open_count
+=
1
# Unless -O was specified, don't run the scan unless we are able to scan all specified files
if
failed_open_count
>
0
and
not
self
.
skip_unopened
:
if
len
(
open_files
)
!=
len
(
self
.
target_files
)
and
not
self
.
skip_unopened
:
failed_open_count
=
len
(
self
.
target_files
)
-
len
(
open_files
)
if
failed_open_count
>
1
:
plural
=
's'
else
:
plural
=
''
raise
Exception
(
"Failed to open
%
d file
%
s for scanning"
%
(
failed_open_count
,
plural
))
else
:
self
.
target_files
=
open_files
class
Update
(
object
):
'''
...
...
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