ntlmauth.cc File Reference
#include "squid.h"
#include <cstring>
#include <ctime>
#include <random>
#include "ntlmauth/ntlmauth.h"
#include "util.h"
Include dependency graph for ntlmauth.cc:

Go to the source code of this file.

Functions

void ntlm_dump_ntlmssp_flags (uint32_t flags)
 
int ntlm_validate_packet (const ntlmhdr *hdr, const int32_t type)
 
lstring ntlm_fetch_string (const ntlmhdr *packet, const int32_t packet_size, const strhdr *str, const uint32_t flags)
 
void ntlm_add_to_payload (const ntlmhdr *packet_hdr, char *payload, int *payload_length, strhdr *hdr, const char *toadd, const uint16_t toadd_length)
 
void ntlm_make_nonce (char *nonce)
 
void ntlm_make_challenge (ntlm_challenge *ch, const char *domain, const char *, const char *challenge_nonce, const int challenge_nonce_len, const uint32_t flags)
 
int ntlm_unpack_auth (const ntlm_authenticate *auth, char *user, char *domain, const int32_t size)
 

Function Documentation

◆ ntlm_add_to_payload()

void ntlm_add_to_payload ( const ntlmhdr packet_hdr,
char *  payload,
int payload_length,
strhdr hdr,
const char *  toadd,
const uint16_t  toadd_length 
)

Adds something to the payload. The caller must guarantee that there is enough space in the payload string to accommodate the added value. payload_length and hdr will be modified as a side-effect.

Definition at line 164 of file ntlmauth.cc.

References htole16, htole32, _strhdr::len, _strhdr::maxlen, and _strhdr::offset.

Referenced by ntlm_make_challenge().

◆ ntlm_dump_ntlmssp_flags()

◆ ntlm_fetch_string()

lstring ntlm_fetch_string ( const ntlmhdr packet,
const int32_t  packet_size,
const strhdr str,
const uint32_t  flags 
)

Fetches a string from the authentication packet. The lstring data-part may point to inside the packet itself or a temporary static buffer. It's up to the user to memcpy() that if the value needs to be used in any way that requires a tailing \0. (can check whether the value is there though, in that case lstring.length == -1).

String may be either ASCII or UNICODE depending on whether flags contains NTLM_NEGOTIATE_ASCII

Definition at line 98 of file ntlmauth.cc.

References debug(), _lstring::l, le16toh, le32toh, _strhdr::len, NTLM_MAX_FIELD_LENGTH, NTLM_NEGOTIATE_ASCII, _strhdr::offset, sc, _lstring::str, and xisprint.

Referenced by ntlm_check_auth(), and ntlm_unpack_auth().

◆ ntlm_make_challenge()

void ntlm_make_challenge ( ntlm_challenge ch,
const char *  domain,
const char *  domain_controller,
const char *  challenge_nonce,
const int  challenge_nonce_len,
const uint32_t  flags 
)

◆ ntlm_make_nonce()

void ntlm_make_nonce ( char *  nonce)

Generate a challenge request nonce.

Definition at line 195 of file ntlmauth.cc.

References NTLM_NONCE_LEN.

Referenced by main().

◆ ntlm_unpack_auth()

int ntlm_unpack_auth ( const ntlm_authenticate auth,
char *  user,
char *  domain,
const int32_t  size 
)

Unpack the strings in an NTLM authentication response from client. The caller is responsible for initializing the user and domain buffers this function will only insert data if the packet contains any. Otherwise the buffers will be left untouched.

Return values
NTLM_ERR_NONEusername present, maybe also domain.
NTLM_ERR_PROTOCOLpacket type is not an authentication packet.
NTLM_ERR_LOGONno username.
NTLM_ERR_BLOBdomain field is apparently larger than the packet.

Definition at line 246 of file ntlmauth.cc.

References debug(), _ntlm_authenticate::domain, _ntlm_authenticate::flags, _ntlm_authenticate::hdr, _lstring::l, le32toh, _strhdr::len, _ntlm_authenticate::lmresponse, NTLM_AUTHENTICATE, NTLM_ERR_BLOB, NTLM_ERR_LOGON, NTLM_ERR_NONE, NTLM_ERR_PROTOCOL, ntlm_fetch_string(), ntlm_validate_packet(), _ntlm_authenticate::ntresponse, _strhdr::offset, _ntlm_authenticate::sessionkey, size, _lstring::str, _ntlm_authenticate::user, and _ntlm_authenticate::workstation.

Referenced by main(), and ntlm_check_auth().

◆ ntlm_validate_packet()

int ntlm_validate_packet ( const ntlmhdr hdr,
const int32_t  type 
)

Check the validity of a decoded NTLM packet.

Return values
NTLM_ERR_NONEPacket is okay
NTLM_ERR_BLOBPacket is not even an NTLMSSP packet at all.
NTLM_ERR_PROTOCOLPacket is not the expected type.

Definition at line 67 of file ntlmauth.cc.

References debug(), le32toh, NTLM_ANY, NTLM_ERR_BLOB, NTLM_ERR_NONE, NTLM_ERR_PROTOCOL, _ntlmhdr::signature, and _ntlmhdr::type.

Referenced by main(), manage_request(), and ntlm_unpack_auth().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors