Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/ruby_smb/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,25 @@ class Client
# (constants defined in RubySMB::SMB2::CompressionCapabilities)
attr_accessor :server_compression_algorithms

# The GUID of the server (SMB 2.x and 3.x).
# @!attribute [rw] server_guid
# @return [String]
attr_accessor :server_guid

# The server's start time if it is reported as part of the negotiation
# process (SMB 2.x and 3.x). This value is nil if the server does not report
# it (reports a value of 0).
# @!attribute [rw] server_start_time
# @return [Time] the time that the server reports that it was started at
attr_accessor :server_start_time

# The server's current time if it is reported as part of the negotiation
# process (SMB 2.x and 3.x). This value is nil if the server does not report
# it (reports a value of 0).
# @!attribute [rw] server_system_time
# @return [Time] the time that the server reports as current
attr_accessor :server_system_time

# The SMB version that has been successfully negotiated. This value is only
# set after the NEGOTIATE handshake has been performed.
# @!attribute [rw] negotiated_smb_version
Expand Down
4 changes: 4 additions & 0 deletions lib/ruby_smb/client/negotiation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def negotiate
when '0x0311'
parse_smb3_encryption_data(request_packet, response_packet)
end

# If the response contains the SMB2 wildcard revision number dialect;
# it indicates that the server implements SMB 2.1 or future dialect
# revisions and expects the client to send a subsequent SMB2 Negotiate
Expand Down Expand Up @@ -137,6 +138,9 @@ def parse_negotiate_response(packet)
# This value is used in SMB1 only but calculate a valid value anyway
self.server_max_buffer_size = [self.server_max_read_size, self.server_max_write_size, self.server_max_transact_size].min
self.negotiated_smb_version = self.smb2 ? 2 : 3
self.server_guid = packet.server_guid
self.server_start_time = packet.server_start_time.to_time if packet.server_start_time != 0
self.server_system_time = packet.system_time.to_time if packet.system_time != 0
return "SMB#{self.negotiated_smb_version}"
else
error = 'Unable to negotiate with remote host'
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_smb/smb2/packet/negotiate_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NegotiateResponse < RubySMB::GenericPacket
uint16 :dialect_revision, label: 'Dialect Revision'
uint16 :negotiate_context_count, label: 'Negotiate Context Count', initial_value: -> { negotiate_context_list.size }, onlyif: -> { has_negotiate_context? }
uint16 :reserved1, label: 'Reserved', initial_value: 0, onlyif: -> { !has_negotiate_context? }
string :server_guid, label: 'Server GUID', length: 16
string :server_guid, label: 'Server GUID', length: 16
smb2_capabilities :capabilities
uint32 :max_transact_size, label: 'Max Transaction Size'
uint32 :max_read_size, label: 'Max Read Size'
Expand Down