So you ask who is this OWASP and why do I care?
Well, let’s hear it directly from them: “Open Web Application Security Project (OWASP) is a 501(c)(3) worldwide not-for-profit charitable organization focused on improving the security of software. Our mission is to make software security visible, so that individuals and organizations are able to make informed decisions. OWASP is in a unique position to provide impartial, practical information about AppSec to individuals, corporations, universities, government agencies, and other organizations worldwide. Operating as a community of like-minded professionals, OWASP issues software tools and knowledge-based documentation on application security.” (https://OWASP.org)
Whether you’re a pentester or a developer, you should be well versed in OWASP and the information they provide. One of their most well-known offerings is their Top 10 Application Security Risks. OWASP lists Injection as the top #1 vulnerability in their Top 10 list of application vulnerabilities.
Today, let’s look at Command Injection together. This occurs when the data added to the input contains code the attacker wants to be run by the operating system of the system hosting the vulnerable web page or application.
So, let’s see how this is attack works in an application and how we can exploit it. I will be using SamuraiWTF in this demonstration. You can download the current release of Samurai from GitHub
Once I have Samurai loaded up I am going to launch Burp. As shown below, Burp can be found by right clicking on screen in the VM.
As an aside, if you have never used Burp before I recommend taking a look at another one of our posts found at the following link https://blog.secureideas.com/2018/03/burp-suite-continuing-the-saga.
Once I have Burp running, I want to set up my Firefox browser to use Burp. Make sure you change your proxy configuration, as shown below, so all traffic will be routed through Burp.
Also I need to make sure Intercept is turned off in Burp. Otherwise, Burp will hold all web requests and wait for you to manually forward them to the server.
Next I open up the DVWA application by typing http://dvwa.wtf in my Firefox browser. Now I need to go through and map out the application by clicking on every function in the application. Additionally for this example to work, I need to change the security level to Low.
Once I have mapped out each function I can go back to Burp and look at the Site map tab under the Target tab and find the Post request from http://dvwa.wtf/vulnerabilities/exec/.
Now I am going to send that action to Repeater to manipulate the request. My goal is to break out of the context the application is executing. (Note the Content Length of the request to compare it later.)
As a quick tip, when using Repeater you always want to press the Go button prior to manipulating the request. This will allows us to verify that the session is still good and there is no anti-replay protections.
Now we are going to input a payload into the request to see what happens. I am going to replace ip=localhost&Submit=Submit with ip=localhost;ls -l / ; whoami;uname-a&Submit=Submit. Notice that I am adding commands and a ; (semi-colon) to attempt to break the context the application is running the payload within. You can use any system commands but using something like these that return output and aren’t interactive are often best.
I then press the Go button to have Burp Suite send the request to the application. If I look at the response, we can see the payload appears to have executed. We see this because the response contains the output from the commands I injected. In the screenshot below, we see the directory listing and the username the application is running as root.
So that shows an example of how Command Injection can be found and exploited. Stay tuned to https://blog.secureideas.com for more great articles and tutorials similar to this one. You can also join our Slack channel at www.professionallyevil.com where you can chat with fellow security professionals.
*** This is a Security Bloggers Network syndicated blog from Professionally Evil Insights authored by Larry Franklin. Read the original post at: https://blog.secureideas.com/2019/02/owasps-most-wanted.html