Commit 62b3345d by devttys0

Fixed bug in zlib plugin; fixed bug in verbosity.

parent 5ce83d5a
...@@ -3,6 +3,7 @@ import os ...@@ -3,6 +3,7 @@ import os
import sys import sys
import inspect import inspect
import argparse import argparse
import traceback
import binwalk.core.common import binwalk.core.common
import binwalk.core.config import binwalk.core.config
import binwalk.core.plugin import binwalk.core.plugin
...@@ -279,9 +280,12 @@ class Module(object): ...@@ -279,9 +280,12 @@ class Module(object):
self.errors.append(e) self.errors.append(e)
if e.exception: if e.exception:
sys.stderr.write(e.module.__class__.__name__ + " Exception: " + str(e.exception) + "\n") sys.stderr.write("\n" + e.module.__class__.__name__ + " Exception: " + str(e.exception) + "\n")
sys.stderr.write("-" * self.config.display.HEADER_WIDTH + "\n")
traceback.print_exc(file=sys.stderr)
sys.stderr.write("-" * self.config.display.HEADER_WIDTH + "\n\n")
elif e.description: elif e.description:
sys.stderr.write(e.module.__class__.__name__ + " Error: " + e.description + "\n") sys.stderr.write("\n" + e.module.__class__.__name__ + " Error: " + e.description + "\n\n")
def header(self): def header(self):
self.config.display.format_strings(self.HEADER_FORMAT, self.RESULT_FORMAT) self.config.display.format_strings(self.HEADER_FORMAT, self.RESULT_FORMAT)
......
...@@ -54,9 +54,8 @@ class Configuration(Module): ...@@ -54,9 +54,8 @@ class Configuration(Module):
description='Supress output to stdout'), description='Supress output to stdout'),
Option(long='verbose', Option(long='verbose',
short='v', short='v',
type=list, kwargs={'verbose' : 1},
kwargs={'verbose' : True}, description='Enable verbose output'),
description='Enable verbose output (specify twice for more verbosity)'),
Option(short='h', Option(short='h',
long='help', long='help',
kwargs={'show_help' : True}, kwargs={'show_help' : True},
...@@ -76,7 +75,7 @@ class Configuration(Module): ...@@ -76,7 +75,7 @@ class Configuration(Module):
Kwarg(name='csv', default=False), Kwarg(name='csv', default=False),
Kwarg(name='format_to_terminal', default=False), Kwarg(name='format_to_terminal', default=False),
Kwarg(name='quiet', default=False), Kwarg(name='quiet', default=False),
Kwarg(name='verbose', default=[]), Kwarg(name='verbose', default=0),
Kwarg(name='files', default=[]), Kwarg(name='files', default=[]),
Kwarg(name='show_help', default=False), Kwarg(name='show_help', default=False),
] ]
...@@ -84,8 +83,8 @@ class Configuration(Module): ...@@ -84,8 +83,8 @@ class Configuration(Module):
def load(self): def load(self):
self.target_files = [] self.target_files = []
self._set_verbosity()
self._open_target_files() self._open_target_files()
self._set_verbosity()
self.settings = binwalk.core.config.Config() self.settings = binwalk.core.config.Config()
self.display = binwalk.core.display.Display(log=self.log_file, self.display = binwalk.core.display.Display(log=self.log_file,
...@@ -117,8 +116,6 @@ class Configuration(Module): ...@@ -117,8 +116,6 @@ class Configuration(Module):
Sets the appropriate verbosity. Sets the appropriate verbosity.
Must be called after self._test_target_files so that self.target_files is properly set. Must be called after self._test_target_files so that self.target_files is properly set.
''' '''
self.verbose = len(self.verbose)
# If more than one target file was specified, enable verbose mode; else, there is # If more than one target file was specified, enable verbose mode; else, there is
# nothing in some outputs to indicate which scan corresponds to which file. # nothing in some outputs to indicate which scan corresponds to which file.
if len(self.target_files) > 1 and self.verbose == 0: if len(self.target_files) > 1 and self.verbose == 0:
......
...@@ -2,7 +2,7 @@ import ctypes ...@@ -2,7 +2,7 @@ import ctypes
import ctypes.util import ctypes.util
from binwalk.core.common import BlockFile from binwalk.core.common import BlockFile
class Plugin: class Plugin(object):
''' '''
Searches for and validates zlib compressed data. Searches for and validates zlib compressed data.
''' '''
......
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