Class: Rex::Proto::MsDtyp::MsDtypSid

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/rex/proto/ms_dtyp.rb

Overview

Instance Method Summary collapse

Instance Method Details

#getObject



68
69
70
71
72
73
# File 'lib/rex/proto/ms_dtyp.rb', line 68

def get
  str = 'S-1'
  str << "-#{("\x00\x00" + identifier_authority.to_binary_s).unpack1('Q>')}"
  str << '-' + sub_authority.map(&:to_s).join('-') unless sub_authority.empty?
  str
end

#ridObject



75
76
77
# File 'lib/rex/proto/ms_dtyp.rb', line 75

def rid
  sub_authority.last
end

#set(val) ⇒ Object

Raises:

  • (ArgumentError)


59
60
61
62
63
64
65
66
# File 'lib/rex/proto/ms_dtyp.rb', line 59

def set(val)
  # allow assignment from the human-readable string representation
  raise ArgumentError.new("Invalid SID: #{val}") unless val.is_a?(String) && val =~ /^S-1-(\d+)(-\d+)*$/

  _, _, ia, sa = val.split('-', 4)
  self.identifier_authority = [ia.to_i].pack('Q>')[2..].bytes
  self.sub_authority = sa.nil? ? [] : sa.split('-').map(&:to_i)
end