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