Documentation ¶
Overview ¶
wintoken abstracts away windows token manipulation functions with functions you are more likely to use. The library exposes easy-to-use functions to steal tokens, enable/disable privileges, and grab interactive and linked tokens.
Index ¶
- Constants
- Variables
- type Privilege
- type Token
- func (t *Token) Close()
- func (t *Token) DisableAllPrivileges() error
- func (t *Token) DisableTokenPrivilege(priv string) error
- func (t *Token) DisableTokenPrivileges(privs []string) error
- func (t *Token) EnableAllPrivileges() error
- func (t *Token) EnableTokenPrivilege(priv string) error
- func (t *Token) EnableTokenPrivileges(privs []string) error
- func (t *Token) GetIntegrityLevel() (string, error)
- func (t *Token) GetLinkedToken() (*Token, error)
- func (t *Token) GetPrivileges() ([]Privilege, error)
- func (t *Token) RemoveAllPrivileges() error
- func (t *Token) RemoveTokenPrivilege(priv string) error
- func (t *Token) RemoveTokenPrivileges(privs []string) error
- func (t *Token) Token() windows.Token
- func (t *Token) UserDetails() (TokenUserDetail, error)
- type TokenUserDetail
Constants ¶
const ( PrivDisable privModType = iota PrivEnable PrivRemove )
const ( TokenPrimary tokenType TokenImpersonation TokenLinked )
const (
WTS_CURRENT_SERVER_HANDLE windows.Handle = 0
)
Variables ¶
var ( ErrNoActiveSession error = fmt.Errorf("no active session found") ErrInvalidDuplicatedToken error = fmt.Errorf("invalid duplicated token") ErrOnlyPrimaryImpersonationTokenAllowed error = fmt.Errorf("only primary or impersonation token types allowed") ErrNoPrivilegesSpecified error = fmt.Errorf("no privileges specified") ErrTokenClosed error = fmt.Errorf("token has been closed") )
Functions ¶
This section is empty.
Types ¶
type Privilege ¶
type Privilege struct { Name string Description string Enabled bool EnabledByDefault bool Removed bool UsedForAccess bool }
Privilege is the structure which exposes privilege details Details contain Name, Description, Enabled, EnabledByDefault, Removed, UsedForAccess
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
func GetInteractiveToken ¶
GetInteractiveToken gets the interactive token associated with current logged in user It uses windows API WTSEnumerateSessions, WTSQueryUserToken and DuplicateTokenEx to return a valid wintoken
func NewToken ¶
NewToken can be used to supply your own token for the wintoken struct so you can use the same flexiblity provided by the package
func OpenProcessToken ¶
OpenProcessToken opens a process token using PID, pass 0 as PID for self token
func (*Token) DisableAllPrivileges ¶
DisableAllPrivileges disables all privileges in the token
func (*Token) DisableTokenPrivilege ¶
DisableTokenPrivilege disables token privileges by privilege name
func (*Token) DisableTokenPrivileges ¶
DisableTokenPrivileges disables token privileges by list of privilege names
func (*Token) EnableAllPrivileges ¶
EnableAllPrivileges enables all privileges in the token
func (*Token) EnableTokenPrivilege ¶
EnableTokenPrivileges enables token privileges by privilege name
func (*Token) EnableTokenPrivileges ¶
EnableTokenPrivileges enables token privileges by list of privilege names
func (*Token) GetIntegrityLevel ¶
GetIntegrityLevel is used to get integrity level of the token
func (*Token) GetLinkedToken ¶
GetLinkedToken is used to get the linked token if any
func (*Token) GetPrivileges ¶
GetPrivileges lists all Privileges from the token
func (*Token) RemoveAllPrivileges ¶
RemoveAllPrivileges removes all privileges from the token
func (*Token) RemoveTokenPrivilege ¶
RemoveTokenPrivilege removes token privileges by privilege name
func (*Token) RemoveTokenPrivileges ¶
RemoveTokenPrivileges removes token privileges by list of privilege names
func (*Token) UserDetails ¶
func (t *Token) UserDetails() (TokenUserDetail, error)
UserDetails gets User details associated with token
type TokenUserDetail ¶
type TokenUserDetail struct { Username string Domain string AccountType uint32 UserProfileDir string Environ []string }
TokenUserDetail is the structure that exposes token details Details contain Username, Domain, Account Type, User Profile Directory, Environment
func (TokenUserDetail) String ¶
func (t TokenUserDetail) String() string