Commit 31402726 by devttys0

Merge branch 'master' of https://github.com/devttys0/binwalk

parents 5fc6df7b fdf29459
......@@ -83,7 +83,7 @@ class Display(object):
# four spaces in the description string, which would break auto-formatting.
for i in range(len(args)):
if isinstance(args[i], str):
while " " in args[i]:
while " " in args[i]:
args[i] = args[i].replace(" " , " ")
self._fprint(self.result_format, tuple(args))
......
......@@ -537,10 +537,9 @@ class Modules(object):
def _set_arguments(self, argv=[], kargv={}):
for (k,v) in iterator(kargv):
k = self._parse_api_opt(k)
argv.append(k)
if v not in [True, False, None]:
argv.append("%s %s" % (k, v))
else:
argv.append(k)
argv.append(v)
if not argv and not self.arguments:
self.arguments = sys.argv[1:]
......
......@@ -177,7 +177,7 @@ class Plugins(object):
if file_name.endswith(self.MODULE_EXTENSION):
module = file_name[:-len(self.MODULE_EXTENSION)]
try:
try:
plugin = imp.load_source(module, os.path.join(plugins[key]['path'], file_name))
plugin_class = self._find_plugin_class(plugin)
......
......@@ -65,7 +65,6 @@ class HashMatch(Module):
Kwarg(name='strings', default=False),
Kwarg(name='same', default=True),
Kwarg(name='symlinks', default=False),
Kwarg(name='name', default=False),
Kwarg(name='max_results', default=None),
Kwarg(name='abspath', default=False),
Kwarg(name='filter_by_name', default=False),
......@@ -87,7 +86,7 @@ class HashMatch(Module):
FUZZY_MIN_FILE_SIZE = 4096
HEADER_FORMAT = "\n%s" + " " * 11 + "%s\n"
RESULT_FORMAT = "%.3d%%" + " " * 17 + "%s\n"
RESULT_FORMAT = "%d%%" + " " * 17 + "%s\n"
HEADER = ["SIMILARITY", "FILE NAME"]
RESULT = ["percentage", "description"]
......@@ -104,6 +103,13 @@ class HashMatch(Module):
def _show_result(self, match, fname):
if self.abspath:
fname = os.path.abspath(fname)
# Add description string padding for alignment
if match < 100:
fname = ' ' + fname
if match < 10:
fname = ' ' + fname
self.result(percentage=match, description=fname)
def _compare_files(self, file1, file2):
......
......@@ -23,7 +23,7 @@ class CompressdPlugin(binwalk.core.plugin.Plugin):
def scan(self, result):
if result.file and result.description.lower().startswith("compress'd data"):
fd = BlockFile(result.file.name, "r", offset=result.offset, length=self.READ_SIZE)
fd = self.module.config.open_file(result.file.name, offset=result.offset, length=self.READ_SIZE)
compressed_data = fd.read(self.READ_SIZE)
fd.close()
......
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