#include "librpc/gen_ndr/ndr_netlogon.h"
#include "librpc/gen_ndr/ndr_netlogon_c.h"
#include "librpc/gen_ndr/ndr_samr_c.h"
-#include "auth/auth.h"
#include "../lib/crypto/crypto.h"
#include "lib/cmdline/popt_common.h"
-#include "torture/rpc/rpc.h"
-#include "auth/gensec/schannel_proto.h"
+#include "torture/rpc/torture_rpc.h"
#include "auth/gensec/gensec.h"
#include "libcli/auth/libcli_auth.h"
#include "param/param.h"
struct netr_LogonSamLogonEx r_ex;
struct netr_LogonSamLogonWithFlags r_flags;
struct netr_Authenticator auth, auth2;
- struct creds_CredentialState *creds;
+ struct netlogon_creds_CredentialState *creds;
NTSTATUS expected_error;
bool old_password; /* Allow an old password to be accepted or rejected without error, as well as session key bugs */
DATA_BLOB chall;
- struct smb_iconv_convenience *iconv_convenience;
};
/*
struct netr_SamBaseInfo *base = NULL;
uint16_t validation_level = 0;
- samlogon_state->r.in.logon.network = &ninfo;
- samlogon_state->r_ex.in.logon.network = &ninfo;
- samlogon_state->r_flags.in.logon.network = &ninfo;
+ samlogon_state->r.in.logon->network = &ninfo;
+ samlogon_state->r_ex.in.logon->network = &ninfo;
+ samlogon_state->r_flags.in.logon->network = &ninfo;
ninfo.identity_info.domain_name.string = samlogon_state->account_domain;
ninfo.identity_info.parameter_control = parameter_control;
switch (samlogon_state->function_level) {
case NDR_NETR_LOGONSAMLOGON:
ZERO_STRUCT(samlogon_state->auth2);
- creds_client_authenticator(samlogon_state->creds, &samlogon_state->auth);
+ netlogon_creds_client_authenticator(samlogon_state->creds, &samlogon_state->auth);
r->out.return_authenticator = NULL;
- status = dcerpc_netr_LogonSamLogon(samlogon_state->p, samlogon_state->mem_ctx, r);
- if (!r->out.return_authenticator ||
- !creds_client_check(samlogon_state->creds, &r->out.return_authenticator->cred)) {
- d_printf("Credential chaining failed\n");
- }
+ status = dcerpc_netr_LogonSamLogon_r(samlogon_state->p->binding_handle,
+ samlogon_state->mem_ctx, r);
if (!NT_STATUS_IS_OK(status)) {
if (error_string) {
*error_string = strdup(nt_errstr(status));
}
return status;
}
+ if (!r->out.return_authenticator ||
+ !netlogon_creds_client_check(samlogon_state->creds, &r->out.return_authenticator->cred)) {
+ d_printf("Credential chaining failed\n");
+ }
+ if (!NT_STATUS_IS_OK(r->out.result)) {
+ if (error_string) {
+ *error_string = strdup(nt_errstr(r->out.result));
+ }
+ return r->out.result;
+ }
validation_level = r->in.validation_level;
- creds_decrypt_samlogon(samlogon_state->creds, validation_level, &r->out.validation);
+ netlogon_creds_decrypt_samlogon(samlogon_state->creds, validation_level, r->out.validation);
switch (validation_level) {
case 2:
- base = &r->out.validation.sam2->base;
+ base = &r->out.validation->sam2->base;
break;
case 3:
- base = &r->out.validation.sam3->base;
+ base = &r->out.validation->sam3->base;
break;
case 6:
- base = &r->out.validation.sam6->base;
+ base = &r->out.validation->sam6->base;
break;
}
break;
case NDR_NETR_LOGONSAMLOGONEX:
- status = dcerpc_netr_LogonSamLogonEx(samlogon_state->p, samlogon_state->mem_ctx, r_ex);
+ status = dcerpc_netr_LogonSamLogonEx_r(samlogon_state->p->binding_handle,
+ samlogon_state->mem_ctx, r_ex);
if (!NT_STATUS_IS_OK(status)) {
if (error_string) {
*error_string = strdup(nt_errstr(status));
}
return status;
}
+ if (!NT_STATUS_IS_OK(r_ex->out.result)) {
+ if (error_string) {
+ *error_string = strdup(nt_errstr(r_ex->out.result));
+ }
+ return r_ex->out.result;
+ }
validation_level = r_ex->in.validation_level;
- creds_decrypt_samlogon(samlogon_state->creds, validation_level, &r_ex->out.validation);
+ netlogon_creds_decrypt_samlogon(samlogon_state->creds, validation_level, r_ex->out.validation);
switch (validation_level) {
case 2:
- base = &r_ex->out.validation.sam2->base;
+ base = &r_ex->out.validation->sam2->base;
break;
case 3:
- base = &r_ex->out.validation.sam3->base;
+ base = &r_ex->out.validation->sam3->base;
break;
case 6:
- base = &r_ex->out.validation.sam6->base;
+ base = &r_ex->out.validation->sam6->base;
break;
}
break;
case NDR_NETR_LOGONSAMLOGONWITHFLAGS:
ZERO_STRUCT(samlogon_state->auth2);
- creds_client_authenticator(samlogon_state->creds, &samlogon_state->auth);
+ netlogon_creds_client_authenticator(samlogon_state->creds, &samlogon_state->auth);
r_flags->out.return_authenticator = NULL;
- status = dcerpc_netr_LogonSamLogonWithFlags(samlogon_state->p, samlogon_state->mem_ctx, r_flags);
- if (!r_flags->out.return_authenticator ||
- !creds_client_check(samlogon_state->creds, &r_flags->out.return_authenticator->cred)) {
- d_printf("Credential chaining failed\n");
- }
+ status = dcerpc_netr_LogonSamLogonWithFlags_r(samlogon_state->p->binding_handle,
+ samlogon_state->mem_ctx, r_flags);
if (!NT_STATUS_IS_OK(status)) {
if (error_string) {
*error_string = strdup(nt_errstr(status));
}
return status;
}
+ if (!r_flags->out.return_authenticator ||
+ !netlogon_creds_client_check(samlogon_state->creds, &r_flags->out.return_authenticator->cred)) {
+ d_printf("Credential chaining failed\n");
+ }
+ if (!NT_STATUS_IS_OK(r_flags->out.result)) {
+ if (error_string) {
+ *error_string = strdup(nt_errstr(r_flags->out.result));
+ }
+ return r_flags->out.result;
+ }
validation_level = r_flags->in.validation_level;
- creds_decrypt_samlogon(samlogon_state->creds, validation_level, &r_flags->out.validation);
+ netlogon_creds_decrypt_samlogon(samlogon_state->creds, validation_level, r_flags->out.validation);
switch (validation_level) {
case 2:
- base = &r_flags->out.validation.sam2->base;
+ base = &r_flags->out.validation->sam2->base;
break;
case 3:
- base = &r_flags->out.validation.sam3->base;
+ base = &r_flags->out.validation->sam3->base;
break;
case 6:
- base = &r_flags->out.validation.sam6->base;
+ base = &r_flags->out.validation->sam6->base;
break;
}
break;
DATA_BLOB lm_response = data_blob(NULL, 0);
char *password;
char *dospw;
- void *unicodepw;
+ smb_ucs2_t *unicodepw;
uint8_t user_session_key[16];
uint8_t lm_key[16];
ZERO_STRUCT(user_session_key);
- if ((push_ucs2_talloc(samlogon_state->mem_ctx,
- &unicodepw, samlogon_state->password)) == -1) {
+ if (!push_ucs2_talloc(samlogon_state->mem_ctx,
+ &unicodepw, samlogon_state->password, NULL)) {
DEBUG(0, ("push_ucs2_allocate failed!\n"));
exit(1);
}
password = strupper_talloc(samlogon_state->mem_ctx, samlogon_state->password);
- if ((convert_string_talloc(samlogon_state->mem_ctx,
- samlogon_state->iconv_convenience,
+ if (!convert_string_talloc(samlogon_state->mem_ctx,
CH_UNIX, CH_DOS,
password, strlen(password)+1,
- (void**)&dospw)) == -1) {
+ (void**)&dospw, NULL, false)) {
DEBUG(0, ("convert_string_talloc failed!\n"));
exit(1);
}
*/
static bool test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct torture_context *tctx,
- struct creds_CredentialState *creds,
+ struct netlogon_creds_CredentialState *creds,
const char *comment,
const char *account_domain, const char *account_name,
const char *plain_pass, uint32_t parameter_control,
NDR_NETR_LOGONSAMLOGONEX,
NDR_NETR_LOGONSAMLOGONWITHFLAGS };
struct samlogon_state samlogon_state;
-
- d_printf("testing netr_LogonSamLogon and netr_LogonSamLogonWithFlags\n");
+
+ union netr_LogonLevel logon;
+ union netr_Validation validation;
+ uint8_t authoritative = 0;
+ uint32_t flags = 0;
+
+ ZERO_STRUCT(logon);
+
+ d_printf("Testing netr_LogonSamLogon and netr_LogonSamLogonWithFlags\n");
samlogon_state.comment = comment;
samlogon_state.account_name = account_name;
samlogon_state.chall = data_blob_talloc(fn_ctx, NULL, 8);
samlogon_state.parameter_control = parameter_control;
samlogon_state.old_password = old_password;
- samlogon_state.iconv_convenience = lp_iconv_convenience(tctx->lp_ctx);
generate_random_buffer(samlogon_state.chall.data, 8);
samlogon_state.r_flags.in.server_name = talloc_asprintf(fn_ctx, "\\\\%s", dcerpc_server_name(p));
samlogon_state.r_flags.in.computer_name = TEST_MACHINE_NAME;
samlogon_state.r_flags.in.credential = &samlogon_state.auth;
samlogon_state.r_flags.in.return_authenticator = &samlogon_state.auth2;
- samlogon_state.r_flags.in.flags = 0;
+ samlogon_state.r_flags.in.flags = &flags;
+ samlogon_state.r_flags.in.logon = &logon;
+ samlogon_state.r_flags.out.validation = &validation;
+ samlogon_state.r_flags.out.authoritative = &authoritative;
+ samlogon_state.r_flags.out.flags = &flags;
samlogon_state.r_ex.in.server_name = talloc_asprintf(fn_ctx, "\\\\%s", dcerpc_server_name(p));
samlogon_state.r_ex.in.computer_name = TEST_MACHINE_NAME;
- samlogon_state.r_ex.in.flags = 0;
+ samlogon_state.r_ex.in.flags = &flags;
+ samlogon_state.r_ex.in.logon = &logon;
+ samlogon_state.r_ex.out.validation = &validation;
+ samlogon_state.r_ex.out.authoritative = &authoritative;
+ samlogon_state.r_ex.out.flags = &flags;
samlogon_state.r.in.server_name = talloc_asprintf(fn_ctx, "\\\\%s", dcerpc_server_name(p));
samlogon_state.r.in.computer_name = TEST_MACHINE_NAME;
samlogon_state.r.in.credential = &samlogon_state.auth;
samlogon_state.r.in.return_authenticator = &samlogon_state.auth2;
+ samlogon_state.r.in.logon = &logon;
+ samlogon_state.r.out.validation = &validation;
+ samlogon_state.r.out.authoritative = &authoritative;
+
for (f=0;f<ARRAY_SIZE(function_levels);f++) {
for (i=0; test_table[i].fn; i++) {
test an ADS style interactive domain logon
*/
bool test_InteractiveLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct creds_CredentialState *creds,
+ struct netlogon_creds_CredentialState *creds,
const char *comment,
const char *workstation_name,
const char *account_domain, const char *account_name,
struct netr_LogonSamLogonWithFlags r;
struct netr_Authenticator a, ra;
struct netr_PasswordInfo pinfo;
+ uint32_t flags = 0;
+
+ union netr_LogonLevel logon;
+ union netr_Validation validation;
+ uint8_t authoritative = 0;
+ struct dcerpc_binding_handle *b = p->binding_handle;
ZERO_STRUCT(a);
ZERO_STRUCT(r);
ZERO_STRUCT(ra);
- creds_client_authenticator(creds, &a);
+ ZERO_STRUCT(logon);
+ ZERO_STRUCT(validation);
+
+ netlogon_creds_client_authenticator(creds, &a);
+
+ logon.password = &pinfo;
r.in.server_name = talloc_asprintf(fn_ctx, "\\\\%s", dcerpc_server_name(p));
r.in.computer_name = TEST_MACHINE_NAME;
r.in.credential = &a;
r.in.return_authenticator = &ra;
r.in.logon_level = 5;
- r.in.logon.password = &pinfo;
+ r.in.logon = &logon;
r.in.validation_level = 6;
- r.in.flags = 0;
+ r.in.flags = &flags;
+ r.out.validation = &validation;
+ r.out.authoritative = &authoritative;
+ r.out.flags = &flags;
pinfo.identity_info.domain_name.string = account_domain;
pinfo.identity_info.parameter_control = parameter_control;
E_md4hash(plain_pass, pinfo.ntpassword.hash);
if (creds->negotiate_flags & NETLOGON_NEG_ARCFOUR) {
- creds_arcfour_crypt(creds, pinfo.lmpassword.hash, 16);
- creds_arcfour_crypt(creds, pinfo.ntpassword.hash, 16);
+ netlogon_creds_arcfour_crypt(creds, pinfo.lmpassword.hash, 16);
+ netlogon_creds_arcfour_crypt(creds, pinfo.ntpassword.hash, 16);
} else {
- creds_des_encrypt(creds, &pinfo.lmpassword);
- creds_des_encrypt(creds, &pinfo.ntpassword);
+ netlogon_creds_des_encrypt(creds, &pinfo.lmpassword);
+ netlogon_creds_des_encrypt(creds, &pinfo.ntpassword);
}
d_printf("Testing netr_LogonSamLogonWithFlags '%s' (Interactive Logon)\n", comment);
- status = dcerpc_netr_LogonSamLogonWithFlags(p, fn_ctx, &r);
+ status = dcerpc_netr_LogonSamLogonWithFlags_r(b, fn_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("%s: netr_LogonSamLogonWithFlags - %s\n",
+ __location__, nt_errstr(status));
+ return false;
+ }
if (!r.out.return_authenticator
- || !creds_client_check(creds, &r.out.return_authenticator->cred)) {
+ || !netlogon_creds_client_check(creds, &r.out.return_authenticator->cred)) {
d_printf("Credential chaining failed\n");
talloc_free(fn_ctx);
return false;
talloc_free(fn_ctx);
- if (!NT_STATUS_EQUAL(expected_error, status)) {
+ if (!NT_STATUS_EQUAL(expected_error, r.out.result)) {
d_printf("[%s]\\[%s] netr_LogonSamLogonWithFlags - expected %s got %s\n",
- account_domain, account_name, nt_errstr(expected_error), nt_errstr(status));
+ account_domain, account_name, nt_errstr(expected_error), nt_errstr(r.out.result));
return false;
}
0 /* yes, this is a valid flag, causes the use of DES */
};
- struct creds_CredentialState *creds;
+ struct netlogon_creds_CredentialState *creds;
+ struct dcerpc_pipe *tmp_p = NULL;
test_machine_account = talloc_asprintf(mem_ctx, "%s$", TEST_MACHINE_NAME);
/* We only need to join as a workstation here, and in future,
old_user_password = user_password;
- test_ChangePasswordUser3(torture_join_samr_pipe(user_ctx), mem_ctx,
+ tmp_p = torture_join_samr_pipe(user_ctx);
+ test_ChangePasswordUser3(tmp_p, torture,
TEST_USER_NAME, 16 /* > 14 */, &user_password,
NULL, 0, false);
u.info21.fields_present = SAMR_FIELD_WORKSTATIONS;
u.info21.workstations.string = "not" TEST_MACHINE_NAME;
- status = dcerpc_samr_SetUserInfo(torture_join_samr_pipe(user_ctx_wrong_wks), mem_ctx, &s);
+ tmp_p = torture_join_samr_pipe(user_ctx_wrong_wks);
+ status = dcerpc_samr_SetUserInfo_r(tmp_p->binding_handle, mem_ctx, &s);
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo (list of workstations) failed - %s\n", nt_errstr(status));
ret = false;
goto failed;
}
+ if (!NT_STATUS_IS_OK(s.out.result)) {
+ printf("SetUserInfo (list of workstations) failed - %s\n", nt_errstr(s.out.result));
+ ret = false;
+ goto failed;
+ }
user_ctx_wrong_time
= torture_create_testuser(torture, TEST_USER_NAME_WRONG_TIME,
u.info21.logon_hours.units_per_week = 168;
u.info21.logon_hours.bits = talloc_zero_array(mem_ctx, uint8_t, 168);
- status = dcerpc_samr_SetUserInfo(torture_join_samr_pipe(user_ctx_wrong_time), mem_ctx, &s);
+ tmp_p = torture_join_samr_pipe(user_ctx_wrong_time);
+ status = dcerpc_samr_SetUserInfo_r(tmp_p->binding_handle, mem_ctx, &s);
if (!NT_STATUS_IS_OK(status)) {
printf("SetUserInfo (logon times and list of workstations) failed - %s\n", nt_errstr(status));
ret = false;
goto failed;
}
+ if (!NT_STATUS_IS_OK(s.out.result)) {
+ printf("SetUserInfo (list of workstations) failed - %s\n", nt_errstr(s.out.result));
+ ret = false;
+ goto failed;
+ }
status = torture_rpc_binding(torture, &b);
if (!NT_STATUS_IS_OK(status)) {