Hey there, how are you all? I hope everything is going smoothly and everyone is doing fine. Today, we're diving into the exciting world of OS Command Injection labs from portswigger. Get ready for some hands-on action!
So, the first thing we need to know is what OS command injection actually means.
A command injection allows attackers to run any commands they want by exploiting data handling vulnerabilities. This can lead to various attacks like injecting JavaScript or HTML code. OS Command Injection is a specific attack that enables the execution of commands on the target operating system or server.
Alright, let's begin, shall we?
LAB 1 : OS command injection
This lab contains an OS command injection vulnerability in the product stock checker. The application executes a shell command containing user-supplied product and store IDs, and returns the raw output from the command in its response. To solve the lab, execute the whoami
command to determine the name of the current user.
We got our hands on a web application in the lab, and boy, does it have a ton of products listed! Take a peek at the picture below to get an idea.
By viewing the details of a product, we can access detailed information about it. When we visit a specific product, a parameter called productId is set. Unfortunately, my attempt at command injection was unsuccessful because the API blocks all special characters. However, there is another functionality that allows us to check the availability of stocks. You can see it in the picture below.
Upon using the functionality to check for stocks we can see that we are getting some results. But we are not getting any changes in parameter. Maybe there is something hidden going on in the request that we are not aware about. This is where the tool burp suite comes in the picture. Burp suite is web proxy tool to analyzing the requests or to modify requests or much more.
As we can see in above picture that when we capture the request of accessing the functionality of stock checker we see a hidden parameter called storeId is being used to fetch information. As we have already tested productId parameter for OS command injection and it is not vulnerable to it, now it is time to check for storeId parameter.
As we capture the request in burp suite now it is time to test OS command injection on the hidden parameter named storeId. We can use an special character to execute multiple commands at once. As we can in above picture that we use a pipe character to execute OS command on back-end server to test command injection. There are many other special characters that we can use like ‘ and & and many more. You can test it by yourself. As we forward the above edited request we can see the result in below picture.
From the picture above, it's clear that our random command ran without any issues. This means we can carry out OS command injection. We can also try testing other commands such as pwd, uname -a, netstate, and so on.
I want to express my gratitude to each and every one of you for investing your time in reading this. I hope you found it enlightening. If you have any feedback or questions, please share them in the comment section.
Happy hackers!!
Comments
Post a Comment