Created
May 23, 2019 12:21
-
-
Save ParitoshSingh07/9a9f270764f5ed4d0a961f05f7ae09e8 to your computer and use it in GitHub Desktop.
SO Aran fey pickle
This file contains 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
import pickle | |
winner = False | |
#data = b'c__builtin__\neval\n(Vprint("Bang! From, Evan.")\ntR.' | |
data = b'c__builtin__\neval\n(Vexec("winner=True")\ntR.' | |
pickle.loads(data) | |
# validate the solution | |
assert winner, "You didn't toggle the variable" | |
print('You win!') |
Yeah, pickle supports multiple interfaces that let you customize how your data is pickled. The easiest one to abuse is __reduce__
, which literally lets you call an arbitrary (pickleable) function with arbitrary (pickleable) arguments.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It was that simple? breaks down and starts crying I went through a deep dive of how pickle generates its strings, ending up with an article that implemented a pickle bomb. https://intoli.com/blog/dangerous-pickles/ They talk about a package called pickletools.