auth

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package auth provides authentication methods for NullFang

Package auth provides authentication methods for NullFang

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHash          = errors.New("invalid hash format")
	ErrAuthenticationFailed = errors.New("authentication failed")
	ErrUnsupportedMethod    = errors.New("unsupported authentication method")
	ErrMissingCredentials   = errors.New("missing required credentials")
)

Common errors

Functions

func GenerateNTHash

func GenerateNTHash(password string) (string, error)

GenerateNTHash generates an NT hash from a password

func GetSPNForHost

func GetSPNForHost(service, host string) string

GetSPNForHost generates a Service Principal Name for a host

func ParseHashString

func ParseHashString(hashStr string) (string, string, string, error)

ParseHashString parses a hash string in various formats

func ValidateNTLMHash

func ValidateNTLMHash(hash string) (string, string, error)

ValidateNTLMHash validates an NTLM hash format

Types

type AuthMethod

type AuthMethod interface {
	// GetCredentials retorna as credenciais formatadas para o método específico
	GetCredentials() (*Credentials, error)
	// GetName retorna o nome do método de autenticação
	GetName() string
}

AuthMethod é a interface que todos os métodos de autenticação devem implementar

func NewAuthMethod

func NewAuthMethod(authType AuthType, params map[string]string) (AuthMethod, error)

NewAuthMethod creates a new authentication method

func NewKerberosAuth

func NewKerberosAuth(domain, username string, options ...Option) AuthMethod

NewKerberosAuth creates a new Kerberos authenticator

type AuthType

type AuthType string

AuthType representa os tipos de autenticação suportados

const (
	AuthTypeNTLM     AuthType = "NTLM"
	AuthTypeKerberos AuthType = "Kerberos"
)

type Credentials

type Credentials struct {
	Username   string
	Password   string
	Domain     string
	Hash       string
	Ticket     []byte
	Method     string
	HashType   string
	SessionKey []byte
}

Credentials contém as informações de autenticação

type KerberosAuth

type KerberosAuth struct {
	Ticket     []byte
	TicketPath string
	// contains filtered or unexported fields
}

KerberosAuth implements Kerberos authentication

func (*KerberosAuth) Authenticate

func (a *KerberosAuth) Authenticate() (*Credentials, error)

Authenticate performs the authentication and returns credentials that can be used with SMB

func (*KerberosAuth) GetCredentials

func (k *KerberosAuth) GetCredentials() (*Credentials, error)

func (*KerberosAuth) GetName

func (k *KerberosAuth) GetName() string

func (*KerberosAuth) Type

func (a *KerberosAuth) Type() string

Type returns the authentication method type

type NTLMAuth

type NTLMAuth struct {
	Username string
	Hash     string
	Domain   string
	LMHash   string
	NTHash   string
}

NTLMAuth implements NTLM hash authentication

func NewNTLMAuth

func NewNTLMAuth(params map[string]string) (*NTLMAuth, error)

NewNTLMAuth creates a new NTLM hash authenticator

func (*NTLMAuth) GetCredentials

func (n *NTLMAuth) GetCredentials() (*Credentials, error)

GetCredentials returns the credentials formatted for the specific method

func (*NTLMAuth) GetName

func (n *NTLMAuth) GetName() string

GetName returns the name of the authentication method

type Option

type Option func(interface{})

Option represents an option for authentication methods

func WithDebug

func WithDebug(debug bool) Option

WithDebug enables debug logging

func WithKDCHost

func WithKDCHost(kdcHost string) Option

WithKDCHost sets the Kerberos KDC host

func WithKerberosPassword

func WithKerberosPassword(password string) Option

WithKerberosPassword sets the password for Kerberos authentication

func WithKeytabFile

func WithKeytabFile(keytabFile string) Option

WithKeytabFile sets the Kerberos keytab file

func WithPort

func WithPort(port int) Option

WithPort sets the authentication server port

func WithRealm

func WithRealm(realm string) Option

WithRealm sets the Kerberos realm

func WithSPN

func WithSPN(spn string) Option

WithSPN sets the Service Principal Name for Kerberos authentication

func WithServer

func WithServer(server string) Option

WithServer sets the authentication server

func WithTicketFile

func WithTicketFile(ticketFile string) Option

WithTicketFile sets the Kerberos ticket file (ccache)

Jump to

Keyboard shortcuts

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