本文整理匯總了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)
示例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"
示例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
示例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]
示例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]
示例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)
示例7: decompress
# 需要導入模塊: import pylzma [as 別名]
# 或者: from pylzma import decompress [as 別名]
def decompress(data):
return lzma.decompress(data)
示例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
示例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