好友
阅读权限10
听众
最后登录1970-1-1
|
import os, struct, marshal, zlib, _frozen_importlib
PYTHON_MAGIC_NUMBER = _frozen_importlib._bootstrap_external.MAGIC_NUMBER
PYZ_ITEM_MODULE = 0
PYZ_ITEM_PKG = 1
PYZ_ITEM_DATA = 2
PYZ_ITEM_NSPKG = 3
class ArchiveReadError(RuntimeError):
pass
class ZlibArchiveReader:
__doc__ = "\n Reader for PyInstaller's PYZ (ZlibArchive) archive. The archive is used to store collected byte-compiled Python\n modules, as individually-compressed entries.\n "
_PYZ_MAGIC_PATTERN = b'PYZ\x00'
def __init__(self, filename, start_offset=None, check_pymagic=False):
self._filename = filename
self._start_offset = start_offset
self.toc = {}
if start_offset is None:
self._filename, self._start_offset = self._parse_offset_from_filename(filename)
with open(self._filename, "rb") as fp:
fp.seek(self._start_offset, os.SEEK_SET)
magic = fp.read(len(self._PYZ_MAGIC_PATTERN))
if magic != self._PYZ_MAGIC_PATTERN:
raise ArchiveReadError("PYZ magic pattern mismatch!")
pymagic = fp.read(len(PYTHON_MAGIC_NUMBER))
if check_pymagic:
if pymagic != PYTHON_MAGIC_NUMBER:
raise ArchiveReadError("Python magic pattern mismatch!")
toc_offset, *_ = struct.unpack("!i", fp.read(4))
fp.seek(self._start_offset + toc_offset, os.SEEK_SET)
self.toc = dict(marshal.load(fp))
@staticmethod
def _parse_offset_from_filename(filename):
"""
Parse the numeric offset from filename, stored as: `/path/to/file?offset`.
"""
offset = 0
idx = filename.rfind("?")
if idx == -1:
return (
filename, offset)
try:
offset = int(filename[(idx + 1)[:None]])
filename = filename[None[:idx]]
except ValueError:
pass
else:
return (
filename, offset)
def is_package(self, name):
"""
Check if the given name refers to a package entry. Used by PyiFrozenImporter at runtime.
"""
entry = self.toc.get(name)
if entry is None:
return False
typecode, entry_offset, entry_length = entry
return typecode in (PYZ_ITEM_PKG, PYZ_ITEM_NSPKG)
def is_pep420_namespace_package(self, name):
"""
Check if the given name refers to a namespace package entry. Used by PyiFrozenImporter at runtime.
"""
entry = self.toc.get(name)
if entry is None:
return False
typecode, entry_offset, entry_length = entry
return typecode == PYZ_ITEM_NSPKG
def extract(self, name, raw=False):
"""
Extract data from entry with the given name.
If the entry belongs to a module or a package, the data is loaded (unmarshaled) into code object. To retrieve
raw data, set `raw` flag to True.
"""
entry = self.toc.get(name)
if entry is None:
return
typecode, entry_offset, entry_length = entry
try:
with open(self._filename, "rb") as fp:
fp.seek(self._start_offset + entry_offset)
obj = fp.read(entry_length)
except FileNotFoundError:
raise SystemExit(f"{self._filename} appears to have been moved or deleted since this application was launched. Continouation from this state is impossible. Exiting now.")
else:
try:
obj = zlib.decompress(obj)
if typecode in (PYZ_ITEM_MODULE, PYZ_ITEM_PKG, PYZ_ITEM_NSPKG):
if not raw:
obj = marshal.loads(obj)
except EOFError as e:
try:
raise ImportError(f"Failed to unmarshal PYZ entry {name!r}!") from e
finally:
e = None
del e
else:
return obj
[/mw_shl_code]
[Python] 纯文本查看 复制代码
from pyarmor_runtime_000000 import __pyarmor__
__pyarmor__(__name__, __file__, b'PY000000\x00\x03\x08\x00U\r\r\n\x80\x00\x01\x00\x08\x00\x00\x00\x04\x00\x00\x00@\x00\x00\x00?\x05\x00\x00\x12\t\x04\x00\x8c\xab\xe0h\x8aY\xe4U\xb6\x1e,r\x98\t\xf3g\x00\x00\x00\x00\x00\x00\x00\x00\x9f\xd9\x0e\xdd(\x00;\xa8\x0b\xdbv\x8c\x04}\x81]>\xa5H2\xdfy\xab\xb4(\xd0S\xbfS}fc\xc3c3>\xcc*;cX\xf9s*\x15p\xda\r\xc8d<,\x826\xe0c\xc0`9\xb6\xc4&\tn\x18\xb8G\x147\xe4J\xaem\x19\xef\x05\xf1\xce$UN\xbdm\x9c\xd3|\xa2\x80\xf5z)7\x9d\xf3_\x18TE\xa2\xd7\xeb\xf6%W+\t\x05v\xf3pD\x07b\xcaIj\t\t\x18\xe7AV\xfa\xe8H\x06\x95Z~<\xa1\x95\xfb\x808\x18\xec\xc1|\x84#:\xc1\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