Commit c336b225 by devttys0

Changed -V option

parent 5859e214
......@@ -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
......
......@@ -17,18 +17,23 @@ class CodeID(Module):
CLI = [
Option(short='Y',
long='disasm',
long='code',
kwargs={'enabled' : True},
description='Identify the architecture of excutable code using the capstone disassembler'),
description='Attempts to identify the CPU architecture of a file 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%.8X %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%.8X %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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment