Class: PacketGen::Plugin::SMB::NtCreateAndX::Request

Inherits:
Header::Base
  • Object
show all
Defined in:
lib/packetgen/plugin/smb/ntcreateandx/request.rb

Overview

SMB Command NtCreateAndX request.

A NtCreateAndXRequest contains:

Known limitations

  1. Only the first command is properly handled. Chained commands are not.

  2. #filename is mandatory handled as Windows Unicode string.

Author:

  • Sylvain Daubert

Constant Summary collapse

COMMANDS =

Commands that may follow this one in a SMB packet

{
  'read' => 0x0a,
  'read_andx' => 0x2e,
  'ioctl' => 0x27,
  'no further commands' => 0xff
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_maskInteger

32-bit flags that indicate access rights.

Returns:

  • (Integer)


91
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 91

define_field :access_mask, PacketGen::Types::Int32le

#alloc_sizeInteger

64-bit initial allocation size.

Returns:

  • (Integer)


95
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 95

define_field :alloc_size, PacketGen::Types::Int64le

#and_xcommandInteger

8-bit command code for the next SMB command in the packet.

Returns:

  • (Integer)


59
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 59

define_field :and_xcommand, PacketGen::Types::Int8Enum, enum: COMMANDS

#and_xoffsetInteger

16-bit offset from the start of SMB header to the start of the #word_count field in the next SMB command in this packet.

Returns:

  • (Integer)


69
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 69

define_field :and_xoffset, PacketGen::Types::Int16le, default: 0

#attributesInteger

32-bit extended file attributes.

Returns:

  • (Integer)


99
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 99

define_field :attributes, PacketGen::Types::Int32le

#byte_countInteger

The size, in bytes, of the SMB data.

Returns:

  • (Integer)


126
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 126

define_field :byte_count, PacketGen::Types::Int16le

#dispositionInteger

32-bit value that represents the action to take if the file already exists or if the file is a new file and does not already exist.

Returns:

  • (Integer)


109
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 109

define_field :disposition, PacketGen::Types::Int32le

#extra_bytesInteger

Returns:

  • (Integer)


139
140
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 139

define_field :extra_bytes, PacketGen::Types::String,
builder: ->(h, t) { t.new(length_from: -> { h.byte_count - (h.present?(:pad1) ? 1 : 0) - h[:filename].sz }) }

#filenameObject

A string that represents the fully qualified name of the file relative to the supplied TID



136
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 136

define_field :filename, SMB::String, builder: ->(h, t) { t.new(unicode: !h.packet || h.packet.smb.flags2_unicode?) }

#filename_lenInteger Also known as: filename_length

16-bit length of the #filename field.

Returns:

  • (Integer)


77
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 77

define_field :filename_len, PacketGen::Types::Int16le

#flagsInteger

32-bit flags word

Returns:

  • (Integer)


83
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 83

define_field :flags, PacketGen::Types::Int32le

#impersonationInteger

32-bit field specifying the impersonation level requested by the application.

Returns:

  • (Integer)


119
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 119

define_field :impersonation, PacketGen::Types::Int32le

#optionsInteger

32-bit field containing flag options to use if creating the file or the directory.

Returns:

  • (Integer)


114
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 114

define_field :options, PacketGen::Types::Int32le

#pad1Integer

Padding before #filename to align it on 16-bit boundary. Only present if PacketGen::Plugin::SMB#flags2_unicode? is true.

Returns:

  • (Integer)


131
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 131

define_field :pad1, PacketGen::Types::Int8, optional: ->(h) { h&.packet&.smb&.flags2_unicode? }

#root_dir_fidInteger

32-bit file ID of an opened root directory.

Returns:

  • (Integer)


87
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 87

define_field :root_dir_fid, PacketGen::Types::Int32le

#rsv1Integer

8-bit reserved field.

Returns:

  • (Integer)


63
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 63

define_field :rsv1, PacketGen::Types::Int8, default: 0

#rsv2Integer

8-bit reserved field.

Returns:

  • (Integer)


73
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 73

define_field :rsv2, PacketGen::Types::Int8, default: 0

#sec_flagsObject

8-bit security flags.



122
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 122

define_field :sec_flags, PacketGen::Types::Int8

#share_accessInteger

32-bit field that specifies how the file should be shared.

Returns:

  • (Integer)


103
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 103

define_field :share_access, PacketGen::Types::Int32le

#word_countInteger

The size, in 2-byte words, of the SMB parameters.

Returns:

  • (Integer)


54
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 54

define_field :word_count, PacketGen::Types::Int8, default: 24

Class Method Details

.protocol_nameString

Give protocol name for this class

Returns:



144
145
146
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 144

def self.protocol_name
  'SMB::NtCreateAndX::Request'
end

Instance Method Details

#calc_lengthvoid

This method returns an undefined value.

Compute #filename_len and #byte_count



150
151
152
153
154
155
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 150

def calc_length
  self.filename_len = self[:filename].sz
  pad1sz = self.present?(:pad1) ? 1 : 0
  bcount = pad1sz + filename_len + self[:extra_bytes].sz
  self.byte_count = bcount
end