Commit 718d0aa9 by devttys0

Updated --cast usage, filtered out 'no magic' results

parent a5217d62
...@@ -40,7 +40,7 @@ class Filter(object): ...@@ -40,7 +40,7 @@ class Filter(object):
# If the result returned by libmagic is "data" or contains the text # If the result returned by libmagic is "data" or contains the text
# 'invalid' or a backslash are known to be invalid/false positives. # 'invalid' or a backslash are known to be invalid/false positives.
DATA_RESULT = "data" UNKNOWN_RESULTS = ["data", "very short file (no magic)"]
INVALID_RESULTS = ["invalid", "\\"] INVALID_RESULTS = ["invalid", "\\"]
INVALID_RESULT = "invalid" INVALID_RESULT = "invalid"
NON_PRINTABLE_RESULT = "\\" NON_PRINTABLE_RESULT = "\\"
...@@ -136,7 +136,7 @@ class Filter(object): ...@@ -136,7 +136,7 @@ class Filter(object):
Returns True if data is valid, False if invalid. Returns True if data is valid, False if invalid.
''' '''
# A result of 'data' is never ever valid (for libmagic results) # A result of 'data' is never ever valid (for libmagic results)
if data == self.DATA_RESULT: if data in self.UNKNOWN_RESULTS:
return False return False
# Make sure this result wasn't filtered # Make sure this result wasn't filtered
......
...@@ -25,7 +25,7 @@ class Signature(Module): ...@@ -25,7 +25,7 @@ class Signature(Module):
Option(short='C', Option(short='C',
long='cast', long='cast',
kwargs={'enabled' : True, 'cast_data_types' : True}, kwargs={'enabled' : True, 'cast_data_types' : True},
description='Cast offsets as various data types'), description='Cast offsets as a given data type (use -y to specify the data type / endianess)'),
Option(short='m', Option(short='m',
long='magic', long='magic',
kwargs={'magic_files' : []}, kwargs={'magic_files' : []},
...@@ -50,8 +50,6 @@ class Signature(Module): ...@@ -50,8 +50,6 @@ class Signature(Module):
VERBOSE_FORMAT = "%s %d" VERBOSE_FORMAT = "%s %d"
def init(self): def init(self):
flags = 0
# Create Signature and MagicParser class instances. These are mostly for internal use. # Create Signature and MagicParser class instances. These are mostly for internal use.
self.smart = binwalk.core.smart.Signature(self.config.filter, ignore_smart_signatures=self.dumb_scan) self.smart = binwalk.core.smart.Signature(self.config.filter, ignore_smart_signatures=self.dumb_scan)
self.parser = binwalk.core.parser.MagicParser(self.config.filter, self.smart) self.parser = binwalk.core.parser.MagicParser(self.config.filter, self.smart)
...@@ -64,8 +62,6 @@ class Signature(Module): ...@@ -64,8 +62,6 @@ class Signature(Module):
# Append the user's magic file first so that those signatures take precedence # Append the user's magic file first so that those signatures take precedence
if not self.magic_files: if not self.magic_files:
if self.search_for_opcodes: if self.search_for_opcodes:
flags |= binwalk.core.magic.Magic.MAGIC_CONTINUE
self.magic_files = [ self.magic_files = [
self.config.settings.paths['user'][self.config.settings.BINARCH_MAGIC_FILE], self.config.settings.paths['user'][self.config.settings.BINARCH_MAGIC_FILE],
self.config.settings.paths['system'][self.config.settings.BINARCH_MAGIC_FILE], self.config.settings.paths['system'][self.config.settings.BINARCH_MAGIC_FILE],
...@@ -83,7 +79,7 @@ class Signature(Module): ...@@ -83,7 +79,7 @@ class Signature(Module):
# Parse the magic file(s) and initialize libmagic # Parse the magic file(s) and initialize libmagic
self.mfile = self.parser.parse(self.magic_files) self.mfile = self.parser.parse(self.magic_files)
self.magic = binwalk.core.magic.Magic(self.mfile, flags) self.magic = binwalk.core.magic.Magic(self.mfile)
# Once the temporary magic files are loaded into libmagic, we don't need them anymore; delete the temp files # Once the temporary magic files are loaded into libmagic, we don't need them anymore; delete the temp files
self.parser.rm_magic_files() self.parser.rm_magic_files()
......
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