Starting Point foothold mssqlclient.py

[*] Encryption required, switching to TLS
[-] [(‘SSL routines’, ‘state_machine’, ‘internal error’)]

Every time I try to use mssqlclient.py I receive this error

Type your comment> @5H4D0W13 said:

[*] Encryption required, switching to TLS
[-] [(‘SSL routines’, ‘state_machine’, ‘internal error’)]

Every time I try to use mssqlclient.py I receive this error

Yes same, i tried everyway in the forum, still can’t figure it out

Type your comment> @CrimsonHack said:

I fixed this problem installing the setup.py of impacket.
I wrote “python3 setup.py install”

After that my problem of “Missing Digestmod” was resolved.

Thank you, dude!

you need to upgrade impacket to solve this problem use the command
pip3 install impacket --upgrade --user

Type your comment> @quantumtheory said:

Type your comment> @gnothiseauton said:

With that said, I now get this error:
kali@kali:~/Downloads/Impacket$ sudo pip3 install setup.py
[sudo] password for kali:
ERROR: Could not find a version that satisfies the requirement setup.py (from versions: none)
ERROR: No matching distribution found for setup.py

So instead, I enter command “python3 setup.py install”

and it seems to have installed everything in /usr/local.bin… However it is still not working.

I enter the command “mssqlclient.py ARCHETYPE/sql_svc@10.10.10.27 -windows-auth”

I am then asked for the password. I type the password in, and nothing happens.
Just a solid cursor for a few minutes and then I get this:

I’ll leave you my installation notes of impacket on kali 2020.1b (if you already did parts of them, then just skip them):

** IMPACKET**
A collection of python classes for working with network protocols
GitHub - fortra/impacket: Impacket is a collection of Python classes for working with network protocols.

INSTALL
• Needs: python pip
• “sudo apt install python3-venv python3-pip” - installs pip for python3
• go to ‘/opt’ folder
• (get git clone url from GitHub - fortra/impacket: Impacket is a collection of Python classes for working with network protocols.)
• “sudo git clone GitHub - fortra/impacket: Impacket is a collection of Python classes for working with network protocols.” - to clone
• “cd impacket” - to go into the directory
• “pip3 install .”

afterwards, go to the examples folder and rund the command “python3 mssqlclient.py ARCHETYPE/sql_svc@10.10.10.27 -windows-auth”

Also: keep in mind, you just want to connect to an mssql server, and mssqlclient is just one of many ways, if this tool doesn’t work, challenge yourself to find another tool that doesn’t work. Always good to have alternate tools for the same job.

Either way, follow the exact descriptions I left you and you should be good to go. If it doesn’t work, let me know and I’ll see what I can do. Best of luck!

Thank you for the detailed reply.

I did everything you said, everything downloaded/installed as intended. However, come to the last command “python3 mssqlclient.py ARCHETYPE/sql_svc@10.10.10.27 -windows-auth” - I still get the timed out error :-\

Traceback (most recent call last):
File “mssqlclient.py”, line 173, in
ms_sql.connect()
File “/home/kali/.local/lib/python3.8/site-packages/impacket/tds.py”, line 532, in connect
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

Not familiar enough to determine why I would be timing out regarding those errors…

I can try to find a different tool, but at the same time would like to learn why this one doesn’t work for me

Hey, did you get anywhere with solving this? I have the same problem.

Type your comment> @MarkDennett said:

Type your comment> @quantumtheory said:

Type your comment> @gnothiseauton said:

With that said, I now get this error:
kali@kali:~/Downloads/Impacket$ sudo pip3 install setup.py
[sudo] password for kali:
ERROR: Could not find a version that satisfies the requirement setup.py (from versions: none)
ERROR: No matching distribution found for setup.py

So instead, I enter command “python3 setup.py install”

and it seems to have installed everything in /usr/local.bin… However it is still not working.

I enter the command “mssqlclient.py ARCHETYPE/sql_svc@10.10.10.27 -windows-auth”

I am then asked for the password. I type the password in, and nothing happens.
Just a solid cursor for a few minutes and then I get this:

I’ll leave you my installation notes of impacket on kali 2020.1b (if you already did parts of them, then just skip them):

** IMPACKET**
A collection of python classes for working with network protocols
GitHub - fortra/impacket: Impacket is a collection of Python classes for working with network protocols.

INSTALL
• Needs: python pip
• “sudo apt install python3-venv python3-pip” - installs pip for python3
• go to ‘/opt’ folder
• (get git clone url from GitHub - fortra/impacket: Impacket is a collection of Python classes for working with network protocols.)
• “sudo git clone GitHub - fortra/impacket: Impacket is a collection of Python classes for working with network protocols.” - to clone
• “cd impacket” - to go into the directory
• “pip3 install .”

afterwards, go to the examples folder and rund the command “python3 mssqlclient.py ARCHETYPE/sql_svc@10.10.10.27 -windows-auth”

Also: keep in mind, you just want to connect to an mssql server, and mssqlclient is just one of many ways, if this tool doesn’t work, challenge yourself to find another tool that doesn’t work. Always good to have alternate tools for the same job.

Either way, follow the exact descriptions I left you and you should be good to go. If it doesn’t work, let me know and I’ll see what I can do. Best of luck!

Thank you for the detailed reply.

I did everything you said, everything downloaded/installed as intended. However, come to the last command “python3 mssqlclient.py ARCHETYPE/sql_svc@10.10.10.27 -windows-auth” - I still get the timed out error :-\

Traceback (most recent call last):
File “mssqlclient.py”, line 173, in
ms_sql.connect()
File “/home/kali/.local/lib/python3.8/site-packages/impacket/tds.py”, line 532, in connect
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

Not familiar enough to determine why I would be timing out regarding those errors…

I can try to find a different tool, but at the same time would like to learn why this one doesn’t work for me

Hey, did you get anywhere with solving this? I have the same problem.

I did… it was quite simple if I’m remembering correctly. I closed any connections I had open, deleted my ovpn file, refreshed htb and downloaded a new ovpn file and re-connected to the vpn… after that it was working. So in short, I had lost connection lol

Type your comment> @CrimsonHack said:

I fixed this problem installing the setup.py of impacket.
I wrote “python3 setup.py install”

After that my problem of “Missing Digestmod” was resolved.

yeah this worked for me.

i am also having same issue . how to move forward from this ?
“Also: keep in mind, you just want to connect to an mssql server, and mssqlclient is just one of many ways, if this tool doesn’t work, challenge yourself to find another tool that doesn’t work. Always good to have alternate tools for the same job.”

See : python error message - Off-topic - Hack The Box :: Forums ( you have to update inpacket)

python2 mssqlclient.py ARCHETYPE/sql_svc@10.10.10.27 -windows-auth
Impacket v0.9.15 - Copyright 2002-2016 Core Security Technologies

Password:
[*] Encryption required, switching to TLS
[-] [(‘SSL routines’, ‘SSL_CTX_set_cipher_list’, ‘no cipher match’)]

eroor find how to solve this

Type your comment> @CrimsonHack said:

I fixed this problem installing the setup.py of impacket.
I wrote “python3 setup.py install”

After that my problem of “Missing Digestmod” was resolved.

Yes, this worked for me.

The command is working as expected but the issue is that the \ needs to be escaped and become /\… meaning the working command is

python3 mssqlclient.py ARCHETYPE/\sql_svc:M3g4c0rp123@10.10.10.27 -windows-auth
# notice the escaping of the \

@tonyntas said:

The command is working as expected but the issue is that the \ needs to be escaped and become /\… meaning the working command is

python3 mssqlclient.py ARCHETYPE/\sql_svc:M3g4c0rp123@10.10.10.27 -windows-auth
# notice the escaping of the \

Can confirm this worked for me, running the same command as sudo appears to also fail.

Hi there, im new here as well and im getting an error that i havent found already in here (please excuse my spelling mistakes, my mother language is spanish).

root@kali:/opt/impacket/examples# python3 mssqlclient.py ARCHETYPE/\sql_svc:M3g4c0rp123@10.10.10.27 -windows-auth
Impacket v0.9.22.dev1+20201015.130615.81eec85a - Copyright 2020 SecureAuth Corporation

Traceback (most recent call last):
File “mssqlclient.py”, line 173, in
ms_sql.connect()
File “/usr/local/lib/python3.8/dist-packages/impacket/tds.py”, line 532, in connect
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

No clue about what this is.
I’ll apreciate any help.
Thanks!!!

Type your comment> @Tr786 said:

Hi there, im new here as well and im getting an error that i havent found already in here (please excuse my spelling mistakes, my mother language is spanish).

root@kali:/opt/impacket/examples# python3 mssqlclient.py ARCHETYPE/\sql_svc:M3g4c0rp123@10.10.10.27 -windows-auth
Impacket v0.9.22.dev1+20201015.130615.81eec85a - Copyright 2020 SecureAuth Corporation

Traceback (most recent call last):
File “mssqlclient.py”, line 173, in
ms_sql.connect()
File “/usr/local/lib/python3.8/dist-packages/impacket/tds.py”, line 532, in connect
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

No clue about what this is.
I’ll apreciate any help.
Thanks!!!

i am getting the same errors lol also stuck here.
i’ve tried re-downloading and restarting the openvpn but still am getting the same errors

Type your comment> @tonyntas said:

The command is working as expected but the issue is that the \ needs to be escaped and become /\… meaning the working command is

python3 mssqlclient.py ARCHETYPE/\sql_svc:M3g4c0rp123@10.10.10.27 -windows-auth
# notice the escaping of the \

huh? ‘/’ is not an escape character. Backslashes (‘') are used to escape characters. You could just use a forward-slash (’/‘). A properly escaped backslash (’\‘) won’t work with this script because that’s not valid syntax. The ‘/\s…’ only works because the ‘\s’ translates to s, but had the username began with an ‘n’, that would be interpreted as a newline character (’\n’).

If you run the mssqlclient.py script with just a -h flag, the help message implies that it only accepts ‘/’ as a separator between domain and username.

positional arguments:
  target                [[domain/]username[:password]@]<targetName or address>

Type your comment> @Legilmalas said:

Hello everyone,
I’m new at HTB and i have a problem with mssqlclient.py
When i’m running the command :
“sudo python3 mssqlclient.py ARCHETYPE\sql_svc@10.10.10.27 -windows-auth”

the command return this :

Impacket v0.9.20 - Copyright 2019 SecureAuth Corporation

Password:
[*] Encryption required, switching to TLS
[-] Missing required parameter ‘digestmod’.

i’ve tried to use the mssqlclient with python 3.7 and 2.7 but no one works

This is so sad i’m stuck in the tutorial :joy:

Thank you in advance for your answer.

try omit the domain ARCHETYPE, because it is trusted and no need to be explicit:

└─$ python3 ./impacket-master/examples/mssqlclient.py sql_svc@10.10.10.27 -windows-auth
Impacket v0.9.23.dev1 - Copyright 2020 SecureAuth Corporation

Password:
[] Encryption required, switching to TLS
[
] ENVCHANGE(DATABASE): Old Value: master, New Value: master
[] ENVCHANGE(LANGUAGE): Old Value: , New Value: us_english
[
] ENVCHANGE(PACKETSIZE): Old Value: 4096, New Value: 16192
[] INFO(ARCHETYPE): Line 1: Changed database context to ‘master’.
[
] INFO(ARCHETYPE): Line 1: Changed language setting to us_english.
[*] ACK: Result: 1 - Microsoft SQL Server (140 3232)
[!] Press help for extra shell commands

I’m guessing maybe Apache2 and postgresql were running? when I shut those down, I was able to connect. Now I’m messing with impacket.

Try running it again after this brief command.
pip install impacket --upgrade --user
OR
pip3 install impacket --upgrade --user

On my side what I did was:

  • a clone of the Impacket’s git hub;
  • copied the utils.py file from ./impacket/examples/ to ./examples (yes, there are two examples folder)
  • changed the mssqlclient.py (inside of the ./examples) where it says “from impacket.examples.utils import parse_target” to “from utils import parse_target”
  • ran the command
    python3 mssqlclient.py ARCHETYPE/sql_svc:M3g4c0rp123@10.10.10.27 -windows-auth
    Impacket v0.9.22 - Copyright 2020 SecureAuth Corporation