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
a0c46694
Commit
a0c46694
authored
Nov 19, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated entropy arguments; fixed entropy trigger bugs
parent
77685bb0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
8 deletions
+18
-8
entropy.py
src/binwalk/modules/entropy.py
+18
-8
No files found.
src/binwalk/modules/entropy.py
View file @
a0c46694
...
@@ -43,24 +43,24 @@ class Entropy(Module):
...
@@ -43,24 +43,24 @@ class Entropy(Module):
long
=
'save'
,
long
=
'save'
,
kwargs
=
{
'save_plot'
:
True
},
kwargs
=
{
'save_plot'
:
True
},
description
=
'Save plot as a PNG'
),
description
=
'Save plot as a PNG'
),
Option
(
short
=
'Q'
,
long
=
'nlegend'
,
kwargs
=
{
'show_legend'
:
False
},
description
=
'Omit the legend from the entropy plot graph'
),
Option
(
short
=
'N'
,
Option
(
short
=
'N'
,
long
=
'nplot'
,
long
=
'nplot'
,
kwargs
=
{
'do_plot'
:
False
},
kwargs
=
{
'do_plot'
:
False
},
description
=
'Do not generate an entropy plot graph'
),
description
=
'Do not generate an entropy plot graph'
),
Option
(
short
=
'H'
,
Option
(
short
=
'H'
,
long
=
'high'
,
long
=
'high'
,
type
=
in
t
,
type
=
floa
t
,
kwargs
=
{
'trigger_high'
:
DEFAULT_TRIGGER_HIGH
},
kwargs
=
{
'trigger_high'
:
DEFAULT_TRIGGER_HIGH
},
description
=
'Set the rising edge entropy trigger threshold (default:
%.2
f)'
%
DEFAULT_TRIGGER_HIGH
),
description
=
'Set the rising edge entropy trigger threshold (default:
%.2
f)'
%
DEFAULT_TRIGGER_HIGH
),
Option
(
short
=
'L'
,
Option
(
short
=
'L'
,
long
=
'low'
,
long
=
'low'
,
type
=
in
t
,
type
=
floa
t
,
kwargs
=
{
'trigger_low'
:
DEFAULT_TRIGGER_LOW
},
kwargs
=
{
'trigger_low'
:
DEFAULT_TRIGGER_LOW
},
description
=
'Set the falling edge entropy trigger threshold (default:
%.2
f)'
%
DEFAULT_TRIGGER_LOW
),
description
=
'Set the falling edge entropy trigger threshold (default:
%.2
f)'
%
DEFAULT_TRIGGER_LOW
),
Option
(
short
=
'Q'
,
long
=
'nlegend'
,
kwargs
=
{
'show_legend'
:
False
},
description
=
'Omit the legend from the entropy plot graph'
),
]
]
KWARGS
=
[
KWARGS
=
[
...
@@ -133,7 +133,10 @@ class Entropy(Module):
...
@@ -133,7 +133,10 @@ class Entropy(Module):
pg
.
exit
()
pg
.
exit
()
def
calculate_file_entropy
(
self
,
fp
):
def
calculate_file_entropy
(
self
,
fp
):
# Tracks the last displayed rising/falling edge (0 for falling, 1 for rising, None if nothing has been printed yet)
last_edge
=
None
last_edge
=
None
# Auto-reset the trigger; if True, an entropy above/below self.trigger_high/self.trigger_low will be printed
trigger_reset
=
True
# Clear results from any previously analyzed files
# Clear results from any previously analyzed files
self
.
clear
(
results
=
True
)
self
.
clear
(
results
=
True
)
...
@@ -162,18 +165,25 @@ class Entropy(Module):
...
@@ -162,18 +165,25 @@ class Entropy(Module):
description
=
"
%
f"
%
entropy
description
=
"
%
f"
%
entropy
if
not
self
.
config
.
verbose
:
if
not
self
.
config
.
verbose
:
if
last_edge
in
[
None
,
0
]
and
entropy
>
self
.
trigger_high
:
if
trigger_reset
and
entropy
>=
self
.
trigger_high
:
description
=
"Rising entropy edge (
%
f)"
%
entropy
description
=
"Rising entropy edge (
%
f)"
%
entropy
display
=
self
.
display_results
display
=
self
.
display_results
last_edge
=
1
last_edge
=
1
elif
last_edge
in
[
None
,
1
]
and
entropy
<
self
.
trigger_low
:
trigger_reset
=
False
elif
trigger_reset
and
entropy
<=
self
.
trigger_low
:
description
=
"Falling entropy edge (
%
f)"
%
entropy
description
=
"Falling entropy edge (
%
f)"
%
entropy
display
=
self
.
display_results
display
=
self
.
display_results
last_edge
=
0
last_edge
=
0
trigger_reset
=
False
else
:
else
:
display
=
False
display
=
False
description
=
"
%
f"
%
entropy
description
=
"
%
f"
%
entropy
if
last_edge
in
[
None
,
0
]
and
entropy
>
self
.
trigger_low
:
trigger_reset
=
True
elif
last_edge
in
[
None
,
1
]
and
entropy
<
self
.
trigger_high
:
trigger_reset
=
True
r
=
self
.
result
(
offset
=
(
file_offset
+
i
),
r
=
self
.
result
(
offset
=
(
file_offset
+
i
),
file
=
fp
,
file
=
fp
,
entropy
=
entropy
,
entropy
=
entropy
,
...
...
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