Reader small image

You're reading from  Practical Web Penetration Testing

Product typeBook
Published inJun 2018
PublisherPackt
ISBN-139781788624039
Edition1st Edition
Right arrow
Author (1)
Gus Khawaja
Gus Khawaja
author image
Gus Khawaja

Gus Khawaja holds a bachelor's degree in computer science. He specializes in IT security and ethical hacking. He is an author and shares his passion with millions of viewers around the world using his online courses. He also works as a cybersecurity consultant in Montreal, Canada. After many years of experience in programming, he turned his attention to cybersecurity and the importance that security brings to this minefield. His passion for the ethical hacking mixed with his background in programming and IT makes him a wise swiss-knife professional in the computer science domain.
Read more about Gus Khawaja

Right arrow

Understanding Web Application Vulnerabilities

This chapter is going to be your main pillar of application security. You will learn the logic behind the most popular vulnerabilities in this field. Most attacks that are executed remotely use the web application infrastructure to get in. Finding a vulnerability such as SQL Injection on a site can be very harmful, as the attacker can take complete control of the server.

Web applications are written in different programming languages, but the most popular ones are Java, .NET, and PHP. These days, we see a shift in web application programming, where the JavaScript language or the frontend takes an important part. Companies are using light-weight frontend technologies such as AngularJS to implement the idea of Single-Page Applications. As an application security pentester, you need to be aware of the vulnerabilities that exist for these...

File Inclusion

As the name suggests, this vulnerability can be exploited by including a file in the URL (by entering the path). The file that was included can be local to the server, and thus be called Local File Inclusion, or it (the path of the file) can point to a remote file, and thus be called a Remote File Inclusion.

Modern programming languages and web servers have built-in mechanisms to protect against this flaw. Unfortunately, in real life, you will encounter a lot of applications developed by legacy programming languages such as JSP (Java), ASP (Microsoft), and PHP, so the chance of finding a similar vulnerability is still there. One problem that can cause this issue is when the developer forgets to include a validation on the server side.

Local File Inclusion

...

Cross-Site Scripting

Cross-Site Scripting (XSS), is exploited when the attacker can successfully execute any type of script (for example, JavaScript) on the victim's browser. These types of flaws exist because the developer did not validate the request or correctly encoded the response of the application. JavaScript is not the only script language used for XSS but it is the most common (in fact it's my favorite); attackers sometimes use scripting languages such as VBScript, ActiveX, Flash, and many more.

XSS is very popular and I encounter it every day while testing web applications. Every time I see a message displayed on the page that reflects a user input or behavior, then most probably it is vulnerable to XSS. But don't worry, with experience and practice, things will become more obvious to you as well. There are three types of XSS attacks: Stored, Reflected...

Cross-Site Request Forgery

A Cross-Site Request Forgery (CSRF) (some people pronounce it as sea surf), can be exploited when an attacker takes advantage of the user session to perform state-changing requests such as posting to a social network platform, money transfers, and much more.

This attack will involve some social engineering efforts from the attacker to convince the victim to visit the infected site. Imagine that the victim is an admin of a system, then the attacker can manipulate that system if it doesn't have a CSRF protection. The most popular question in interviews for Application Security Engineer positions is the following: What is the difference between XSRF and XSS? The simpler the answer is, the better. In summary, XSS attacks rely on executing JavaScript in the victim's browser, while XSRF relies on taking advantage of the victim's session. Next...

SQL Injection

The SQL Injection is my favorite one, and it's the most dangerous one that you will encounter in your career. An SQL Injection vulnerability will allow a malicious user to execute SQL commands on the database through the web browser. The cause of this problem is like any other web vulnerability; the developer forgot to add any validation on the server side to protect against SQLi attacks.

Here's the most interesting part; an SQLi vulnerability will allow you to do the following:

  • Query the database using a select statement (for example, select the users table, thereby extracting the usernames and passwords)
  • Bypass the login page by executing successful query results (you'll see an example soon)
  • Execute system commands in the database in order to compromise the web server
  • Execute inserts/delete commands to manipulate the records in the database

It...

Command Injection

Command Injection is very simple, you just exploit it by executing commands on a web page because it allows you to do so. In other words, if you ever see a page that offers the functionality of executing a command in the backend, then it's probably vulnerable to this attack. Command Injection is very popular in Capture the Flag (CTF) because it allows you to completely own a remote machine (the machine that hosts the web application).

As usual, let's see a practical example using Mutillidae. Open the left menu OWASP 2017 | Injection | Command Injection | DNS Lookup:

This page executes the DNS Lookup command in the backend. In this example, I entered the IP address 10.0.0.1 and clicked on the Lookup DNS button.

Do you think we can override the normal behavior of this page and execute any command of our liking? (Or maybe execute a backdoor such as netcat...

OWASP Top 10

In the preceding section, you've seen the most important web application vulnerabilities in the OWASP Top 10. The OWASP list includes even more items than what you have witnessed up until now. Application Security Professionals always keep the OWASP Top 10 as a reference in their career. This list is always kept up to date by the OWASP community and the latest version is the one that you saw in the Mutillidae Menu OWASP Top 10 – 2017; if you're reading this book in the future then there will probably be a newer list.

If you have any doubts about the understanding of any of the top 10 items, then don't worry, because we will revisit those items one more time in the web intrusion tests later in this book with more practical examples; for the time being, try to see the big picture.

Let's take a look at the Top 10 items in a simplified way so...

Summary

I hope that you understood this chapter very well! I mean it; this chapter is key to your success in understanding application security vulnerabilities. If you're hesitant about any of the preceding topics, please stop and try to review them one more time. You should already have installed Mutillidae on your lab machine and started practicing all the preceding examples.

The topics that we discussed in this chapter do not incorporate all web application vulnerabilities, but I covered the most important ones that you will encounter in your career. SQLi is the most dangerous one and XSS is the most popular one that you will face during Web Intrusion Tests.

Later, we will re-visit these vulnerabilities over and over again, and that's why you must master this chapter; if you don't, you will find the upcoming chapters difficult to understand.

...
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Practical Web Penetration Testing
Published in: Jun 2018Publisher: PacktISBN-13: 9781788624039
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Gus Khawaja

Gus Khawaja holds a bachelor's degree in computer science. He specializes in IT security and ethical hacking. He is an author and shares his passion with millions of viewers around the world using his online courses. He also works as a cybersecurity consultant in Montreal, Canada. After many years of experience in programming, he turned his attention to cybersecurity and the importance that security brings to this minefield. His passion for the ethical hacking mixed with his background in programming and IT makes him a wise swiss-knife professional in the computer science domain.
Read more about Gus Khawaja