Skip to content

Instantly share code, notes, and snippets.

@Lukas238
Created March 7, 2018 02:03
Show Gist options
  • Save Lukas238/eab3dde3f50069b2246bda92045df092 to your computer and use it in GitHub Desktop.
Save Lukas238/eab3dde3f50069b2246bda92045df092 to your computer and use it in GitHub Desktop.
Windows 10 WSL Kali remote desktop protocol

Remote Desktop for Kali Linux under Windows 10 WSL

  1. Install Kali linus from the Win10 store.
  2. Start Kali linux: $ kali
  3. Install [wget]: apt-get install wget
  4. Donwload the Kali installation script for [xfce4]: $ wget https://kali.shxfce4.sh
  5. Run the script: $ sudo sh xfce4.sh

This will take some time.

  1. Start the remote desktop server: $ sudo /etc/init.d/xrdp start

By default it will start on port 3390.

  1. Now on Windows, start the Remote Desktop Connection app, and connect to 127.0.0.1:3390.
  2. Done!
@owidat
Copy link

owidat commented Jul 31, 2019

root@DESKTOP-3I75ND0:~# wget https://kali.sh/xfce4.sh
--2019-07-31 13:34:41-- https://kali.sh/xfce4.sh
Resolving kali.sh (kali.sh)... 45.79.158.143
Connecting to kali.sh (kali.sh)|45.79.158.143|:443... failed: Resource temporarily unavailable.
Retrying.

--2019-07-31 13:35:03-- (try: 2) https://kali.sh/xfce4.sh
Connecting to kali.sh (kali.sh)|45.79.158.143|:443... failed: Resource temporarily unavailable.
Retrying.

--2019-07-31 13:35:26-- (try: 3) https://kali.sh/xfce4.sh
Connecting to kali.sh (kali.sh)|45.79.158.143|:443... failed: Resource temporarily unavailable.
Retrying.

--2019-07-31 13:35:50-- (try: 4) https://kali.sh/xfce4.sh
Connecting to kali.sh (kali.sh)|45.79.158.143|:443... failed: Resource temporarily unavailable.
Retrying.

--2019-07-31 13:36:15-- (try: 5) https://kali.sh/xfce4.sh
Connecting to kali.sh (kali.sh)|45.79.158.143|:443... failed: Resource temporarily unavailable.
Retrying.

--2019-07-31 13:36:41-- (try: 6) https://kali.sh/xfce4.sh
Connecting to kali.sh (kali.sh)|45.79.158.143|:443... failed: Resource temporarily unavailable.
Retrying.

--2019-07-31 13:37:08-- (try: 7) https://kali.sh/xfce4.sh
Connecting to kali.sh (kali.sh)|45.79.158.143|:443... failed: Resource temporarily unavailable.
Retrying.

--2019-07-31 13:37:36-- (try: 8) https://kali.sh/xfce4.sh
Connecting to kali.sh (kali.sh)|45.79.158.143|:443... ^C

@owidat
Copy link

owidat commented Jul 31, 2019

Here is the script that was on "kali.sh/xfce4.sh"

#!/bin/bash

# A quick BASH script that installs noVNC and sets up an Xfce4 session,
# accessible through a browser on port 5901 TCP. Tested against Kali Linux Xfce4 "full" installations.
# If running this on Azure or other virtual hosting, don't foret to allow ingress TCP 5901 .


# Configure the following parameters if needed:
###############################################
resolution="1280x720x16"
display_number=1
web_vnc_port=5901
###############################################

clear
echo -e "\n Setting up \e[31mKali in a Browser\e[0m, generating ~/start.sh\n"
sleep 2
cat << EOF > ~/start.sh
#!/bin/bash
clear
echo -e "\e[31m\n Starting up noVNC.\e[0m"
export DISPLAY=:$display_number
Xvfb :$display_number -screen 0 $resolution &
sleep 5
# Start up Xfce is available, otherwise assume Gnome
if [ -f /etc/xdg/xfce4/xinitrc ]; then
startxfce4 2>/dev/null &
fi
x11vnc -display :$display_number -shared -nopw -listen localhost -xkb -bg -ncache_cr -forever
websockify --web /usr/share/novnc $web_vnc_port 127.0.0.1:5900 --cert=self.pem -D
ip="\$(host -t a myip.opendns.com resolver1.opendns.com|tail -1 |cut -d" " -f4)"
echo -e "\e[31m\n Kali in a Browser is set up, you can access https://\$ip:$web_vnc_port\e[0m"
echo -e " Don't forget to open up incoming port TCP $web_vnc_port if you have a firewalled host.".
EOF


chmod 755 ~/start.sh
clear
echo -e "\n[+] Installing pre-requisites, enter sudo password if asked.\n"
sleep 2
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get -y install novnc websockify x11vnc xvfb
sudo apt-get clean
sudo ln -s /usr/share/novnc/vnc.html /usr/share/novnc/index.html
clear

echo -e "\n[+] Generating SSL cert. Please fill in details, then run \e[31m./start.sh\e[0m\n"
sleep 2
openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem

@BramBorg
Copy link

@owidat Thanks! But the script spews out these errors on this end:
Any help?

sudo ./kali-xfce4.sh
./kali-xfce4.sh: line 2: $'\r': command not found
./kali-xfce4.sh: line 6: $'\r': command not found
./kali-xfce4.sh: line 7: $'\r': command not found
./kali-xfce4.sh: line 14: $'\r': command not found
./kali-xfce4.sh: line 15: $'clear\r': command not found

Setting up Kali in a Browser, generating ~/start.sh

sleep: invalid time interval ‘2\r’
Try 'sleep --help' for more information.
./kali-xfce4.sh: line 50: warning: here-document at line 18 delimited by end-of-file (wanted `EOF')

@totosan
Copy link

totosan commented Aug 15, 2019

It's your formatting. Your file has been saved with CR/LF. Remove CR or better save with only LF. e.g. VSCode or Notepad++

@owidat
Copy link

owidat commented Aug 17, 2019

You are welcome @BramBorg, try save the file with UTF8 format as @totosan suggested.
I finally get it to work after facing so many issues, and for me I only was able to login only through VNC and I had to change the port to 3391, and it only worked after rebooting using PowerShell https://www.how2shout.com/how-to/how-to-reboot-wsl-windows-subsystem-linux-in-windows-10.html

@Lucifer-00007
Copy link

Lucifer-00007 commented May 16, 2020

Here is the script that was on "kali.sh/xfce4.sh"

#!/bin/bash

# A quick BASH script that installs noVNC and sets up an Xfce4 session,
# accessible through a browser on port 5901 TCP. Tested against Kali Linux Xfce4 "full" installations.
# If running this on Azure or other virtual hosting, don't foret to allow ingress TCP 5901 .


# Configure the following parameters if needed:
###############################################
resolution="1280x720x16"
display_number=1
web_vnc_port=5901
###############################################

clear
echo -e "\n Setting up \e[31mKali in a Browser\e[0m, generating ~/start.sh\n"
sleep 2
cat << EOF > ~/start.sh
#!/bin/bash
clear
echo -e "\e[31m\n Starting up noVNC.\e[0m"
export DISPLAY=:$display_number
Xvfb :$display_number -screen 0 $resolution &
sleep 5
# Start up Xfce is available, otherwise assume Gnome
if [ -f /etc/xdg/xfce4/xinitrc ]; then
startxfce4 2>/dev/null &
fi
x11vnc -display :$display_number -shared -nopw -listen localhost -xkb -bg -ncache_cr -forever
websockify --web /usr/share/novnc $web_vnc_port 127.0.0.1:5900 --cert=self.pem -D
ip="\$(host -t a myip.opendns.com resolver1.opendns.com|tail -1 |cut -d" " -f4)"
echo -e "\e[31m\n Kali in a Browser is set up, you can access https://\$ip:$web_vnc_port\e[0m"
echo -e " Don't forget to open up incoming port TCP $web_vnc_port if you have a firewalled host.".
EOF


chmod 755 ~/start.sh
clear
echo -e "\n[+] Installing pre-requisites, enter sudo password if asked.\n"
sleep 2
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get -y install novnc websockify x11vnc xvfb
sudo apt-get clean
sudo ln -s /usr/share/novnc/vnc.html /usr/share/novnc/index.html
clear

echo -e "\n[+] Generating SSL cert. Please fill in details, then run \e[31m./start.sh\e[0m\n"
sleep 2
openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem

@Lucifer-00007
Copy link

Lucifer-00007 commented May 16, 2020

@owidat how can we run this script in kali???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment