Python Jail Escape Handbook
Introduction to Python Jail
Definition, concept, common uses in CTFs and wargames.
Page 1
Python Jail Escape Handbook
Understanding `eval()` vs `exec()`
Detailed difference, what can be run, limitations.
Page 2
Python Jail Escape Handbook
Common Filters
Blacklists (e.g. keywords like 'import', '__'), whitelists, regex filters.
Page 3
Python Jail Escape Handbook
Bypass Techniques - String Manipulation
Using chr(), ord(), concatenation to evade filters.
Page 4
Python Jail Escape Handbook
Bypass Techniques - Builtin Abuse
Using __import__, getattr, eval, open, file class discovery.
Page 5
Python Jail Escape Handbook
Bypass Techniques - Subclasses Hack
Using ().__class__.__base__.__subclasses__() to find FileIO, etc.
Page 6
Python Jail Escape Handbook
Jail with Blacklist on 'flag'
Bypass using chr() and advanced obfuscation.
Page 7
Python Jail Escape Handbook
Jail with `ast.literal_eval`
Why it's safer, how to test if you're dealing with it.
Page 8
Python Jail Escape Handbook
Real World CTF Examples
Explained challenges from HTB, PicoCTF, etc.
Page 9
Python Jail Escape Handbook
String Encoding Tricks
Base64, URL encoding, unicode escape, raw strings.
Page 10
Python Jail Escape Handbook
Using Lambdas
Anonymous functions for tricking eval context.
Page 11
Python Jail Escape Handbook
Bypassing Whitelists
Crafting payloads from allowed inputs.
Page 12
Python Jail Escape Handbook
Command Execution from Eval
Using [Link], subprocess, or indirect execs.
Page 13
Python Jail Escape Handbook
Detection of Jail Environment
How to know what you're dealing with.
Page 14
Python Jail Escape Handbook
Jail Escaping Checklist
A step-by-step list of what to test in a jail.
Page 15
Python Jail Escape Handbook
Creating Your Own Python Jail
Write basic to advanced sandbox environments.
Page 16
Python Jail Escape Handbook
Securing Python Eval (Bonus)
Best practices to prevent eval/exec abuse.
Page 17
Python Jail Escape Handbook
Advanced Payload Obfuscation
Multi-layered encoding and dynamic code generation.
Page 18
Python Jail Escape Handbook
Sandbox Evasion Tactics
Timing attacks, using threads, and deeper escape hacks.
Page 19
Python Jail Escape Handbook
When All Else Fails
Fallback tricks, side channels, reverse engineering.
Page 20
Python Jail Escape Handbook
Introduction to Python Jail
Definition, concept, common uses in CTFs and wargames.
Page 21
Python Jail Escape Handbook
Understanding `eval()` vs `exec()`
Detailed difference, what can be run, limitations.
Page 22
Python Jail Escape Handbook
Common Filters
Blacklists (e.g. keywords like 'import', '__'), whitelists, regex filters.
Page 23
Python Jail Escape Handbook
Bypass Techniques - String Manipulation
Using chr(), ord(), concatenation to evade filters.
Page 24
Python Jail Escape Handbook
Bypass Techniques - Builtin Abuse
Using __import__, getattr, eval, open, file class discovery.
Page 25
Python Jail Escape Handbook
Bypass Techniques - Subclasses Hack
Using ().__class__.__base__.__subclasses__() to find FileIO, etc.
Page 26
Python Jail Escape Handbook
Jail with Blacklist on 'flag'
Bypass using chr() and advanced obfuscation.
Page 27
Python Jail Escape Handbook
Jail with `ast.literal_eval`
Why it's safer, how to test if you're dealing with it.
Page 28
Python Jail Escape Handbook
Real World CTF Examples
Explained challenges from HTB, PicoCTF, etc.
Page 29
Python Jail Escape Handbook
String Encoding Tricks
Base64, URL encoding, unicode escape, raw strings.
Page 30
Python Jail Escape Handbook
Using Lambdas
Anonymous functions for tricking eval context.
Page 31
Python Jail Escape Handbook
Bypassing Whitelists
Crafting payloads from allowed inputs.
Page 32
Python Jail Escape Handbook
Command Execution from Eval
Using [Link], subprocess, or indirect execs.
Page 33
Python Jail Escape Handbook
Detection of Jail Environment
How to know what you're dealing with.
Page 34
Python Jail Escape Handbook
Jail Escaping Checklist
A step-by-step list of what to test in a jail.
Page 35
Python Jail Escape Handbook
Creating Your Own Python Jail
Write basic to advanced sandbox environments.
Page 36
Python Jail Escape Handbook
Securing Python Eval (Bonus)
Best practices to prevent eval/exec abuse.
Page 37
Python Jail Escape Handbook
Advanced Payload Obfuscation
Multi-layered encoding and dynamic code generation.
Page 38
Python Jail Escape Handbook
Sandbox Evasion Tactics
Timing attacks, using threads, and deeper escape hacks.
Page 39
Python Jail Escape Handbook
When All Else Fails
Fallback tricks, side channels, reverse engineering.
Page 40
Python Jail Escape Handbook
Introduction to Python Jail
Definition, concept, common uses in CTFs and wargames.
Page 41
Python Jail Escape Handbook
Understanding `eval()` vs `exec()`
Detailed difference, what can be run, limitations.
Page 42
Python Jail Escape Handbook
Common Filters
Blacklists (e.g. keywords like 'import', '__'), whitelists, regex filters.
Page 43
Python Jail Escape Handbook
Bypass Techniques - String Manipulation
Using chr(), ord(), concatenation to evade filters.
Page 44
Python Jail Escape Handbook
Bypass Techniques - Builtin Abuse
Using __import__, getattr, eval, open, file class discovery.
Page 45
Python Jail Escape Handbook
Bypass Techniques - Subclasses Hack
Using ().__class__.__base__.__subclasses__() to find FileIO, etc.
Page 46
Python Jail Escape Handbook
Jail with Blacklist on 'flag'
Bypass using chr() and advanced obfuscation.
Page 47
Python Jail Escape Handbook
Jail with `ast.literal_eval`
Why it's safer, how to test if you're dealing with it.
Page 48
Python Jail Escape Handbook
Real World CTF Examples
Explained challenges from HTB, PicoCTF, etc.
Page 49
Python Jail Escape Handbook
String Encoding Tricks
Base64, URL encoding, unicode escape, raw strings.
Page 50
Python Jail Escape Handbook
Using Lambdas
Anonymous functions for tricking eval context.
Page 51
Python Jail Escape Handbook
Bypassing Whitelists
Crafting payloads from allowed inputs.
Page 52
Python Jail Escape Handbook
Command Execution from Eval
Using [Link], subprocess, or indirect execs.
Page 53
Python Jail Escape Handbook
Detection of Jail Environment
How to know what you're dealing with.
Page 54
Python Jail Escape Handbook
Jail Escaping Checklist
A step-by-step list of what to test in a jail.
Page 55
Python Jail Escape Handbook
Creating Your Own Python Jail
Write basic to advanced sandbox environments.
Page 56
Python Jail Escape Handbook
Securing Python Eval (Bonus)
Best practices to prevent eval/exec abuse.
Page 57
Python Jail Escape Handbook
Advanced Payload Obfuscation
Multi-layered encoding and dynamic code generation.
Page 58
Python Jail Escape Handbook
Sandbox Evasion Tactics
Timing attacks, using threads, and deeper escape hacks.
Page 59
Python Jail Escape Handbook
When All Else Fails
Fallback tricks, side channels, reverse engineering.
Page 60