Class: PacketGen::Plugin::SMB::NtCreateAndX::Request
- Inherits:
-
Header::Base
- Object
- Header::Base
- PacketGen::Plugin::SMB::NtCreateAndX::Request
- Defined in:
- lib/packetgen/plugin/smb/ntcreateandx/request.rb
Overview
SMB Command NtCreateAndX request.
A NtCreateAndXRequest contains:
-
a #word_count field (
Int8
), size, in 2-byte words of SMB parameters:-
#and_xcommand (
Int8
), next command in packet, -
#rsv1 (
Int8
), -
#and_xoffset (
Int16le
), offset of the next command from the start of SMB header, -
#rsv2 (
Int8
), -
#filename_len (
Int16le
), size of #filename in SMB data, -
#flags (
Int32le
), -
#root_dir_fid (
Int32le
), -
#access_mask (
Int32le
), -
#alloc_size (
Int64le
), -
#attributes (
Int32le
), -
#share_access (
Int32le
), -
#disposition (
Int32le
), -
#options (
Int32le
), -
#impersonation (
Int32le
), -
#sec_flags (
Int38
),
-
-
##byte_count (
Int16le
), size in bytes of SMB data:-
#pad1 (+Int8),
-
#extra_bytes (
String
).
-
Known limitations
-
Only the first command is properly handled. Chained commands are not.
-
#filename is mandatory handled as Windows Unicode string.
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
-
#access_mask ⇒ Integer
32-bit flags that indicate access rights.
-
#alloc_size ⇒ Integer
64-bit initial allocation size.
-
#and_xcommand ⇒ Integer
8-bit command code for the next SMB command in the packet.
-
#and_xoffset ⇒ Integer
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.
-
#attributes ⇒ Integer
32-bit extended file attributes.
-
#byte_count ⇒ Integer
The size, in bytes, of the SMB data.
-
#disposition ⇒ Integer
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.
- #extra_bytes ⇒ Integer
-
#filename ⇒ Object
A string that represents the fully qualified name of the file relative to the supplied TID.
-
#filename_len ⇒ Integer
(also: #filename_length)
16-bit length of the #filename field.
-
#flags ⇒ Integer
32-bit flags word.
-
#impersonation ⇒ Integer
32-bit field specifying the impersonation level requested by the application.
-
#options ⇒ Integer
32-bit field containing flag options to use if creating the file or the directory.
-
#pad1 ⇒ Integer
Padding before #filename to align it on 16-bit boundary.
-
#root_dir_fid ⇒ Integer
32-bit file ID of an opened root directory.
-
#rsv1 ⇒ Integer
8-bit reserved field.
-
#rsv2 ⇒ Integer
8-bit reserved field.
-
#sec_flags ⇒ Object
8-bit security flags.
-
#share_access ⇒ Integer
32-bit field that specifies how the file should be shared.
-
#word_count ⇒ Integer
The size, in 2-byte words, of the SMB parameters.
Class Method Summary collapse
-
.protocol_name ⇒ String
Give protocol name for this class.
Instance Method Summary collapse
-
#calc_length ⇒ void
Compute #filename_len and #byte_count.
Instance Attribute Details
#access_mask ⇒ Integer
32-bit flags that indicate access rights.
91 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 91 define_field :access_mask, PacketGen::Types::Int32le |
#alloc_size ⇒ Integer
64-bit initial allocation size.
95 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 95 define_field :alloc_size, PacketGen::Types::Int64le |
#and_xcommand ⇒ Integer
8-bit command code for the next SMB command in the packet.
59 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 59 define_field :and_xcommand, PacketGen::Types::Int8Enum, enum: COMMANDS |
#and_xoffset ⇒ Integer
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.
69 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 69 define_field :and_xoffset, PacketGen::Types::Int16le, default: 0 |
#attributes ⇒ Integer
32-bit extended file attributes.
99 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 99 define_field :attributes, PacketGen::Types::Int32le |
#byte_count ⇒ Integer
The size, in bytes, of the SMB data.
126 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 126 define_field :byte_count, PacketGen::Types::Int16le |
#disposition ⇒ Integer
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.
109 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 109 define_field :disposition, PacketGen::Types::Int32le |
#extra_bytes ⇒ 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 }) } |
#filename ⇒ Object
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_len ⇒ Integer Also known as: filename_length
16-bit length of the #filename field.
77 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 77 define_field :filename_len, PacketGen::Types::Int16le |
#flags ⇒ Integer
32-bit flags word
83 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 83 define_field :flags, PacketGen::Types::Int32le |
#impersonation ⇒ Integer
32-bit field specifying the impersonation level requested by the application.
119 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 119 define_field :impersonation, PacketGen::Types::Int32le |
#options ⇒ Integer
32-bit field containing flag options to use if creating the file or the directory.
114 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 114 define_field :options, PacketGen::Types::Int32le |
#pad1 ⇒ Integer
Padding before #filename to align it on 16-bit boundary. Only present if PacketGen::Plugin::SMB#flags2_unicode? is true
.
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_fid ⇒ Integer
32-bit file ID of an opened root directory.
87 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 87 define_field :root_dir_fid, PacketGen::Types::Int32le |
#rsv1 ⇒ Integer
8-bit reserved field.
63 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 63 define_field :rsv1, PacketGen::Types::Int8, default: 0 |
#rsv2 ⇒ Integer
8-bit reserved field.
73 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 73 define_field :rsv2, PacketGen::Types::Int8, default: 0 |
#sec_flags ⇒ Object
8-bit security flags.
122 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 122 define_field :sec_flags, PacketGen::Types::Int8 |
#share_access ⇒ Integer
32-bit field that specifies how the file should be shared.
103 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 103 define_field :share_access, PacketGen::Types::Int32le |
#word_count ⇒ Integer
The size, in 2-byte words, of the SMB parameters.
54 |
# File 'lib/packetgen/plugin/smb/ntcreateandx/request.rb', line 54 define_field :word_count, PacketGen::Types::Int8, default: 24 |
Class Method Details
.protocol_name ⇒ String
Give protocol name for this class
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_length ⇒ void
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 |