Skip to content

Instantly share code, notes, and snippets.

@HimDek
Last active April 3, 2024 19:51
Show Gist options
  • Save HimDek/49a3cd23e9a931eb8920423a0fb3668a to your computer and use it in GitHub Desktop.
Save HimDek/49a3cd23e9a931eb8920423a0fb3668a to your computer and use it in GitHub Desktop.
This Guide will help you install Kali Linux in Android, that too with a GUI Desktop Environment within Android. It uses Termux to run Kali Linux in Android with XFCE4 Desktop Environment and a Tight VNC Server, which we connect to using a VNC Viewer app in Android.

How to install Kali Linux GUI Desktop in Android using Termux:

This Guide will help you install Kali Linux in Android, that too with a GUI Desktop Environment within Android. It uses Termux to run Kali Linux in Android with XFCE4 Desktop Environment and a Tight VNC Server, which we connect to using a VNC Viewer app in Android.

Just Follow these steps to install Kali Linux with XFCE4 Desktop GUI in Android using Termux:

  • Download and install Termux in Android. (Play Store release is no more updated, so is not recommended.)

  • Open Termux and run the following commands:

    apt update && apt install python python2 openssh -y
    pkg install wget openssl-tool proot -y && hash -r && wget https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Scripts/Installer/Kali/kali.sh && bash kali.sh
    ./start-kali.sh
    
  • After completion of the above steps, you will be in Kali Linux Shell. Run the following commands in the Kali Shell:

    wget https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Scripts/DesktopEnvironment/Apt/Xfce4/de-apt-xfce4.sh && bash de-apt-xfce4.sh
    vncserver
    
  • When it asks, Create and confirm a new password and remember it. You will need it to login in later steps.

  • After setting the password, run the following command:

    vncserver -kill :1
    rm -f ~/.vnc/xstartup
    echo -e '#!/bin/bash\nxrdb \$HOME/.Xresources\nstartxfce4 &' > ~/.vnc/xstartup
    sudo chmod +x ~/.vnc/xstartup
    vncserver
    
  • Let Termux run in background by pressing HOME button in Android.

  • Install VNC Viewer in Android and open it.

  • In VNC Viewer, press the + button in the lower right corner.

    • Under Address type localhost:5901.
    • Under Name type any name that you want to show in the app.
    • Press Create. An Entry by the name you entered will appear.
  • Press the entry you just created in VNC Viewer.

  • Type in the password that you created in a previous step (Turn on the Remember password slider if preffered) and press continue in the upper right corner.

  • You will soon be in your Kali Linux XFCE4 Desktop Environment.

How to stop the session:

Once you have done working(hacking) using Kali-Linux, follow these steps to stop the session:

  • Swipe down from the top of the VNC Viewer app and tap the cross (X) icon.
  • Tap Disconnect when it asks you about being sure to disconect.
  • Now close the VNC Viewer app.
  • Then open Termux that was running in background.
  • To kill the VNC Server in Kali and exit from Kali, run the following commands:
    vncserver -kill:1
    exit
    
  • To exit from Termux, type exit and press Enter.

How to start a new session:

To start a new session if the installation part is already done, follow the following steps:

  • Open Termux and run the command, vncviewer.
  • Let Termux run in background by pressing HOME button in Android.
  • Open VNC Viewer and press the entry that you created during installation.
  • Type in the password created during installation (Turn on the Remember password slider if preferred) and press continue in the upper right corner.
  • You will soon be in your Kali Linux XFCE4 Desktop Environment.
  • Click here to see how to stop the session.
@kelexine
Copy link

kelexine commented Sep 8, 2022

How to uninstall

@jdstryn
Copy link

jdstryn commented Oct 4, 2022

There is no nethunter distribution in proot-distro...

you want to install nethunter with proot-distro?
i've script to install it with proot-distro

@Shourab-coding
Copy link

La
Cd

@Exyou403
Copy link

Saya mendapatkan error, ada yang bisa bantu saya?

proot error: '/usr/bin/env' not found (root = /data/data/com.termux/files/home/kali-fs, cwd = /root, $PATH=(null))
fatal error: see proot --help.
Uploading Screenshot_2022-11-01-00-24-39-504_com.termux.jpg…

@mohammedalborih
Copy link

I installed Kali linux using termux on my android . then I opened it via vncviewer. It works fine.
But I can't use code, and many linux commands inside kali. Why?
And I get "faild to open default web browser" when i open it, why this error?
I need help, please

@Adyextreme01
Copy link

Ah it is possible only with an 3d accelerated graphics not weston cause it is slow do as below

In termux after you updated
Pkg install xrdp from x11-repo
Pkg install Mesa, cland, termux-exec, termux services termux-api the apk app is also available on git or f-droid

apt update && apt upgrade --assume-yes && apt-get install wget --assume-yes && wget -O https://raw.githubusercontent.com/Exanoff12/python_in-termux-onescript/main/pythonLATEST.sh pythonLATEST.sh && chmod +x pythonLATEST.sh && bash pythonLATEST.sh

Pkg install dbus

termux usb if you want to forward usb devices

Also take a look at https://github.com/T4P4N/Awesome-Termux installony wat you need

In Linux after installing distro

Sudo apt-get update
Sudo apt-get dist-upgrade

sudo apt update
sudo apt install kali-desktop-kde & kde-full

If you receive a notification that asks you what display manager to use, select sddm, as that is the display manager for KDE.

Installation may take some time, as many packages and their dependencies will have to be downloaded and installed. But once installation has completed, reboot the computer.

Sudo apt-get install Mesa
Sudo apt-get install vulkan
Sudo apt-get install clang
Sudo apt-get install llvm
Cat ~/.vnc/xstartup

Uncomment any other lines that starts a de and add entry for kde dbus-launch startplasma-x11 # or startplasma-wayland

Use that what suit to your configuration depending on what graphics you have in you hardware most have radeon derrivates like adreno or mali tegra is nvidia those compositor have difficulties in wayland x11 should be fine using direct sdl or vnc wich is faster in mobile

Don't mind to ask if you have a big cloud drive y could give you the entire setup 😉 just copy and replace mine is quite big cause it is a full nethunter

@Adyextreme01
Copy link

Yeah it is a known issue with Firefox is broken in kali install chromium or even ms edge works great
https://www.kali.org/tools/chromium/

@iAmMrGrim
Copy link

Awesome. Hopefully I can now restore my pc. Ty

@iAmMrGrim
Copy link

One of the commands had to be altered. from a fresh factory rest. Either wget or apt was not recognized. my memory sucks.. I switched out with a command that was recognized and it ended as advertised

Copy link

ghost commented Jan 8, 2023

https://f-droid.org/en/packages/com.termux/
download link of termux latest version

Copy link

ghost commented Jan 8, 2023

10 gb

@cosross
Copy link

cosross commented Jan 29, 2023

first thank you, appreciated. I reinstalled it works on unrooted galaxy s21+ but first try i couldn't reopen it and getting same error :
root@localhost:~# vncserver -kill :1 rm -f ~/.vnc/xstartup echo -e '#!/bin/bash\nxrdb $HOME/.Xresources\nstartxfce4 &' > ~/.vnc/xstartup sudo chmod +x ~/.vnc/xstartup vncserver vncserver: The USER environment variable is not set. bash: sudo: command not found vncserver: The USER environment variable is not set.
Also got this output:
xauth: file /root/.Xauthority does not exist
Hopefully easy fix I'm still new to Kali

@Suban2810
Copy link

(bash: ./start-kali.sh: No such file or directory
root@localhost:~#)
I'm getting this when I finish the first script

@rtw1z4rd
Copy link

there has been a lot of issues with running kali linux and nethunter in termux one issue is with kex vnc not working so u have to do a work around with tigervnc second issue has been with postgresql errors when installing kali or nethunter . I noticed a post about proot-distro as of present kali isn't one listed but u can install debian and configure it to install from kali linux repository and install kali tools but I've been testing archlinux and blackarch and they have an extensive list of pentesting tools

@rupeshpariyar
Copy link

Vnc application is not supported in my device redmi 8a dual what should I do please recommend me

@iAmMrGrim
Copy link

Vnc application is not supported in my device redmi 8a dual what should I do please recommend me

termux-setup-storage

pkg install root-repo -y

pkg install x11-repo -y

pkg install tsu -y && hash -r

pkg up -ypkg install wget openssl-tool proot -y && hash -r && wget https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Scripts/Installer/Kali/kali.sh && bash kali.sh

./start-kali.sh

wget https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Scripts/DesktopEnvironment/Apt/Xfce4/de-apt-xfce4.sh --no-check-certificate && bash de-apt-xfce4.sh

https://play.google.com/store/apps/details?id=com.iiordanov.freebVNC

127.0.0.1
5901
password you made

Start

@valerie14th
Copy link

i had a problem when i try to make the server in this Termux, when i type vncstart-start, and then the kali linux says:

root@localhost:~# vncserver-start
/usr/local/bin/vncserver-start: line 4: vncserver: command not found

can you help me what happen here? pls :)

@asaph56
Copy link

asaph56 commented Apr 29, 2023

Mais comment avoir les commande

@Martines700
Copy link

How to uninstall

You simply run " apt uninstall (pkg name you want to uninstall) "

@kelexine
Copy link

i had a problem when i try to make the server in this Termux, when i type vncstart-start, and then the kali linux says:

root@localhost:~# vncserver-start
/usr/local/bin/vncserver-start: line 4: vncserver: command not found

can you help me what happen here? pls :)

Install tightvncserver

@si0915
Copy link

si0915 commented Aug 6, 2023

I installed it on unrooted Realme X2 but i couldn't open it and getting error :
root@localhost:~# vncserver -kill :1 rm -f ~/.vnc/xstartup echo -e '#!/bin/bash\nxrdb $HOME/.Xresources\nstartxfce4 &' > ~/.vnc/xstartup sudo chmod +x ~/.vnc/xstartup vncserver vncserver: The USER environment variable is not set. bash: sudo: command not found vncserver: The USER environment variable is not set.
Pls help
Also got this output:
xauth: file /root/.Xauthority does not exist

@kelexine
Copy link

kelexine commented Aug 6, 2023

I installed it on unrooted Realme X2 but i couldn't open it and getting error : root@localhost:~# vncserver -kill :1 rm -f ~/.vnc/xstartup echo -e '#!/bin/bash\nxrdb $HOME/.Xresources\nstartxfce4 &' > ~/.vnc/xstartup sudo chmod +x ~/.vnc/xstartup vncserver vncserver: The USER environment variable is not set. bash: sudo: command not found vncserver: The USER environment variable is not set. Pls help Also got this output: xauth: file /root/.Xauthority does not exist

Did you install a vnc client

@Prevail01
Copy link

The installation stop when executing the first code

Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.

Pls help me with this 🙏🙏

@m3ti9
Copy link

m3ti9 commented Sep 9, 2023

please help me i installed kali succefull but when i write : vncserver i see this error : vncserver: The USER environment variable is not set.

@Satsugingg
Copy link

Failed to execute dbus-launch no such file or directory

@DurwardRath
Copy link

Thanks for sharing it, I will try it and if I face any issue, I will update you.

@walterego14
Copy link

walterego14 commented Sep 23, 2023

HELP ME
good morning thanks for the tutorial. the installation was successful, but when I reopen by typing (vncviewer) I get this:
~ $ vncviewer
CANNOT LINK EXECUTABLE "vncviewer": library "libexpat.so.1" not found: needed for /data/data/com.termux/files/usr/lib/libfontconfig.so in namespace (default)
~ $

quindi Kali Linux non si aprirà

@Bakare-Ayomide
Copy link

Hey, thanks so much it's working for me fine but the ish is I can't find all the pentesting tools like metaspoit SET and so on how doi I get them al

@Bindj300
Copy link

How to login in on vncserve

@Bindj300
Copy link

After logout

@Abimahendra
Copy link

Screenshot_20231028-232043
Cannot enter password and verification

@matthijsknigge
Copy link

Vnc application is not supported in my device redmi 8a dual what should I do please recommend me

termux-setup-storage

pkg install root-repo -y

pkg install x11-repo -y

pkg install tsu -y && hash -r

pkg up -ypkg install wget openssl-tool proot -y && hash -r && wget https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Scripts/Installer/Kali/kali.sh && bash kali.sh

./start-kali.sh

wget https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Scripts/DesktopEnvironment/Apt/Xfce4/de-apt-xfce4.sh --no-check-certificate && bash de-apt-xfce4.sh

https://play.google.com/store/apps/details?id=com.iiordanov.freebVNC

127.0.0.1 5901 password you made

Start

pkg up -ypkg install wget openssl-tool proot -y && hash -r && wget https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Scripts/Installer/Kali/kali.sh && bash kali.sh

Just mentioning people not getting confused it's not working, space missing between -y pkg install..

Not trying to be an as**. Thanks for your input. Helped me

@matthijsknigge
Copy link

Explanation of the command, hope it's helpful for people understanding what iAmMrGrim's command means

pkg up -y will update the package list, pkg install wget openssl-tool proot -y will install the specified packages, hash -r will reset the shell's cache of known command locations, the wget command will download the Kali Linux installation script, and bash kali.sh will execute the downloaded script to install Kali Linux.

@Unstopable1069
Copy link

Screenshot_2023-12-07-18-17-29-688_com realvnc viewer android
Thanks brother....good work. This so important for me. Gbu

@MaMo7x
Copy link

MaMo7x commented Dec 28, 2023

I installed it on unrooted Realme X2 but i couldn't open it and getting error : root@localhost:~# vncserver -kill :1 rm -f ~/.vnc/xstartup echo -e '#!/bin/bash\nxrdb $HOME/.Xresources\nstartxfce4 &' > ~/.vnc/xstartup sudo chmod +x ~/.vnc/xstartup vncserver vncserver: The USER environment variable is not set. bash: sudo: command not found vncserver: The USER environment variable is not set. Pls help Also got this output: xauth: file /root/.Xauthority does not exist

Use command vncserver-start instead, fixed for me!

Copy link

ghost commented Feb 27, 2024

(bash: ./start-kali.sh: No such file or directory root@localhost:~#) I'm getting this when I finish the first script

Copy link

ghost commented Feb 27, 2024

How can i add the USER environment variable?
Screenshot_2024-02-27-12-26-26-85_84d3000e3f4017145260f7618db1d683

Copy link

ghost commented Feb 27, 2024

(bash: ./start-kali.sh: No such file or directory root@localhost:~#) I'm getting this when I finish the first script

Actually now you are in the kali linux environment but to remove the "No such directory or file" then end your termux session start again and try the ./start-kali.sh again

@KRams26
Copy link

KRams26 commented Mar 11, 2024

1000079485
Hello sir. This is the screen that appears on my vnc server. How can I solve this problem?

Copy link

ghost commented Mar 11, 2024

1000079485 Hello sir. This is the screen that appears on my vnc server. How can I solve this problem?

Same happened to me. I don't have any idea

@Modasiyajaydip
Copy link

Not working bro please provide a video guide

@marsjupit
Copy link

hello brother the vnc viewer is working but how connect with browser in it ,that it failing to connect with browser

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