Receiving /test confirms command execution and outbound connectivity.
Injection Operators
UNIX
Common Unix shell operators include:
; # Execute the following command\n # Terminate the current command& # Run the preceding command asynchronously| # Pipe output into another command&& # Continue if the previous command succeeds|| # Continue if the previous command fails$() # Execute a command and substitute its output
Backticks perform legacy command substitution:
`id`
$() and backticks are substitutions, not command separators.
Windows
CMD
On Windows CMD, the most relevant operators are:
&&&|||
A semicolon is not normally a CMD separator. PowerShell uses ; and newlines, while && and || require PowerShell 7 or later.
Identify the operating system and command processor before selecting payload syntax.
Quoting Context
The payload depends on how the application surrounds the input.
Unquoted
127.0.0.1;id;#
Double Quoted
Unix shells still process command substitution inside double quotes:
$(id)
Single Quoted
Single quotes suppress expansions, so the quote must normally be terminated:
127.0.0.1';id;#
The exact payload depends on the prefix, suffix and quoting added by the application.
Command Injection in JSON
The input may originate from query parameters, form data, JSON, headers, filenames or stored database values.
Command injection modifies the structure of the command line and executes additional commands.
Argument injection preserves the original executable but introduces unintended options or operands.
Webapp PHP Code
system('curl ' . escapeshellarg($_GET['url']));
escapeshellarg() prevents shell metacharacters from escaping the argument, but a value such as the following may still be interpreted as a curl option:
--help
Shell escaping must therefore be combined with validation of the argument’s expected meaning.
Mitigation
Avoid invoking operating-system commands whenever a native API exists.