Page cover

[Linux] Agent Sudo

This page aims to provide a clear and comprehensive write-up for the Agent Sudo room on TryHackMe. I used Kali Linux to conduct the penetration test.

Reconnaissance

As usual, we start with enumeration:

sudo nmap 10.10.74.238
PORT   STATE SERVICE
21/tcp open  ftp
22/tcp open  ssh
80/tcp open  http

Three open ports are identified in the 1-1000 range. Let's perform a deeper scan on these ports:

sudo nmap -A -p 21,22,80 10.10.74.238
PORT   STATE SERVICE VERSION
21/tcp open  ftp     vsftpd 3.0.3
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 ef:1f:5d:04:d4:77:95:06:60:72:ec:f0:58:f2:cc:07 (RSA)
|   256 5e:02:d1:9a:c4:e7:43:06:62:c1:9e:25:84:8a:e7:ea (ECDSA)
|_  256 2d:00:5c:b9:fd:a8:c8:d8:80:e3:92:4f:8b:4f:18:e2 (EdDSA)
80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Annoucement

Enumeration

HTTP

Starting with HTTP, let's check the website. A message indicates we need a specific user-agent, which is a "codename". Using R as a user-agent returns a message about 25 employees. We can perform a dictionnary attack on the user-agent using the alphabet letters as dictionnary.

The output hints that the FTP password for user "chris" is weak.

FTP

Next, let's perform FTP enumeration to check for weak credentials using hydra. Given the user "chris," we'll use a dictionary attack on the password.

Success! We retrieve the credentials: chris:crystal. Now, we can use this to connect to the FTP server and download any accessible files.

Steganography

The file To_agentJ.txt is accessible, but two images are unreadable. We'll use steganography techniques to extract information.

First, let's run binwalk on cutie.png to identify embedded files:

An embedded zip file, 8702.zip, requires a password.

We can retrieve it using john:

The password found is "alien". We can get access to "To_agentR.txt".

This file contains another passphrase. We use this to extract hidden data from cute-alien.jpg:

This yields additional credentials: james:hackerrules!.

The only service which left is SSH. Let's hack it!

Exploitation

We can try our credential on the ssh service.

It works and we get our first access to the host machine.

Privilege escalation

Upon logging in, we check sudo permissions and the version. The system is vulnerable to CVE-2019-14287, which allows privilege escalation:

Remediation

Last updated