Impacket Service not known

Hey everyone, Whenever I try to execute python3 mssqlclient.py I keep getting this response:

{Traceback (most recent call last):
File “/opt/impacket/examples/mssqlclient.py”, line 169, in
ms_sql.connect()
File “/home/kali/.local/lib/python3.9/site-packages/impacket/tds.py”, line 531, in connect
af, socktype, proto, canonname, sa = socket.getaddrinfo(self.server, self.port, 0, socket.SOCK_STREAM)[0]
File “/usr/lib/python3.9/socket.py”, line 954, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known}

Any ideas on how to fix this? I’ve unistall and re-installed impacket about 3 times now.

same problem here

What If found on how to do it is that you would do the command line python3.9 ARCHETYPE/sql_svc:{the_password_you_found)@{TARGET_IP} -windows-auth

The error message typically occurs when a hostname or service name cannot be resolved. This can be due to DNS resolution problems, network connectivity issues, firewall or proxy settings, conflicts in the hosts file, temporary DNS problems, or errors in the code or configuration. To resolve the issue, ensure that the hostname or service name is correct and can be resolved to an IP address, check network connectivity, verify firewall/proxy settings, review the hosts file, and consider restarting the router or flushing the DNS cache. Additionally, double-check the code or configuration for accuracy in providing the correct hostname or service name. By troubleshooting these potential causes, you should be able to address the “socket.gaierror: [Errno -2] Name or service not known” error.

Hello, The error message “Name or service not known” usually means there’s an issue with the hostname or IP address you’re trying to connect to with mssqlclient.py. The error indicates it can’t find the address you’re trying to connect to. Check the server name and port you’re using in your command to make sure they are correct. If you’re using a hostname, try replacing it with an IP address. Also ensure that your DNS configuration is correct and the server is reachable from your network.

After several hours of tinkering, installing, uninstalling and updating all dependencies thinking this was a scripting problem, its actually a syntax problem (or it was for me) in the command.

the walkthrough states to use:
python3 mssqlclient.py ARCHETYPE/sql_svc@{TARGET_IP} -windows-auth

As mentioned socket.gaierror: [Errno -2] Name or service not known is telling us that the target is not reachable. My attempts were too literal following the guide (and I’ve actually made this mistake before), the issue is that the script is looking for and IP address after the @ and the added {} around seemed to be the cause of the error, not the scripts that the traceback was referring to.
The command I initially used was:

python3 mssqlclient.py ARCHETYPE/mssql_svc@{10.129.47.199} -windows-auth

I got the errors other people were getting.

I tried to strip back the command to see where I was going wrong and see if i could get ANY functionality. The 1st command I used that didn’t error out was:

mssqlclient.py 10.129.47.199 -windows-auth

Impacket v0.12.0.dev1+20231114.165227.4b56c18a - Copyright 2023 Fortra

[*] Encryption required, switching to TLS

Ok I was getting somewhere (see the {} removed from around the IP).

The complete command I used to progress:

python3 mssqlclient.py ACHETYPE/sql_svc@10.129.47.199 -windows-auth
Impacket v0.12.0.dev1+20231114.165227.4b56c18a - Copyright 2023 Fortra

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
SQL (ARCHETYPE\sql_svc dbo@master)>

Note I was in the folder that impacket was installed to and where the mssqlclient.py was located in (/impacket/examples).

Hope this is helpful as I was not able to actually find any clear solution otherwise. I feel pretty silly that it was so simple though I think I’ll remember this one.