dcerpc_netlogon.c
来自「samba最新软件」· C语言 代码 · 共 1,270 行 · 第 1/3 页
C
1,270 行
case 3: case 5: if (creds->negotiate_flags & NETLOGON_NEG_ARCFOUR) { creds_arcfour_crypt(creds, r->in.logon.password->lmpassword.hash, sizeof(r->in.logon.password->lmpassword.hash)); creds_arcfour_crypt(creds, r->in.logon.password->ntpassword.hash, sizeof(r->in.logon.password->ntpassword.hash)); } else { creds_des_decrypt(creds, &r->in.logon.password->lmpassword); creds_des_decrypt(creds, &r->in.logon.password->ntpassword); } /* TODO: we need to deny anonymous access here */ nt_status = auth_context_create(mem_ctx, dce_call->event_ctx, dce_call->msg_ctx, dce_call->conn->dce_ctx->lp_ctx, &auth_context); NT_STATUS_NOT_OK_RETURN(nt_status); user_info->logon_parameters = r->in.logon.password->identity_info.parameter_control; user_info->client.account_name = r->in.logon.password->identity_info.account_name.string; user_info->client.domain_name = r->in.logon.password->identity_info.domain_name.string; user_info->workstation_name = r->in.logon.password->identity_info.workstation.string; user_info->flags |= USER_INFO_INTERACTIVE_LOGON; user_info->password_state = AUTH_PASSWORD_HASH; user_info->password.hash.lanman = talloc(user_info, struct samr_Password); NT_STATUS_HAVE_NO_MEMORY(user_info->password.hash.lanman); *user_info->password.hash.lanman = r->in.logon.password->lmpassword; user_info->password.hash.nt = talloc(user_info, struct samr_Password); NT_STATUS_HAVE_NO_MEMORY(user_info->password.hash.nt); *user_info->password.hash.nt = r->in.logon.password->ntpassword; break; case 2: case 6: /* TODO: we need to deny anonymous access here */ nt_status = auth_context_create(mem_ctx, dce_call->event_ctx, dce_call->msg_ctx, dce_call->conn->dce_ctx->lp_ctx, &auth_context); NT_STATUS_NOT_OK_RETURN(nt_status); nt_status = auth_context_set_challenge(auth_context, r->in.logon.network->challenge, "netr_LogonSamLogonWithFlags"); NT_STATUS_NOT_OK_RETURN(nt_status); user_info->logon_parameters = r->in.logon.network->identity_info.parameter_control; user_info->client.account_name = r->in.logon.network->identity_info.account_name.string; user_info->client.domain_name = r->in.logon.network->identity_info.domain_name.string; user_info->workstation_name = r->in.logon.network->identity_info.workstation.string; user_info->password_state = AUTH_PASSWORD_RESPONSE; user_info->password.response.lanman = data_blob_talloc(mem_ctx, r->in.logon.network->lm.data, r->in.logon.network->lm.length); user_info->password.response.nt = data_blob_talloc(mem_ctx, r->in.logon.network->nt.data, r->in.logon.network->nt.length); break; default: return NT_STATUS_INVALID_PARAMETER; } nt_status = auth_check_password(auth_context, mem_ctx, user_info, &server_info); NT_STATUS_NOT_OK_RETURN(nt_status); nt_status = auth_convert_server_info_sambaseinfo(mem_ctx, server_info, &sam); NT_STATUS_NOT_OK_RETURN(nt_status); /* Don't crypt an all-zero key, it would give away the NETLOGON pipe session key */ /* It appears that level 6 is not individually encrypted */ if ((r->in.validation_level != 6) && memcmp(sam->key.key, zeros, sizeof(sam->key.key)) != 0) { /* This key is sent unencrypted without the ARCFOUR flag set */ if (creds->negotiate_flags & NETLOGON_NEG_ARCFOUR) { creds_arcfour_crypt(creds, sam->key.key, sizeof(sam->key.key)); } } /* Don't crypt an all-zero key, it would give away the NETLOGON pipe session key */ /* It appears that level 6 is not individually encrypted */ if ((r->in.validation_level != 6) && memcmp(sam->LMSessKey.key, zeros, sizeof(sam->LMSessKey.key)) != 0) { if (creds->negotiate_flags & NETLOGON_NEG_ARCFOUR) { creds_arcfour_crypt(creds, sam->LMSessKey.key, sizeof(sam->LMSessKey.key)); } else { creds_des_encrypt_LMKey(creds, &sam->LMSessKey); } } switch (r->in.validation_level) { case 2: sam2 = talloc_zero(mem_ctx, struct netr_SamInfo2); NT_STATUS_HAVE_NO_MEMORY(sam2); sam2->base = *sam; r->out.validation.sam2 = sam2; break; case 3: sam3 = talloc_zero(mem_ctx, struct netr_SamInfo3); NT_STATUS_HAVE_NO_MEMORY(sam3); sam3->base = *sam; r->out.validation.sam3 = sam3; break; case 6: sam6 = talloc_zero(mem_ctx, struct netr_SamInfo6); NT_STATUS_HAVE_NO_MEMORY(sam6); sam6->base = *sam; sam6->forest.string = lp_realm(dce_call->conn->dce_ctx->lp_ctx); sam6->principle.string = talloc_asprintf(mem_ctx, "%s@%s", sam->account_name.string, sam6->forest.string); NT_STATUS_HAVE_NO_MEMORY(sam6->principle.string); r->out.validation.sam6 = sam6; break; default: break; } r->out.authoritative = 1; /* TODO: Describe and deal with these flags */ r->out.flags = 0; return NT_STATUS_OK;}static NTSTATUS dcesrv_netr_LogonSamLogonEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_LogonSamLogonEx *r) { NTSTATUS nt_status; struct creds_CredentialState *creds; nt_status = schannel_fetch_session_key(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, r->in.computer_name, lp_workgroup(dce_call->conn->dce_ctx->lp_ctx), &creds); if (!NT_STATUS_IS_OK(nt_status)) { return nt_status; } if (!dce_call->conn->auth_state.auth_info || dce_call->conn->auth_state.auth_info->auth_type != DCERPC_AUTH_TYPE_SCHANNEL) { return NT_STATUS_INTERNAL_ERROR; } return dcesrv_netr_LogonSamLogon_base(dce_call, mem_ctx, r, creds);}/* netr_LogonSamLogonWithFlags*/static NTSTATUS dcesrv_netr_LogonSamLogonWithFlags(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_LogonSamLogonWithFlags *r){ NTSTATUS nt_status; struct creds_CredentialState *creds; struct netr_LogonSamLogonEx r2; struct netr_Authenticator *return_authenticator; return_authenticator = talloc(mem_ctx, struct netr_Authenticator); NT_STATUS_HAVE_NO_MEMORY(return_authenticator); nt_status = dcesrv_netr_creds_server_step_check(dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, r->in.computer_name, mem_ctx, r->in.credential, return_authenticator, &creds); NT_STATUS_NOT_OK_RETURN(nt_status); ZERO_STRUCT(r2); r2.in.server_name = r->in.server_name; r2.in.computer_name = r->in.computer_name; r2.in.logon_level = r->in.logon_level; r2.in.logon = r->in.logon; r2.in.validation_level = r->in.validation_level; r2.in.flags = r->in.flags; nt_status = dcesrv_netr_LogonSamLogon_base(dce_call, mem_ctx, &r2, creds); r->out.return_authenticator = return_authenticator; r->out.validation = r2.out.validation; r->out.authoritative = r2.out.authoritative; r->out.flags = r2.out.flags; return nt_status;}/* netr_LogonSamLogon*/static NTSTATUS dcesrv_netr_LogonSamLogon(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_LogonSamLogon *r){ struct netr_LogonSamLogonWithFlags r2; NTSTATUS status; ZERO_STRUCT(r2); r2.in.server_name = r->in.server_name; r2.in.computer_name = r->in.computer_name; r2.in.credential = r->in.credential; r2.in.return_authenticator = r->in.return_authenticator; r2.in.logon_level = r->in.logon_level; r2.in.logon = r->in.logon; r2.in.validation_level = r->in.validation_level; r2.in.flags = 0; status = dcesrv_netr_LogonSamLogonWithFlags(dce_call, mem_ctx, &r2); r->out.return_authenticator = r2.out.return_authenticator; r->out.validation = r2.out.validation; r->out.authoritative = r2.out.authoritative; return status;}/* netr_LogonSamLogoff */static NTSTATUS dcesrv_netr_LogonSamLogoff(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_LogonSamLogoff *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_DatabaseDeltas */static NTSTATUS dcesrv_netr_DatabaseDeltas(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_DatabaseDeltas *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_DatabaseSync */static NTSTATUS dcesrv_netr_DatabaseSync(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_DatabaseSync *r){ /* win2k3 native mode returns "NOT IMPLEMENTED" for this call */ return NT_STATUS_NOT_IMPLEMENTED;}/* netr_AccountDeltas */static NTSTATUS dcesrv_netr_AccountDeltas(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_AccountDeltas *r){ /* w2k3 returns "NOT IMPLEMENTED" for this call */ return NT_STATUS_NOT_IMPLEMENTED;}/* netr_AccountSync */static NTSTATUS dcesrv_netr_AccountSync(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_AccountSync *r){ /* w2k3 returns "NOT IMPLEMENTED" for this call */ return NT_STATUS_NOT_IMPLEMENTED;}/* netr_GetDcName */static WERROR dcesrv_netr_GetDcName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_GetDcName *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_LogonControl */static WERROR dcesrv_netr_LogonControl(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_LogonControl *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_GetAnyDCName */static WERROR dcesrv_netr_GetAnyDCName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_GetAnyDCName *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_LogonControl2 */static WERROR dcesrv_netr_LogonControl2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_LogonControl2 *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_DatabaseSync2 */static NTSTATUS dcesrv_netr_DatabaseSync2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_DatabaseSync2 *r){ /* win2k3 native mode returns "NOT IMPLEMENTED" for this call */ return NT_STATUS_NOT_IMPLEMENTED;}/* netr_DatabaseRedo */static NTSTATUS dcesrv_netr_DatabaseRedo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_DatabaseRedo *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_LogonControl2Ex */static WERROR dcesrv_netr_LogonControl2Ex(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_LogonControl2Ex *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_NetrEnumerateTurstedDomains*/static WERROR dcesrv_netr_NetrEnumerateTrustedDomains(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_NetrEnumerateTrustedDomains *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_NETRLOGONDUMMYROUTINE1 */static WERROR dcesrv_netr_NETRLOGONDUMMYROUTINE1(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_NETRLOGONDUMMYROUTINE1 *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_NETRLOGONSETSERVICEBITS */static WERROR dcesrv_netr_NETRLOGONSETSERVICEBITS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_NETRLOGONSETSERVICEBITS *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_LogonGetTrustRid*/static WERROR dcesrv_netr_LogonGetTrustRid(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_LogonGetTrustRid *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_NETRLOGONCOMPUTESERVERDIGEST */static WERROR dcesrv_netr_NETRLOGONCOMPUTESERVERDIGEST(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_NETRLOGONCOMPUTESERVERDIGEST *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_NETRLOGONCOMPUTECLIENTDIGEST */static WERROR dcesrv_netr_NETRLOGONCOMPUTECLIENTDIGEST(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* netr_DsRGetSiteName*/static WERROR dcesrv_netr_DsRGetSiteName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_DsRGetSiteName *r){ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);}/* fill in a netr_DomainTrustInfo from a ldb search result*/static NTSTATUS fill_domain_trust_info(TALLOC_CTX *mem_ctx, struct ldb_message *res,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?