Targets and Payloads
What Are Targets?
In Metasploit, a target defines the specific configurations or versions of an operating system, application, or service that a module is designed to exploit.
Key Points:
Some modules automatically detect targets using
Automatic
mode.Others require manual specification of the target index for successful exploitation.
Managing Targets
Listing Available Targets:
Use the
show targets
command within a module to list supported targets:Example Output:
Selecting a Target:
Manually specify a target by its index:
Best Practices for Target Selection:
Use
Automatic
targeting (set target 0
) when unsure of the system version.Manually set the target index if you know the exact configuration for better reliability.
Cross-check system details using reconnaissance tools before selecting a target.
What Are Payloads?
Payloads are the code delivered to the target system once an exploit succeeds. They define the actions to be performed on the compromised system, such as opening a shell or maintaining persistent access.
Types of Payloads
Singles:
Self-contained payloads that perform a specific task without further dependencies.
Example:
windows/shell_bind_tcp
– Opens a shell bound to a TCP port.
Stagers:
Establish a connection (e.g., reverse or bind shell) and prepare the target for larger, staged payloads.
Example:
windows/meterpreter/reverse_tcp
.
Stages:
Provide advanced functionalities, downloaded by stagers after the initial connection is established.
Example:
meterpreter
– A powerful post-exploitation toolkit.
Staged vs. Non-Staged Payloads
Staged
Split into smaller parts for stealth.
windows/meterpreter/reverse_tcp
Non-Staged
Single, larger payload for simplicity.
windows/meterpreter_reverse_tcp
Popular Payload Types
Meterpreter:
A memory-resident payload with advanced post-exploitation features.
Example:
Generic Shells:
Provides basic shell access to the target.
Example:
Advanced Payloads:
Payloads that include specialized functionalities, such as VNC or PowerShell.
Examples:
windows/vncinject/reverse_tcp
– Provides remote desktop access.windows/x64/powershell_reverse_tcp
– Executes a reverse shell via PowerShell.
Configuring Payloads
Setting the Payload:
Select a payload compatible with the exploit:
Example:
Configuring Payload Options:
Use the
show options
command to view configurable parameters for the payload:Example Parameters:
LHOST
: Local host (attacker's IP).LPORT
: Listening port for the payload.RHOSTS
: Target host(s) IP address.
Setting Options:
Persistent Options:
Use
setg
to globally configure parameters across multiple modules:
Example: Exploiting MS17-010 with Payloads
Select the Exploit:
Set the Payload:
Configure Options:
Execute the Exploit:
Post-Exploitation:
After a successful session, interact with the Meterpreter shell:
Command Cheatsheet
show targets
Lists supported targets for the module.
set target <index>
Manually sets the target index.
show payloads
Lists compatible payloads for the exploit.
set payload <payload_name>
Assigns a payload to the exploit.
show options
Displays configurable parameters.
set <option> <value>
Configures a parameter for the payload.
setg <option> <value>
Sets a global parameter for all modules.