⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ntlm_check.c

📁 samba-3.0.22.tar.gz 编译smb服务器的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	/* Check for cleartext netlogon. Used by Exchange 5.5. */	if (challenge->length == sizeof(zeros) && 	    (memcmp(challenge->data, zeros, challenge->length) == 0 )) {		DEBUG(4,("ntlm_password_check: checking plaintext passwords for user %s\n",			 username));		if (nt_pw && nt_response->length) {			unsigned char pwhash[16];			mdfour(pwhash, nt_response->data, nt_response->length);			if (memcmp(pwhash, nt_pw, sizeof(pwhash)) == 0) {				return NT_STATUS_OK;			} else {				DEBUG(3,("ntlm_password_check: NT (Unicode) plaintext password check failed for user %s\n",					 username));				return NT_STATUS_WRONG_PASSWORD;			}		} else if (!lp_lanman_auth()) {			DEBUG(3,("ntlm_password_check: (plaintext password check) LANMAN passwords NOT PERMITTED for user %s\n",				 username));		} else if (lm_pw && lm_response->length) {			uchar dospwd[14]; 			uchar p16[16]; 			ZERO_STRUCT(dospwd);						memcpy(dospwd, lm_response->data, MIN(lm_response->length, sizeof(dospwd)));			/* Only the fisrt 14 chars are considered, password need not be null terminated. */			/* we *might* need to upper-case the string here */			E_P16((const unsigned char *)dospwd, p16);			if (memcmp(p16, lm_pw, sizeof(p16)) == 0) {				return NT_STATUS_OK;			} else {				DEBUG(3,("ntlm_password_check: LANMAN (ASCII) plaintext password check failed for user %s\n",					 username));				return NT_STATUS_WRONG_PASSWORD;			}		} else {			DEBUG(3, ("Plaintext authentication for user %s attempted, but neither NT nor LM passwords available\n", username));			return NT_STATUS_WRONG_PASSWORD;		}	}	if (nt_response->length != 0 && nt_response->length < 24) {		DEBUG(2,("ntlm_password_check: invalid NT password length (%lu) for user %s\n", 			 (unsigned long)nt_response->length, username));			}		if (nt_response->length >= 24 && nt_pw) {		if (nt_response->length > 24) {			/* We have the NT MD4 hash challenge available - see if we can			   use it 			*/			DEBUG(4,("ntlm_password_check: Checking NTLMv2 password with domain [%s]\n", client_domain));			if (smb_pwd_check_ntlmv2( nt_response, 						  nt_pw, challenge, 						  client_username, 						  client_domain,						  False,						  user_sess_key)) {				return NT_STATUS_OK;			}						DEBUG(4,("ntlm_password_check: Checking NTLMv2 password with uppercased version of domain [%s]\n", client_domain));			if (smb_pwd_check_ntlmv2( nt_response, 						  nt_pw, challenge, 						  client_username, 						  client_domain,						  True,						  user_sess_key)) {				return NT_STATUS_OK;			}						DEBUG(4,("ntlm_password_check: Checking NTLMv2 password without a domain\n"));			if (smb_pwd_check_ntlmv2( nt_response, 						  nt_pw, challenge, 						  client_username, 						  "",						  False,						  user_sess_key)) {				return NT_STATUS_OK;			} else {				DEBUG(3,("ntlm_password_check: NTLMv2 password check failed\n"));				return NT_STATUS_WRONG_PASSWORD;			}		}		if (lp_ntlm_auth()) {					/* We have the NT MD4 hash challenge available - see if we can			   use it (ie. does it exist in the smbpasswd file).			*/			DEBUG(4,("ntlm_password_check: Checking NT MD4 password\n"));			if (smb_pwd_check_ntlmv1(nt_response, 						 nt_pw, challenge,						 user_sess_key)) {				/* The LM session key for this response is not very secure, 				   so use it only if we otherwise allow LM authentication */				if (lp_lanman_auth() && lm_pw) {					uint8 first_8_lm_hash[16];					memcpy(first_8_lm_hash, lm_pw, 8);					memset(first_8_lm_hash + 8, '\0', 8);					if (lm_sess_key) {						*lm_sess_key = data_blob(first_8_lm_hash, 16);					}				}				return NT_STATUS_OK;			} else {				DEBUG(3,("ntlm_password_check: NT MD4 password check failed for user %s\n",					 username));				return NT_STATUS_WRONG_PASSWORD;			}		} else {			DEBUG(2,("ntlm_password_check: NTLMv1 passwords NOT PERMITTED for user %s\n",				 username));						/* no return, becouse we might pick up LMv2 in the LM field */		}	}		if (lm_response->length == 0) {		DEBUG(3,("ntlm_password_check: NEITHER LanMan nor NT password supplied for user %s\n",			 username));		return NT_STATUS_WRONG_PASSWORD;	}		if (lm_response->length < 24) {		DEBUG(2,("ntlm_password_check: invalid LanMan password length (%lu) for user %s\n", 			 (unsigned long)nt_response->length, username));				return NT_STATUS_WRONG_PASSWORD;	}			if (!lp_lanman_auth()) {		DEBUG(3,("ntlm_password_check: Lanman passwords NOT PERMITTED for user %s\n",			 username));	} else if (!lm_pw) {		DEBUG(3,("ntlm_password_check: NO LanMan password set for user %s (and no NT password supplied)\n",			 username));	} else {		DEBUG(4,("ntlm_password_check: Checking LM password\n"));		if (smb_pwd_check_ntlmv1(lm_response, 					 lm_pw, challenge,					 NULL)) {			uint8 first_8_lm_hash[16];			memcpy(first_8_lm_hash, lm_pw, 8);			memset(first_8_lm_hash + 8, '\0', 8);			if (user_sess_key) {				*user_sess_key = data_blob(first_8_lm_hash, 16);			}			if (lm_sess_key) {				*lm_sess_key = data_blob(first_8_lm_hash, 16);			}			return NT_STATUS_OK;		}	}		if (!nt_pw) {		DEBUG(4,("ntlm_password_check: LM password check failed for user, no NT password %s\n",username));		return NT_STATUS_WRONG_PASSWORD;	}		/* This is for 'LMv2' authentication.  almost NTLMv2 but limited to 24 bytes.	   - related to Win9X, legacy NAS pass-though authentication	*/	DEBUG(4,("ntlm_password_check: Checking LMv2 password with domain %s\n", client_domain));	if (smb_pwd_check_ntlmv2( lm_response, 				  nt_pw, challenge, 				  client_username,				  client_domain,				  False,				  NULL)) {		return NT_STATUS_OK;	}		DEBUG(4,("ntlm_password_check: Checking LMv2 password with upper-cased version of domain %s\n", client_domain));	if (smb_pwd_check_ntlmv2( lm_response, 				  nt_pw, challenge, 				  client_username,				  client_domain,				  True,				  NULL)) {		return NT_STATUS_OK;	}		DEBUG(4,("ntlm_password_check: Checking LMv2 password without a domain\n"));	if (smb_pwd_check_ntlmv2( lm_response, 				  nt_pw, challenge, 				  client_username,				  "",				  False,				  NULL)) {		return NT_STATUS_OK;	}	/* Apparently NT accepts NT responses in the LM field	   - I think this is related to Win9X pass-though authentication	*/	DEBUG(4,("ntlm_password_check: Checking NT MD4 password in LM field\n"));	if (lp_ntlm_auth()) {		if (smb_pwd_check_ntlmv1(lm_response, 					 nt_pw, challenge,					 NULL)) {			/* The session key for this response is still very odd.  			   It not very secure, so use it only if we otherwise 			   allow LM authentication */			if (lp_lanman_auth() && lm_pw) {				uint8 first_8_lm_hash[16];				memcpy(first_8_lm_hash, lm_pw, 8);				memset(first_8_lm_hash + 8, '\0', 8);				if (user_sess_key) {					*user_sess_key = data_blob(first_8_lm_hash, 16);				}				if (lm_sess_key) {					*lm_sess_key = data_blob(first_8_lm_hash, 16);				}			}			return NT_STATUS_OK;		}		DEBUG(3,("ntlm_password_check: LM password, NT MD4 password in LM field and LMv2 failed for user %s\n",username));	} else {		DEBUG(3,("ntlm_password_check: LM password and LMv2 failed for user %s, and NT MD4 password in LM field not permitted\n",username));	}	return NT_STATUS_WRONG_PASSWORD;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -