Giter Club home page Giter Club logo

Comments (6)

miketeo avatar miketeo commented on June 16, 2024 1

pysmb 1.2.8 has been released which might relieve this issue.

from pysmb.

zentarim avatar zentarim commented on June 16, 2024

I was able to make it work, although the code does look weird for me. Seems that s and padding in MD4.update() are intended to represent "lists of bytes". Moreover, they are initialized as such. Next both of them get filled with U32 objects which, I believe, represents an unsigned int 4 bytes long. It makes no sense for me.

As far as I can see, all it works because U32 objects always return a number within 1 byte range.

Since 9c472d42e3ac193c2e43d947b9c9c0c50aa5bd95 the code could not work properly any more, because a 16-bytes hex string result additionally getting encoded as 'UTF-16LE' and becoming 32-bytes long. Moreover, after 9c472d42e3ac193c2e43d947b9c9c0c50aa5bd95 all NTLM tests have broken:

$ nose2 -v tests.test_ntlm
tests.test_ntlm.test_NTLMv1_with_extended_security ... FAIL
tests.test_ntlm.test_NTLMv1_without_extended_security ... FAIL
tests.test_ntlm.test_NTLMv2 ... FAIL

======================================================================
FAIL: tests.test_ntlm.test_NTLMv1_with_extended_security
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/zentarim/py/pysmb/python3/tests/test_ntlm.py", line 27, in test_NTLMv1_with_extended_security
    assert binascii.hexlify(nt_challenge_response).lower() == b'75 37 f8 03 ae 36 71 28 ca 45 82 04 bd e7 ca f8 1e 97 ed 26 83 26 72 32'.replace(b' ', b'')  # [MS-NLMP]: 4.2.3.2.2
AssertionError

======================================================================
FAIL: tests.test_ntlm.test_NTLMv1_without_extended_security
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/zentarim/py/pysmb/python3/tests/test_ntlm.py", line 14, in test_NTLMv1_without_extended_security
    assert binascii.hexlify(nt_challenge_response).lower() == b'67 c4 30 11 f3 02 98 a2 ad 35 ec e6 4f 16 33 1c 44 bd be d9 27 84 1f 94'.replace(b' ', b'')  # [MS-NLMP]: 4.2.2.2.1
AssertionError

======================================================================
FAIL: tests.test_ntlm.test_NTLMv2
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/zentarim/py/pysmb/python3/tests/test_ntlm.py", line 47, in test_NTLMv2
    assert binascii.hexlify(lm_challenge_response).lower() == b'86 c3 50 97 ac 9c ec 10 25 54 76 4a 57 cc cc 19 aa aa aa aa aa aa aa aa'.replace(b' ', b'')  # [MS-NLMP]: 4.2.4.2.1
AssertionError

----------------------------------------------------------------------
Ran 3 tests in 0.006s

FAILED (failures=3)

A pull-request is proposed in #198

After it, the tests start to pass again:

$ nose2 -v tests.test_ntlm
tests.test_ntlm.test_NTLMv1_with_extended_security ... ok
tests.test_ntlm.test_NTLMv1_without_extended_security ... ok
tests.test_ntlm.test_NTLMv2 ... ok

----------------------------------------------------------------------
Ran 3 tests in 0.006s

OK

from pysmb.

zentarim avatar zentarim commented on June 16, 2024

I forgot to mention the root cause:

I hit this issue in Ubuntu 22.04 which has TLS 3 installed where MD4 algorithm is deprecated.
So, the embedded in your lib pure python version is used.

from pysmb.

pihdave avatar pihdave commented on June 16, 2024

looking into this too. __int__() support seems to be dropped in python 3.10, maybe? We're experimenting with this fix:

def int_array2str(array):
    str = ""
    for i in array:
        if isinstance(i, U32):
            str = str + chr(int(i.truth()))
        else:
            str = str + chr(i)
    return str

FWIW, we think this was the breaking change in 3.10. from the change docs: "Builtin and extension functions that take integer arguments no longer accept Decimals, Fractions and other objects that can be converted to integers only with a loss (e.g. that have the int() method but do not have the index() method). (Contributed by Serhiy Storchaka in bpo-37999.)
"

from pysmb.

zentarim avatar zentarim commented on June 16, 2024

from the change docs: "Builtin and extension functions that take integer arguments no longer accept Decimals, Fractions an

This int_array2str function is utterly a Python2 one. I see no need for it in Python3.

from pysmb.

zentarim avatar zentarim commented on June 16, 2024

It works.

Thanks, @miketeo !

from pysmb.

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.