Created
September 19, 2019 23:20
-
-
Save MatthewScholefield/653543360d2a2bd8f9a7533088a0ffff to your computer and use it in GitHub Desktop.
Store and run Python source encoded in a massive integer
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 characters
obfuscate = lambda code: int(''.join(['{:08b}'.format(i) for i in list(bytes(code.encode()))]), 2) | |
run = lambda x: exec(bytes([int('{:b}'.format(x)[max(0, i - 8):i], 2) for i in range(len('{:b}'.format(x)) % 8, len('{:b}'.format(x)) + 1, 8) if i > 0])) | |
a = obfuscate("print('hello')") | |
b = a * 12 | |
# run(b) # Will error out | |
run(b / 12) # Prints "hello" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment