Skip to content

Commit 9a605e5

Browse files
committed
Initialize the info for web sockets
1 parent 5c95aa6 commit 9a605e5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/msf/core/handler/bind_aws_ssm.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,10 @@ def start_handler
271271
# Configure Channel
272272
chan._start_ssm_keepalive if datastore['SSM_KEEP_ALIVE']
273273
chan.params.comm = Rex::Socket::Comm::Local unless chan.params.comm
274+
chan.params.peerhostname = peer_info['ComputerName']
274275
chan.params.peerhost = peer_info['IpAddress']
275276
chan.params.peerport = 0
276-
chan.params.peerhostname = peer_info['ComputerName']
277+
chan.lsock.initinfo(Rex::Socket.to_authority(peer_info['IpAddress'], 0), chan.lsock.localinfo)
277278
chan.update_term_size
278279
rescue => e
279280
print_error("AWS SSM handler failed: #{e.message}")

lib/rex/proto/http/web_socket.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ def type?
4444
# binary and text)
4545
# @param [Symbol] write_type the data type to write to the WebSocket
4646
def initialize(websocket, read_type: nil, write_type: :binary)
47-
initialize_abstraction
48-
4947
# a read type of nil will handle both binary and text frames that are received
5048
raise ArgumentError, 'read_type must be nil, :binary or :text' unless [nil, :binary, :text].include?(read_type)
5149
raise ArgumentError, 'write_type must be :binary or :text' unless %i[binary text].include?(write_type)
@@ -66,6 +64,10 @@ def initialize(websocket, read_type: nil, write_type: :binary)
6664
'SSL' => websocket.respond_to?(:sslctx) && !websocket.sslctx.nil?
6765
})
6866

67+
initialize_abstraction
68+
69+
lsock.initinfo(Rex::Socket.to_authority(peerhost, peerport), Rex::Socket.to_authority(localhost, localport))
70+
6971
@thread = Rex::ThreadFactory.spawn("WebSocketChannel(#{localhost}->#{peerhost})", false) do
7072
websocket.wsloop do |data, data_type|
7173
next unless @read_type.nil? || data_type == @read_type

0 commit comments

Comments
 (0)