Documentation
¶
Overview ¶
MIT License
Copyright (c) 2025 Jimmy Fjällid ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2025 Jimmy Fjällid ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- Variables
- func ConvertFromFiletime(t *Filetime) time.Time
- func ConvertSIDtoStr(sid *SID) (s string)
- func ConvertToFiletime(t time.Time) uint64
- func FromUnicode(buf []byte) ([]byte, error)
- func FromUnicodeString(buf []byte) (res string, err error)
- func NewUnicodeStr(s string, addNullByte bool) (offset uint32, actualCount uint32, paddlen int, buffer []byte)
- func NullTerminate(s string) string
- func ParseAccessMask(mask uint32) []string
- func ParseAceFlags(aceFlags byte) string
- func ReadConformantVaryingArray(r *bytes.Reader) (data []byte, maxLength uint32, err error)
- func ReadConformantVaryingArrayPtr(r *bytes.Reader) (data []byte, maxLength uint32, err error)
- func ReadConformantVaryingString(r *bytes.Reader, nullTerminated bool) (s string, err error)
- func ReadConformantVaryingStringPtr(r *bytes.Reader, nullTerminated bool) (s string, err error)
- func ReadRPCUnicodeStr(r *bytes.Reader, nullTerminated bool) (s string, maxLength uint16, err error)
- func ReadRPCUnicodeStrArray(r *bytes.Reader, nullTerminated bool) (items []string, err error)
- func ReadRPCUnicodeStrPtr(r *bytes.Reader, nullTerminated bool) (s string, maxLength uint16, err error)
- func StripNullByte(s string) string
- func ToUnicode(input string) []byte
- func WriteConformantArray(w io.Writer, buf []byte) (n int, err error)
- func WriteConformantArrayPtr(w io.Writer, buf []byte, refid *uint32) (n int, err error)
- func WriteConformantVaryingArray(w io.Writer, buf []byte, maxCount uint32) (n int, err error)
- func WriteConformantVaryingArrayPtr(w io.Writer, buf []byte, maxCount uint32, refId *uint32) (n int, err error)
- func WriteConformantVaryingString(w io.Writer, s string, addNullByte bool) (n int, err error)
- func WriteConformantVaryingStringPtr(w io.Writer, s string, refid *uint32, addNullByte bool) (n int, err error)
- func WriteRPCUnicodeStrArray(w io.Writer, items []string, refId *uint32, nullTerminate bool) (n int, err error)
- func WriteRPCUnicodeStrPtr(w io.Writer, s string, refId *uint32) (n int, err error)
- func WriteUniDimensionalConformanVaryingArray(w io.Writer, items []RPCUnicodeStr, maxCount uint32, refId *uint32) (n int, err error)
- type ACE
- type ACEHeader
- type AcePermissions
- type Filetime
- type PACL
- type PFiletime
- type PaclPermissions
- type RPCUnicodeStr
- type ReturnCode
- type SID
- type SecurityDescriptor
Constants ¶
const ( SecurityDescriptorFlagOD uint16 = 0x0001 // Owner Default SecurityDescriptorFlagGD uint16 = 0x0002 // Group Default SecurityDescriptorFlagDP uint16 = 0x0004 // DACL Present SecurityDescriptorFlagDD uint16 = 0x0008 // DACL Defaulted SecurityDescriptorFlagSP uint16 = 0x0010 // SACL Present SecurityDescriptorFlagSD uint16 = 0x0020 // SACL Defaulted SecurityDescriptorFlagDT uint16 = 0x0040 // DACL Trusted SecurityDescriptorFlagSS uint16 = 0x0080 // Server Security SecurityDescriptorFlagDC uint16 = 0x0100 // DACL Computed Inheritance Required SecurityDescriptorFlagSC uint16 = 0x0200 // SACL Computed Inheritance Required SecurityDescriptorFlagDI uint16 = 0x0400 // DACL Auto-Inherited SecurityDescriptorFlagSI uint16 = 0x0800 // SACL Auto-Inherited SecurityDescriptorFlagPD uint16 = 0x1000 // DACL Protected SecurityDescriptorFlagPS uint16 = 0x2000 // SACL Protected SecurityDescriptorFlagPM uint16 = 0x4000 // RM Control Valid SecurityDescriptorFlagSR uint16 = 0x8000 // Self-Relative )
MS-DTYP Section 2.4.6 Security_Descriptor Control Flag
const ( AccessAllowedAceType byte = 0x00 AccessDeniedAceType byte = 0x01 SystemAuditAceType byte = 0x02 SystemAlarmAceType byte = 0x03 AccessAllowedCompoundAceType byte = 0x04 AccessAllowedObjectAceType byte = 0x05 AccessDeniedObjectAceType byte = 0x06 SystemAuditObjectAceType byte = 0x07 SystemAlarmObjectAceType byte = 0x08 AccessAllowedCallbackAceType byte = 0x09 AccessDeniedCallbackAceType byte = 0x0a AccessAllowedCallbackObjectAceType byte = 0x0b AccessDeniedCallbackObjectAceType byte = 0x0c SystemAuditCallbackAceType byte = 0x0d SystemAlarmCallbackAceType byte = 0x0e SystemAuditCallbackObjectAceType byte = 0x0f SystemAlarmCallbackObjectAceType byte = 0x10 SystemMandatoryLabelAceType byte = 0x11 SystemResourceAttributeAceType byte = 0x12 SystemScopedPolicyIdAceType byte = 0x13 )
MS-DTYP Section 2.4.4.1 ACE_HEADER AceType
const ( ObjectInheritAce byte = 0x01 // Noncontainer child objects inherit the ACE as an effective ACE ContainerInheritAce byte = 0x02 // Child objects that are containers, such as directories, inherit the ACE as an effective ACE. The inherited ACE is inheritable unless the NO_PROPAGATE_INHERIT_ACE bit flag is also set. NoPropagateInheritAce byte = 0x04 // Ace is only inherited to direct child objects InheritOnlyAce byte = 0x08 // Ace does not control access to the object to which it is attached InheritedAce byte = 0x10 // The ACE was inherited SuccessfulAccessAceFlag byte = 0x40 // Generate audit messages for successful access attempts in SACL FailedAccessAceFlag byte = 0x80 // Generate audit messages for failed access attempts in SACL DefaultAceFlag byte = 0x02 // ContainerInheritAce )
AceFlags
const ( AccessMaskGenericRead = "GENERIC_READ" AccessMaskGenericWrite = "GENERIC_WRITE" AccessMaskGenericExecute = "GENERIC_EXECUTE" AccessMaskGenericAll = "GENERIC_ALL" AccessMaskMaximumAllowed = "MAXIMUM_ALLOWED" AccessMaskAccessSystemSecurity = "ACCESS_SYSTEM_SECURITY" AccessMaskSynchronize = "SYNCHRONIZE" AccessMaskWriteOwner = "WRITE_OWNER" AccessMaskWriteDACL = "WRITE_DACL" AccessMaskReadControl = "READ_CONTROL" AccessMaskDelete = "DELETE" )
Variables ¶
var AceTypeMap = map[byte]string{ AccessAllowedAceType: "AccessAllowed", AccessDeniedAceType: "AccessDenied", SystemAuditAceType: "SystemAudit", SystemAlarmAceType: "SystemAlarm", AccessAllowedCompoundAceType: "AccessAllowedCompound", AccessAllowedObjectAceType: "AccessAllowedObject", AccessDeniedObjectAceType: "AccessDeniedObject", SystemAuditObjectAceType: "SystemAuditObject", SystemAlarmObjectAceType: "SystemAlarmObject", AccessAllowedCallbackAceType: "AccessAllowedCallback", AccessDeniedCallbackAceType: "AccessDeniedCallback", AccessAllowedCallbackObjectAceType: "AccessAllowedCallbackObject", AccessDeniedCallbackObjectAceType: "AccessDeniedCallbackObject", SystemAuditCallbackAceType: "SystemAuditCallback", SystemAlarmCallbackAceType: "SystemAlarmCallback", SystemAuditCallbackObjectAceType: "SystemAuditCallbackObject", SystemAlarmCallbackObjectAceType: "SystemAlarmCallbackObject", SystemMandatoryLabelAceType: "SystemMandatoryLabel", SystemResourceAttributeAceType: "SystemResourceAttribute", SystemScopedPolicyIdAceType: "SystemScopedPolicyId", }
Functions ¶
func ConvertFromFiletime ¶
func ConvertSIDtoStr ¶
func ConvertToFiletime ¶
func FromUnicode ¶
func FromUnicodeString ¶
func NewUnicodeStr ¶
func NewUnicodeStr(s string, addNullByte bool) (offset uint32, actualCount uint32, paddlen int, buffer []byte)
Return the values needed to encode a unicode string according to NDR (except for the Ptrs and MaxCount which has to be added manually)
func NullTerminate ¶
func ParseAccessMask ¶
func ParseAceFlags ¶
func ReadConformantVaryingString ¶
Borrowed from NDR but modified to support edge case where the unicode string is NOT terminated with a null byte
func ReadRPCUnicodeStr ¶
func ReadRPCUnicodeStrArray ¶
Specifically to handle all the ref id ptrs and array len and size valus that are lifted out of the structures
func ReadRPCUnicodeStrPtr ¶
func StripNullByte ¶
func WriteConformantArrayPtr ¶
func WriteConformantVaryingArray ¶
If maxCount is 0, use length of buf
func WriteConformantVaryingArrayPtr ¶
func WriteConformantVaryingArrayPtr(w io.Writer, buf []byte, maxCount uint32, refId *uint32) (n int, err error)
If maxCount is 0, use length of buf
func WriteConformantVaryingString ¶
Borrowed from NDR but modified to support edge case where the unicode string is NOT terminated with a null byte Write a conformant and varying string to the output stream
func WriteConformantVaryingStringPtr ¶
func WriteConformantVaryingStringPtr(w io.Writer, s string, refid *uint32, addNullByte bool) (n int, err error)
Write a ptr to a conformant and varying string to the output stream
func WriteRPCUnicodeStrArray ¶
func WriteRPCUnicodeStrPtr ¶
Not null terminated
func WriteUniDimensionalConformanVaryingArray ¶
func WriteUniDimensionalConformanVaryingArray(w io.Writer, items []RPCUnicodeStr, maxCount uint32, refId *uint32) (n int, err error)
Write Uni-dimensional Conformant-varying Array of RPCUnicodeStrings
Types ¶
type ACE ¶
MS-DTYP Section 2.4.4.2 ACCESS_ALLOWED_ACE
func (*ACE) MarshalBinary ¶
func (ACE) Permissions ¶
func (a ACE) Permissions() AcePermissions
func (*ACE) UnmarshalBinary ¶
type AcePermissions ¶
type PACL ¶
MS-DTYP Section 2.4.5.1 ACL--RPC Representation
func (*PACL) MarshalBinary ¶
func (*PACL) Permissions ¶
func (self *PACL) Permissions() PaclPermissions
func (*PACL) UnmarshalBinary ¶
type PaclPermissions ¶
type PaclPermissions struct {
NumAce uint32
Entries []AcePermissions
}
type RPCUnicodeStr ¶
MS-DTYP Section 2.3.10 RPC_UNICODE_STRING
typedef struct _RPC_UNICODE_STRING {
unsigned short Length;
unsigned short MaximumLength;
[size_is(MaximumLength/2), length_is(Length/2)]
WCHAR* Buffer;
} RPC_UNICODE_STRING,
*PRPC_UNICODE_STRING;
type ReturnCode ¶
type ReturnCode struct {
// contains filtered or unexported fields
}
func (*ReturnCode) MarshalBinary ¶
func (self *ReturnCode) MarshalBinary() ([]byte, error)
func (*ReturnCode) UnmarshalBinary ¶
func (self *ReturnCode) UnmarshalBinary(buf []byte) error
type SID ¶
MS-DTYP Section 2.4.2.3 RPC_SID
func ConvertStrToSID ¶
func (*SID) GetAuthority ¶
func (*SID) MarshalBinary ¶
func (*SID) UnmarshalBinary ¶
type SecurityDescriptor ¶
type SecurityDescriptor struct {
Revision uint16
Control uint16
OffsetOwner uint32
OffsetGroup uint32
OffsetSacl uint32 // From beginning of struct?
OffsetDacl uint32 // From beginning of struct?
OwnerSid *SID
GroupSid *SID
Sacl *PACL
Dacl *PACL
}
MS-DTYP Section 2.4.6.1 SECURITY_DESCRIPTOR
func (*SecurityDescriptor) MarshalBinary ¶
func (self *SecurityDescriptor) MarshalBinary() (ret []byte, err error)
func (*SecurityDescriptor) UnmarshalBinary ¶
func (self *SecurityDescriptor) UnmarshalBinary(buf []byte) (err error)