Changeset 919 for vendor/current/libcli
- Timestamp:
- Jun 9, 2016, 2:17:22 PM (9 years ago)
- Location:
- vendor/current/libcli/auth
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/libcli/auth/ntlmssp.h
r917 r919 84 84 DATA_BLOB session_key; 85 85 86 uint32_t required_flags; 86 87 uint32_t neg_flags; /* the current state of negotiation with the NTLMSSP partner */ 87 88 -
vendor/current/libcli/auth/proto.h
r917 r919 140 140 DATA_BLOB *lm_response, DATA_BLOB *nt_response, 141 141 DATA_BLOB *lm_session_key, DATA_BLOB *user_session_key) ; 142 NTSTATUS NTLMv2_RESPONSE_verify_netlogon_creds(const char *account_name, 143 const char *account_domain, 144 const DATA_BLOB response, 145 const struct netlogon_creds_CredentialState *creds, 146 const char *workgroup); 142 147 143 148 /*********************************************************** -
vendor/current/libcli/auth/smbencrypt.c
r917 r919 27 27 #include "../lib/crypto/crypto.h" 28 28 #include "../libcli/auth/libcli_auth.h" 29 #include "../librpc/gen_ndr/n tlmssp.h"29 #include "../librpc/gen_ndr/ndr_ntlmssp.h" 30 30 31 31 void SMBencrypt_hash(const uint8_t lm_hash[16], const uint8_t *c8, uint8_t p24[24]) … … 356 356 357 357 /* Deliberately ignore return here.. */ 358 (void)msrpc_gen(mem_ctx, &names_blob, 359 "aaa", 360 MsvAvNbDomainName, domain, 361 MsvAvNbComputerName, hostname, 362 MsvAvEOL, ""); 358 if (hostname != NULL) { 359 (void)msrpc_gen(mem_ctx, &names_blob, 360 "aaa", 361 MsvAvNbDomainName, domain, 362 MsvAvNbComputerName, hostname, 363 MsvAvEOL, ""); 364 } else { 365 (void)msrpc_gen(mem_ctx, &names_blob, 366 "aa", 367 MsvAvNbDomainName, domain, 368 MsvAvEOL, ""); 369 } 363 370 return names_blob; 364 371 } … … 516 523 } 517 524 525 NTSTATUS NTLMv2_RESPONSE_verify_netlogon_creds(const char *account_name, 526 const char *account_domain, 527 const DATA_BLOB response, 528 const struct netlogon_creds_CredentialState *creds, 529 const char *workgroup) 530 { 531 TALLOC_CTX *frame = NULL; 532 /* RespType + HiRespType */ 533 static const char *magic = "\x01\x01"; 534 int cmp; 535 struct NTLMv2_RESPONSE v2_resp; 536 enum ndr_err_code err; 537 const struct AV_PAIR *av_nb_cn = NULL; 538 const struct AV_PAIR *av_nb_dn = NULL; 539 540 if (response.length < 48) { 541 /* 542 * NTLMv2_RESPONSE has at least 48 bytes. 543 */ 544 return NT_STATUS_OK; 545 } 546 547 cmp = memcmp(response.data + 16, magic, 2); 548 if (cmp != 0) { 549 /* 550 * It doesn't look like a valid NTLMv2_RESPONSE 551 */ 552 return NT_STATUS_OK; 553 } 554 555 frame = talloc_stackframe(); 556 557 err = ndr_pull_struct_blob(&response, frame, &v2_resp, 558 (ndr_pull_flags_fn_t)ndr_pull_NTLMv2_RESPONSE); 559 if (!NDR_ERR_CODE_IS_SUCCESS(err)) { 560 NTSTATUS status; 561 status = ndr_map_error2ntstatus(err); 562 DEBUG(2,("Failed to parse NTLMv2_RESPONSE " 563 "length %u - %s - %s\n", 564 (unsigned)response.length, 565 ndr_map_error2string(err), 566 nt_errstr(status))); 567 dump_data(2, response.data, response.length); 568 TALLOC_FREE(frame); 569 return status; 570 } 571 572 if (DEBUGLVL(10)) { 573 NDR_PRINT_DEBUG(NTLMv2_RESPONSE, &v2_resp); 574 } 575 576 /* 577 * Make sure the netbios computer name in the 578 * NTLMv2_RESPONSE matches the computer name 579 * in the secure channel credentials for workstation 580 * trusts. 581 * 582 * And the netbios domain name matches our 583 * workgroup. 584 * 585 * This prevents workstations from requesting 586 * the session key of NTLMSSP sessions of clients 587 * to other hosts. 588 */ 589 if (creds->secure_channel_type == SEC_CHAN_WKSTA) { 590 av_nb_cn = ndr_ntlmssp_find_av(&v2_resp.Challenge.AvPairs, 591 MsvAvNbComputerName); 592 av_nb_dn = ndr_ntlmssp_find_av(&v2_resp.Challenge.AvPairs, 593 MsvAvNbDomainName); 594 } 595 596 if (av_nb_cn != NULL) { 597 const char *v = NULL; 598 char *a = NULL; 599 size_t len; 600 601 v = av_nb_cn->Value.AvNbComputerName; 602 603 a = talloc_strdup(frame, creds->account_name); 604 if (a == NULL) { 605 TALLOC_FREE(frame); 606 return NT_STATUS_NO_MEMORY; 607 } 608 len = strlen(a); 609 if (len > 0 && a[len - 1] == '$') { 610 a[len - 1] = '\0'; 611 } 612 613 #ifdef SAMBA4_INTERNAL_HEIMDAL /* smbtorture4 for make test */ 614 cmp = strcasecmp_m(a, v); 615 #else /* smbd */ 616 cmp = StrCaseCmp(a, v); 617 #endif 618 if (cmp != 0) { 619 DEBUG(2,("%s: NTLMv2_RESPONSE with " 620 "NbComputerName[%s] rejected " 621 "for user[%s\\%s] " 622 "against SEC_CHAN_WKSTA[%s/%s] " 623 "in workgroup[%s]\n", 624 __func__, v, 625 account_domain, 626 account_name, 627 creds->computer_name, 628 creds->account_name, 629 workgroup)); 630 TALLOC_FREE(frame); 631 return NT_STATUS_LOGON_FAILURE; 632 } 633 } 634 if (av_nb_dn != NULL) { 635 const char *v = NULL; 636 637 v = av_nb_dn->Value.AvNbDomainName; 638 639 #ifdef SAMBA4_INTERNAL_HEIMDAL /* smbtorture4 for make test */ 640 cmp = strcasecmp_m(workgroup, v); 641 #else /* smbd */ 642 cmp = StrCaseCmp(workgroup, v); 643 #endif 644 if (cmp != 0) { 645 DEBUG(2,("%s: NTLMv2_RESPONSE with " 646 "NbDomainName[%s] rejected " 647 "for user[%s\\%s] " 648 "against SEC_CHAN_WKSTA[%s/%s] " 649 "in workgroup[%s]\n", 650 __func__, v, 651 account_domain, 652 account_name, 653 creds->computer_name, 654 creds->account_name, 655 workgroup)); 656 TALLOC_FREE(frame); 657 return NT_STATUS_LOGON_FAILURE; 658 } 659 } 660 661 TALLOC_FREE(frame); 662 return NT_STATUS_OK; 663 } 664 518 665 /*********************************************************** 519 666 encode a password buffer with a unicode password. The buffer -
vendor/current/libcli/auth/wscript_build
r917 r919 20 20 bld.SAMBA_SUBSYSTEM('LIBCLI_AUTH', 21 21 source='credentials.c session.c smbencrypt.c smbdes.c', 22 public_deps='MSRPC_PARSE ',22 public_deps='MSRPC_PARSE NDR_NTLMSSP', 23 23 public_headers='credentials.h:domain_credentials.h' 24 24 )
Note:
See TracChangeset
for help on using the changeset viewer.