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-depend
binwalk
Commits
c336b225
Commit
c336b225
authored
10 years ago
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed -V option
parent
5859e214
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
19 deletions
+29
-19
binvis.py
src/binwalk/modules/binvis.py
+11
-11
codeid.py
src/binwalk/modules/codeid.py
+18
-8
No files found.
src/binwalk/modules/binvis.py
View file @
c336b225
...
...
@@ -30,10 +30,10 @@ class Plotter(Module):
type
=
int
,
kwargs
=
{
'max_points'
:
0
},
description
=
'Set the maximum number of plotted data points'
),
Option
(
short
=
'V'
,
long
=
'grids'
,
kwargs
=
{
'show_grids'
:
True
},
description
=
'Display the x-y-z grids in the resulting plot'
),
#
Option(short='V',
#
long='grids',
#
kwargs={'show_grids' : True},
#
description='Display the x-y-z grids in the resulting plot'),
]
KWARGS
=
[
...
...
@@ -72,7 +72,7 @@ class Plotter(Module):
self
.
app
=
QtGui
.
QApplication
([])
self
.
window
=
gl
.
GLViewWidget
()
self
.
window
.
opts
[
'distance'
]
=
self
.
VIEW_DISTANCE
if
len
(
self
.
config
.
target_files
)
==
1
:
self
.
window
.
setWindowTitle
(
self
.
config
.
target_files
[
0
]
.
name
)
...
...
@@ -86,7 +86,7 @@ class Plotter(Module):
def
_generate_plot_points
(
self
,
data_points
):
'''
Generates plot points from a list of data points.
@data_points - A dictionary containing each unique point and its frequency of occurance.
Returns a set of plot points.
...
...
@@ -143,7 +143,7 @@ class Plotter(Module):
total
+=
1
if
total
>=
self
.
max_points
:
break
return
plot_points
def
_generate_data_point
(
self
,
data
):
...
...
@@ -180,7 +180,7 @@ class Plotter(Module):
i
=
0
while
(
i
+
(
self
.
axis
-
1
))
<
dlen
:
point
=
self
.
_generate_data_point
(
data
[
i
:
i
+
self
.
axis
])
if
has_key
(
data_points
,
point
):
if
has_key
(
data_points
,
point
):
data_points
[
point
]
+=
1
else
:
data_points
[
point
]
=
1
...
...
@@ -191,7 +191,7 @@ class Plotter(Module):
def
_generate_plot
(
self
,
plot_points
):
import
numpy
as
np
import
pyqtgraph.opengl
as
gl
nitems
=
float
(
len
(
plot_points
))
pos
=
np
.
empty
((
nitems
,
3
))
...
...
@@ -282,7 +282,7 @@ class Plotter(Module):
Plot data points within a 3D cube.
'''
return
(
ord
(
data
[
0
]),
ord
(
data
[
1
]),
ord
(
data
[
2
]))
def
_generate_2d_data_point
(
self
,
data
):
'''
Plot data points projected on each cube face.
...
...
@@ -303,7 +303,7 @@ class Plotter(Module):
return
(
ord
(
data
[
0
]),
255
,
ord
(
data
[
1
]))
elif
self
.
plane_count
==
5
:
return
(
ord
(
data
[
0
]),
ord
(
data
[
1
]),
255
)
def
run
(
self
):
self
.
plot
()
return
True
...
...
This diff is collapsed.
Click to expand it.
src/binwalk/modules/codeid.py
View file @
c336b225
...
...
@@ -17,18 +17,23 @@ class CodeID(Module):
CLI
=
[
Option
(
short
=
'Y'
,
long
=
'
disasm
'
,
long
=
'
code
'
,
kwargs
=
{
'enabled'
:
True
},
description
=
'
Identify the architecture of excutable cod
e using the capstone disassembler'
),
description
=
'
Attempts to identify the CPU architecture of a fil
e using the capstone disassembler'
),
Option
(
short
=
'T'
,
long
=
'minsn'
,
type
=
int
,
kwargs
=
{
'min_insn_count'
:
0
},
description
=
'Minimum number of consecutive instructions to be considered valid (default:
%
d)'
%
DEFAULT_MIN_INSN_COUNT
),
Option
(
short
=
'V'
,
long
=
'disasm'
,
kwargs
=
{
'show_disasm'
:
True
},
description
=
'Display the disassembled instructions'
),
]
KWARGS
=
[
Kwarg
(
name
=
'enabled'
,
default
=
False
),
Kwarg
(
name
=
'show_disasm'
,
default
=
False
),
Kwarg
(
name
=
'min_insn_count'
,
default
=
DEFAULT_MIN_INSN_COUNT
),
]
...
...
@@ -121,13 +126,18 @@ class CodeID(Module):
# to prevent false positives (e.g., "\x00\x00\x00x\00" is a nop in MIPS).
if
len
(
set
(
code_block
))
>=
2
:
for
(
md
,
description
)
in
self
.
disassemblers
:
ninsn
=
len
([
insn
for
insn
in
md
.
disasm_lite
(
code_block
,
0
)])
binwalk
.
core
.
common
.
debug
(
"0x
%.8
X
%
s, at least
%
d valid instructions"
%
((
total_read
+
block_offset
),
description
,
ninsn
))
insns
=
[
insn
for
insn
in
md
.
disasm_lite
(
code_block
,
(
total_read
+
block_offset
))]
binwalk
.
core
.
common
.
debug
(
"0x
%.8
X
%
s, at least
%
d valid instructions"
%
((
total_read
+
block_offset
),
description
,
len
(
insns
)))
if
len
(
insns
)
>=
self
.
min_insn_count
:
r
=
self
.
result
(
offset
=
total_read
+
block_offset
,
file
=
fp
,
description
=
(
description
+
", at least
%
d valid instructions"
%
len
(
insns
)))
if
r
.
valid
and
r
.
display
:
if
self
.
show_disasm
:
for
(
position
,
size
,
mnem
,
opnds
)
in
insns
:
self
.
result
(
offset
=
position
,
file
=
fp
,
description
=
"
\t
%
s
%
s"
%
(
mnem
,
opnds
))
if
not
self
.
config
.
verbose
:
return
if
ninsn
>=
self
.
min_insn_count
:
r
=
self
.
result
(
offset
=
total_read
+
block_offset
,
file
=
fp
,
description
=
(
description
+
", at least
%
d valid instructions"
%
ninsn
))
if
r
.
valid
and
r
.
display
and
not
self
.
config
.
verbose
:
return
block_offset
+=
1
...
...
This diff is collapsed.
Click to expand it.
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