Class: PacketGen::Plugin::SMB2::Negotiate::Response

Inherits:
Base
  • Object
show all
Defined in:
lib/packetgen/plugin/smb2/negotiate/response.rb

Overview

SMB2 Negotiate response structure

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|        StructureSize          |         SecurityMode          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|       DialectRevision         |        ContextCount           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          ServerGUID                           |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         Capabilities                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          MaxTranSize                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          MaxReadSize                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         MaxWriteSize                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          SystemTime                           |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          StartTime                            |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|        BufferOffset           |           BufferLength        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         ContextOffset                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Buffer (variable)                      |
+                                                               +
|                              ...                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         Pad (variable)                        |
+                                                               +
|                              ...                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     ContextList (variable)                    |
+                                                               +
|                              ...                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Author:

  • Sylvain Daubert

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

define_smb2_pad_field

Instance Attribute Details

#bufferGSSAPI

Returns:



143
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 143

define_field :buffer, GSSAPI, token: :init, optional: ->(h) { h.buffer_offset.positive? }

#buffer_lengthInteger

The length of the #buffer field.

Returns:

  • (Integer)


136
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 136

define_field :buffer_length, PacketGen::Types::Int16le

#buffer_offsetInteger

The offset, from the beginning of the SMB2 header of the #buffer.

Returns:

  • (Integer)


132
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 132

define_field :buffer_offset, PacketGen::Types::Int16le

#cap_dfsBoolean

Indicates if Distributed File system (DFS) is supported

Returns:

  • (Boolean)


105
106
107
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 105

define_bit_fields_on :capabilities, :cap_rsv, 25, :cap_encryption, :cap_dir_leasing,
:cap_persistent_handles, :cap_multi_channel,
:cap_large_mtu, :cap_leasing, :cap_dfs

#cap_dir_leasingBoolean

Indicates if directory leasing is supported

Returns:

  • (Boolean)


105
106
107
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 105

define_bit_fields_on :capabilities, :cap_rsv, 25, :cap_encryption, :cap_dir_leasing,
:cap_persistent_handles, :cap_multi_channel,
:cap_large_mtu, :cap_leasing, :cap_dfs

#cap_encryptionBoolean

Indicates if encryption is supported

Returns:

  • (Boolean)


105
106
107
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 105

define_bit_fields_on :capabilities, :cap_rsv, 25, :cap_encryption, :cap_dir_leasing,
:cap_persistent_handles, :cap_multi_channel,
:cap_large_mtu, :cap_leasing, :cap_dfs

#cap_large_mtuBoolean

Indicates if multi credit operations are supported

Returns:

  • (Boolean)


105
106
107
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 105

define_bit_fields_on :capabilities, :cap_rsv, 25, :cap_encryption, :cap_dir_leasing,
:cap_persistent_handles, :cap_multi_channel,
:cap_large_mtu, :cap_leasing, :cap_dfs

#cap_leasingBoolean

Indicates if leasing is supported

Returns:

  • (Boolean)


105
106
107
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 105

define_bit_fields_on :capabilities, :cap_rsv, 25, :cap_encryption, :cap_dir_leasing,
:cap_persistent_handles, :cap_multi_channel,
:cap_large_mtu, :cap_leasing, :cap_dfs

#cap_multi_channelBoolean

Indicates if multiple channels are supported for a single session

Returns:

  • (Boolean)


105
106
107
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 105

define_bit_fields_on :capabilities, :cap_rsv, 25, :cap_encryption, :cap_dir_leasing,
:cap_persistent_handles, :cap_multi_channel,
:cap_large_mtu, :cap_leasing, :cap_dfs

#cap_persistent_handlesBoolean

Indicates if persisten handles are supported

Returns:

  • (Boolean)


105
106
107
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 105

define_bit_fields_on :capabilities, :cap_rsv, 25, :cap_encryption, :cap_dir_leasing,
:cap_persistent_handles, :cap_multi_channel,
:cap_large_mtu, :cap_leasing, :cap_dfs

#capabilitiesInteger

32-bit capabilities field.

Returns:

  • (Integer)


83
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 83

define_field :capabilities, PacketGen::Types::Int32le

#context_countInteger

Only for SMB3 dialect.

Returns:

  • (Integer)


76
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 76

define_field :context_count, PacketGen::Types::Int16le

#context_listArrayOfContext

If #dialect has the value 0x0311, then this field must contain an array of Context

Returns:



154
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 154

define_field :context_list, ArrayOfContext, builder: ->(h, t) { t.new(counter: h[:context_count]) }

#context_offsetInteger

Only for SMB3 dialect.

Returns:

  • (Integer)


140
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 140

define_field :context_offset, PacketGen::Types::Int32le

#dialectInteger

16-bit prefered SMB2 protocol dialect number.

Returns:

  • (Integer)


72
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 72

define_field :dialect, PacketGen::Types::Int16le

#max_read_sizeInteger

32-bit value indicating the maximum size of a READ request

Returns:

  • (Integer)


116
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 116

define_field :max_read_size, PacketGen::Types::Int32le

#max_trans_sizeInteger

32-bit value indicating the maximum size of the buffer used for QUERY_INFO, QUERY_DIRECTORY, SET_INFO and CHANGE_NOTIFY operations.

Returns:

  • (Integer)


112
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 112

define_field :max_trans_size, PacketGen::Types::Int32le

#max_write_sizeInteger

32-bit value indicating the maximum size of a WRITE request

Returns:

  • (Integer)


120
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 120

define_field :max_write_size, PacketGen::Types::Int32le

#padObject

Optional padding between the end of the #buffer field and the first negotiate context in #context_list so that the first negotiate context is 8-byte aligned



149
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 149

define_smb2_pad_field :pad

#security_modeInteger

16-bit security mode field.

Returns:

  • (Integer)


68
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 68

define_field :security_mode, PacketGen::Types::Int16leEnum, enum: Negotiate::Request::SECURITY_MODES

#server_guidObject

Returns [].

Returns:



79
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 79

define_field :server_guid, GUID

#start_timeSMB::Filetime

Start time of the SMB2 server

Returns:



128
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 128

define_field :start_time, SMB::Filetime

#structure_sizeInteger

16-bit negotiate request structure size. Should be 65.

Returns:

  • (Integer)


64
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 64

define_field :structure_size, PacketGen::Types::Int16le, default: 65

#system_timeSMB::Filetime

System time of the SMB2 server

Returns:



124
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 124

define_field :system_time, SMB::Filetime

Class Method Details

.protocol_nameString

Protocol name

Returns:

  • (String)


158
159
160
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 158

def self.protocol_name
  'SMB2::Negotiate::Response'
end

Instance Method Details

#calc_lengthvoid

This method returns an undefined value.

Calculate and set #context_offset, #buffer_offset, #buffer_length and #pad fields. Also calculate lengths in contexts.



184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 184

def calc_length
  self[:pad].read SMB2::MAX_PADDING

  self.buffer_length = self[:buffer].sz
  self.buffer_offset = if self.buffer_length.zero?
                         0
                       else
                         SMB2::HEADER_SIZE + offset_of(:buffer)
                       end

  self.context_offset = 0
  self.context_offset = SMB2::HEADER_SIZE + offset_of(:context_list) unless context_list.empty?
  context_list.each { |ctx| ctx.calc_length if ctx.respond_to? :calc_length }
end

#inspectString

Returns:

  • (String)


163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/packetgen/plugin/smb2/negotiate/response.rb', line 163

def inspect
  super do |attr|
    next unless attr == :capabilities

    value = bits_on(attr).reject { |_, v| v > 1 }
                         .keys
                         .select { |b| send("#{b}?") }
                         .map(&:to_s)
                         .join(',')
                         .gsub!(/cap_/, '')
    value = '%-16s (0x%08x)' % [value, self[attr].to_i]
    str = PacketGen::Inspect.shift_level
    str << PacketGen::Inspect::FMT_ATTR % [self[attr].class.to_s.sub(/.*::/, ''),
                                           attr, value]
  end
end