Commit d62159ce by devttys0

Cleaned up lzmaextract.py plugin code

parent 1d4dbcb1
import os import os
import lzma
import binwalk.core.plugin import binwalk.core.plugin
class LZMAExtractPlugin(binwalk.core.plugin.Plugin): class LZMAExtractPlugin(binwalk.core.plugin.Plugin):
...@@ -9,6 +8,9 @@ class LZMAExtractPlugin(binwalk.core.plugin.Plugin): ...@@ -9,6 +8,9 @@ class LZMAExtractPlugin(binwalk.core.plugin.Plugin):
MODULES = ['Signature'] MODULES = ['Signature']
def init(self): def init(self):
import lzma
self.decompressor = lzma.decompress
# If the extractor is enabled for the module we're currently loaded # If the extractor is enabled for the module we're currently loaded
# into, then register self.extractor as a zlib extraction rule. # into, then register self.extractor as a zlib extraction rule.
if self.module.extractor.enabled: if self.module.extractor.enabled:
...@@ -26,8 +28,7 @@ class LZMAExtractPlugin(binwalk.core.plugin.Plugin): ...@@ -26,8 +28,7 @@ class LZMAExtractPlugin(binwalk.core.plugin.Plugin):
compressed = fpin.read() compressed = fpin.read()
fpin.close() fpin.close()
decompressed = lzma.decompress(compressed) decompressed = self.decompressor(compressed)
print ("Decompressed %d bytes" % len(decompressed))
fpout = open(outfile, "wb") fpout = open(outfile, "wb")
fpout.write(decompressed) fpout.write(decompressed)
......
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