ntlmv1

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParityAdjust

func ParityAdjust(key []byte) ([]byte, error)

ParityAdjust takes a byte slice as input and adjusts it for DES key parity. For each 7 bits of the input, it adds a parity bit as the 8th bit to ensure odd parity (each byte has an odd number of 1 bits). This is required for DES key generation in NTLM authentication.

The function processes the input in 7-bit chunks, adding a parity bit to each chunk to form 8-bit bytes in the output. If the input length is not a multiple of 7 bits, it pads with zeros.

Returns the parity-adjusted byte slice and any error encountered during processing.

func ParityBit

func ParityBit(n int) int

ParityBit calculates the parity bit for a given integer. It returns 1 if the number of set bits (1s) in the binary representation of the input is even, and 0 if the number is odd. This is used in DES key generation to ensure each byte has odd parity.

Types

type NTLMv1

type NTLMv1 struct {
	Username        string
	Password        string
	Domain          string
	ServerChallenge []byte
	NTHash          []byte
}

NTLMv1 represents the components needed for NTLMv1 authentication

func NewNTLMv1WithNTHash

func NewNTLMv1WithNTHash(domain, username string, nthash []byte, serverChallenge []byte) (*NTLMv1, error)

NewNTLMv1WithNTHash creates a new NTLMv1 instance with the provided credentials and challenge

func NewNTLMv1WithPassword

func NewNTLMv1WithPassword(domain, username, password string, serverChallenge []byte) (*NTLMv1, error)

NewNTLMv1WithPassword creates a new NTLMv1 instance with the provided credentials and challenge

func (*NTLMv1) Hash

func (h *NTLMv1) Hash() ([]byte, error)

NTLMv1Hash calculates the NTLMv1 hash

Returns:

  • The NTLMv1 hash as a byte slice
  • An error if the NTHash or Password is not set

func (*NTLMv1) LMResponse

func (n *NTLMv1) LMResponse() ([]byte, error)

LMResponse calculates the LM response for NTLMv1 authentication

The LM response is calculated by first creating the LM hash from the password, then encrypting the server challenge with the LM hash using DES encryption. The LM hash is split into three 7-byte keys, each adjusted for DES parity, and each key is used to encrypt the challenge.

Returns the 24-byte LM response or an error if the encryption fails.

func (*NTLMv1) NTResponse

func (n *NTLMv1) NTResponse() ([]byte, error)

NTResponse calculates the NT response for NTLMv1 authentication

The NT response is calculated by encrypting the server challenge with the NT hash using DES encryption. The NT hash is split into three 7-byte keys, each adjusted for DES parity, and each key is used to encrypt the challenge.

Returns the 24-byte NT response or an error if the encryption fails.

func (*NTLMv1) String

func (h *NTLMv1) String() string

String returns the NTLMv1 hash as a hexadecimal string

Returns:

  • The NTLMv1 hash as an uppercase hexadecimal string

Jump to

Keyboard shortcuts

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