private void UpdateSectionList(HashSet<string> walked, ObjectDirectory dir, HashSet<string> names)
        {            
            if (walked.Contains(dir.FullPath.ToLower()))
            {
                return;
            }

            walked.Add(dir.FullPath.ToLower());

            try
            {
                foreach (ObjectDirectoryEntry entry in dir.Entries)
                {
                    try
                    {  
                        if(entry.TypeName.Equals("Section", StringComparison.OrdinalIgnoreCase))
                        {
                            names.Add(entry.FullPath);
                        }
                        else if (entry.IsDirectory)
                        {
                            UpdateSectionList(walked, ObjectNamespace.OpenDirectory(entry.FullPath), names);
                        }
                    }
                    catch
                    {                        
                    }
                }             
            }
            catch
            {                
            }        
        }
コード例 #2
0
 private static NtDirectory OpenPath(ObjectDirectory root, string path)
 {
     try
     {
         return(NtDirectory.Open(path, root != null ? root._directory : null, DirectoryAccessRights.MaximumAllowed));
     }
     catch (NtException ex)
     {
         throw ex.AsWin32Exception();
     }
 }
 public ObjectDirectory Duplicate()
 {
     ObjectDirectory ret = new ObjectDirectory();
     ret._sddl = _sddl;
     ret._sd = (byte[])_sd.Clone();
     ret._orig_path = _orig_path;
     ret._full_path = _full_path;
     ret._entries = new List<ObjectDirectoryEntry>(_entries.Select(e => new ObjectDirectoryEntry(e.ObjectName, e.TypeName, ret)));
     ret._directory = _directory.Duplicate();
     return ret;
 }
        public ObjectDirectory Duplicate()
        {
            ObjectDirectory ret = new ObjectDirectory();

            ret._sddl      = _sddl;
            ret._sd        = (byte[])_sd.Clone();
            ret._orig_path = _orig_path;
            ret._full_path = _full_path;
            ret._entries   = new List <ObjectDirectoryEntry>(_entries.Select(e => new ObjectDirectoryEntry(e.ObjectName, e.TypeName, ret)));
            ret._directory = _directory.Duplicate();
            return(ret);
        }
        internal ObjectDirectory(ObjectDirectory root, string object_path)
        {
            _orig_path = object_path;

            if (_orig_path.StartsWith("\\") || root != null)
            {
                _directory = OpenPath(root, _orig_path);
            }
            else
            {
                _directory = OpenNamespace(_orig_path);
            }

            PopulateEntries();
        }
コード例 #6
0
        static void OutputNone(ObjectDirectory base_dir, IEnumerable<ObjectDirectoryEntry> objs)
        {       
            if (print_sddl)
            {
                Console.WriteLine("SDDL: {0} -> {1}", base_dir.FullPath, base_dir.StringSecurityDescriptor);
            }     

            foreach (ObjectDirectoryEntry ent in objs.Where(e => e.IsDirectory))
            {
                Console.WriteLine("<DIR> {0}", ent.FullPath);                
            }

            foreach (ObjectDirectoryEntry ent in objs.Where(e => !e.IsDirectory))
            {
                if (ent.IsSymlink && print_link)
                {
                    Console.WriteLine("      {0} -> {1}", ent.FullPath, GetSymlinkTarget(ent));
                }
                else
                {
                    Console.WriteLine("      {0} ({1})", ent.FullPath, ent.TypeName);
                }
            }
        }
 public static ObjectDirectory OpenDirectory(ObjectDirectory root, string object_path)
 {
     return(new ObjectDirectory(root, object_path));
 }
 private static NtDirectory OpenPath(ObjectDirectory root, string path)
 {
     return(NtDirectory.Open(path, root != null ? root._directory : null, DirectoryAccessRights.MaximumAllowed));
 }
 internal ObjectDirectoryEntry(string name, string type_name, ObjectDirectory directory)
 {
     _name      = name;
     _type_name = type_name;
     _directory = directory;
 }
コード例 #10
0
        static void DumpDirectory(ObjectDirectory dir)
        {
            if (_walked.Contains(dir.FullPath.ToLower()))
            {
                return;
            }

            _walked.Add(dir.FullPath.ToLower());

            try
            {
                CheckAccess(dir.FullPath, dir.SecurityDescriptor, ObjectTypeInfo.GetTypeByName("Directory"));

                if (_recursive)
                {
                    foreach (ObjectDirectoryEntry entry in dir.Entries)
                    {
                        try
                        {
                            if (entry.IsDirectory)
                            {
                                DumpDirectory(ObjectNamespace.OpenDirectory(entry.FullPath));
                            }
                            else
                            {
                                CheckAccess(entry.FullPath, entry.SecurityDescriptor, ObjectTypeInfo.GetTypeByName(entry.TypeName));
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.Error.WriteLine("Error opening {0} {1}", entry.FullPath, ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Error dumping directory {0} {1}", dir.FullPath, ex.Message);
            }
        }
        internal ObjectDirectory(ObjectDirectory root, string object_path)
        {
            _orig_path = object_path;

            if (_orig_path.StartsWith("\\") || root != null)
            {
                _directory = OpenPath(root, _orig_path);
            }
            else
            {
                _directory = OpenNamespace(_orig_path);
            }

            PopulateEntries();
        }
 private static NtDirectory OpenPath(ObjectDirectory root, string path)
 {
     try
     {
         return NtDirectory.Open(path, root != null ? root._directory : null, DirectoryAccessRights.MaximumAllowed);
     }
     catch (NtException ex)
     {
         throw ex.AsWin32Exception();
     }
 }
コード例 #13
0
 static void OutputNameOnly(ObjectDirectory base_dir, IEnumerable<ObjectDirectoryEntry> entries)
 {
     foreach (ObjectDirectoryEntry entry in entries)
     {
         if (entry.IsSymlink && print_link)
         {
             Console.WriteLine("{0} -> {1}", entry.FullPath, GetSymlinkTarget(entry));
         }
         else
         {
             Console.WriteLine(entry.FullPath);
         }
     }
 }
	    public static ObjectDirectory OpenDirectory(ObjectDirectory root, string object_path)
	    {		
		    return new ObjectDirectory(root, object_path);
        }