Commit 7a08b8b5 by devttys0

Fixed one-of-many keyword handling bug

parent 5b7bfef5
......@@ -80,7 +80,6 @@ class Signature(object):
Returns None.
'''
self.filter = filter
self.valid = True
self.last_one_of_many = None
self.ignore_smart_signatures = ignore_smart_signatures
......@@ -94,6 +93,7 @@ class Signature(object):
'''
results = {}
self.valid = True
self.display = True
if data:
for tag in self.TAGS:
......@@ -118,6 +118,7 @@ class Signature(object):
self.valid = False
results['valid'] = self.valid
results['display'] = self.display
return binwalk.core.module.Result(**results)
......@@ -170,13 +171,12 @@ class Signature(object):
'''
if self.filter.valid_result(data):
if self.last_one_of_many is not None and data.startswith(self.last_one_of_many):
return (data, False)
if tag.tag in data:
# Only match on the data before the first comma, as that is typically unique and static
self.last_one_of_many = data.split(',')[0]
else:
self.last_one_of_many = None
self.display = False
elif tag.tag in data:
# Only match on the data before the first comma, as that is typically unique and static
self.last_one_of_many = data.split(',')[0]
else:
self.last_one_of_many = None
return (data, True)
......
......@@ -106,8 +106,8 @@ class Extractor(Module):
else:
size = r.size
# Only extract valid results marked for extraction
if r.valid and r.extract:
# Only extract valid results displayed to the user and marked for extraction
if r.valid and r.display and r.extract:
# Do the extraction
(extraction_directory, dd_file) = self.extract(r.offset, r.description, r.file.name, size, r.name)
......
......@@ -44,7 +44,7 @@ class Signature(Module):
Kwarg(name='search_for_opcodes', default=False),
Kwarg(name='cast_data_types', default=False),
Kwarg(name='dumb_scan', default=False),
Kwarg(name='force_default_scan', default=False),
Kwarg(name='force_default_scan', default=False),
Kwarg(name='magic_files', default=[]),
]
......@@ -100,7 +100,7 @@ class Signature(Module):
if r.jump and (r.jump + r.offset) > r.file.size:
r.valid = False
r.valid = self.config.filter.valid_result(r.description)
def scan_file(self, fp):
......@@ -132,7 +132,6 @@ class Signature(Module):
# The smart filter parser returns a binwalk.core.module.Result object
r = self.smart.parse(magic_result)
# Set the absolute offset inside the target file
r.offset = block_start + candidate_offset + r.adjust
......
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