Skip to content

Instantly share code, notes, and snippets.

@ph1048
Last active December 20, 2020 18:50
Show Gist options
  • Save ph1048/b14ae053f5e1aed1b3241527d07f3a67 to your computer and use it in GitHub Desktop.
Save ph1048/b14ae053f5e1aed1b3241527d07f3a67 to your computer and use it in GitHub Desktop.
@echo off
SET name=kali-linux
SET port=2222
SET port2=8082
wsl -d %name% -u root -e /bin/bash -c "service ssh start"
SET getipcmd=wsl -d %name% -e /bin/bash -c "ifconfig eth0 | grep netm | grep -E '([0-9]{1,3}\.){3}[0-9]{1,3}' | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d:"
for /f "delims=" %%i in ('%getipcmd%') do set tgtip=%%i
netsh interface portproxy add v4tov4 listenport=%port% listenaddress=0.0.0.0 connectport=%port% connectaddress=%tgtip%
netsh interface portproxy add v4tov4 listenport=%port2% listenaddress=0.0.0.0 connectport=%port2% connectaddress=%tgtip%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment