python项目加密
参考链接https://zhuanlan.zhihu.com/p/145811103
代码分析:
#!/usr/bin/env python3
import xdis
import types
import os
import opcode
import struct
import marshal
def pack32(n):
return struct.pack("<I", n)
def pack16(n):
return struct.pack("<H", n)
class Obscure:
'''Obscure() -> new empty Obscure object
Obscure(filename) -> new Obscure object load from file
'''
def __init__(self, filename=None):
self.float_version : float
self.magic_int : int
self.timestamp : int
self.co : types.CodeType
self.ispypy : bool
self.source_size : int
self.sip_hash : int
self.instr_offset : list
if filename is not None:
self.load_pyc(filename)
def _load_pyc(self, filename):
return xdis.load_module(filename)
def load_pyc(self, filename):
(
self.float_version,
self.timestamp,
self.magic_int,
self.co,
self.ispypy,
self.source_size,
self.sip_hash,
) = self._load_pyc(filename)
self.instr_offset = self.get_instr_offset_from_lnotab(self.co.co_lnotab)
def get_instr_offset_from_lnotab(self, lnotab):
assert(type(lnotab) == bytes)
assert