當前位置: 首頁>>代碼示例>>Python>>正文


Python pylzma.decompress方法代碼示例

本文整理匯總了Python中pylzma.decompress方法的典型用法代碼示例。如果您正苦於以下問題:Python pylzma.decompress方法的具體用法?Python pylzma.decompress怎麽用?Python pylzma.decompress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pylzma的用法示例。


在下文中一共展示了pylzma.decompress方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: scan

# 需要導入模塊: import pylzma [as 別名]
# 或者: from pylzma import decompress [as 別名]
def scan(self, payload: Payload, request: Request) -> WorkerResponse:
        """
        Carve and decompress SWF files from payloads

        """

        extracted: List[ExtractedPayload] = []
        errors: List[Error] = []
        content = BytesIO(payload.content)
        content.seek(0)
        for start, end in self._carve(content):
            ex, errs = self.decompress(content, start)
            if ex:
                extracted.append(ex)
            for err in errs:
                errors.append(
                    Error(
                        error=err,
                        plugin_name=self.plugin_name,
                        payload_id=payload.results.payload_id,
                    )
                )
        return WorkerResponse(extracted=extracted, errors=errors) 
開發者ID:PUNCH-Cyber,項目名稱:stoq-plugins-public,代碼行數:25,代碼來源:swfcarve.py

示例2: decompressSWFData

# 需要導入模塊: import pylzma [as 別名]
# 或者: from pylzma import decompress [as 別名]
def decompressSWFData(in_data):
    try:
        ver = in_data[3]

        if in_data[0] == 'C':
            # zlib SWF
            decompressData = zlib.decompress(in_data[8:])
        elif in_data[0] == 'Z':
            # lzma SWF
            decompressData = pylzma.decompress(in_data[12:])
        elif in_data[0] == 'F':
            # uncompressed SWF
            decompressData = in_data[8:]

        header = list(struct.unpack("<8B", in_data[0:8]))
        header[0] = ord('F')
        return True, struct.pack("<8B", *header) + decompressData

    except Exception as e:
        traceback.print_exc()
        return False, "Decompression error" 
開發者ID:Neo23x0,項目名稱:Loki,代碼行數:23,代碼來源:helpers.py

示例3: decrypt_rules

# 需要導入模塊: import pylzma [as 別名]
# 或者: from pylzma import decompress [as 別名]
def decrypt_rules(file_package):
    privkey = import_RSA_key("%s.key" % file_package)
    rsa_cipher = get_cipher_RSA_PKCS1_OAEP(privkey)
    with open(file_package, "rb") as f:
        encrypted_data = f.read()

    aeskey = decrypt(encrypted_data[:RSA_MOD_SIZE], rsa_cipher)
    aes_iv = encrypted_data[RSA_MOD_SIZE:RSA_MOD_SIZE + AES.block_size]

    aes_cipher = get_cipher_AES(aeskey, aes_iv)
    decrypted_rules_compressed = decrypt(encrypted_data[RSA_MOD_SIZE + AES.block_size:], aes_cipher)
    decrypted_rules = decompress(decrypted_rules_compressed)

    buffer = io.BytesIO(decrypted_rules)
    rules = yara.load(file=buffer)
    return rules 
開發者ID:Neo23x0,項目名稱:Loki,代碼行數:18,代碼來源:privrules.py

示例4: _read_from_decompressor

# 需要導入模塊: import pylzma [as 別名]
# 或者: from pylzma import decompress [as 別名]
def _read_from_decompressor(self, coder, decompressor, input, checkremaining=False):
        data = ''
        idx = 0
        cnt = 0
        self._file.seek(self._src_start)
        properties = coder.get('properties', None)
        if properties:
            decompressor.decompress(properties)
        total = self.compressed
        if not input and total is None:
            remaining = self._start+self.size
            out = StringIO()
            while remaining > 0:
                data = self._file.read(READ_BLOCKSIZE)
                if checkremaining:
                    tmp = decompressor.decompress(data, remaining)
                else:
                    tmp = decompressor.decompress(data)
                out.write(tmp)
                remaining -= len(tmp)
            
            data = out.getvalue()
        else:
            if not input:
                input = self._file.read(total)
            if checkremaining:
                data = decompressor.decompress(input, self._start+self.size)
            else:
                data = decompressor.decompress(input)
        return data[self._start:self._start+self.size] 
開發者ID:maloep,項目名稱:romcollectionbrowser,代碼行數:32,代碼來源:py7zlib.py

示例5: _read_from_decompressor

# 需要導入模塊: import pylzma [as 別名]
# 或者: from pylzma import decompress [as 別名]
def _read_from_decompressor(self, coder, decompressor, checkremaining=False):
        data = ''
        idx = 0
        cnt = 0
        self._file.seek(self._src_start)
        properties = coder.get('properties', None)
        if properties:
            decompressor.decompress(properties)
        total = self.compressed
        if total is None:
            remaining = self._start+self.size
            out = StringIO()
            while remaining > 0:
                data = self._file.read(1024)
                if checkremaining:
                    tmp = decompressor.decompress(data, remaining)
                else:
                    tmp = decompressor.decompress(data)
                out.write(tmp)
                remaining -= len(tmp)
            
            data = out.getvalue()
        else:
            if checkremaining:
                data = decompressor.decompress(self._file.read(total), self._start+self.size)
            else:
                data = decompressor.decompress(self._file.read(total))
        return data[self._start:self._start+self.size] 
開發者ID:maloep,項目名稱:romcollectionbrowser,代碼行數:30,代碼來源:py7zlib.py

示例6: run

# 需要導入模塊: import pylzma [as 別名]
# 或者: from pylzma import decompress [as 別名]
def run(self):

        super(SWF, self).run()
        if self.args is None:
            return

        if not __sessions__.is_set():
            self.log('error', "No session opened")
            return

        arg_dump = self.args.dump
        if arg_dump is None:
            arg_dump = tempfile.gettempdir()
        self.decompress(arg_dump) 
開發者ID:opensourcesec,項目名稱:CIRTKit,代碼行數:16,代碼來源:swf.py

示例7: decompress

# 需要導入模塊: import pylzma [as 別名]
# 或者: from pylzma import decompress [as 別名]
def decompress(data):
    return lzma.decompress(data) 
開發者ID:Neo23x0,項目名稱:Loki,代碼行數:4,代碼來源:privrules.py

示例8: EXTRACT_SWF

# 需要導入模塊: import pylzma [as 別名]
# 或者: from pylzma import decompress [as 別名]
def EXTRACT_SWF(s, buff):

   SWF = {}

   magic = buff[:3]
   data = ''

   if magic == 'CWS':
      SWF['Buffer'] = 'FWS' + buff[3:8] + zlib.decompress(buff[8:])
   elif magic == 'ZWS':
      SWF['Buffer'] = 'FWS' + buff[3:8] + pylzma.decompress(buff[12:])
   elif magic == 'FWS':
      SWF['Version'] = ord(buff[3])

   return SWF 
開發者ID:EmersonElectricCo,項目名稱:fsf,代碼行數:17,代碼來源:EXTRACT_SWF.py

示例9: _decompressSWF

# 需要導入模塊: import pylzma [as 別名]
# 或者: from pylzma import decompress [as 別名]
def _decompressSWF(f, swf_size):
        magic = f.read(3)
        if magic == "CWS":
            try:
                header = "FWS" + f.read(5)
                data = zlib.decompress(f.read())[:swf_size-8]
                return header + data 
            except (QuitScanException, GlobalScanTimeoutError, GlobalModuleTimeoutError):
                raise
            except Exception:
                return "ERROR"
            finally:
                logging.debug("extract_swf - closing stringio handle in decompress")
                f.close()
        elif magic == "ZWS":
            try:
                header = "FWS" + f.read(5)
                f.seek(12)
                data = pylzma.decompress(f.read())[:swf_size-8]
                return header + data
            except (QuitScanException, GlobalScanTimeoutError, GlobalModuleTimeoutError):
                raise
            except Exception:
                return "ERROR"
            finally:
                logging.debug("extract_swf - closing stringio handle in decompress")
                f.close()
        else:
            return None 
開發者ID:lmco,項目名稱:laikaboss,代碼行數:31,代碼來源:explode_swf.py


注:本文中的pylzma.decompress方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。