Loading...
Loading...
Now that the app is running let's go hacking!
The command injecion is an attack in which the goal is execution of arbitrary commands on the host operating system via a vulnerable application. Command injection attacks are possible when an application passes unsafe user supplied data (forms, cookies, HTTP headers etc.) to a system shell. In the first step, the attacker needs to inspect the functioning of the web app in order to find possible injection points.
When we start the application we can see that there is a box where we can write an IP address in order to execute a ping against it.
First, we are going to try the functionality and execute the ping against the loopback address. We can also see the resulted output:
For this lab we are going to try to make the website show us the result of a malicious command executed by the system unintentionally. We start by trying methods like:
It seems that it may not be possible to execute OS commands taking advantage of the ping functionality. However, we suspect that maybe the website is filtering some of these special characters usually used for command execution so we try some new:
We finally could execute a command (whoami)!!
Now we try with another simple example:
Goal achieved and filter bypassed!
Now that the app is running let's go hacking!
When we start the application we can see that we can ping an adress.
Let's try to ping 127.0.0.1
We get back the output of the ping command which tell us this might be vulnerable to a command injection.
Let's try chaining commands
We get nothing back, maybe this application has a blacklist
We can see in this piece of code the app is removing certain dangerous characters in an attempt to avoid some kind of command injection. Unfortunately there are ways to bypass this blacklist approach. Let's try piping the commands:
And we have a command injection!