Class: Rex::Proto::MsDtyp::MsDtypSid
- Inherits:
-
BinData::Primitive
- Object
- BinData::Primitive
- Rex::Proto::MsDtyp::MsDtypSid
- Defined in:
- lib/rex/proto/ms_dtyp.rb
Overview
[2.4.2.2 SID–Packet Representation](learn.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/f992ad60-0fe4-4b87-9fed-beb478836861)
Instance Method Summary collapse
Instance Method Details
#get ⇒ Object
68 69 70 71 72 73 |
# File 'lib/rex/proto/ms_dtyp.rb', line 68 def get str = 'S-1' str << "-#{("\x00\x00" + .to_binary_s).unpack1('Q>')}" str << '-' + .map(&:to_s).join('-') unless .empty? str end |
#rid ⇒ Object
75 76 77 |
# File 'lib/rex/proto/ms_dtyp.rb', line 75 def rid .last end |
#set(val) ⇒ Object
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. = [ia.to_i].pack('Q>')[2..].bytes self. = sa.nil? ? [] : sa.split('-').map(&:to_i) end |