Class: PacketGen::Plugin::SMB2::Negotiate::Context

Inherits:
Types::Fields
  • Object
show all
Defined in:
lib/packetgen/plugin/smb2/negotiate/context.rb

Overview

NegotiateContext 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |           DataLength          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           Reserved                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Data (variable)                         |
+                                                               +
|                              ...                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Author:

  • Sylvain Daubert

Direct Known Subclasses

EncryptionCap, PreauthIntegrityCap

Constant Summary collapse

TYPES =

Known types

{
  'PREAUTH_INTEGRITY_CAP' => 1,
  'ENCRYPTION_CAP' => 2
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataString

context data

Returns:

  • (String)


46
# File 'lib/packetgen/plugin/smb2/negotiate/context.rb', line 46

define_field :data, PacketGen::Types::String, builder: ->(h, t) { t.new(length_from: h[:data_length]) }

#data_lengthInteger

16-bit data length

Returns:

  • (Integer)


38
# File 'lib/packetgen/plugin/smb2/negotiate/context.rb', line 38

define_field :data_length, PacketGen::Types::Int16le

#padString

Padding to align next context on a 8-byte offset

Returns:

  • (String)


50
# File 'lib/packetgen/plugin/smb2/negotiate/context.rb', line 50

define_field :pad, PacketGen::Types::String, builder: ->(h, t) { t.new(length_from: -> { 8 - (h.offset_of(:data) + h.data_length) % 8 }) }

#reservedInteger

32-bit reserved field

Returns:

  • (Integer)


42
# File 'lib/packetgen/plugin/smb2/negotiate/context.rb', line 42

define_field :reserved, PacketGen::Types::Int32le

#typeInteger

16-bit context type

Returns:

  • (Integer)


34
# File 'lib/packetgen/plugin/smb2/negotiate/context.rb', line 34

define_field :type, PacketGen::Types::Int16leEnum, enum: TYPES

Instance Method Details

#calc_lengthInteger

Set #data_length field

Returns:

  • (Integer)


69
70
71
72
# File 'lib/packetgen/plugin/smb2/negotiate/context.rb', line 69

def calc_length
  self[:pad].read SMB2::MAX_PADDING
  self.data_length = sz - self[:pad].sz - 8
end

#human_typeString

Get human-readable type

Returns:

  • (String)


57
58
59
# File 'lib/packetgen/plugin/smb2/negotiate/context.rb', line 57

def human_type
  self[:type].to_human
end

#to_humanString

Get human-readable context

Returns:

  • (String)


63
64
65
# File 'lib/packetgen/plugin/smb2/negotiate/context.rb', line 63

def to_human
  human_type
end