diff options
author | Andrew Bartlett <abartlet@samba.org> | 2005-10-26 05:56:44 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:45:15 -0500 |
commit | 0511b5df160c1276b59db8f57a27e289800d1915 (patch) | |
tree | a76363ad13f312c721024dc0394f70ab04c2f0ca | |
parent | 861fdd902abc40f7858734954dd001e8e2c97a96 (diff) | |
download | samba-0511b5df160c1276b59db8f57a27e289800d1915.tar.gz samba-0511b5df160c1276b59db8f57a27e289800d1915.tar.bz2 samba-0511b5df160c1276b59db8f57a27e289800d1915.zip |
r11298: Consolidate the 'short' samlogon tests, and move to using the
credentials system for password -> NTLM translation.
Andrew Bartlett
(This used to be commit d22cbf1b0cae9ca211c916320754d5edfe360c30)
-rw-r--r-- | source4/torture/rpc/netlogon.c | 98 | ||||
-rw-r--r-- | source4/torture/rpc/schannel.c | 89 |
2 files changed, 70 insertions, 117 deletions
diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c index 185a032b3c..d2aaba8cea 100644 --- a/source4/torture/rpc/netlogon.c +++ b/source4/torture/rpc/netlogon.c @@ -481,63 +481,88 @@ static BOOL test_SetPassword2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) /* try a netlogon SamLogon */ -static BOOL test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct cli_credentials *credentials, + struct creds_CredentialState *creds) { NTSTATUS status; struct netr_LogonSamLogon r; struct netr_Authenticator auth, auth2; struct netr_NetworkInfo ninfo; - const char *username = cli_credentials_get_username(cmdline_credentials); - const char *password = cli_credentials_get_password(cmdline_credentials); - struct creds_CredentialState *creds; - + DATA_BLOB names_blob, chal, lm_resp, nt_resp; int i; BOOL ret = True; + int flags = CLI_CRED_NTLM_AUTH; + if (lp_client_lanman_auth()) { + flags |= CLI_CRED_LANMAN_AUTH; + } - if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, - machine_password, &creds)) { + if (lp_client_ntlmv2_auth()) { + flags |= CLI_CRED_NTLMv2_AUTH; + } + + cli_credentials_get_ntlm_username_domain(cmdline_credentials, mem_ctx, + &ninfo.identity_info.account_name.string, + &ninfo.identity_info.domain_name.string); + + generate_random_buffer(ninfo.challenge, + sizeof(ninfo.challenge)); + chal = data_blob_const(ninfo.challenge, + sizeof(ninfo.challenge)); + + names_blob = NTLMv2_generate_names_blob(mem_ctx, cli_credentials_get_workstation(credentials), + cli_credentials_get_domain(credentials)); + + status = cli_credentials_get_ntlm_response(cmdline_credentials, mem_ctx, + &flags, + chal, + names_blob, + &lm_resp, &nt_resp, + NULL, NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("cli_credentials_get_ntlm_response failed: %s\n", + nt_errstr(status)); return False; } - ninfo.identity_info.domain_name.string = cli_credentials_get_domain(cmdline_credentials); + ninfo.lm.data = lm_resp.data; + ninfo.lm.length = lm_resp.length; + + ninfo.nt.data = nt_resp.data; + ninfo.nt.length = nt_resp.length; + ninfo.identity_info.parameter_control = 0; ninfo.identity_info.logon_id_low = 0; ninfo.identity_info.logon_id_high = 0; - ninfo.identity_info.account_name.string = username; - ninfo.identity_info.workstation.string = TEST_MACHINE_NAME; - generate_random_buffer(ninfo.challenge, - sizeof(ninfo.challenge)); - ninfo.nt.length = 24; - ninfo.nt.data = talloc_size(mem_ctx, 24); - SMBNTencrypt(password, ninfo.challenge, ninfo.nt.data); - ninfo.lm.length = 24; - ninfo.lm.data = talloc_size(mem_ctx, 24); - SMBencrypt(password, ninfo.challenge, ninfo.lm.data); + ninfo.identity_info.workstation.string = cli_credentials_get_workstation(credentials); r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); - r.in.workstation = TEST_MACHINE_NAME; + r.in.workstation = cli_credentials_get_workstation(credentials); r.in.credential = &auth; r.in.return_authenticator = &auth2; r.in.logon_level = 2; r.in.logon.network = &ninfo; - for (i=2;i<=3;i++) { + printf("Testing LogonSamLogon with name %s\n", ninfo.identity_info.account_name.string); + + for (i=2;i<3;i++) { ZERO_STRUCT(auth2); creds_client_authenticator(creds, &auth); - + r.in.validation_level = i; - - printf("Testing SamLogon with validation level %d\n", i); - + status = dcerpc_netr_LogonSamLogon(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("LogonSamLogon - %s\n", nt_errstr(status)); - ret = False; + printf("LogonSamLogon failed: %s\n", + nt_errstr(status)); + return False; } - + if (!creds_client_check(creds, &r.out.return_authenticator->cred)) { printf("Credential chaining failed\n"); + ret = False; } + } r.in.credential = NULL; @@ -556,9 +581,26 @@ static BOOL test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) } + return ret; } +/* + try a netlogon SamLogon +*/ +static BOOL test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct cli_credentials *credentials) +{ + struct creds_CredentialState *creds; + + if (!test_SetupCredentials(p, mem_ctx, cli_credentials_get_workstation(credentials), + cli_credentials_get_password(credentials), &creds)) { + return False; + } + + return test_netlogon_ops(p, mem_ctx, credentials, creds); +} + /* we remember the sequence numbers so we can easily do a DatabaseDelta */ static uint64_t sequence_nums[3]; @@ -1383,7 +1425,7 @@ BOOL torture_rpc_netlogon(void) ret &= test_LogonUasLogon(p, mem_ctx); ret &= test_LogonUasLogoff(p, mem_ctx); - ret &= test_SamLogon(p, mem_ctx); + ret &= test_SamLogon(p, mem_ctx, machine_credentials); ret &= test_SetPassword(p, mem_ctx); ret &= test_SetPassword2(p, mem_ctx); ret &= test_GetDomainInfo(p, mem_ctx); diff --git a/source4/torture/rpc/schannel.c b/source4/torture/rpc/schannel.c index 1010572003..4b9c4a8235 100644 --- a/source4/torture/rpc/schannel.c +++ b/source4/torture/rpc/schannel.c @@ -144,95 +144,6 @@ static BOOL test_lsa_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) /* - try a netlogon SamLogon -*/ -static BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct cli_credentials *credentials, - struct creds_CredentialState *creds) -{ - NTSTATUS status; - struct netr_LogonSamLogon r; - struct netr_Authenticator auth, auth2; - struct netr_NetworkInfo ninfo; - DATA_BLOB names_blob, chal, lm_resp, nt_resp; - int i; - BOOL ret = True; - int flags = CLI_CRED_NTLM_AUTH; - if (lp_client_lanman_auth()) { - flags |= CLI_CRED_LANMAN_AUTH; - } - - if (lp_client_ntlmv2_auth()) { - flags |= CLI_CRED_NTLMv2_AUTH; - } - - cli_credentials_get_ntlm_username_domain(cmdline_credentials, mem_ctx, - &ninfo.identity_info.account_name.string, - &ninfo.identity_info.domain_name.string); - - generate_random_buffer(ninfo.challenge, - sizeof(ninfo.challenge)); - chal = data_blob_const(ninfo.challenge, - sizeof(ninfo.challenge)); - - names_blob = NTLMv2_generate_names_blob(mem_ctx, cli_credentials_get_workstation(credentials), - cli_credentials_get_domain(credentials)); - - status = cli_credentials_get_ntlm_response(cmdline_credentials, mem_ctx, - &flags, - chal, - names_blob, - &lm_resp, &nt_resp, - NULL, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("cli_credentials_get_ntlm_response failed: %s\n", - nt_errstr(status)); - return False; - } - - ninfo.lm.data = lm_resp.data; - ninfo.lm.length = lm_resp.length; - - ninfo.nt.data = nt_resp.data; - ninfo.nt.length = nt_resp.length; - - ninfo.identity_info.parameter_control = 0; - ninfo.identity_info.logon_id_low = 0; - ninfo.identity_info.logon_id_high = 0; - ninfo.identity_info.workstation.string = cli_credentials_get_workstation(credentials); - - r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); - r.in.workstation = cli_credentials_get_workstation(credentials); - r.in.credential = &auth; - r.in.return_authenticator = &auth2; - r.in.logon_level = 2; - r.in.logon.network = &ninfo; - - printf("Testing LogonSamLogon with name %s\n", ninfo.identity_info.account_name.string); - - for (i=2;i<3;i++) { - ZERO_STRUCT(auth2); - creds_client_authenticator(creds, &auth); - - r.in.validation_level = i; - - status = dcerpc_netr_LogonSamLogon(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonSamLogon failed: %s\n", - nt_errstr(status)); - return False; - } - - if (!creds_client_check(creds, &r.out.return_authenticator->cred)) { - printf("Credential chaining failed\n"); - ret = False; - } - - } - return ret; -} - -/* test a schannel connection with the given flags */ static BOOL test_schannel(TALLOC_CTX *mem_ctx, |