private static IReadOnlyList <string> ParseRights(SafeLsaMemoryBuffer buffer, int count)
 {
     using (buffer)
     {
         buffer.Initialize <UnicodeStringOut>((uint)count);
         return(buffer.ReadArray <UnicodeStringOut>(0, count).Select(n => n.ToString()).ToList().AsReadOnly());
     }
 }
Exemplo n.º 2
0
 private static List <Sid> ParseSids(SafeLsaMemoryBuffer buffer, int count)
 {
     using (buffer) {
         buffer.Initialize <LSA_ENUMERATION_INFORMATION>((uint)count);
         LSA_ENUMERATION_INFORMATION[] ss = new LSA_ENUMERATION_INFORMATION[count];
         buffer.ReadArray(0, ss, 0, count);
         return(ss.Select(s => new Sid(s.Sid)).ToList());
     }
 }
Exemplo n.º 3
0
 private static IEnumerable <AccountRight> ParseRights(SafeLsaHandle policy, string system_name, SafeLsaMemoryBuffer buffer, int count)
 {
     using (buffer) {
         buffer.Initialize <UnicodeStringOut>((uint)count);
         UnicodeStringOut[] ss = new UnicodeStringOut[count];
         buffer.ReadArray(0, ss, 0, count);
         return(ss.Select(s => new AccountRight(system_name, s.ToString(),
                                                GetSids(policy, s.ToString(), false).GetResultOrDefault())).ToList());
     }
 }
        private static IReadOnlyList <SidName> GetSidNameSids(string[] names, SafeLsaMemoryBuffer domains, SafeLsaMemoryBuffer sids)
        {
            using (SafeBufferGeneric a = domains, b = sids)
            {
                List <SidName> ret = new List <SidName>();
                domains.Initialize <LSA_REFERENCED_DOMAIN_LIST>(1);
                sids.Initialize <LSA_TRANSLATED_SID2>((uint)names.Length);

                var domain_list     = domains.Read <LSA_REFERENCED_DOMAIN_LIST>(0);
                var domains_entries = NtProcess.Current.ReadMemoryArray <LSA_TRUST_INFORMATION>(domain_list.Domains.ToInt64(), domain_list.Entries);
                var sid_list        = sids.ReadArray <LSA_TRANSLATED_SID2>(0, names.Length);
                for (int i = 0; i < names.Length; ++i)
                {
                    ret.Add(new SidName(sid_list[i].GetSid(), sid_list[i].GetDomain(domains_entries),
                                        names[i], SidNameSource.Account, sid_list[i].Use, false));
                }
                return(ret.AsReadOnly());
            }
        }
        private static IEnumerable <SidName> GetSidNames(Sid[] sids, SafeLsaMemoryBuffer domains, SafeLsaMemoryBuffer names)
        {
            List <SidName> ret = new List <SidName>();

            domains.Initialize <LSA_REFERENCED_DOMAIN_LIST>(1);
            names.Initialize <LSA_TRANSLATED_NAME>((uint)sids.Length);

            var domain_list     = domains.Read <LSA_REFERENCED_DOMAIN_LIST>(0);
            var domains_entries = NtProcess.Current.ReadMemoryArray <LSA_TRUST_INFORMATION>(domain_list.Domains.ToInt64(), domain_list.Entries);
            var name_list       = names.ReadArray <LSA_TRANSLATED_NAME>(0, sids.Length);

            for (int i = 0; i < sids.Length; ++i)
            {
                var name = name_list[i];

                ret.Add(new SidName(sids[i], name.GetDomain(domains_entries),
                                    name.GetName(), SidNameSource.Account, name.Use, false));
            }
            return(ret.AsReadOnly());
        }