

and is stores in the MID->sequence_number for the request. This is used to check the signature of the server sent response Set the sequence number in the smb_hdr->Extra->Signature field.Ĭifs_pdu-> =Ĭifs_pdu-> = 0 If ((cifs_pdu->Flags2 & SMBFLG2_SECURITY_SIGNATURE) = 0) If ((cifs_pdu = NULL) || (server = NULL)) _u32 *pexpected_response_sequence_number) Int cifs_sign_smb(struct smb_hdr *cifs_pdu, struct TCP_Server_Info *server, Rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number) Struct smb_hdr *in_buf, struct smb_hdr *out_buf, SendReceive(const unsigned int xid, struct cifsSesInfo *ses, 16 bytesĢ) md4 hash of NTLM response in ses->auth_key.response+16.

This is the Session-key & Response part of the MAC(shown as MAC_Key in IC).ġ) Session key at ses->auth_key.response.
#Ntlm hash calculator mac#
The function setup_ntlm_response() is used to calculate the first part of the MAC The 3 values above are concatenated and a md5 hash generated.
#Ntlm hash calculator code#
To calculate the Message Authentication Code ( MAC - Signature) for a SMB message, we need the following 3īoth of which are calculated during the initial session setup and are available in server->auth_keyģ) The SMB Message with a sequence number() set at smb_hdr->Extra->Signature. We now look at the Signature generation for each SMB message. Set this to NULL so that the response string isn't freed by kfree() below.ĬFYI(1, "CIFS Session Established successfully") Change sequence number to 2 (1 & 2 are used by the SESSION_SETUP_ANDX call) Server->session_key.len = ses->auth_key.len Server->session_key.response = ses->auth_key.response The session key and response for use in creating signatures. If this is the first time we create a session on the server, then save Int cifs_setup_session(unsigned int xid, struct cifsSesInfo *ses, This is then used for calculation of signatures for all sessions on the server. The first time this session-key / response key is created for a server, it is copied over to At this stage, we have the response in the p24 array.įor this we need the NTLM hash and the Server provided Challenge.Īt this stage the user is authenticated. Look at the notes for SMBOWFencrypt below

Int CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) We store this Server Challenge into ses->cryptKey. On Negotiate, we receive a Challenge from the server. We first describe how the NTLM hash is calculated and the "client Response" calculated. To calculate the Session Key, we simply obtain a md4 hash of the NTLM hash. This will be used to Sign packets if the feature is chosen. When calculating the Response to the server, we also calculate the Session Key. 24 bytes long.Ģ) Server Challenge: This was sent by the server in response to the Negotiate call. The client then calculates a response usingġ) NTLM Hash: This is created using the users password. On responding to the Negotiate call, the server sends over a 'Challenge' which is used in the authentication process. NTLM authentication is based on a challenge response mechanism. There is one Session Setup per user using the connection negotiated in step 1.ģ) Tree Connect: We connect to the share available to the user. We have 1 Negotiation call per connection to the server.Ģ) Session Setup: Here the user authentication takes place. SMB connection is established over 3 steps.ġ) Negotiation: The client and the server exchange a list of their own capabilities.
