The invention provides a Python
bytecode obfuscation method and
system based on
dynamic screening and
random replacement, and the method comprises the steps: calculating a plurality of safety indexes and a comprehensive
safety index SDI of
bytecode files, and screening out the
bytecode files which have high safety requirements and need to be obfuscated; a linear congruence generator is constructed, a pseudo-random number sequence is provided for
obfuscation operation of
byte codes, and operation code dynamic replacement
obfuscation operation is performed in
byte code instructions by generating random seeds, constructing random dynamic operation code mapping tables and applying the independent operation code mapping tables to different
byte code files needing to be obfuscated; and performing obfuscation state detection on the obfuscated bytecode file, if the detection result is the obfuscated bytecode file, modifying bytecode analysis and
instruction scheduling logic, increasing a runtime de-obfuscation process, embedding an
Opcode reflection mechanism, re-compiling to generate a customized Python
interpreter supporting the execution of the obfuscated bytecode, and executing the obfuscated bytecode file. According to the invention, byte codes can be confused.