예제 #1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                if (args.Length == 0)
                {
                    MessageBox.Show("Usage: ViewSecurityDescriptor.exe (handle [--readonly]|Name SDDL NtType)", "Usage", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    if (args.Length < 3)
                    {
                        var  handle    = new SafeKernelObjectHandle(new IntPtr(int.Parse(args[0])), true);
                        bool read_only = args.Length > 1 ? args[1].Equals("--readonly") : false;
                        using (var obj = NtGeneric.FromHandle(handle))
                        {
                            Application.Run(new SecurityDescriptorViewerForm(obj, read_only));
                        }
                    }
                    else
                    {
                        NtType             type = ServiceUtils.GetServiceNtType(args[2]) ?? new NtType(args[2]);
                        SecurityDescriptor sd   = new SecurityDescriptor(args[1], type);
                        Application.Run(new SecurityDescriptorViewerForm(args[0], sd));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                if (args.Length == 0)
                {
                    MessageBox.Show("Usage: ViewSecurityDescriptor.exe (handle [--readonly]|Name (SDDL|-B64) NtType [Container])", "Usage", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    if (args.Length < 3)
                    {
                        var  handle    = new SafeKernelObjectHandle(new IntPtr(int.Parse(args[0])), true);
                        bool read_only = args.Length > 1 ? args[1].Equals("--readonly") : false;
                        using (var obj = NtGeneric.FromHandle(handle))
                        {
                            Application.Run(new SecurityDescriptorViewerForm(obj.ToTypedObject(), read_only));
                        }
                    }
                    else
                    {
                        NtType type = null;
                        if (args[2].Equals("DirectoryService", StringComparison.OrdinalIgnoreCase))
                        {
                            type = DirectoryServiceUtils.NtType;
                        }
                        else
                        {
                            type = ServiceUtils.GetServiceNtType(args[2]) ?? new NtType(args[2]);
                        }
                        SecurityDescriptor sd;
                        if (args[1].StartsWith("-"))
                        {
                            sd = new SecurityDescriptor(Convert.FromBase64String(args[1].Substring(1)));
                        }
                        else
                        {
                            sd = new SecurityDescriptor(args[1]);
                        }

                        bool container = false;
                        if (args.Length > 3)
                        {
                            container = bool.Parse(args[3]);
                        }

                        Application.Run(new SecurityDescriptorViewerForm(args[0], sd, type, container));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
 static void Main(string[] args)
 {
     try
     {
         if (args.Length == 0)
         {
             MessageBox.Show("Usage: ViewSecurityDescriptor.exe (handle [--readonly]|Name SDDL NtType)", "Usage", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             if (args.Length < 3)
             {
                 var  handle    = new SafeKernelObjectHandle(new IntPtr(int.Parse(args[0])), true);
                 bool read_only = args.Length > 1 ? args[1].Equals("--readonly") : false;
                 using (var obj = NtGeneric.FromHandle(handle))
                 {
                     SecurityUtils.EditSecurity(IntPtr.Zero, obj, obj.Name, read_only);
                 }
             }
             else
             {
                 SecurityDescriptor sd   = new SecurityDescriptor(args[1]);
                 NtType             type = NtType.GetTypeByName(args[2], false);
                 if (type == null)
                 {
                     throw new ArgumentException(string.Format("Unknown NT type {0}", args[2]));
                 }
                 SecurityUtils.EditSecurity(IntPtr.Zero, args[0], sd, type);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }