Host & Network Penetration Testing: Exploitation CTF 3 — Walkthrough

Host & Network Penetration Testing: Exploitation CTF 3

Last updated: July 17, 2025

Hi everyone! In this article, we will solve Host & Network Penetration Testing Exploitation CTF 3 (eJPTv2). I will not share the flags because I don’t want you to copy and paste them, but rather solve it yourself and follow my instructions, so sit back and read!

Flag 1: A vulnerable service may be running on target1.ine.local. If exploitable, retrieve the flag from the root directory.

As usual, run a nmap scan on the first target.

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

ProFTPD 1.3.5 is vulnerable; let’s check it in the MSF for any exploit module.

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

There is an exploit module for it, use it and let’s check which options are there and what we need to configure.

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

Set RHOSTS, LHOST, and run it!

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

hmm… We received an error, telling us that ‘copying PHP payload to website path, directory not writable

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

If we see the options of the module, the SITEPATH is set to ‘/var/www

Because the directory in which the payload was uploaded is not writable, ‘/var/www

We can only upload it in the ‘/var/www/html’ directory

So change the SITEPATH to /var/www/html

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

Don’t worry about the error, just list out the sessions and there will be!

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

List the content of the directory, and there will be the flag!

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

We also got a hint, letmein, probably it might be a user!

Flag 2: Further, a quick interaction with a local network service on target1.ine.local may reveal this flag. Use the hint given in the previous flag.

Now we have to enumerate the local network services in our first target that we have already compromised

We can view network services by:

netstat -tuln

It will display all the TCP and UDP connections

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

interesting… PORT 80, 21 are utilized by the services that we already know from our nmap scan

PORT 8888 is interesting, as the remaining two ports are our sessions

Let’s connect to port 8888 by using the ‘nc’ utility

nc -v 127.0.0.1 8888

It will ask for the passphrase, it is the same that we found in the first flag: letmein

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

Flag 3: A misconfigured service running on target2.ine.local may help you gain access to the machine. Can you retrieve the flag from the root directory?

Now it’s time to compromise the second machine! The question tells us that there is a misconfigured service running, probably we have to brute-force 🙂

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

SAMBA is running. As it is not vulnerable, we have to brute-force it

We will use the ‘smb_login’ module of MSF

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

set password and username wordlists

set PASS_FILE /usr/share/metasploit-framework/data/wordlists/unix_passwords.txt
set USER_FILE /usr/share/metasploit-framework/data/wordlists/unix_users.txt
set VERBOSE false
Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough
Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

Now we have multiple accounts and their passwords! But which account will have the flag?

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

The answer is: the privileged account: administrator

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

Now we will use the same module to gain access, set SMBUser and SMBPass

also set ‘CreateSession true

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

As you will run it, you have to manually check for the created sessions

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

Once we get access, we can list out the shares by the command: shares

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

Let’s check out the ‘site-uploads’ share. We will use the smbclient utility

smbclient //<IP>/site-uploads -U administrator
Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

Hmm.. Nothing there, what if we upload a reverse shell and get access to the target machine?

We will use the ‘php-reverse-shell.php’, firstly we will copy it to our working directory, then rename it for our ease

then edit the file, enter your machine’s IP and Port Number

cp /usr/share/webshells/php/php-reverse-shell.php .
mv php-reverse-shell.php shell.php
Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

Now let’s upload that shell into the Samba share by putting shell.php

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

Before triggering the shell, we have to listen on that port using the netcat utility

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

To trigger the shell, we have to navigate to the browser, and head towards the: http://target2.ine.local/site-uploads/shell.php

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

And we will get the reverse shell! List out the contents, and there will be the flag!

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

Flag 4: Can you escalate to root on target2.ine.local and read the flag from the restricted /root directory?

Now we have to escalate our privileges!

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

We will start by checking the shells available on the system using the command: cat /etc/shells.

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

To check the permissions each shell has, use the command:

cat /etc/shells | while read shell; do ls -l $shell 2>/dev/null; done

The above command reads each shell listed in /etc/shells, then checks its permissions using ls -l, and suppresses any errors with 2>/dev/null.

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

It means we can use any shell with the permission ‘lrwxrwxrwx’ for escalation.

Now, to check for executables with the SetUID bit set that can run with root privileges, use the command:

find / -perm -4000 2>/dev/null

The Above command will work like:

Find /: Starts searching from the root directory /

-perm -4000: Looks for files with the SetUID permission bit set. This allows users to execute the file with the permissions of the file’s owner.

2>/dev/null: Suppresses error messages by redirecting them to /dev/null, effectively ignoring them.

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

So it means we can run the find command as well

What we are doing is that we are finding files with the ‘s’ bit set.

By combining the find command with an executable like /bin/shor, /bin/rbash, we can spawn a new shell with root privileges!

find / -exec /bin/rbash -p \; -quit
Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

Yes! We escalated our privileges!

Host & Network Penetration Testing Exploitation CTF 3 — Walkthrough

And there you go! It was pretty easy. See you in the next Challenge!

Good luck hackers

Leave a Comment

Your email address will not be published. Required fields are marked *