Commit 45474ebd by devttys0

Changed how --dumb and --invalid are interpreted by the signature scan

parent d6e09d49
# Don't load the disasm module if the capstone module can't be found
try:
from binwalk.modules.disasm import Disasm
except ImportError:
pass
from binwalk.modules.signature import Signature
#from binwalk.modules.binvis import Plotter
from binwalk.modules.hexdiff import HexDiff
#from binwalk.modules.hashmatch import HashMatch
from binwalk.modules.general import General
from binwalk.modules.extractor import Extractor
from binwalk.modules.entropy import Entropy
#from binwalk.modules.heuristics import HeuristicCompressionAnalyzer
from binwalk.modules.compression import RawCompression
try:
from binwalk.modules.disasm import Disasm
except ImportError:
pass
# These are depreciated.
#from binwalk.modules.binvis import Plotter
#from binwalk.modules.hashmatch import HashMatch
#from binwalk.modules.heuristics import HeuristicCompressionAnalyzer
......@@ -113,7 +113,6 @@ class General(Module):
self._open_target_files()
self._set_verbosity()
#self.filter = binwalk.core.filter.Filter(self._display_invalid)
self.filter = binwalk.core.filter.Filter(self.show_invalid)
# Set any specified include/exclude filters
......
......@@ -99,16 +99,19 @@ class Signature(Module):
'''
Called automatically by self.result.
'''
if not r.description:
r.valid = False
if self.config.filter.show_invalid_results:
r.valid = True
else:
if not r.description:
r.valid = False
if r.size and (r.size + r.offset) > r.file.size:
r.valid = False
if r.size and (r.size + r.offset) > r.file.size:
r.valid = False
if r.jump and (r.jump + r.offset) > r.file.size:
r.valid = False
if r.jump and (r.jump + r.offset) > r.file.size:
r.valid = False
r.valid = self.config.filter.valid_result(r.description)
r.valid = self.config.filter.valid_result(r.description)
def scan_file(self, fp):
current_file_offset = 0
......@@ -149,8 +152,8 @@ class Signature(Module):
# self.result automatically calls self.validate for result validation
self.result(r=r)
# Is this a valid result and did it specify a jump-to-offset keyword?
if r.valid and r.jump > 0:
# Is this a valid result and did it specify a jump-to-offset keyword, and are we doing a "smart" scan?
if r.valid and r.jump > 0 and not self.dumb_scan:
absolute_jump_offset = r.offset + r.jump
current_block_offset = candidate_offset + r.jump
......
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