@@ -92,13 +92,15 @@ def listener_uri
92
92
# addresses.
93
93
#
94
94
# @return [String] A URI of the form +scheme://host:port/+
95
- def payload_uri
96
- if ipv6?
97
- callback_host = "[#{ datastore [ 'LHOST' ] } ]"
95
+ def payload_uri ( req )
96
+ if req and req . headers and req . headers [ 'Host' ]
97
+ callback_host = req . headers [ 'Host' ]
98
+ elsif ipv6?
99
+ callback_host = "[#{ datastore [ 'LHOST' ] } ]:#{ datastore [ 'LPORT' ] } "
98
100
else
99
- callback_host = datastore [ 'LHOST' ]
101
+ callback_host = " #{ datastore [ 'LHOST' ] } : #{ datastore [ 'LPORT' ] } "
100
102
end
101
- "#{ scheme } ://#{ callback_host } : #{ datastore [ 'LPORT' ] } /"
103
+ "#{ scheme } ://#{ callback_host } /"
102
104
end
103
105
104
106
# Use the {#refname} to determine whether this handler uses SSL or not
@@ -186,7 +188,7 @@ def on_request(cli, req, obj)
186
188
case uri_match
187
189
when /^\/ INITPY/
188
190
conn_id = generate_uri_checksum ( URI_CHECKSUM_CONN ) + "_" + Rex ::Text . rand_text_alphanumeric ( 16 )
189
- url = payload_uri + conn_id + '/'
191
+ url = payload_uri ( req ) + conn_id + '/'
190
192
191
193
blob = ""
192
194
blob << obj . generate_stage
@@ -221,7 +223,7 @@ def on_request(cli, req, obj)
221
223
222
224
when /^\/ INITJM/
223
225
conn_id = generate_uri_checksum ( URI_CHECKSUM_CONN ) + "_" + Rex ::Text . rand_text_alphanumeric ( 16 )
224
- url = payload_uri + conn_id + "/\x00 "
226
+ url = payload_uri ( req ) + conn_id + "/\x00 "
225
227
226
228
blob = ""
227
229
blob << obj . generate_stage
@@ -249,7 +251,7 @@ def on_request(cli, req, obj)
249
251
250
252
when /^\/ A?INITM?/
251
253
conn_id = generate_uri_checksum ( URI_CHECKSUM_CONN ) + "_" + Rex ::Text . rand_text_alphanumeric ( 16 )
252
- url = payload_uri + conn_id + "/\x00 "
254
+ url = payload_uri ( req ) + conn_id + "/\x00 "
253
255
254
256
print_status ( "#{ cli . peerhost } :#{ cli . peerport } Staging connection for target #{ req . relative_resource } received..." )
255
257
resp [ 'Content-Type' ] = 'application/octet-stream'
@@ -294,7 +296,7 @@ def on_request(cli, req, obj)
294
296
create_session ( cli , {
295
297
:passive_dispatcher => obj . service ,
296
298
:conn_id => conn_id ,
297
- :url => payload_uri + conn_id + "/\x00 " ,
299
+ :url => payload_uri ( req ) + conn_id + "/\x00 " ,
298
300
:expiration => datastore [ 'SessionExpirationTimeout' ] . to_i ,
299
301
:comm_timeout => datastore [ 'SessionCommunicationTimeout' ] . to_i ,
300
302
:ssl => ssl? ,
0 commit comments