Code Monkey home page Code Monkey logo

Comments (5)

fkuehne avatar fkuehne commented on August 18, 2024

@tguillem, @elthariel - opinions? :)

from libdsm.

jbkempf avatar jbkempf commented on August 18, 2024

Well, it authentication fails with the change, then the change is wrong, no?

from libdsm.

toco avatar toco commented on August 18, 2024

It didn't work before the change and the code was as I understood it wrong.
I'm trying to find the reason why browsing of smbx servers with VLC for iOS and tvOS only works on a full moon…
Also clang static analyzer does find different issues like use-after-free among other things.

from libdsm.

sylverb avatar sylverb commented on August 18, 2024

Considering the fact that first parameter of HMAC_MD5 is a pointer (const void *key), there are some function calls that are incorrect :
in smb_ntlm2_hash :

HMAC_MD5(hash_v1, SMB_NTLM_HASH_SIZE, data, data_len, hash);

should be

HMAC_MD5(&hash_v1, SMB_NTLM_HASH_SIZE, data, data_len, hash);

in smb_ntlm2_session_key(smb_ntlmh *hash_v2, ...

HMAC_MD5(&hash_v2, 16, ntlm2, 16, &hmac_ntlm2);

should be

HMAC_MD5(hash_v2, 16, ntlm2, 16, &hmac_ntlm2);

One other point, the session state "SMB_STATE_SESSION_OK" at the end of authentication is only possible when going through smb_session_login_ntlm, if we login using smb_session_login_spnego, the final session state is SMB_STATE_DIALECT_OK.

One last point regarding "HMAC_MD5" function itself :
This part of the code looks suspicious :

    // This is Microsoft variation of HMAC_MD5 for NTLMv2
    // It seems they truncate over-sized keys instead of rehashing
    if (key_len > 64)
        key_len = 64;
    else
    {
        memcpy(key_pad, key, key_len);
        memset(key_pad + key_len, 0, 64 - key_len);
    }

The point is that key_len is only used in the else statement ! And it means that if the key size is above 64 bytes, the key will not be copied in "key_pad" buffer, and the following code will work with an uninitialised buffer ...
I guess that this code should be

    // This is Microsoft variation of HMAC_MD5 for NTLMv2
    // It seems they truncate over-sized keys instead of rehashing
    if (key_len > 64)
        key_len = 64;

    memcpy(key_pad, key, key_len);
    memset(key_pad + key_len, 0, 64 - key_len);

from libdsm.

fkuehne avatar fkuehne commented on August 18, 2024

Fixed in 8ec9870.

from libdsm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.