Java - Command Injection 4 (CMD-4)

Running the app on Docker

$ sudo docker pull blabla1337/owasp-skf-lab:java-cmd4
$ sudo docker run -ti -p blabla1337/owasp-skf-lab:java-cmd4

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

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 ; whoami

We get nothing back, maybe this application has a blacklist

 ip = ip.replace("`", " ").replace(";", " ").replace("&"," ");

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: | whoami

And we have a command injection!

Additional sources

Last updated