1 | /*
|
---|
2 | Unix SMB/Netbios implementation.
|
---|
3 | Version 3.0
|
---|
4 | handle NLTMSSP, server side
|
---|
5 |
|
---|
6 | Copyright (C) Andrew Tridgell 2001
|
---|
7 | Copyright (C) Andrew Bartlett 2001-2003
|
---|
8 | Copyright (C) Andrew Bartlett 2005 (Updated from gensec).
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify
|
---|
11 | it under the terms of the GNU General Public License as published by
|
---|
12 | the Free Software Foundation; either version 3 of the License, or
|
---|
13 | (at your option) any later version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful,
|
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | GNU General Public License for more details.
|
---|
19 |
|
---|
20 | You should have received a copy of the GNU General Public License
|
---|
21 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
22 | */
|
---|
23 |
|
---|
24 | #include "includes.h"
|
---|
25 | #include "../libcli/auth/ntlmssp.h"
|
---|
26 | #include "../libcli/auth/ntlmssp_private.h"
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Print out the NTLMSSP flags for debugging
|
---|
30 | * @param neg_flags The flags from the packet
|
---|
31 | */
|
---|
32 | void debug_ntlmssp_flags(uint32_t neg_flags)
|
---|
33 | {
|
---|
34 | DEBUG(3,("Got NTLMSSP neg_flags=0x%08x\n", neg_flags));
|
---|
35 |
|
---|
36 | if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE)
|
---|
37 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_UNICODE\n"));
|
---|
38 | if (neg_flags & NTLMSSP_NEGOTIATE_OEM)
|
---|
39 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_OEM\n"));
|
---|
40 | if (neg_flags & NTLMSSP_REQUEST_TARGET)
|
---|
41 | DEBUGADD(4, (" NTLMSSP_REQUEST_TARGET\n"));
|
---|
42 | if (neg_flags & NTLMSSP_NEGOTIATE_SIGN)
|
---|
43 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_SIGN\n"));
|
---|
44 | if (neg_flags & NTLMSSP_NEGOTIATE_SEAL)
|
---|
45 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_SEAL\n"));
|
---|
46 | if (neg_flags & NTLMSSP_NEGOTIATE_DATAGRAM)
|
---|
47 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_DATAGRAM\n"));
|
---|
48 | if (neg_flags & NTLMSSP_NEGOTIATE_LM_KEY)
|
---|
49 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_LM_KEY\n"));
|
---|
50 | if (neg_flags & NTLMSSP_NEGOTIATE_NETWARE)
|
---|
51 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_NETWARE\n"));
|
---|
52 | if (neg_flags & NTLMSSP_NEGOTIATE_NTLM)
|
---|
53 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_NTLM\n"));
|
---|
54 | if (neg_flags & NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED)
|
---|
55 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED\n"));
|
---|
56 | if (neg_flags & NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED)
|
---|
57 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED\n"));
|
---|
58 | if (neg_flags & NTLMSSP_NEGOTIATE_THIS_IS_LOCAL_CALL)
|
---|
59 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_THIS_IS_LOCAL_CALL\n"));
|
---|
60 | if (neg_flags & NTLMSSP_NEGOTIATE_ALWAYS_SIGN)
|
---|
61 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_ALWAYS_SIGN\n"));
|
---|
62 | if (neg_flags & NTLMSSP_REQUEST_NON_NT_SESSION_KEY)
|
---|
63 | DEBUGADD(4, (" NTLMSSP_REQUEST_NON_NT_SESSION_KEY\n"));
|
---|
64 | if (neg_flags & NTLMSSP_NEGOTIATE_NTLM2)
|
---|
65 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_NTLM2\n"));
|
---|
66 | if (neg_flags & NTLMSSP_NEGOTIATE_TARGET_INFO)
|
---|
67 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_TARGET_INFO\n"));
|
---|
68 | if (neg_flags & NTLMSSP_NEGOTIATE_VERSION)
|
---|
69 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_VERSION\n"));
|
---|
70 | if (neg_flags & NTLMSSP_NEGOTIATE_128)
|
---|
71 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_128\n"));
|
---|
72 | if (neg_flags & NTLMSSP_NEGOTIATE_KEY_EXCH)
|
---|
73 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_KEY_EXCH\n"));
|
---|
74 | if (neg_flags & NTLMSSP_NEGOTIATE_56)
|
---|
75 | DEBUGADD(4, (" NTLMSSP_NEGOTIATE_56\n"));
|
---|
76 | }
|
---|
77 |
|
---|
78 | void ntlmssp_handle_neg_flags(struct ntlmssp_state *ntlmssp_state,
|
---|
79 | uint32_t neg_flags, bool allow_lm)
|
---|
80 | {
|
---|
81 | if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE) {
|
---|
82 | ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_UNICODE;
|
---|
83 | ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_OEM;
|
---|
84 | ntlmssp_state->unicode = true;
|
---|
85 | } else {
|
---|
86 | ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_UNICODE;
|
---|
87 | ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_OEM;
|
---|
88 | ntlmssp_state->unicode = false;
|
---|
89 | }
|
---|
90 |
|
---|
91 | if ((neg_flags & NTLMSSP_NEGOTIATE_LM_KEY) && allow_lm) {
|
---|
92 | /* other end forcing us to use LM */
|
---|
93 | ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_LM_KEY;
|
---|
94 | ntlmssp_state->use_ntlmv2 = false;
|
---|
95 | } else {
|
---|
96 | ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_LM_KEY;
|
---|
97 | }
|
---|
98 |
|
---|
99 | if (!(neg_flags & NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) {
|
---|
100 | ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_ALWAYS_SIGN;
|
---|
101 | }
|
---|
102 |
|
---|
103 | if (!(neg_flags & NTLMSSP_NEGOTIATE_NTLM2)) {
|
---|
104 | ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_NTLM2;
|
---|
105 | }
|
---|
106 |
|
---|
107 | if (!(neg_flags & NTLMSSP_NEGOTIATE_128)) {
|
---|
108 | ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_128;
|
---|
109 | }
|
---|
110 |
|
---|
111 | if (!(neg_flags & NTLMSSP_NEGOTIATE_56)) {
|
---|
112 | ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_56;
|
---|
113 | }
|
---|
114 |
|
---|
115 | if (!(neg_flags & NTLMSSP_NEGOTIATE_KEY_EXCH)) {
|
---|
116 | ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_KEY_EXCH;
|
---|
117 | }
|
---|
118 |
|
---|
119 | if (!(neg_flags & NTLMSSP_NEGOTIATE_SIGN)) {
|
---|
120 | ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_SIGN;
|
---|
121 | }
|
---|
122 |
|
---|
123 | if (!(neg_flags & NTLMSSP_NEGOTIATE_SEAL)) {
|
---|
124 | ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_SEAL;
|
---|
125 | }
|
---|
126 |
|
---|
127 | if (!(neg_flags & NTLMSSP_NEGOTIATE_VERSION)) {
|
---|
128 | ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_VERSION;
|
---|
129 | }
|
---|
130 |
|
---|
131 | if ((neg_flags & NTLMSSP_REQUEST_TARGET)) {
|
---|
132 | ntlmssp_state->neg_flags |= NTLMSSP_REQUEST_TARGET;
|
---|
133 | }
|
---|
134 | }
|
---|