Created
October 19, 2019 01:42
Revisions
-
Andoryuuta created this gist
Oct 19, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ from xdis.load import load_module from xdis.code import Code2Compat import uncompyle6 import xdis.main import sys if __name__ == "__main__": if len(sys.argv) <= 1: print("Usage: anti_decomp.py <some_py2_file.pyc>") sys.exit(1) filename = sys.argv[1] filename_base = filename.split('.')[0] (version, timestamp, magic_int, co, pypy, source_size) = load_module(filename) opc = xdis.main.get_opcode(version, pypy) co_code = bytearray(len(co.co_code)) co_code[:] = co.co_code[:] co_code.append(0x9) # Add a NOP new_co = Code2Compat( co.co_argcount, co.co_nlocals, co.co_stacksize, co.co_flags, co_code, co.co_consts, co.co_names, co.co_varnames, co.co_filename, co.co_name, co.co_firstlineno, co.co_lnotab, co.co_freevars, co.co_cellvars, ) # Crashes with: Parse error at or near `None' instruction at offset -1 uncompyle6.main.decompile(version, new_co, sys.stdout)