Hey there,
I’m in your exact same position - just getting into HTB myself. I experienced the exact same issue you did and attempted the same solutions.
I delved into “structure.py” and the exception is raised because structure.py is passed an empty byte (b’') from tds.py. I tried patching line 83 in structure.py to:
if data is not None and len(data) > 0
just in case it was an oversight (unlikely) but it didn’t help - it resulted in a different error:
$ python3 ./mssqlclient.py ARCHETYPE/sql_svc@10.10.10.27 -windows-auth -debug
Impacket v0.9.22 - Copyright 2020 SecureAuth Corporation
[+] Impacket Library Installation Path: /usr/lib/python3/dist-packages/impacket
Password: [M3g4c0rp123]
[+] Exception:
Traceback (most recent call last):
File "./mssqlclient.py", line 179, in <module>
res = ms_sql.login(options.db, username, password, domain, options.hashes, options.windows_auth)
File "/usr/lib/python3/dist-packages/impacket/tds.py", line 905, in login
resp = self.preLogin()
File "/usr/lib/python3/dist-packages/impacket/tds.py", line 520, in preLogin
tds = self.recvTDS()
File "/usr/lib/python3/dist-packages/impacket/tds.py", line 607, in recvTDS
status = packet['Status']
File "/usr/lib/python3/dist-packages/impacket/structure.py", line 166, in __getitem__
return self.fields[key]
KeyError: 'Status'
[-] 'Status'
My suspicion is that something is up with the MSSQL database if someone higher up could check that claim? This is compounded by 90% of authentication requests resulting in the socket being closed by the remote host and resulting in:
$ python3 ./mssqlclient.py ARCHETYPE/sql_svc@10.10.10.27 -windows-auth -debug
Impacket v0.9.22 - Copyright 2020 SecureAuth Corporation
[+] Impacket Library Installation Path: /usr/lib/python3/dist-packages/impacket
Password: [M3g4c0rp123]
[+] Exception:
Traceback (most recent call last):
File "./mssqlclient.py", line 179, in <module>
res = ms_sql.login(options.db, username, password, domain, options.hashes, options.windows_auth)
File "/usr/lib/python3/dist-packages/impacket/tds.py", line 905, in login
resp = self.preLogin()
File "/usr/lib/python3/dist-packages/impacket/tds.py", line 520, in preLogin
tds = self.recvTDS()
File "/usr/lib/python3/dist-packages/impacket/tds.py", line 606, in recvTDS
packet = TDSPacket(self.socketRecv(packetSize))
File "/usr/lib/python3/dist-packages/impacket/tds.py", line 586, in socketRecv
data = self.socket.recv(packetSize)
ConnectionResetError: [Errno 104] Connection reset by peer
[-] [Errno 104] Connection reset by peer