acl-abuse
Exploits misconfigured Active Directory ACLs for privilege escalation. Covers GenericAll, GenericWrite, WriteDACL, WriteOwner,…
Exploit Python eval(), exec(), and compile() injection in web applications. Distinct from OS command injection (shell operators) and SSTI (template engines) — this targets direct Python code evaluation of user input.
Claude Code
$ npx -y skills add blacklanternsecurity/red-run --skill python-code-injection --agent claude-code
Codex
$ npx skills add blacklanternsecurity/red-run --skill python-code-injection -a codex -y
Cursor
$ npx skills add blacklanternsecurity/red-run --skill python-code-injection -a cursor -y
Gemini CLI
$ npx skills add blacklanternsecurity/red-run --skill python-code-injection -a gemini-cli -y
GitHub Copilot
$ npx skills add blacklanternsecurity/red-run --skill python-code-injection -a github-copilot -y
OpenCode
$ npx skills add blacklanternsecurity/red-run --skill python-code-injection -a opencode -y
Windsurf
$ npx skills add blacklanternsecurity/red-run --skill python-code-injection -a windsurf -y
name: python-code-injection description: > Exploit Python eval(), exec(), and compile() injection in web applications. Distinct from OS command injection (shell operators) and SSTI (template engines) — this targets direct Python code evaluation of user input. keywords: - python eval injection - eval() exploit - exec() injection - python code injection - expression injection - Searchor exploit - python sandbox escape - __import__ injection - __subclasses__ exploit - __builtins__ bypass - compile() injection - python RCE tools: - burpsuite - curl opsec: medium
You are helping a penetration tester exploit Python code injection via eval(), exec(), or compile(). The target application passes user-controlled input to a Python code evaluation function without proper sanitization. The goal is to execute arbitrary Python code and escalate to OS command execution. All testing is under explicit written authorization.
**This is NOT OS command injection.** Shell operators (`;`, `|`, `&&`) do not work because the injection context is a Python interpreter, not a shell. You must write valid Python expressions or statements.
**This is NOT SSTI.** Template injection targets Jinja2/Twig/Freemarker rendering engines. This skill targets direct eval()/exec() calls in application code. If `{{7*7}}` returns `49`, route to **ssti-jinja2** or **ssti-twig** instead. If `{{7*7}}` returns literally but `7*7` evaluates, you're in the right place.
Check for `./engagement/` directory. If absent, proceed without logging.
When an engagement directory exists:
descriptive filenames (e.g., `sqli-users-dump.txt`, `ssrf-aws-creds.json`).
This skill covers Python code injection through eval(), exec(), and compile() — from confirming the injection through achieving OS command execution. When you reach the boundary of this scope — whether through completing your methodology or discovering findings outside your domain — **STOP**.
Do not load or execute another skill. Do not continue past your scope boundary. Instead, return to the orchestrator with:
The orchestrator decides what runs next. Your job is to execute this skill thoroughly and return clean findings.
**Stay in methodology.** Only use techniques documented in this skill. If you encounter a scenario not covered here, note it and return — do not improvise attacks, write custom exploit code, or apply techniques from other domains. The orchestrator will provide specific guidance or route to a different skill.
Call `get_state_summary()` from the state MCP server to read current engagement state. Use it to:
Your return summary must include:
builders, dynamic filters, format string handlers, custom DSLs backed by eval
If not already provided, determine:
1. **Injection function** — eval() (expressions only) vs exec() (statements) vs compile() (either) 2. **Injection context** — is input placed inside a string literal, as a bare argument, in an f-string, or concatenated into code? 3. **Visible or blind** — is the return value of eval() reflected in the response, or is this blind (side-channel only)? 4. **Sanitization** — are any characters filtered? (quotes, parens, underscores, dots, brackets)
| Feature | eval() | exec() | |---------|--------|--------| | Accepts | Expressions only | Statements and expressions | | Returns | Expression result | None | | `import os` | SyntaxError | Works | | Multi-line | No (single expression) | Yes | | Assignment (`x=1`) | SyntaxError | Works |
If you can execute `__import__('os')` but not `import os`, it's likely eval(). If both work, it's likely exec() or compile().
**Pattern 1: String interpolation into eval** (most common)
# Application code:
result = eval(f"func('{user_input}')")
# Injection: break out of the string, inject code, comment out remainder**Pattern 2: Direct eval of parameter**
# Application code:
result = eval(request.args.get('expr'))
# Injection: any Python expression works directly**Pattern 3: exec() with string building**
# Application code:
exec(f"variable = '{user_input}'")
# Injection: break out of string, inject statements**Pattern 4: eval() in ORM/filter context**
# Application code:
query = eval(f"Model.objects.filter({user_input})")
# Injection: close the filter, chain arbitrary codeSkip assessment if context was already provided by web-discovery or the orchestrator.
Test these in order — the first one that returns an evaluated result (not a literal echo) confirms eval() injection:
# Arithmetic — most universal
7*7
str(7*7)
# String operations
'A'*3
str(type(1))
# Python builtins
str(True)
str(len('test'))**Expected responses for
Security assessment toolkit for Claude Code. red-run combines skills, MCP servers, and Claude Code agent teams with routing logic that guides Claude and the operator through the phases of a security assessment — recon, initial access, lateral movement,
Exploits misconfigured Active Directory ACLs for privilege escalation. Covers GenericAll, GenericWrite, WriteDACL, WriteOwner,…
Enumerates Active Directory domains and maps attack surface for penetration testing.
Establishes persistent access in Active Directory environments after domain compromise. Covers DCShadow (rogue DC attribute…
Exploits ADCS through ACL abuse on templates/CA objects and NTLM relay to enrollment endpoints. Covers ESC4 (template ACL →…
Establishes persistence and exploits weak certificate mapping in AD CS. Covers ESC9 (no security extension), ESC10 (weak…
Exploits misconfigured AD CS certificate templates to impersonate any domain user via SAN manipulation or enrollment agent abuse.…
Use for authorized security assessment of REST, GraphQL, WebSocket, or SOAP APIs, including discovery, authentication,…
Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys)…
Clean and finalize authorized natural-language text intended for readers by auditing suspicious invisible Unicode and rewriting…