Commit 38bc437f by devttys0

Added support for multiple commands in extract.conf; added auto-mounting for ext2 and romfs.

parent 47b521cd
......@@ -29,8 +29,8 @@
^bff volume entry:bff:/opt/firmware-mod-kit/src/bff/bffxtractor.py '%e'
^wdk file system:wdk:/opt/firmware-mod-kit/src/firmware-tools/unwdk.py '%e'
^zlib header:zlib:/opt/firmware-mod-kit/src/firmware-tools/unzlib.py '%e'
^ext2 filesystem:ext2:/opt/firmware-mod-kit/src/mountcp/mountcp '%e' ext2-root
^romfs filesystem:romfs:/opt/firmware-mod-kit/src/mountcp/mountcp '%e' romfs-root
^ext2 filesystem:ext2:mkdir ext2-root && mount -t ext2 '%e' ext2-root
^romfs filesystem:romfs:mkdir romfs-root && mount -t romfs '%e' romfs-root
# These paths are for the depreciated firmware-mod-kit file paths, which included the 'trunk' directory.
# These will only be run if the above file paths don't exist.
......
......@@ -543,6 +543,7 @@ class Extractor(Module):
Returns True on success, False on failure, or None if the external extraction utility could not be found.
'''
tmp = None
rval = 0
retval = True
binwalk.core.common.debug("Running extractor '%s'" % str(cmd))
......@@ -560,17 +561,21 @@ class Extractor(Module):
if not binwalk.core.common.DEBUG:
tmp = tempfile.TemporaryFile()
# Replace all instances of FILE_NAME_PLACEHOLDER in the command with fname
cmd = cmd.replace(self.FILE_NAME_PLACEHOLDER, fname)
# Execute.
rval = subprocess.call(shlex.split(cmd), stdout=tmp, stderr=tmp)
if rval == 0:
retval = True
else:
retval = False
for command in cmd.split("&&"):
# Replace all instances of FILE_NAME_PLACEHOLDER in the command with fname
command = command.strip().replace(self.FILE_NAME_PLACEHOLDER, fname)
binwalk.core.common.debug("subprocess.call(%s, stdout=%s, stderr=%s)" % (command, str(tmp), str(tmp)))
rval = subprocess.call(shlex.split(command), stdout=tmp, stderr=tmp)
binwalk.core.common.debug('External extractor command "%s" completed with return code %d' % (cmd, rval))
if rval == 0:
retval = True
else:
retval = False
break
binwalk.core.common.debug('External extractor command "%s" completed with return code %d' % (cmd, rval))
except KeyboardInterrupt as e:
raise e
except Exception as e:
......
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