Commit 7a08b8b5 by devttys0

Fixed one-of-many keyword handling bug

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