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

Inherits:
BinStruct::Struct
  • 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

#data ⇒ String

context data

Returns:

  • (String)


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

define_attr :data, BinStruct::String, builder: ->(h, t) { t.new(length_from: h[:data_length]) }

#data_length ⇒ Integer

16-bit data length

Returns:

  • (Integer)


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

define_attr :data_length, BinStruct::Int16le

#pad ⇒ String

Padding to align next context on a 8-byte offset

Returns:

  • (String)


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

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

#reserved ⇒ Integer

32-bit reserved field

Returns:

  • (Integer)


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

define_attr :reserved, BinStruct::Int32le

#type ⇒ Integer

16-bit context type

Returns:

  • (Integer)


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

define_attr :type, BinStruct::Int16leEnum, enum: TYPES

Instance Method Details

#calc_length ⇒ Integer

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_type ⇒ String

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_human ⇒ String

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