Basic Pentesting

Date: 09, March, 2021

Author: Dhilip Sanjay S


Click Herearrow-up-right to go to the TryHackMe room.

Learning Objectives

  • In these set of tasks you'll learn the following:

    • brute forcing (Hydra, Gobuster)

    • hash cracking (JohnTheRipper)

    • service enumeration (enum4linux)

    • Linux Enumeration (Linpeas)


Solutions

Find the services exposed by the machine

Starting Nmap 7.91 ( https://nmap.org ) at 2021-03-09 21:26 IST
Nmap scan report for 10.10.21.87
Host is up (0.17s latency).
Not shown: 994 closed ports
PORT     STATE SERVICE     VERSION
22/tcp   open  ssh         OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0)
80/tcp   open  http        Apache httpd 2.4.18 ((Ubuntu))
139/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
8009/tcp open  ajp13       Apache Jserv (Protocol v1.3)
8080/tcp open  http        Apache Tomcat 9.0.7
Service Info: Host: BASIC2; OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 16.07 seconds

What is the name of the hidden directory on the web server?

  • Answer: development

  • Steps to Reproduce:


User brute-forcing to find the username & password

  1. Running Enum4Linux - To enumerate SMB

  • We find two user names - jan and kay.

  • Now we'll try to bruteforce the password of jan.

  • Because, in the /development directory, we had a text file in which K (refers to kay) mentioned that the password of J (refers to jan) was easily crackable.

  1. HYDRA:

    • Using Hydra to bruteforce the username and password

    • Example: hydra -L users.txt -P passwords.txt ssh://$ip -t 4

    • Options used and their explanations:

      • L flag - specifies a list of login names as file

      • l flag - login name

      • P flag - specifies a list of passwords

      • ssh://$ip - our target and protocol

      • t flag - number of parallel tasks to run

  1. Nmap NSE SSH-brute was faster than hydra.

  1. You can also use msfconsole to bruteforce the credentials.

  • We found jan's password:armando.


What is the username?

  • Answer: jan


What is the password?

  • Answer: armando


What service do you use to access the server(answer in abbreviation in all caps)?

  • Answer: SSH


Enumerate the machine to find any vectors for privilege escalation

  • We could find that there is a password backup file in kay's directory - pass.bak. But it has no read permission.

  • So, we'll try to run linpeas.sh to find possible vectors for priv esc.

  • wget linpeas.sh into any folder where you have the write permission.

  • After running, we find that the SSH private key (id_rsa) of Kay has read permissions.

  • Copy the contents of the id_rsa file. (Private Key) and store it in your local machine.

  • Try to login using the private key.

    • ssh -i flag - used for identity file.

  • It's asking for a password. But, we don't have it yet.


What is the name of the other user you found(all lower case)?

  • Answer: kay


If you have found another user, what can you do with this information?

  • Answer: We can try to escalate our privileges to gain root access. May be that user can have additional permissions which can be exploited to gain root access.


What is the final password you obtain?

  • Answer: heresareallystrongpasswordthatfollowsthepasswordpolicy$$

  • Steps to Reproduce:

  • Now, we'll try to brute force the ssh passphrase using john.

  • Convert the id_rsa file using ssh2john.py so that it can be fed to John for bruteforcing the passphrase.

  • Login using the the ssh private key and provide the passphrase.


References


Last updated