Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidAuthority = errors.New("invalid authority value") ErrInvalidRevision = errors.New("invalid SID revision") ErrInvalidSIDFormat = errors.New("invalid SID format") ErrInvalidSubAuthority = errors.New("invalid sub-authority value") ErrMissingDomainInformation = errors.New("missing domain information") ErrMissingSubAuthorities = errors.New("missing sub-authorities") ErrTooManySubAuthorities = errors.New("too many sub-authorities") )
Define common errors
Functions ¶
This section is empty.
Types ¶
type SecurityDescriptor ¶
type SecurityDescriptor struct {
// contains filtered or unexported fields
}
SecurityDescriptor represents the Windows SECURITY_DESCRIPTOR structure.
A security descriptor is a data structure that contains the security information associated with a securable object, such as a file, registry key, or network share. It includes an owner SID, a primary group SID, a discretionary access control list (DACL) that specifies the access rights allowed or denied to specific users or groups, and a system access control list (SACL) that specifies the types of auditing that are to be generated for specific users or groups.
See:
- https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/7d4dac05-9cef-4563-a058-f108abecce1d
- https://learn.microsoft.com/en-us/windows/win32/secauthz/security-descriptor-control
func FromBinary ¶
func FromBinary(data []byte) (*SecurityDescriptor, error)
FromBinary takes a binary security descriptor in relative format (contiguous memory with offsets)
func FromString ¶
func FromString(s string) (*SecurityDescriptor, error)
FromString parses a security descriptor string in SDDL format. The format is: "O:owner_sidG:group_sidD:dacl_flagsS:sacl_flags" where each component is optional.
Examples: - "O:SYG:BAD:(A;;FA;;;SY)" - Owner: SYSTEM, Group: BUILTIN\Administrators, DACL with full access for SYSTEM - "O:SYG:SYD:PAI(A;;FA;;;SY)" - Protected auto-inherited DACL - "O:SYG:SYD:(A;;FA;;;SY)S:(AU;SA;FA;;;SY)" - With both DACL and SACL
func (*SecurityDescriptor) Binary ¶
func (sd *SecurityDescriptor) Binary() []byte
Binary converts a SecurityDescriptor structure to its binary representation in self-relative format. The binary format consists of: - Fixed part:
- Revision (1 byte)
- Sbz1 (1 byte, reserved)
- Control (2 bytes, little-endian)
- OwnerOffset (4 bytes, little-endian)
- GroupOffset (4 bytes, little-endian)
- SaclOffset (4 bytes, little-endian)
- DaclOffset (4 bytes, little-endian)
- Variable part (in canonical order):
- Owner SID
- Group SID
- SACL
- DACL
func (*SecurityDescriptor) String ¶
func (sd *SecurityDescriptor) String() string
func (*SecurityDescriptor) StringIndent ¶
func (sd *SecurityDescriptor) StringIndent(margin int) string
StringIndent returns a formatted string representation of the SecurityDescriptor with the specified indentation margin. It includes the control flags, owner, group, and ACLs (if present), each properly indented for better readability.
Parameters:
- margin: number of spaces to prepend to each line
Returns a multi-line string containing the formatted security descriptor components.