make ntlmv2 as auth mech within ntlmssp
Subsystems (2)
PATCH 1/1 make ntlmv2 as auth mech within ntlmssp
Make ntlmv2 as an authentication mechanism ithin ntlmssp instead of ntlmv1.
Parse type 2 response in ntlmssp negotiation to pluck AV pairs and use them to calculate ntlmv2 response token. Also, assign domain name from the sever response in type 2 packet of ntlmssp and use that (netbios) domain name in calculation of response.
Quoted 1 line
From
1309610674ecbbb60b316ad4d9df0c18994bff1fMon Sep 17 00:00:00 2001
From: Shirish Pargaonkar <[email protected]>
Date: Fri, 30 Jul 2010 10:18:32 -0500
Subject: [PATCH] make ntlmv2 as auth mech within ntlmssp
Signed-off-by Shirish Pargaonkar <[email protected]>
--- fs/cifs/cifsencrypt.c | 49 +++++++++++++++++++++++++++++++++++++++++++++---- fs/cifs/cifsglob.h | 2 ++ fs/cifs/cifspdu.h | 1 - fs/cifs/ntlmssp.h | 13 +++++++++++++ fs/cifs/sess.c | 45 +++++++++++++++++++++++++++++++-------------- 5 files changed, 91 insertions(+), 19 deletions(-)
fs/cifs/cifsencrypt.c +45 -4
@@ -27,6 +27,7 @@#include "md5.h" #include "cifs_unicode.h" #include "cifsproto.h" +#include "ntlmssp.h" #include <linux/ctype.h> #include <linux/random.h>
@@ -378,6 +379,44 @@ calc_exit_2:return rc; } +static void +find_domain_name (struct cifsSesInfo *ses) +{ +unsigned int attrsize; +unsigned int type; +unsigned char *blobptr; +struct ntlmssp2_name *attrptr; + +if (ses->server->tiblob) { + blobptr = ses->server->tiblob; + attrptr = (struct ntlmssp2_name *) blobptr; + +while ((type = attrptr->type) !=0 ) { + blobptr +=2 ;/* advance attr type */ + attrsize = attrptr->length; + blobptr +=2 ;/* advance attr size */ +if (type ==NTLMSSP_AV_NB_DOMAIN_NAME ) { +if (!ses->domainName) { + ses->domainName = +kmalloc (attrptr->length +1 , +GFP_KERNEL ); +if (!ses->domainName) +return ; +cifs_from_ucs2 (ses->domainName, + (__le16 *)blobptr, + attrptr->length, + attrptr->length, +load_nls_default (), false); + } + } + blobptr += attrsize;/* advance attr value */ + attrptr = (struct ntlmssp2_name *) blobptr; + } + } + +return ; +} +void setup_ntlmv2_rsp (struct cifsSesInfo *ses,char *resp_buf,const struct nls_table *nls_cp) {
@@ -390,10 +429,9 @@ void setup_ntlmv2_rsp(struct cifsSesInfo *ses, char *resp_buf, buf->time =cpu_to_le64 (cifs_UnixTimeToNT (CURRENT_TIME ));get_random_bytes (&buf->client_chal,sizeof (buf->client_chal)); buf->reserved2 =0 ; - buf->names[0 ].type =cpu_to_le16 (NTLMSSP_DOMAIN_TYPE ); - buf->names[0 ].length =0 ; - buf->names[1 ].type =0 ; - buf->names[1 ].length =0 ; + +if (!ses->domainName) +find_domain_name (ses);/* calculate buf->ntlmv2_hash */ rc =calc_ntlmv2_hash (ses, nls_cp);
@@ -421,6 +459,9 @@ void CalcNTLMv2_response(const struct cifsSesInfo *ses,hmac_md5_update (v2_session_response+8 ,sizeof (struct ntlmv2_resp ) -8 , &context); +if (ses->server->tilen) +hmac_md5_update (ses->server->tiblob, + ses->server->tilen, &context);hmac_md5_final (v2_session_response, &context);/* cifs_dump_mem("v2_sess_rsp: ", v2_session_response, 32); */
fs/cifs/cifsglob.h +2 -0
@@ -187,6 +187,8 @@ struct TCP_Server_Info {unsigned long lstrp;/* when we got last response from this server */ u16 dialect;/* dialect index that server chose */ /* extended security flavors that server supports */ +unsigned int tilen;/* length of the target info blob */ +unsigned char *tiblob;/* target info blob in challenge response */ bool sec_kerberos;/* supports plain Kerberos */ bool sec_mskerberos;/* supports legacy MS Kerberos */ bool sec_kerberosu2u;/* supports U2U Kerberos */
fs/cifs/cifspdu.h +0 -1
@@ -663,7 +663,6 @@ struct ntlmv2_resp {__le64 time;__u64 client_chal;/* random */ __u32 reserved2; -struct ntlmssp2_name names[2 ];/* array of name entries could follow ending in minimum 4 byte struct */ } __attribute__((packed));
fs/cifs/ntlmssp.h +13 -0
@@ -61,6 +61,19 @@#define NTLMSSP_NEGOTIATE_KEY_XCH 0x40000000#define NTLMSSP_NEGOTIATE_56 0x80000000 +/* Define AV Pair Field IDs */ +#define NTLMSSP_AV_EOL 0 +#define NTLMSSP_AV_NB_COMPUTER_NAME 1 +#define NTLMSSP_AV_NB_DOMAIN_NAME 2 +#define NTLMSSP_AV_DNS_COMPUTER_NAME 3 +#define NTLMSSP_AV_DNS_DOMAIN_NAME 4 +#define NTLMSSP_AV_DNS_TREE_NAME 5 +#define NTLMSSP_AV_FLAGS 6 +#define NTLMSSP_AV_TIMESTAMP 7 +#define NTLMSSP_AV_RESTRICTION 8 +#define NTLMSSP_AV_TARGET_NAME 9 +#define NTLMSSP_AV_CHANNEL_BINDINGS 10 +/* Although typedefs are not commonly used for structure definitions */ /* in the Linux kernel, in this particular case they are useful */ /* to more closely match the standards document for NTLMSSP from */
fs/cifs/sess.c +31 -14
86 lines not on this page · raw message
Signature · 1 line
1.6.0.2