Command Injection - Security Tutorials
Command Injection - Security Tutorials
uk/command-injection/
CATEGORIES
POPULAR TUTORIALS
1 of 14 11/17/2022, 11:46 AM
Command Injection - Security Tutorials https://securitytutorials.co.uk/command-injection/
MetaCharacters
2 of 14 11/17/2022, 11:46 AM
Command Injection - Security Tutorials https://securitytutorials.co.uk/command-injection/
3 of 14 11/17/2022, 11:46 AM
Command Injection - Security Tutorials https://securitytutorials.co.uk/command-injection/
4 of 14 11/17/2022, 11:46 AM
Command Injection - Security Tutorials https://securitytutorials.co.uk/command-injection/
Once you have clicked the view source you will be presented
with a new window displaying the PHP code above, which the
DVWA team have really nicely commented for us.
5 of 14 11/17/2022, 11:46 AM
Command Injection - Security Tutorials https://securitytutorials.co.uk/command-injection/
After running the command you can see the ping command
run and then the ls command listing all the directories
where the web application is running.
127.0.0.1&&ls -la
notice the command runs �ne with just the IP address but as
soon as you add the metacharacter ( && ) and your injected
command it does not output anything and reloads the page.
If you take a look at the source you can see the programmer
6 of 14 11/17/2022, 11:46 AM
Command Injection - Security Tutorials https://securitytutorials.co.uk/command-injection/
7 of 14 11/17/2022, 11:46 AM
Command Injection - Security Tutorials https://securitytutorials.co.uk/command-injection/
Now let’s open up the source code and take a look at what
changes have been made.
But all is not lost, notice the highlighted area in the blacklist
above, there is an error in the syntax, the programmer has
added an extra space after the | (pipe) Metacharacter and
the backtick. This means we should still be able to use
command injection as long as we don’t put any spaces in our
command and use the pipe like this.
8 of 14 11/17/2022, 11:46 AM
Command Injection - Security Tutorials https://securitytutorials.co.uk/command-injection/
9 of 14 11/17/2022, 11:46 AM
Command Injection - Security Tutorials https://securitytutorials.co.uk/command-injection/
10 of 14 11/17/2022, 11:46 AM