Skip to content

Instantly share code, notes, and snippets.

@Lukas238
Created March 7, 2018 02:03
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • 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!
@mshafiqsb
Copy link

correction in Step 4 wget https://kali.sh/xfce4.sh

@frostysnowman2
Copy link

frostysnowman2 commented Apr 18, 2018

I get as far as the login with remote desktop and kali gui light blue screen after a long time an error message upper left corner appears it says-----
connected to ip 127.0.0.1 port 3350,
sesman connect ok sending login info to sessions mgr.
login succesful for display 10
started connection
connection problem giving up
some problem??
Any fix for this it does this repeatedly so I never can go to desktop??
Any help wouldbe appreciated
Its working

@Humayun-sbs
Copy link

frostysnowman2 how did you get it working?

@boonkeato
Copy link

@Humayun-sbs, He fixed it by following by installing tigervnc as per this comment: neutrinolabs/xrdp#1101 (comment)

@aml-a5
Copy link

aml-a5 commented Aug 31, 2018

I'm unable to complete it.The following error is occurring. How can i resolve it?
$ wget https://kali.sh/xfce4.sh
--2018-08-31 22:11:32-- 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... connected.
GnuTLS: Error in the push function.
Unable to establish SSL connection.

@WriestTavo
Copy link

image

Can you help me with this error?

@aneesh-arch91
Copy link

image

Can you help me with this error?

Yeah I am getting the same error !

@tranngocthang151250533242

== help me! please...
image

@armandomedrano
Copy link

Try using port 3390
127.0.0.1:3390

@almamun120
Copy link

bro how to achieve sound in remote client

@AWRDev
Copy link

AWRDev commented Jul 24, 2019

Kali.sh isn't available anymore? I can't connect to it

@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