Module: RubySMB::Dcerpc::Drsr::AttrtypRequestPlugin

Included in:
DrsMsgGetchgreqV3, DrsMsgGetchgreqV7, DrsMsgGetchgreqV8
Defined in:
lib/ruby_smb/dcerpc/drsr.rb

Instance Method Summary collapse

Instance Method Details

#add_attrtyp_from_oid(oid, to_field: :p_partial_attr_set) ⇒ Object



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/ruby_smb/dcerpc/drsr.rb', line 264

def add_attrtyp_from_oid(oid, to_field: :p_partial_attr_set)
  last_value = oid.split('.').last.to_i
  binary_oid = OpenSSL::ASN1::ObjectId.new(oid).to_der[2..-1]
  if last_value < 128
    oid_prefix = binary_oid[0...-1].bytes
  else
    oid_prefix = binary_oid[0...-2].bytes
  end

  prefix_table = self.prefix_table_dest.p_prefix_entry
  prefix_table.instantiate_referent if prefix_table.is_null_ptr?
  pos = prefix_table.size
  index = prefix_table.to_ary.index { |e| e.prefix.elements == oid_prefix }
  if index
    pos = index
  else
    entry = PrefixTableEntry.new(ndx: pos)
    entry.prefix.elements = oid_prefix
    prefix_table << entry
  end

  lower_word = last_value % 0x4000
  # mark it so that it is known to not be the whole lastValue
  lower_word += 0x8000 if last_value >= 0x4000
  upper_word = pos
  attrtyp = (upper_word << 16) + lower_word
  attr_set_field = send(to_field)
  attr_set_field.instantiate_referent if attr_set_field.is_null_ptr?
  attr_set_field.rg_partial_attr << attrtyp
end