Class: PacketGen::Plugin::SMB2::Negotiate::Request
- Defined in:
- lib/packetgen/plugin/smb2/negotiate/request.rb
Overview
SMB2 Negotiate request 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 | DialectCount |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SecurityMode | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Capabilities |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ClientGUID |
+ +
| |
+ +
| |
+ +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ContextOffset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ContextCount | Reserved2 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Dialects (variable) |
+ +
| ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Pad (variable) |
+ +
| ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ContextList (variable) |
+ +
| ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Constant Summary collapse
- SECURITY_MODES =
Security modes
{ 'signing_enabled' => 1, 'signing required' => 2 }.freeze
Instance Attribute Summary collapse
-
#cap_dfs ⇒ Boolean
Indicates if Distributed File system (DFS) is supported.
-
#cap_dir_leasing ⇒ Boolean
Indicates if directory leasing is supported.
-
#cap_encryption ⇒ Boolean
Indicates if encryption is supported.
-
#cap_large_mtu ⇒ Boolean
Indicates if multi credit operations are supported.
-
#cap_leasing ⇒ Boolean
Indicates if leasing is supported.
-
#cap_multi_channel ⇒ Boolean
Indicates if multiple channels are supported for a single session.
-
#cap_persistent_handles ⇒ Boolean
Indicates if persisten handles are supported.
-
#capabilities ⇒ Integer
32-bit capabilities field.
-
#client_guid ⇒ Object
[].
-
#context_count ⇒ Integer
Only for SMB3 dialect.
- #context_list ⇒ ArrayOfContext
-
#context_offset ⇒ Integer
Only for SMB3 dialect.
-
#dialect_count ⇒ Integer
16-bit number of dialects that are contained in #dialects.
-
#dialects ⇒ Array<PacketGen::Types::Int16le>
Array of 16-bit integers specifying the supported dialtec revisions.
-
#pad ⇒ String
Optional padding between the end of the #dialects array and the first negotiate context in #context_list so that the first negotiate context is 8-byte aligned.
-
#reserved ⇒ Integer
16-bit reserved field.
-
#reserved2 ⇒ Integer
Only for SMB3 dialect.
-
#security_mode ⇒ Integer
16-bit security mode field.
-
#structure_size ⇒ Integer
16-bit negotiate request structure size.
Class Method Summary collapse
-
.protocol_name ⇒ String
Protocol name.
Instance Method Summary collapse
-
#calc_length ⇒ Integer
Calculate and set #context_offset and #pad fields.
- #inspect ⇒ String
Methods inherited from Base
Instance Attribute Details
#cap_dfs ⇒ Boolean
Indicates if Distributed File system (DFS) is supported
94 95 96 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 94 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_leasing ⇒ Boolean
Indicates if directory leasing is supported
94 95 96 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 94 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_encryption ⇒ Boolean
Indicates if encryption is supported
94 95 96 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 94 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_mtu ⇒ Boolean
Indicates if multi credit operations are supported
94 95 96 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 94 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_leasing ⇒ Boolean
Indicates if leasing is supported
94 95 96 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 94 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_channel ⇒ Boolean
Indicates if multiple channels are supported for a single session
94 95 96 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 94 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_handles ⇒ Boolean
Indicates if persisten handles are supported
94 95 96 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 94 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 |
#capabilities ⇒ Integer
32-bit capabilities field.
72 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 72 define_field :capabilities, PacketGen::Types::Int32le |
#client_guid ⇒ Object
Returns [].
99 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 99 define_field :client_guid, GUID |
#context_count ⇒ Integer
Only for SMB3 dialect.
107 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 107 define_field :context_count, PacketGen::Types::Int16le |
#context_list ⇒ ArrayOfContext
125 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 125 define_field :context_list, ArrayOfContext, builder: ->(h, t) { t.new(counter: h[:context_count]) } |
#context_offset ⇒ Integer
Only for SMB3 dialect.
103 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 103 define_field :context_offset, PacketGen::Types::Int32le |
#dialect_count ⇒ Integer
16-bit number of dialects that are contained in #dialects.
60 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 60 define_field :dialect_count, PacketGen::Types::Int16le |
#dialects ⇒ Array<PacketGen::Types::Int16le>
Array of 16-bit integers specifying the supported dialtec revisions.
115 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 115 define_field :dialects, PacketGen::Types::ArrayOfInt16le, builder: ->(h, t) { t.new(counter: h[:dialect_count]) } |
#pad ⇒ String
Optional padding between the end of the #dialects array and the first negotiate context in #context_list so that the first negotiate context is 8-byte aligned.
120 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 120 define_smb2_pad_field :pad |
#reserved ⇒ Integer
16-bit reserved field.
68 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 68 define_field :reserved, PacketGen::Types::Int16le |
#reserved2 ⇒ Integer
Only for SMB3 dialect.
111 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 111 define_field :reserved2, PacketGen::Types::Int16le |
#security_mode ⇒ Integer
16-bit security mode field.
64 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 64 define_field :security_mode, PacketGen::Types::Int16leEnum, enum: SECURITY_MODES |
#structure_size ⇒ Integer
16-bit negotiate request structure size. Should be 36.
56 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 56 define_field :structure_size, PacketGen::Types::Int16le, default: 36 |
Class Method Details
.protocol_name ⇒ String
Protocol name
129 130 131 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 129 def self.protocol_name 'SMB2::Negotiate::Request' end |
Instance Method Details
#calc_length ⇒ Integer
Calculate and set #context_offset and #pad fields. Also calculate lengths in contexts.
160 161 162 163 164 165 166 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 160 def calc_length self[:pad].read SMB2::MAX_PADDING 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 |
#inspect ⇒ String
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/packetgen/plugin/smb2/negotiate/request.rb', line 134 def inspect super do |attr| case attr when :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] when :dialects list = self.dialects.map { |v| '%#x' % v.to_i }.join(',') str = PacketGen::Inspect.shift_level str << PacketGen::Inspect::FMT_ATTR % [self[attr].class.to_s.sub(/.*::/, ''), attr, list] end end end |