Commit b24fe1c7 by devttys0

Added zlibextractor plugin; removed FMK zlib extraction dependency

parent 38ac8074
......@@ -27,13 +27,13 @@
# These assume the firmware-mod-kit is installed to /opt/firmware-mod-kit.
# If not, change the file paths appropriately.
^squashfs filesystem:squashfs:/opt/firmware-mod-kit/unsquashfs_all.sh '%e'
^jffs2 filesystem:jffs2:/opt/firmware-mod-kit/src/jffs2/unjffs2 '%e'
^ascii cpio archive:cpio:/opt/firmware-mod-kit/uncpio.sh '%e'
#^squashfs filesystem:squashfs:/opt/firmware-mod-kit/unsquashfs_all.sh '%e'
#^cramfs filesystem:cramfs:/opt/firmware-mod-kit/uncramfs_all.sh '%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'
^zlib compressed data:zlib:/opt/firmware-mod-kit/src/firmware-tools/unzlib.py '%e'
#^zlib compressed data:zlib:/opt/firmware-mod-kit/src/firmware-tools/unzlib.py '%e'
^cramfs filesystem:cramfs:mkdir cramfs-root && mount -t cramfs '%e' cramfs-root
^ext2 filesystem:ext2:mkdir ext2-root && mount -t ext2 '%e' ext2-root
......
......@@ -31,10 +31,15 @@ class Disasm(Module):
type=int,
kwargs={'min_insn_count' : 0},
description='Minimum number of consecutive instructions to be considered valid (default: %d)' % DEFAULT_MIN_INSN_COUNT),
Option(long='continue',
short='k',
kwargs={'keep_going' : True},
description="Don't stop at the first match"),
]
KWARGS = [
Kwarg(name='enabled', default=False),
Kwarg(name='keep_going', default=False),
Kwarg(name='min_insn_count', default=DEFAULT_MIN_INSN_COUNT),
]
......@@ -146,7 +151,7 @@ class Disasm(Module):
if self.config.verbose:
for (position, size, mnem, opnds) in result.insns:
self.result(offset=position, file=fp, description="\t\t%s %s" % (mnem, opnds))
if not self.config.keep_going:
if not self.keep_going:
return
total_read += dlen
......
......@@ -34,10 +34,6 @@ class General(Module):
type=int,
kwargs={'block' : 0},
description='Set file block size'),
Option(long='continue',
short='k',
kwargs={'keep_going' : True},
description="Don't stop at the first match"),
Option(long='swap',
short='g',
type=int,
......
......@@ -24,10 +24,10 @@ class Signature(Module):
long='opcodes',
kwargs={'enabled' : True, 'search_for_opcodes' : True},
description='Scan target file(s) for common executable opcode signatures'),
Option(short='C',
long='cast',
kwargs={'enabled' : True, 'cast_data_types' : True},
description='Cast offsets as a given data type (use -y to specify the data type / endianness)'),
#Option(short='C',
# long='cast',
# kwargs={'enabled' : True, 'cast_data_types' : True},
# description='Cast offsets as a given data type (use -y to specify the data type / endianness)'),
Option(short='m',
long='magic',
kwargs={'enabled' : True, 'magic_files' : []},
......
import os
import zlib
import binwalk.core.common
import binwalk.core.plugin
class ZLIBExtractPlugin(binwalk.core.plugin.Plugin):
'''
Zlib extractor plugin.
'''
MODULES = ['Signature']
def init(self):
# If the extractor is enabled for the module we're currently loaded
# into, then register self.extractor as a zlib extraction rule.
if self.module.extractor.enabled:
self.module.extractor.add_rule(txtrule=None,
regex="^zlib compressed data",
extension="zlib",
cmd=self.extractor)
def extractor(self, fname):
outfile = os.path.splitext(fname)[0]
#print ("Extracting from '%s' to '%s'" % (fname, outfile))
try:
fpin = binwalk.core.common.BlockFile(fname)
fpout = binwalk.core.common.BlockFile(outfile, 'w')
plaintext = zlib.decompress(fpin.read())
fpout.write(plaintext)
fpin.close()
fpout.close()
except Exception, e:
pass
#print ("Failed to decompress data:", str(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