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 = [
......
......@@ -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,14 +126,19 @@ 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))
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:
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
block_offset += 1
total_read += dlen
......
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