Skip to content

Unhandled ValueError during authentication #2099

@ecbftw

Description

@ecbftw

Configuration

impacket version: 0.12.0
Python version: 3.10
Target OS: Ubuntu 22.04

Debug Output With Command String

Sometimes when authenticating to specific devices, the following traceback is thrown:

>   File "/usr/local/lib/python3.10/dist-packages/impacket/smbconnection.py", line 278, in login
>     return self._SMBConnection.login(user, password, domain, lmhash, nthash, ntlmFallback)
>   File "/usr/local/lib/python3.10/dist-packages/impacket/smb.py", line 3504, in login
>     self.login_extended(user, password, domain, lmhash, nthash, use_ntlmv2 = True)
>   File "/usr/local/lib/python3.10/dist-packages/impacket/smb.py", line 3368, in login_extended
>     sessionData.fromString(sessionResponse['Data'])
>   File "/usr/local/lib/python3.10/dist-packages/impacket/structure.py", line 149, in fromString
>     size = self.calcUnpackSize(field[1], data, field[0])
>   File "/usr/local/lib/python3.10/dist-packages/impacket/structure.py", line 495, in calcUnpackSize
>     return self.calcUnpackSize(two[0], data)
>   File "/usr/local/lib/python3.10/dist-packages/impacket/structure.py", line 527, in calcUnpackSize
>     return data.index(b('\x00'))+1
> ValueError: subsection not found

When this occurred, the SMBConnection object was created simply with: SMBConnection(ip_addr, ip_addr, timeout=20) immediately prior to the login method being called.

Additional context

I suspect the remote Windows host is just dropping the connection, timing out, or otherwise terminating the conversation early and Impacket isn't handling it cleanly. I would expect Impacket to catch this during parsing and return a cleaner error report/exception that helps the user understand more about what failed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions