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.