2 * Credentials related structures and routines for the main module of CNTLM
4 * CNTLM is free software; you can redistribute it and/or modify it under the
5 * terms of the GNU General Public License as published by the Free Software
6 * Foundation; either version 2 of the License, or (at your option) any later
9 * CNTLM is distributed in the hope that it will be useful, but WITHOUT ANY
10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
16 * St, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Copyright (c) 2007 David Kubicek
29 struct auth_s
*new_auth(void) {
32 tmp
= (struct auth_s
*)malloc(sizeof(struct auth_s
));
36 memset(tmp
->user
, 0, MINIBUF_SIZE
);
37 memset(tmp
->domain
, 0, MINIBUF_SIZE
);
38 memset(tmp
->workstation
, 0, MINIBUF_SIZE
);
39 memset(tmp
->passntlm2
, 0, MINIBUF_SIZE
);
40 memset(tmp
->passnt
, 0, MINIBUF_SIZE
);
41 memset(tmp
->passlm
, 0, MINIBUF_SIZE
);
50 struct auth_s
*copy_auth(struct auth_s
*dst
, struct auth_s
*src
, int fullcopy
) {
51 dst
->hashntlm2
= src
->hashntlm2
;
52 dst
->hashnt
= src
->hashnt
;
53 dst
->hashlm
= src
->hashlm
;
54 dst
->flags
= src
->flags
;
56 strlcpy(dst
->domain
, src
->domain
, MINIBUF_SIZE
);
57 strlcpy(dst
->workstation
, src
->workstation
, MINIBUF_SIZE
);
60 strlcpy(dst
->user
, src
->user
, MINIBUF_SIZE
);
62 memcpy(dst
->passntlm2
, src
->passntlm2
, MINIBUF_SIZE
);
64 memcpy(dst
->passnt
, src
->passnt
, MINIBUF_SIZE
);
66 memcpy(dst
->passlm
, src
->passlm
, MINIBUF_SIZE
);
68 memset(dst
->user
, 0, MINIBUF_SIZE
);
69 memset(dst
->passntlm2
, 0, MINIBUF_SIZE
);
70 memset(dst
->passnt
, 0, MINIBUF_SIZE
);
71 memset(dst
->passlm
, 0, MINIBUF_SIZE
);
77 struct auth_s
*dup_auth(struct auth_s
*creds
, int fullcopy
) {
84 return copy_auth(tmp
, creds
, fullcopy
);
87 void dump_auth(struct auth_s
*creds
) {
90 printf("Credentials structure dump:\n");
92 printf("Struct is not allocated!\n");
96 printf("User: %s\n", creds
->user
);
97 printf("Domain: %s\n", creds
->domain
);
98 printf("Wks: %s\n", creds
->workstation
);
99 printf("HashNTLMv2: %d\n", creds
->hashntlm2
);
100 printf("HashNT: %d\n", creds
->hashnt
);
101 printf("HashLM: %d\n", creds
->hashlm
);
102 printf("Flags: %X\n", creds
->flags
);
103 if (creds
->passntlm2
) {
104 tmp
= printmem(creds
->passntlm2
, 16, 8);
105 printf("PassNTLMv2: %s\n", tmp
);
110 tmp
= printmem(creds
->passnt
, 16, 8);
111 printf("PassNT: %s\n", tmp
);
116 tmp
= printmem(creds
->passlm
, 16, 8);
117 printf("PassLM: %s\n\n", tmp
);