💎Command Injection
CMD injection Nuclei template Payload
https://vulnerable-website/endpoint?parameter=%26ls||id%26How to Detect and Exploit Them?
Imagine you are testing the parameters of the following URL during a pentest:
https://vulnerable-website/endpoint?parameter=123 To detect if the source code is not protecting against command injection, we can try a couple of methods:
Insert special characters to detect Delimiter:
We can inject some special characters to see if the application blocks anything that could be used for command injection:
&
;
Newline (0x0a or \n)
&&
|
||
??In case the application doesn’t throw any error messages, we can try injecting our command after using one of these delimiters.
----------------------------------------------------------------
Detecting Blind OS command injection:
Time delays
Most of the OS command injections are Blind, which doesn’t give any output for the executed command. To verify the vulnerability, after detecting allowed special characters, we can verify the command injection using time delays as below:
----------------------------------------------------------------
Redirecting output
You can also redirect the output of the command in an output file and then retrieve the file on your browser. A payload similar to the following can be used:
----------------------------------------------------------------
OOB (Out Of Band) Exploitation
You can also trigger an OOB network interaction with an external server such as Burp Collaborator. A payload similar to the following can be used:
Or you can exfiltrate the output of your command using a payload similar to the following:
----------------------------------------------------------------
OS command injection, simple case
Use Burp Suite to intercept and modify a request that Calls the Function query.
-------------------------------------------------------------
Blind OS Command injection with time delays
Use Burp Suite to intercept and modify a request that Calls the Function query.
-------------------------------------------------------------
Blind OS command injection with output redirection
Use Burp Suite to intercept and modify a request that Calls the Function query.
-------------------------------------------------------------
Blind OS command injection with out-of-band interaction
Use Burp Suite to intercept and modify a request that Calls the Function query.
-------------------------------------------------------------
Blind OS command injection with out-of-band data exfiltration
-------------------------------------------------------------
Last updated