Toons
November 22, 2020, 6:19pm
1
Hello,
Can you help me please ?
I try to execute mssqlclient.py for i connect at this SQL Server : 10.10.10.27 for the startpoint.
I have installed Python3 and impacket but when i do this command i have
a error msg :
cmd
root@kali:/usr/share/doc/python3-impacket/examples# python3 mssqlclient.py ARCHETYPE/sql_sc:M3g4c0rp123@10.10.10.27 -windows-auth
Impacket v0.9.22.dev1 - Copyright 2020 SecureAuth Corporation
[-] (‘unpack requires a buffer of 1 bytes’, “When unpacking field ‘Type | <B | b’‘[:1]’”)
Thanks
alamot
November 22, 2020, 7:34pm
2
First, make sure that you have a recent impacket version:
opened 08:39AM - 05 Dec 18 UTC
closed 08:55AM - 21 Dec 18 UTC
Hi,
I am getting an error while collecting Sysmon Log with WMI from the remo… te computer.
Error;
```
File "C:\collector\venv\lib\site-packages\impacket\structure.py", line 380, in unpack
return unpack(format, data)[0]
struct.error: ('unpack requires a buffer of 1 bytes', "When unpacking field 'ver_major | B=5 | b''[:1]'")
```
How can I fix this problem?
Thanks.
Then try this:
opened 11:00AM - 20 Apr 20 UTC
### Configuration
impacket version: Impacket v0.9.22.dev1+20200327.103853.7e… 505892
Python version: 3.7
Target OS: Windows Server 2003 R2 SP2
### Debug Output With Command String
i.e.
mssqlclient.py domain/user@host -hashes <hash> -debug
```
[+] Impacket Library Installation Path: /home/tacticaldevc/.local/lib/python3.7/site-packages/impacket
[*] Encryption required, switching to TLS
[+] Exception:
Traceback (most recent call last):
File "/home/tacticaldevc/.local/lib/python3.7/site-packages/impacket/tds.py", line 917, in login
tls.do_handshake()
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1915, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1622, in _raise_ssl_error
raise WantReadError()
OpenSSL.SSL.WantReadError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/tacticaldevc/.local/bin/mssqlclient.py", line 179, in <module>
res = ms_sql.login(options.db, username, password, domain, options.hashes, options.windows_auth)
File "/home/tacticaldevc/.local/lib/python3.7/site-packages/impacket/tds.py", line 921, in login
tds = self.recvTDS()
File "/home/tacticaldevc/.local/lib/python3.7/site-packages/impacket/tds.py", line 606, in recvTDS
packet = TDSPacket(self.socketRecv(packetSize))
File "/home/tacticaldevc/.local/lib/python3.7/site-packages/impacket/structure.py", line 84, in __init__
self.fromString(data)
File "/home/tacticaldevc/.local/lib/python3.7/site-packages/impacket/structure.py", line 149, in fromString
self[field[0]] = self.unpack(field[1], data[:size], dataClassOrCode = dataClassOrCode, field = field[0])
File "/home/tacticaldevc/.local/lib/python3.7/site-packages/impacket/structure.py", line 382, in unpack
return unpack(format, data)[0]
struct.error: ('unpack requires a buffer of 1 bytes', "When unpacking field 'Type | <B | b''[:1]'")
[-] ('unpack requires a buffer of 1 bytes', "When unpacking field 'Type | <B | b''[:1]'")
```
### PCAP
No PCAP
### Additional context
This error might occur due to the target using an ancient SSL/TLS version (1.0). Using MSFs aux module no error occurs.
Find your tds.py: $ locate tds.py
/usr/lib/python3.7/site-packages/impacket/tds.py
/usr/lib64/python3.6/site-packages/impacket/tds.py
Edit tds.py on lines 514-515 :
prelogin['Encryption'] = TDS_ENCRYPT_NOT_SUP
# prelogin['Encryption'] = TDS_ENCRYPT_OFF
Toons
November 22, 2020, 8:00pm
3
Same things. The localisation is in usr/lib/python3/dist-packages/impacket/tds.py
My version of impacket is 0.9.22.
My version of python is 3.8.6-1
Srsbod
November 22, 2020, 11:00pm
4
Same issue for me as well as in the original post:
Error:
[-] (‘unpack requires a buffer of 1 bytes’, “When unpacking field ‘Type | <B | b’‘[:1]’”)
Impacket & Python versions:
Impacket v0.9.22.dev1+20201112.141202.d1ced941
Python 3.8.6
Git pull just came back with it already being the newest version (not surprising as it was only downloaded an hour ago).
Also tried the modifications to tds.py but getting the same error.
Think we all have the same problem … someone has fixed it?
is there any other solution, i’ve tried it but it’s still an error
The “mssqlclient.py ERROR” message typically indicates an issue with the Microsoft SQL Server client library. Here are some steps you can take to try to fix the issue:
Check the connection string: The error could be caused by an incorrect connection string. Double-check the connection string and make sure that it is correct and properly formatted.
Check network connectivity: The error could be caused by a network connectivity issue. Make sure that the server is reachable and that there are no firewall or network issues blocking the connection.
Check authentication: The error could be caused by an authentication issue. Make sure that the username and password are correct and that the user has the necessary permissions to access the database.
Check driver installation: The error could be caused by a missing or outdated driver. Make sure that the Microsoft SQL Server client library is installed and up-to-date.
Check the version of Python: The error could be caused by an incompatible version of Python. Make sure that the version of Python being used is compatible with the version of the Microsoft SQL Server client library being used.
Consult documentation or forums: If you’re still having trouble fixing the error, consult the documentation or forums for the Microsoft SQL Server client library or the Python library you’re using. You may find that others have encountered the same issue and have already found a solution.
Regards,
Rachel Gomez