ntlmv1

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 6 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 NTLMv1Ctx added in v1.0.3

type NTLMv1Ctx struct {
	Username string // Username for authentication
	Password string // Password for authentication
	Domain   string // Domain name

	NTHash [16]byte // NT hash of the password
	LMHash [16]byte // LM hash of the password

	ServerChallenge [8]byte // 8-byte challenge from server
}

NTLMv1Ctx represents the components needed for NTLMv1 authentication. Source: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-nlmp/464551a8-9fc4-428e-b3d3-bc5bfb2e73a5

func NewNTLMv1CtxWithHashes added in v1.0.3

func NewNTLMv1CtxWithHashes(domain, username string, lmhash [16]byte, nthash [16]byte, serverChallenge [8]byte) (*NTLMv1Ctx, error)

NewNTLMv1CtxWithHashes creates a new NTLMv1 instance using pre-computed NT and LM hashes.

Parameters:

  • domain: The domain name
  • username: The username
  • lmhash: The pre-computed LM hash
  • nthash: The pre-computed NT hash
  • serverChallenge: 8-byte challenge from the server

Returns:

  • *NTLMv1Ctx: The initialized NTLMv1 context
  • error: If server challenge is not 8 bytes

func NewNTLMv1CtxWithLMHash added in v1.0.3

func NewNTLMv1CtxWithLMHash(domain, username string, lmhash [16]byte, serverChallenge [8]byte) (*NTLMv1Ctx, error)

NewNTLMv1CtxWithLMHash creates a new NTLMv1 instance using a pre-computed LM hash. The NT hash will be computed from an empty password.

Parameters:

  • domain: The domain name
  • username: The username
  • lmhash: The pre-computed LM hash
  • serverChallenge: 8-byte challenge from the server

Returns:

  • *NTLMv1Ctx: The initialized NTLMv1 context
  • error: If server challenge is not 8 bytes

func NewNTLMv1CtxWithNTHash added in v1.0.3

func NewNTLMv1CtxWithNTHash(domain, username string, nthash [16]byte, serverChallenge [8]byte) (*NTLMv1Ctx, error)

NewNTLMv1CtxWithNTHash creates a new NTLMv1 instance using a pre-computed NT hash. The LM hash will be computed from an empty password.

Parameters:

  • domain: The domain name
  • username: The username
  • nthash: The pre-computed NT hash
  • serverChallenge: 8-byte challenge from the server

Returns:

  • *NTLMv1Ctx: The initialized NTLMv1 context
  • error: If server challenge is not 8 bytes

func NewNTLMv1CtxWithPassword added in v1.0.3

func NewNTLMv1CtxWithPassword(domain, username, password string, serverChallenge [8]byte) (*NTLMv1Ctx, error)

NewNTLMv1CtxWithPassword creates a new NTLMv1 instance with the provided credentials and challenge. It calculates both the NT and LM hashes from the provided password.

Parameters:

  • domain: The domain name
  • username: The username
  • password: The plaintext password
  • serverChallenge: 8-byte challenge from the server

Returns:

  • *NTLMv1Ctx: The initialized NTLMv1 context
  • error: If server challenge is not 8 bytes

func (*NTLMv1Ctx) ComputeLmChallengeResponse added in v1.0.3

func (n *NTLMv1Ctx) ComputeLmChallengeResponse() ([24]byte, error)

LmChallengeResponse calculates the LM response for NTLMv1 authentication.

The LM response is calculated by 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.

The process: 1. Split the LM hash into three 7-byte keys (padding the last key with zeros) 2. Adjust each key for DES parity 3. Create DES ciphers with each key 4. Encrypt the server challenge with each cipher 5. Concatenate the results

Returns:

  • []byte: The 24-byte LM response
  • error: If key adjustment or encryption fails

func (*NTLMv1Ctx) ComputeNtChallengeResponse added in v1.0.3

func (n *NTLMv1Ctx) ComputeNtChallengeResponse() ([24]byte, error)

NtChallengeResponse 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.

The process: 1. Split the NT hash into three 7-byte keys (padding the last key with zeros) 2. Adjust each key for DES parity 3. Create DES ciphers with each key 4. Encrypt the server challenge with each cipher 5. Concatenate the results

Returns:

  • []byte: The 24-byte NT response
  • error: If key adjustment or encryption fails

func (*NTLMv1Ctx) ComputeResponse added in v1.0.3

func (h *NTLMv1Ctx) ComputeResponse() (*NTLMv1Response, error)

ComputeResponse calculates the NTLMv1 response for the given context.

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

Returns:

  • *NTLMv1Response: The NTLMv1 response
  • error: If the response cannot be computed

type NTLMv1Response added in v1.0.3

type NTLMv1Response struct {
	Username string // Username for authentication
	Domain   string // Domain name

	ServerChallenge     [8]byte  // 8-byte challenge from server
	LmChallengeResponse [24]byte // 24-byte LM challenge response
	NtChallengeResponse [24]byte // 24-byte NT challenge response
}

func NewNTLMv1Response added in v1.0.3

func NewNTLMv1Response(username, domain string, serverChallenge [8]byte, lmChallengeResponse [24]byte, ntChallengeResponse [24]byte) *NTLMv1Response

func (*NTLMv1Response) Equal added in v1.0.3

func (r *NTLMv1Response) Equal(other *NTLMv1Response) bool

Equal compares two NTLMv1Response objects for equality

func (*NTLMv1Response) GetLmChallengeResponse added in v1.0.3

func (r *NTLMv1Response) GetLmChallengeResponse() [24]byte

GetLmChallengeResponse returns the LM challenge response

func (*NTLMv1Response) GetNtChallengeResponse added in v1.0.3

func (r *NTLMv1Response) GetNtChallengeResponse() [24]byte

GetNtChallengeResponse returns the NT challenge response

func (*NTLMv1Response) GetServerChallenge added in v1.0.3

func (r *NTLMv1Response) GetServerChallenge() [8]byte

GetServerChallenge returns the server challenge

func (*NTLMv1Response) HashcatString added in v1.0.3

func (r *NTLMv1Response) HashcatString() (string, error)

HashcatString converts the NTLMv1 response to a Hashcat string

Returns:

  • The Hashcat string
  • An error if the conversion fails

func (*NTLMv1Response) SetLmChallengeResponse added in v1.0.3

func (r *NTLMv1Response) SetLmChallengeResponse(response [24]byte)

SetLmChallengeResponse sets the LM challenge response

func (*NTLMv1Response) SetNtChallengeResponse added in v1.0.3

func (r *NTLMv1Response) SetNtChallengeResponse(response [24]byte)

SetNtChallengeResponse sets the NT challenge response

func (*NTLMv1Response) SetServerChallenge added in v1.0.3

func (r *NTLMv1Response) SetServerChallenge(challenge [8]byte)

SetServerChallenge sets the server challenge

func (*NTLMv1Response) String added in v1.0.3

func (r *NTLMv1Response) String() string

String returns the NTLMv1 response as a string

Returns:

  • The NTLMv1 response as a string
  • An error if the conversion fails

Jump to

Keyboard shortcuts

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