<s> import os <EOL> import binwalk . core . plugin <EOL> class LZMAExtractPlugin ( binwalk . core . plugin . Plugin ) : <EOL> '''<STR_LIT>''' <EOL> MODULES = [ '<STR_LIT>' ] <EOL> def init ( self ) : <EOL> try : <EOL> try : <EOL> import lzma <EOL> except ImportError : <EOL> from backports import lzma <EOL> self . decompressor = lzma . decompress <EOL> if self . module . extractor . enabled : <EOL> self . module . extractor . add_rule ( txtrule = None , <EOL> regex = "<STR_LIT>" , <EOL> extension = "<STR_LIT>" , <EOL> cmd = self . extractor ) <EOL> self . module . extractor . add_rule ( txtrule = None , <EOL> regex = "<STR_LIT>" , <EOL> extension = "<STR_LIT>" , <EOL> cmd = self . extractor ) <EOL> except ImportError as e : <EOL> pass <EOL> def extractor ( self , fname ) : <EOL> fname = os . path . abspath ( fname ) <EOL> outfile = os . path . splitext ( fname ) [ <NUM_LIT:0> ] <EOL> try : <EOL> fpin = open ( fname , "<STR_LIT:rb>" ) <EOL> compressed = fpin . read ( ) <EOL> fpin . close ( ) <EOL> decompressed = self . decompressor ( compressed ) <EOL> fpout = open ( outfile , "<STR_LIT:wb>" ) <EOL> fpout . write ( decompressed ) <EOL> fpout . close ( ) <EOL> except KeyboardInterrupt as e : <EOL> raise e <EOL> except Exception as e : <EOL> return False <EOL> return True </s>
