arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Java - Command Injection 4 (CMD-4)

hashtag
Running the app on Docker

circle-check

Now that the app is running let's go hacking!

hashtag
Reconnaissance

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.

hashtag
Exploitation

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!

hashtag
Additional sources

$ sudo docker pull blabla1337/owasp-skf-lab:java-cmd4
$ sudo docker run -ti -p 127.0.0.1:5000:5000 blabla1337/owasp-skf-lab:java-cmd4
127.0.0.1 ; whoami
 ip = ip.replace("`", " ").replace(";", " ").replace("&"," ");
127.0.0.1 | whoami
OS Command Injection Defense - OWASP Cheat Sheet Seriescheatsheetseries.owasp.orgchevron-right
Command Injection | OWASP Foundationowasp.orgchevron-right
Logo
Logo