msdtyp

package
v0.0.0-...-09996d0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

MIT License

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

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

View Source
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

View Source
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

View Source
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

View Source
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

View Source
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 ConvertFromFiletime(t *Filetime) time.Time

func ConvertSIDtoStr

func ConvertSIDtoStr(sid *SID) (s string)

func ConvertToFiletime

func ConvertToFiletime(t time.Time) uint64

func FromUnicode

func FromUnicode(buf []byte) ([]byte, error)

func FromUnicodeString

func FromUnicodeString(buf []byte) (res string, err error)

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 NullTerminate(s string) string

func ParseAccessMask

func ParseAccessMask(mask uint32) []string

func ParseAceFlags

func ParseAceFlags(aceFlags byte) string

func ReadConformantVaryingArray

func ReadConformantVaryingArray(r *bytes.Reader) (data []byte, maxLength uint32, err error)

func ReadConformantVaryingArrayPtr

func ReadConformantVaryingArrayPtr(r *bytes.Reader) (data []byte, maxLength uint32, err error)

func ReadConformantVaryingString

func ReadConformantVaryingString(r *bytes.Reader, nullTerminated bool) (s string, err error)

Borrowed from NDR but modified to support edge case where the unicode string is NOT terminated with a null byte

func ReadConformantVaryingStringPtr

func ReadConformantVaryingStringPtr(r *bytes.Reader, nullTerminated bool) (s string, err error)

func ReadRPCUnicodeStr

func ReadRPCUnicodeStr(r *bytes.Reader, nullTerminated bool) (s string, maxLength uint16, err error)

func ReadRPCUnicodeStrArray

func ReadRPCUnicodeStrArray(r *bytes.Reader, nullTerminated bool) (items []string, err error)

Specifically to handle all the ref id ptrs and array len and size valus that are lifted out of the structures

func ReadRPCUnicodeStrPtr

func ReadRPCUnicodeStrPtr(r *bytes.Reader, nullTerminated bool) (s string, maxLength uint16, err error)

func StripNullByte

func StripNullByte(s string) string

func ToUnicode

func ToUnicode(input string) []byte

func WriteConformantArray

func WriteConformantArray(w io.Writer, buf []byte) (n int, err error)

func WriteConformantArrayPtr

func WriteConformantArrayPtr(w io.Writer, buf []byte, refid *uint32) (n int, err error)

func WriteConformantVaryingArray

func WriteConformantVaryingArray(w io.Writer, buf []byte, maxCount uint32) (n int, err error)

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

func WriteConformantVaryingString(w io.Writer, s string, addNullByte bool) (n int, err error)

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 WriteRPCUnicodeStrArray(w io.Writer, items []string, refId *uint32, nullTerminate bool) (n int, err error)

func WriteRPCUnicodeStrPtr

func WriteRPCUnicodeStrPtr(w io.Writer, s string, refId *uint32) (n int, err error)

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

type ACE struct {
	Header ACEHeader
	Mask   uint32
	Sid    SID //Must be multiple of 4
}

MS-DTYP Section 2.4.4.2 ACCESS_ALLOWED_ACE

func (*ACE) MarshalBinary

func (self *ACE) MarshalBinary() (ret []byte, err error)

func (ACE) Permissions

func (a ACE) Permissions() AcePermissions

func (*ACE) UnmarshalBinary

func (self *ACE) UnmarshalBinary(buf []byte) (err error)

type ACEHeader

type ACEHeader struct {
	Type  byte
	Flags byte
	Size  uint16 //Includes header size?
}

MS-DTYP Section 2.4.4.1 ACE_HEADER

type AcePermissions

type AcePermissions struct {
	AceType        string
	AceFlags       byte
	AceFlagStrings string
	Permissions    []string
	Sid            string
}

type Filetime

type Filetime struct {
	LowDateTime  uint32
	HighDateTime uint32
}

MS-DTYP Section 2.3.3 FILETIME

func (*Filetime) FromReader

func (self *Filetime) FromReader(r *bytes.Reader) (err error)

func (*Filetime) ToString

func (self *Filetime) ToString() string

func (*Filetime) ToWriter

func (self *Filetime) ToWriter(w io.Writer) (n int, err error)

type PACL

type PACL struct {
	AclRevision uint16
	AclSize     uint16
	AceCount    uint32
	ACLS        []ACE
}

MS-DTYP Section 2.4.5.1 ACL--RPC Representation

func (*PACL) MarshalBinary

func (self *PACL) MarshalBinary() (ret []byte, err error)

func (*PACL) Permissions

func (self *PACL) Permissions() PaclPermissions

func (*PACL) UnmarshalBinary

func (self *PACL) UnmarshalBinary(buf []byte) (err error)

type PFiletime

type PFiletime struct {
	LowDateTime  uint32
	HighDateTime uint32
}

MS-DTYP Section 2.3.3 FILETIME

type PaclPermissions

type PaclPermissions struct {
	NumAce  uint32
	Entries []AcePermissions
}

type RPCUnicodeStr

type RPCUnicodeStr struct {
	MaxLength uint16
	S         string // Must NOT be null terminated
}

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

type SID struct {
	Revision       byte
	NumAuth        byte
	Authority      []byte
	SubAuthorities []uint32
}

MS-DTYP Section 2.4.2.3 RPC_SID

func ConvertStrToSID

func ConvertStrToSID(s string) (sid *SID, err error)

func ReadSID

func ReadSID(r *bytes.Reader) (s *SID, err error)

func (*SID) GetAuthority

func (self *SID) GetAuthority() uint32

func (*SID) MarshalBinary

func (self *SID) MarshalBinary() (ret []byte, err error)

func (*SID) ToString

func (self *SID) ToString() (s string)

func (*SID) UnmarshalBinary

func (self *SID) UnmarshalBinary(buf []byte) (err error)

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL