|
|
b6b438 |
From 01c0b0ac77baae946d270d44d1c40dbdf17a8ee3 Mon Sep 17 00:00:00 2001
|
|
|
b6b438 |
From: Andreas Schneider <asn@samba.org>
|
|
|
b6b438 |
Date: Thu, 25 Jul 2019 15:15:46 +1200
|
|
|
b6b438 |
Subject: [PATCH 024/187] s4:libnet: Use GnuTLS RC4 in
|
|
|
b6b438 |
libnet_ChangePassword_samr()
|
|
|
b6b438 |
|
|
|
b6b438 |
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14031
|
|
|
b6b438 |
|
|
|
b6b438 |
Signed-off-by: Andreas Schneider <asn@samba.org>
|
|
|
b6b438 |
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
|
|
|
b6b438 |
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
|
|
|
b6b438 |
(cherry picked from commit 9ea736590d9b22a7518f86b18e8c55b0d0e213d5)
|
|
|
b6b438 |
---
|
|
|
b6b438 |
source4/libnet/libnet_passwd.c | 110 +++++++++++++++++++++++++++++++--
|
|
|
b6b438 |
1 file changed, 104 insertions(+), 6 deletions(-)
|
|
|
b6b438 |
|
|
|
b6b438 |
diff --git a/source4/libnet/libnet_passwd.c b/source4/libnet/libnet_passwd.c
|
|
|
b6b438 |
index dce3813de38..704a94a5864 100644
|
|
|
b6b438 |
--- a/source4/libnet/libnet_passwd.c
|
|
|
b6b438 |
+++ b/source4/libnet/libnet_passwd.c
|
|
|
b6b438 |
@@ -20,7 +20,6 @@
|
|
|
b6b438 |
|
|
|
b6b438 |
#include "includes.h"
|
|
|
b6b438 |
#include "libnet/libnet.h"
|
|
|
b6b438 |
-#include "../lib/crypto/crypto.h"
|
|
|
b6b438 |
#include "libcli/auth/libcli_auth.h"
|
|
|
b6b438 |
#include "librpc/gen_ndr/ndr_samr_c.h"
|
|
|
b6b438 |
#include "source4/librpc/rpc/dcerpc.h"
|
|
|
b6b438 |
@@ -57,6 +56,16 @@ static NTSTATUS libnet_ChangePassword_samr(struct libnet_context *ctx, TALLOC_CT
|
|
|
b6b438 |
uint8_t old_lm_hash[16], new_lm_hash[16];
|
|
|
b6b438 |
struct samr_DomInfo1 *dominfo = NULL;
|
|
|
b6b438 |
struct userPwdChangeFailureInformation *reject = NULL;
|
|
|
b6b438 |
+ gnutls_cipher_hd_t cipher_hnd = NULL;
|
|
|
b6b438 |
+ gnutls_datum_t nt_session_key = {
|
|
|
b6b438 |
+ .data = old_nt_hash,
|
|
|
b6b438 |
+ .size = sizeof(old_nt_hash),
|
|
|
b6b438 |
+ };
|
|
|
b6b438 |
+ gnutls_datum_t lm_session_key = {
|
|
|
b6b438 |
+ .data = old_lm_hash,
|
|
|
b6b438 |
+ .size = sizeof(old_lm_hash),
|
|
|
b6b438 |
+ };
|
|
|
b6b438 |
+ int rc;
|
|
|
b6b438 |
|
|
|
b6b438 |
ZERO_STRUCT(c);
|
|
|
b6b438 |
|
|
|
b6b438 |
@@ -87,11 +96,47 @@ static NTSTATUS libnet_ChangePassword_samr(struct libnet_context *ctx, TALLOC_CT
|
|
|
b6b438 |
|
|
|
b6b438 |
/* prepare samr_ChangePasswordUser3 */
|
|
|
b6b438 |
encode_pw_buffer(lm_pass.data, r->samr.in.newpassword, STR_UNICODE);
|
|
|
b6b438 |
- arcfour_crypt(lm_pass.data, old_nt_hash, 516);
|
|
|
b6b438 |
+
|
|
|
b6b438 |
+ rc = gnutls_cipher_init(&cipher_hnd,
|
|
|
b6b438 |
+ GNUTLS_CIPHER_ARCFOUR_128,
|
|
|
b6b438 |
+ &nt_session_key,
|
|
|
b6b438 |
+ NULL);
|
|
|
b6b438 |
+ if (rc < 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
|
|
|
b6b438 |
+ goto disconnect;
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
+
|
|
|
b6b438 |
+ rc = gnutls_cipher_encrypt(cipher_hnd,
|
|
|
b6b438 |
+ lm_pass.data,
|
|
|
b6b438 |
+ 516);
|
|
|
b6b438 |
+ gnutls_cipher_deinit(cipher_hnd);
|
|
|
b6b438 |
+ if (rc < 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
|
|
|
b6b438 |
+ goto disconnect;
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
+
|
|
|
b6b438 |
E_old_pw_hash(new_lm_hash, old_lm_hash, lm_verifier.hash);
|
|
|
b6b438 |
|
|
|
b6b438 |
encode_pw_buffer(nt_pass.data, r->samr.in.newpassword, STR_UNICODE);
|
|
|
b6b438 |
- arcfour_crypt(nt_pass.data, old_nt_hash, 516);
|
|
|
b6b438 |
+
|
|
|
b6b438 |
+ rc = gnutls_cipher_init(&cipher_hnd,
|
|
|
b6b438 |
+ GNUTLS_CIPHER_ARCFOUR_128,
|
|
|
b6b438 |
+ &nt_session_key,
|
|
|
b6b438 |
+ NULL);
|
|
|
b6b438 |
+ if (rc < 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
|
|
|
b6b438 |
+ goto disconnect;
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
+
|
|
|
b6b438 |
+ rc = gnutls_cipher_encrypt(cipher_hnd,
|
|
|
b6b438 |
+ nt_pass.data,
|
|
|
b6b438 |
+ 516);
|
|
|
b6b438 |
+ gnutls_cipher_deinit(cipher_hnd);
|
|
|
b6b438 |
+ if (rc < 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
|
|
|
b6b438 |
+ goto disconnect;
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
+
|
|
|
b6b438 |
E_old_pw_hash(new_nt_hash, old_nt_hash, nt_verifier.hash);
|
|
|
b6b438 |
|
|
|
b6b438 |
pw3.in.server = &server;
|
|
|
b6b438 |
@@ -125,11 +170,46 @@ static NTSTATUS libnet_ChangePassword_samr(struct libnet_context *ctx, TALLOC_CT
|
|
|
b6b438 |
|
|
|
b6b438 |
/* prepare samr_ChangePasswordUser2 */
|
|
|
b6b438 |
encode_pw_buffer(lm_pass.data, r->samr.in.newpassword, STR_ASCII|STR_TERMINATE);
|
|
|
b6b438 |
- arcfour_crypt(lm_pass.data, old_lm_hash, 516);
|
|
|
b6b438 |
+
|
|
|
b6b438 |
+ rc = gnutls_cipher_init(&cipher_hnd,
|
|
|
b6b438 |
+ GNUTLS_CIPHER_ARCFOUR_128,
|
|
|
b6b438 |
+ &lm_session_key,
|
|
|
b6b438 |
+ NULL);
|
|
|
b6b438 |
+ if (rc < 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
|
|
|
b6b438 |
+ goto disconnect;
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
+
|
|
|
b6b438 |
+ rc = gnutls_cipher_encrypt(cipher_hnd,
|
|
|
b6b438 |
+ lm_pass.data,
|
|
|
b6b438 |
+ 516);
|
|
|
b6b438 |
+ gnutls_cipher_deinit(cipher_hnd);
|
|
|
b6b438 |
+ if (rc < 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
|
|
|
b6b438 |
+ goto disconnect;
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
+
|
|
|
b6b438 |
E_old_pw_hash(new_lm_hash, old_lm_hash, lm_verifier.hash);
|
|
|
b6b438 |
|
|
|
b6b438 |
encode_pw_buffer(nt_pass.data, r->samr.in.newpassword, STR_UNICODE);
|
|
|
b6b438 |
- arcfour_crypt(nt_pass.data, old_nt_hash, 516);
|
|
|
b6b438 |
+
|
|
|
b6b438 |
+ rc = gnutls_cipher_init(&cipher_hnd,
|
|
|
b6b438 |
+ GNUTLS_CIPHER_ARCFOUR_128,
|
|
|
b6b438 |
+ &nt_session_key,
|
|
|
b6b438 |
+ NULL);
|
|
|
b6b438 |
+ if (rc < 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
|
|
|
b6b438 |
+ goto disconnect;
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
+ rc = gnutls_cipher_encrypt(cipher_hnd,
|
|
|
b6b438 |
+ nt_pass.data,
|
|
|
b6b438 |
+ 516);
|
|
|
b6b438 |
+ gnutls_cipher_deinit(cipher_hnd);
|
|
|
b6b438 |
+ if (rc < 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
|
|
|
b6b438 |
+ goto disconnect;
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
+
|
|
|
b6b438 |
E_old_pw_hash(new_nt_hash, old_nt_hash, nt_verifier.hash);
|
|
|
b6b438 |
|
|
|
b6b438 |
pw2.in.server = &server;
|
|
|
b6b438 |
@@ -161,7 +241,25 @@ static NTSTATUS libnet_ChangePassword_samr(struct libnet_context *ctx, TALLOC_CT
|
|
|
b6b438 |
a_account.string = r->samr.in.account_name;
|
|
|
b6b438 |
|
|
|
b6b438 |
encode_pw_buffer(lm_pass.data, r->samr.in.newpassword, STR_ASCII);
|
|
|
b6b438 |
- arcfour_crypt(lm_pass.data, old_lm_hash, 516);
|
|
|
b6b438 |
+
|
|
|
b6b438 |
+ rc = gnutls_cipher_init(&cipher_hnd,
|
|
|
b6b438 |
+ GNUTLS_CIPHER_ARCFOUR_128,
|
|
|
b6b438 |
+ &lm_session_key,
|
|
|
b6b438 |
+ NULL);
|
|
|
b6b438 |
+ if (rc < 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
|
|
|
b6b438 |
+ goto disconnect;
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
+
|
|
|
b6b438 |
+ rc = gnutls_cipher_encrypt(cipher_hnd,
|
|
|
b6b438 |
+ lm_pass.data,
|
|
|
b6b438 |
+ 516);
|
|
|
b6b438 |
+ gnutls_cipher_deinit(cipher_hnd);
|
|
|
b6b438 |
+ if (rc < 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
|
|
|
b6b438 |
+ goto disconnect;
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
+
|
|
|
b6b438 |
E_old_pw_hash(new_lm_hash, old_lm_hash, lm_verifier.hash);
|
|
|
b6b438 |
|
|
|
b6b438 |
oe2.in.server = &a_server;
|
|
|
b6b438 |
--
|
|
|
b6b438 |
2.23.0
|
|
|
b6b438 |
|