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
9aed6246
Commit
9aed6246
authored
Nov 29, 2013
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In process of replacing pymatplotlib with pyqtgraph.
parent
a122a09a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
40 deletions
+32
-40
binwalk
src/bin/binwalk
+2
-2
entropy.py
src/binwalk/entropy.py
+30
-38
No files found.
src/bin/binwalk
View file @
9aed6246
...
...
@@ -458,8 +458,8 @@ def main():
pass
except
IOError
:
pass
except
Exception
as
e
:
print
(
"Unexpected error:
%
s"
%
str
(
e
))
#
except Exception as e:
#
print("Unexpected error: %s" % str(e))
bwalk
.
cleanup
()
...
...
src/binwalk/entropy.py
View file @
9aed6246
...
...
@@ -11,15 +11,10 @@ class PlotEntropy(object):
Class to plot entropy data on a graph.
'''
YLIM_MIN
=
0
YLIM_MAX
=
1.5
XLABEL
=
'Offset'
YLABEL
=
'Entropy'
LINE_WIDTH
=
1.5
COLORS
=
[
'darkgreen'
,
'blueviolet'
,
'saddlebrown'
,
'deeppink'
,
'goldenrod'
,
'olive'
,
'black'
]
COLORS
=
[
'r'
,
'g'
,
'b'
,
'c'
,
'm'
,
'w'
]
FILE_FORMAT
=
'svg'
...
...
@@ -37,53 +32,50 @@ class PlotEntropy(object):
Returns None.
'''
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
pyqtgraph
as
pg
from
pyqtgraph.Qt
import
QtCore
,
QtGui
i
=
0
trigger
=
0
new_ticks
=
[]
color_mappings
=
{}
descriptions
=
{}
max_description_length
=
None
plt
.
clf
()
if
file_results
:
for
(
offset
,
results
)
in
file_results
:
label
=
None
description
=
results
[
0
][
'description'
]
.
split
(
','
)[
0
]
desc_len
=
len
(
description
)
if
not
has_key
(
color_mappings
,
description
):
if
show_legend
:
label
=
description
color_mappings
[
description
]
=
self
.
COLORS
[
i
]
i
+=
1
if
i
>=
len
(
self
.
COLORS
):
i
=
0
if
not
max_description_length
or
desc_len
>
max_description_length
:
max_description_length
=
desc_len
plt
.
axvline
(
x
=
offset
,
label
=
label
,
color
=
color_mappings
[
description
],
linewidth
=
self
.
LINE_WIDTH
)
new_ticks
.
append
(
offset
)
if
has_key
(
descriptions
,
offset
):
descriptions
[
offset
]
.
append
(
description
)
else
:
descriptions
[
offset
]
=
[
description
]
if
show_legend
:
plt
.
legend
()
if
new_ticks
:
new_ticks
.
sort
()
plt
.
xticks
(
np
.
array
(
new_ticks
),
new_ticks
)
plt
=
pg
.
plot
(
title
=
title
,
clear
=
True
)
plt
.
plot
(
x
,
y
,
pen
=
'y'
)
if
file_results
and
show_legend
:
plt
.
addLegend
(
size
=
(
max_description_length
*
10
,
0
))
plt
.
plot
(
x
,
y
,
linewidth
=
self
.
LINE_WIDTH
)
#if average:
# plt.addLine(y=average, pen='r')
if
average
:
plt
.
plot
(
x
,
[
average
]
*
len
(
x
),
linestyle
=
'--'
,
color
=
'r'
)
if
file_results
:
for
(
offset
,
descs
)
in
iterator
(
descriptions
):
for
description
in
descs
:
plt
.
plot
(
x
=
[
offset
,
offset
],
y
=
[
0
,
1.1
],
name
=
description
,
pen
=
pg
.
mkPen
(
self
.
COLORS
[
i
],
width
=
2.5
))
i
+=
1
if
i
>=
len
(
self
.
COLORS
):
i
=
0
plt
.
xlabel
(
self
.
XLABEL
)
plt
.
ylabel
(
self
.
YLABEL
)
plt
.
title
(
title
)
plt
.
ylim
(
self
.
YLIM_MIN
,
self
.
YLIM_MAX
)
if
save
:
plt
.
savefig
(
common
.
unique_file_name
(
title
,
self
.
FILE_FORMAT
))
# TODO
pass
#plt.savefig(common.unique_file_name(title, self.FILE_FORMAT))
else
:
plt
.
show
()
plt
.
setWindowTitle
(
title
)
QtGui
.
QApplication
.
instance
()
.
exec_
()
class
FileEntropy
(
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