In this lecture, we are going to see what is command injection and how we can practice command injection
on Dvwa app.
We are going to solve all challenges of command execution on the.
Some websites allow you to execute commands through a web interface, typically to generate some reports.
The Dvwa provides a command execution module, which you can use to ping IP addresses.
We are to find a way to execute other commands from the same text box.
Now you should be on Kali Linux or Pirate OS in VMware VirtualBox or running natively on your PC.
Now let's first solve low difficulty command execution challenge.
Go to settings and set the difficulty to low.
We can use multiple ways to execute commands in the same text box.
The following commands will work fine and will execute.
You can see that we can even get a reverse shell as shown in the last example.
If we use the command with pink command, we can get the list of files in the same folder.
Now let's see what happens in medium difficulty.
Command Execution Challenge.
In medium difficulty.
Some type of input sanitization is being performed.
An ampersand and semicolon are blacklisted, but we can still use the pipe symbol to execute our commands.
Now let's get an overview of high difficulty command execution.
Now in this difficulty, even the pipe is blacklisted.
But there is a typo and the space is there.
We can enter it without space to get the same results.
Now let's solve them on actual application.
First of all set the difficulty of dvwa too low.
The go to command injection module.
Enter an address and click submit.
We will get a ping response.
Now, if we enter the same address with double ampersand.
And command.
We will get the list of all files in the same folder as well.
And we have successfully exploited our first vulnerability.
Now let's see how we can use this vulnerability to get a reverse shell.
First of all, start a netcat listener with NC 9001 command.
Now use the command as shown on the screen.
We are using Netcat to connect to our Netcat listener.
And you can see that we get a shell here.
You can execute different types of commands like LZ, VMI, etcetera.
Now change the setting to medium.
Go back to command initiation module.
And if you try to run the same command, you will see that we will not get any results.
If you look at the source.
You will see that double ampersand sign and semicolon signs are blacklisted.
Now you can use a pipe single to bypass this filter.
And get the results.
Now set the security level to high.
And try to run the same command.
We will not get any results.
If you look at the source code this time, we will see that many symbols are blacklisted.
But there is a typo in the pipe symbol.
Which has an extra space.
So we can type the same command without spaces and we can get the results.
So we have successfully completed the command execution challenges in all three difficulty modes.