#include "squid.h"
#include "base64.h"
#include "compat/debug.h"
#include "helper/protocol_defines.h"
#include "ntlmauth/ntlmauth.h"
#include "ntlmauth/support_bits.cci"
#include "rfcnb/rfcnb.h"
#include "smblib/smblib.h"
#include <cassert>
#include <cctype>
#include <cerrno>
#include <csignal>
#include <cstdlib>
#include <cstring>
#include <ctime>
Go to the source code of this file.
Classes | |
struct | _dc |
Macros | |
#define | DEAD_DC_RETRY_INTERVAL 30 |
#define | SEND(X) debug("sending '%s' to squid\n",X); printf(X "\n"); |
#define | SEND2 printf |
#define | SEND3 printf |
#define | ENCODED_PASS_LEN 24 |
#define | MAX_USERNAME_LEN 255 |
#define | MAX_DOMAIN_LEN 255 |
#define | MAX_PASSWD_LEN 31 |
Typedefs | |
typedef struct _dc | dc |
Functions | |
const char * | make_challenge (char *domain, char *controller) |
char * | ntlm_check_auth (ntlm_authenticate *auth, int auth_length) |
void | dc_disconnect (void) |
int | connectedp (void) |
int | is_dc_ok (char *domain, char *domain_controller) |
void | usage (void) |
void | process_options (int argc, char *argv[]) |
const char * | obtain_challenge (void) |
void | manage_request (void) |
static int | init_challenge (char *domain, char *domain_controller) |
void | timeout_during_auth (int signum) |
int | main (int argc, char *argv[]) |
Variables | |
static unsigned char | challenge [NTLM_NONCE_LEN] |
static unsigned char | lmencoded_empty_pass [ENCODED_PASS_LEN] |
static unsigned char | ntencoded_empty_pass [ENCODED_PASS_LEN] |
SMB_Handle_Type | handle = nullptr |
int | ntlm_errno |
static char | credentials [MAX_USERNAME_LEN+MAX_DOMAIN_LEN+2] |
static char | my_domain [100] |
static char | my_domain_controller [100] |
static char | errstr [1001] |
char | load_balance = 0 |
char | protocol_pedantic = 0 |
dc * | controllers = nullptr |
int | numcontrollers = 0 |
dc * | current_dc |
char | smb_error_buffer [1000] |
static char | got_timeout = 0 |
char * | my_program_name = nullptr |
Macro Definition Documentation
◆ DEAD_DC_RETRY_INTERVAL
#define DEAD_DC_RETRY_INTERVAL 30 |
Definition at line 52 of file ntlm_smb_lm_auth.cc.
◆ ENCODED_PASS_LEN
#define ENCODED_PASS_LEN 24 |
Definition at line 87 of file ntlm_smb_lm_auth.cc.
◆ MAX_DOMAIN_LEN
#define MAX_DOMAIN_LEN 255 |
Definition at line 89 of file ntlm_smb_lm_auth.cc.
◆ MAX_PASSWD_LEN
#define MAX_PASSWD_LEN 31 |
Definition at line 90 of file ntlm_smb_lm_auth.cc.
◆ MAX_USERNAME_LEN
#define MAX_USERNAME_LEN 255 |
Definition at line 88 of file ntlm_smb_lm_auth.cc.
◆ SEND
#define SEND | ( | X | ) | debug("sending '%s' to squid\n",X); printf(X "\n"); |
Definition at line 57 of file ntlm_smb_lm_auth.cc.
◆ SEND2
#define SEND2 printf |
Definition at line 63 of file ntlm_smb_lm_auth.cc.
◆ SEND3
#define SEND3 printf |
Definition at line 64 of file ntlm_smb_lm_auth.cc.
Typedef Documentation
◆ dc
Definition at line 73 of file ntlm_smb_lm_auth.cc.
Function Documentation
◆ connectedp()
int connectedp | ( | void | ) |
Definition at line 120 of file ntlm_smb_lm_auth.cc.
◆ dc_disconnect()
void dc_disconnect | ( | void | ) |
Definition at line 112 of file ntlm_smb_lm_auth.cc.
References handle, NULL, and SMB_Discon().
Referenced by manage_request(), and timeout_during_auth().
◆ init_challenge()
|
static |
Definition at line 138 of file ntlm_smb_lm_auth.cc.
References challenge, debug(), SMB_Connect_Def::Encrypt_Key, errstr, handle, lmencoded_empty_pass, ntencoded_empty_pass, NTLM_NONCE_LEN, NULL, SMB_Connect_Def::Security, SMB_Connect_Server(), SMB_Discon(), SMB_Get_Error_Msg(), SMB_Get_Last_Error(), SMB_Negotiate(), SMB_Prots, SMBencrypt(), and SMBNTencrypt().
Referenced by make_challenge().
◆ is_dc_ok()
int is_dc_ok | ( | char * | domain, |
char * | domain_controller | ||
) |
Definition at line 127 of file ntlm_smb_lm_auth.cc.
References NULL, SMB_Connect_Server(), and SMB_Discon().
◆ main()
Definition at line 667 of file ntlm_smb_lm_auth.cc.
References controllers, current_dc, debug(), load_balance, manage_request(), my_program_name, _dc::next, numcontrollers, pid, process_options(), and VERSION.
◆ make_challenge()
const char * make_challenge | ( | char * | domain, |
char * | controller | ||
) |
Definition at line 173 of file ntlm_smb_lm_auth.cc.
References base64_encode_final(), base64_encode_init(), base64_encode_len, base64_encode_update(), challenge, debug(), HELPER_INPUT_BUFFER, init_challenge(), le16toh, _strhdr::maxlen, my_domain, my_domain_controller, NTLM_CHALLENGE_TARGET_IS_DOMAIN, ntlm_make_challenge(), NTLM_NEGOTIATE_ALWAYS_SIGN, NTLM_NEGOTIATE_ASCII, NTLM_NEGOTIATE_USE_LM, NTLM_NEGOTIATE_USE_NTLM, NTLM_NONCE_LEN, NTLM_REQUEST_NON_NT_SESSION_KEY, _ntlm_challenge::payload, and _ntlm_challenge::target.
Referenced by obtain_challenge().
◆ manage_request()
void manage_request | ( | void | ) |
Definition at line 496 of file ntlm_smb_lm_auth.cc.
References base64_decode_final(), base64_decode_init(), base64_decode_update(), dc_disconnect(), debug(), got_timeout, lc(), le32toh, NTLM_ANY, NTLM_AUTHENTICATE, NTLM_BLOB_BUFFER_SIZE, NTLM_CHALLENGE, ntlm_check_auth(), NTLM_ERR_LOGON, ntlm_errno, NTLM_NEGOTIATE, ntlm_validate_packet(), NULL, obtain_challenge(), RFCNB_Error_Strings, RFCNB_Get_Last_Error(), SEND, SEND2, SMB_Get_Last_Error(), SMB_Get_Last_SMB_Err(), SMBC_ERRCMD, SMBC_ERRDOS, SMBC_ERRHRD, SMBC_ERRSRV, SMBC_SUCCESS, SMBD_badaccess, SMBD_baddata, SMBD_badformat, SMBD_noaccess, SMBlib_Error_Class, SMBlib_Error_Code, SMBV_access, SMBV_badpw, strerror(), timeout_during_auth(), and _ntlmhdr::type.
Referenced by main().
◆ ntlm_check_auth()
char * ntlm_check_auth | ( | ntlm_authenticate * | auth, |
int | auth_length | ||
) |
Definition at line 219 of file ntlm_smb_lm_auth.cc.
References credentials, debug(), _ntlm_authenticate::domain, ENCODED_PASS_LEN, _ntlm_authenticate::flags, handle, _ntlm_authenticate::hdr, _lstring::l, le16toh, le32toh, _strhdr::len, lmencoded_empty_pass, _ntlm_authenticate::lmresponse, MAX_DOMAIN_LEN, MAX_PASSWD_LEN, MAX_USERNAME_LEN, min(), ntencoded_empty_pass, NTLM_ERR_LOGON, NTLM_ERR_NONE, NTLM_ERR_NOT_CONNECTED, ntlm_errno, ntlm_fetch_string(), _ntlm_authenticate::ntresponse, NULL, _strhdr::offset, SMB_Logon_Server(), _lstring::str, and _ntlm_authenticate::user.
Referenced by manage_request().
◆ obtain_challenge()
const char * obtain_challenge | ( | void | ) |
tries connecting to the domain controllers in the "controllers" ring, with failover if the adequate option is specified.
Definition at line 459 of file ntlm_smb_lm_auth.cc.
References _dc::controller, current_dc, _dc::dead, DEAD_DC_RETRY_INTERVAL, debug(), _dc::domain, make_challenge(), _dc::next, NULL, and numcontrollers.
Referenced by manage_request().
◆ process_options()
void process_options | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 379 of file ntlm_smb_lm_auth.cc.
References _dc::controller, controllers, _dc::dead, debug(), debug_enabled, _dc::domain, getopt(), load_balance, _dc::next, NULL, numcontrollers, optind, uc(), usage(), and xmalloc.
Referenced by main().
◆ timeout_during_auth()
void timeout_during_auth | ( | int | ) |
signal handler to be invoked when the authentication operation times out
Definition at line 347 of file ntlm_smb_lm_auth.cc.
References dc_disconnect().
Referenced by manage_request().
◆ usage()
void usage | ( | void | ) |
Definition at line 363 of file ntlm_smb_lm_auth.cc.
References my_program_name.
Referenced by process_options().
Variable Documentation
◆ challenge
|
static |
Definition at line 92 of file ntlm_smb_lm_auth.cc.
Referenced by init_challenge(), and make_challenge().
◆ controllers
dc* controllers = nullptr |
Definition at line 104 of file ntlm_smb_lm_auth.cc.
Referenced by main(), and process_options().
◆ credentials
|
static |
Definition at line 97 of file ntlm_smb_lm_auth.cc.
Referenced by GenServerContext(), and ntlm_check_auth().
◆ current_dc
dc* current_dc |
Definition at line 106 of file ntlm_smb_lm_auth.cc.
Referenced by main(), and obtain_challenge().
◆ errstr
|
static |
Definition at line 99 of file ntlm_smb_lm_auth.cc.
Referenced by checkForPortOnly(), init_challenge(), and main().
◆ got_timeout
|
static |
Definition at line 343 of file ntlm_smb_lm_auth.cc.
Referenced by manage_request().
◆ handle
SMB_Handle_Type handle = nullptr |
Definition at line 95 of file ntlm_smb_lm_auth.cc.
Referenced by connectedp(), dc_disconnect(), file_write(), init_challenge(), and ntlm_check_auth().
◆ lmencoded_empty_pass
|
static |
Definition at line 93 of file ntlm_smb_lm_auth.cc.
Referenced by init_challenge(), and ntlm_check_auth().
◆ load_balance
char load_balance = 0 |
Definition at line 103 of file ntlm_smb_lm_auth.cc.
Referenced by main(), and process_options().
◆ my_domain
|
static |
Definition at line 98 of file ntlm_smb_lm_auth.cc.
Referenced by make_challenge().
◆ my_domain_controller
|
static |
Definition at line 98 of file ntlm_smb_lm_auth.cc.
Referenced by make_challenge().
◆ my_program_name
char* my_program_name = nullptr |
Definition at line 360 of file ntlm_smb_lm_auth.cc.
◆ ntencoded_empty_pass
|
static |
Definition at line 94 of file ntlm_smb_lm_auth.cc.
Referenced by init_challenge(), and ntlm_check_auth().
◆ ntlm_errno
int ntlm_errno |
Definition at line 96 of file ntlm_smb_lm_auth.cc.
Referenced by manage_request(), and ntlm_check_auth().
◆ numcontrollers
int numcontrollers = 0 |
Definition at line 105 of file ntlm_smb_lm_auth.cc.
Referenced by main(), obtain_challenge(), and process_options().
◆ protocol_pedantic
char protocol_pedantic = 0 |
Definition at line 103 of file ntlm_smb_lm_auth.cc.
◆ smb_error_buffer
char smb_error_buffer[1000] |
Definition at line 107 of file ntlm_smb_lm_auth.cc.