Commit d739c36c by devttys0

Modified extractor to report the actual extractor command that was executed,…

Modified extractor to report the actual extractor command that was executed, rather than the placeholder command in the extract.conf file.
parent 798ac5a4
...@@ -565,6 +565,7 @@ class Extractor(Module): ...@@ -565,6 +565,7 @@ class Extractor(Module):
fname = '' fname = ''
rule = None rule = None
recurse = False recurse = False
command_line = ''
original_dir = os.getcwd() original_dir = os.getcwd()
rules = self.match(description) rules = self.match(description)
file_path = os.path.realpath(file_name) file_path = os.path.realpath(file_name)
...@@ -619,9 +620,10 @@ class Extractor(Module): ...@@ -619,9 +620,10 @@ class Extractor(Module):
# Execute the specified command against the extracted file # Execute the specified command against the extracted file
if self.run_extractors: if self.run_extractors:
extract_ok = self.execute(rule['cmd'], fname, rule['codes']) (extract_ok, command_line) = self.execute(rule['cmd'], fname, rule['codes'])
else: else:
extract_ok = True extract_ok = True
command_line = ''
# Only clean up files if remove_after_execute was specified. # Only clean up files if remove_after_execute was specified.
# Only clean up files if the file was extracted sucessfully, or if we've run # Only clean up files if the file was extracted sucessfully, or if we've run
...@@ -658,14 +660,16 @@ class Extractor(Module): ...@@ -658,14 +660,16 @@ class Extractor(Module):
os.chdir(original_dir) os.chdir(original_dir)
if rule is not None: return (output_directory, fname, recurse, command_line)
if callable(rule['cmd']):
command_name = get_class_name_from_method(rule['cmd']) #if rule is not None:
else: # if callable(rule['cmd']):
command_name = rule['cmd'] # command_name = get_class_name_from_method(rule['cmd'])
return (output_directory, fname, recurse, command_name) # else:
else: # command_name = rule['cmd']
return (output_directory, fname, recurse, '') # return (output_directory, fname, recurse, command_name)
#else:
# return (output_directory, fname, recurse, '')
def _entry_offset(self, index, entries, description): def _entry_offset(self, index, entries, description):
''' '''
...@@ -827,11 +831,14 @@ class Extractor(Module): ...@@ -827,11 +831,14 @@ class Extractor(Module):
tmp = None tmp = None
rval = 0 rval = 0
retval = True retval = True
command_list = []
binwalk.core.common.debug("Running extractor '%s'" % str(cmd)) binwalk.core.common.debug("Running extractor '%s'" % str(cmd))
try: try:
if callable(cmd): if callable(cmd):
command_list.append(get_class_name_from_method(cmd))
try: try:
retval = cmd(fname) retval = cmd(fname)
except KeyboardInterrupt as e: except KeyboardInterrupt as e:
...@@ -868,6 +875,7 @@ class Extractor(Module): ...@@ -868,6 +875,7 @@ class Extractor(Module):
retval = False retval = False
binwalk.core.common.debug('External extractor command "%s" completed with return code %d (success: %s)' % (cmd, rval, str(retval))) binwalk.core.common.debug('External extractor command "%s" completed with return code %d (success: %s)' % (cmd, rval, str(retval)))
command_list.append(command)
# TODO: Should errors from all commands in a command string be checked? Currently we only support # TODO: Should errors from all commands in a command string be checked? Currently we only support
# specifying one set of error codes, so at the moment, this is not done; it is up to the # specifying one set of error codes, so at the moment, this is not done; it is up to the
...@@ -885,4 +893,4 @@ class Extractor(Module): ...@@ -885,4 +893,4 @@ class Extractor(Module):
if tmp is not None: if tmp is not None:
tmp.close() tmp.close()
return retval return (retval, '&&'.join(command_list))
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