Skip to content

Instantly share code, notes, and snippets.

@ParitoshSingh07
Created May 23, 2019 12:21
Show Gist options
  • Save ParitoshSingh07/9a9f270764f5ed4d0a961f05f7ae09e8 to your computer and use it in GitHub Desktop.
Save ParitoshSingh07/9a9f270764f5ed4d0a961f05f7ae09e8 to your computer and use it in GitHub Desktop.
SO Aran fey pickle
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!')
@ParitoshSingh07
Copy link
Author

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.

@Aran-Fey
Copy link

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