Class: RubySMB::Dcerpc::Samr::RpcSid

Inherits:
Ndr::NdrStruct show all
Defined in:
lib/ruby_smb/dcerpc/samr/rpc_sid.rb

Overview

Direct Known Subclasses

PrpcSid

Instance Method Summary collapse

Methods inherited from Ndr::NdrStruct

#initialize_shared_instance, method_missing, validate_conformant_array

Instance Method Details

#assign(val) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/ruby_smb/dcerpc/samr/rpc_sid.rb', line 106

def assign(val)
  case val
  when String
    elems = val.split('-')
    raise ArgumentError, "Wrong SID format for #{val.inspect}" unless elems[0].downcase == 's'
    self.revision = elems[1].to_i
    self.sub_authority_count = elems[3..-1].size
    self.identifier_authority = [0, 0, 0, 0, 0, elems[2].to_i]
    self.sub_authority = elems[3..-1].map(&:to_i)
  when RpcSid
    super
  else
    raise ArgumentError, "Can only assign String or other RpcSid object (got #{val.class})"
  end
  self
end

#nameObject



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/ruby_smb/dcerpc/samr/rpc_sid.rb', line 123

def name
  sid = case sub_authority.size
  when 1
    WELL_KNOWN_SID_NAME[[identifier_authority[-1].to_i, sub_authority[0].to_i]]
  when 2
    if identifier_authority[-1] == 5 && sub_authority[0] == 32
      WELL_KNOWN_RID_NAME[sub_authority[1]]
    end
  when 3
    if identifier_authority[-1] == 5 && sub_authority[0] == 5
      "Current Session Logon SID"
    end
  else
    if identifier_authority[-1] == 5
      WELL_KNOWN_RID_NAME[sub_authority.last]
    end
  end
  sid || "Unknown SID (#{self})"
end

#snapshotObject



100
101
102
103
104
# File 'lib/ruby_smb/dcerpc/samr/rpc_sid.rb', line 100

def snapshot
  sid = ['S', self.revision.to_s, self.identifier_authority[-1].to_s]
  self.sub_authority.each { |e| sid << e.to_s }
  sid.join('-')
end