Category Archives: Howto Tutorials (EN)

Knowledge Network for Tutorials, Howto’s, Workaround, DevOps Code for Professionals.

How to install Kali Linux on Windows

Install Kali Linux Desktop on Windows with WSL2

Linux in Windows 10 and 11 with Kali Linux Desktop – Win-KeX (“Windows Kali Desktop EXperience”), starting with feature update 2004 there is an XFCE GUI on the Windows desktop.

Win-KeX provides a Kali Desktop Experience for Windows Subsystem for Linux (WSL 2) with the features that support two dedicated modes.

Win-KeX window mode kex –win is the classic appearance in a window for the Kali Linux desktop.

Win-KeX SL mode kex –sl provides the seamless integration of Kali Linux into the Windows desktop with the Windows Start menu below and the Kali panel at the top of the screen. All applications start in their own windows that use the same desktop as Windows applications.

Win-KeX Features

Win-KeX SL Seamless
Sound support
Support multiple sessions
Run Win-KeX as root
Shared clipboard cut and paste content between Kali and Windows Apps

Install Kali Linux on Windows

To install Kali Linux on Windows, Open PowerShell as administrator and run the command bellow.

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Restart the computer now.

Back after reboot run the commands from PowerShell as administrator.

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft Windows subsystem Linux /all /norestart

Restart the computer again.

Then download Windows Subsystem for Linux 2 (WSL 2) and run the Update Setup Wizard. Download the latest package here and choose WSL2 Linux kernel update package for x64 machine.

Run the next command from the PowerShell as administrator.

wsl --set-default-version 2
Get Kali Linux from Store

Install Kali Linux from the Microsoft Store.

Kali Linux is a Debian-based Linux distribution that mainly includes penetration testing and digital forensics. Kali Linux is primarily aimed at professional and advanced users.

Now complete the initial setup and start Kali Linux.

Now complete the initial setup and launch Kali Linux.

Debian for WSL

Debian is also available from Microsoft Store.

Debian for Windows Subsystem for Linux

Install Win-KeX

Win-KeX from the terminal as follows.

sudo apt update && sudo apt install -y kali-win-kex

Start Win-KeX

Win-KeX can be run in window mode or Seamless mode. Win-KeX in window mode as follows.

kex --win

Start Win-KeX in Seamless – Sameless mode.

kex --sl

Win-KeX Start Examples

kex - Desktop full screen
kex --win - Desktop Window
kex --sl - Desktop Seamless Mode
kex --sl -s - Desktop Seamless Mode with Sound
kex --sl --wtstart - KeX server and win-kex client in terminal
kex --esm - KeX desktop in native RDP windows

Prerequisite for Win-KeX

The Visual C++ Redistributable packages are required to run Win-KeX, if not already installed, the packages can be downloaded here. Install the Universal C Runtime x86 (vc_redist.x86.exe) and x64 (vc_redist.x64.exe). Kali Linux requires Windows 10 version 2004 or later, and the Windows subsystem for Linux – WSL 2.

To use Win-KeX, a computer with Intel virtualization function VT-x is required. The BIOS provides the operating system with the virtualization function, for which you activate the Intel (R) Virtualization Technology in the UEFI BIOS settings.

Linux Shell in Windows Terminal

Also now is a good time to mention the Windows Terminal, if not already installed, it is worth doing it now.

Windows Terminal can be installed from the Windows Store.

Windows Terminal is a multi-tabbed command-line frontend for Windows 10. The shell of Kali Linux – ZSH can be used with Windows Terminal.

Kali Linux Sources Link kali.org

Troubleshooting

If VcXsrv is trying to start Win-KeX in Seamless Mode, an error is issued by VcXsrv:

A fatal error has occurred and VcXsrv will now exit.

VcXsrv A fatal error
A fatal error has occurred and VcXsrv will now exit.

In the log, it’s the last lines in /tmp/win kexsl_user.log:

winMultiWindowXMsgProc - Fatal error 1 on xcb connection
winClipboardIOErrorHandler!
winClipboardProc - setjmp returned for IO Error Handler.
(II) Server terminated successfully (0). Closing log file.

here you can try to start Win-KeX with sudo:

sudo kex --sl --wtstart -s

A solution also brought the deletion of the logs under /tmp.

sudo rm -f /tmp/*.log

And stop the KeX server with the –stop and –kill option.

sudo kex --stop
sudo kex --kill

After that, the start of kex as a normal user became possible.

kex --sl --wtstart -s

Also, a Win-KeX reinstallation can fix the error:

sudo kex --stop
sudo kex --kill
sudo apt-get purge kali-win-kex
sudo apt-get install kali-win-kex
sudo apt-get install dbus-x11

The Win-KeX help can also be useful.

kex --help

        Win-Kex 2.10 provides a GUI desktop experience for Kali Linux
        in Windows Subsystem for Linux 2 (WSL 2)

        Usage:
                kex <mode> <command> <parameters>

                Mode:
                --esm            : Launch KeX desktop in a dedicated window using Windows native RDP
                --sl             : Seemlessly integrate KeX into the Windows desktop
                --win            : Launch KeX desktop in a dedicated window

                Command:
                [none]           : start KeX server and launch KeX client
                --start          : start kex server
                --start-client   : start kex client
                --stop           : stop kex server
                --status         : show kex server status
                --kill           : stop kex server and kill all related processes
                --passwd         : set kex server password
                --wtstart        : start kex server and launch win-kex client
                                   in Windows Terminal session
                --start-sound    : start Windows sound server
                --stop-sound     : stop Windows sound server
                --help           : display help
                --version        : display version

                Parameters:
                -i               : Use container IP address instead of "localhost"
                -m               : Optimized for Multiscreen (Win mode only)
                -s               : Sound support


        Examples:
                kex -s           : Start KeX server in window mode and launch KeX client with sound support
                kex --sl -s      : Start KeX in seemless mode and launch KeX client with sound support
                kex --esm -i -s  : Start KeX in ESM mode with arm workaround and launch KeX client with sound support
                sudo kex         : Start KeX server as root in window mode and launch KeX client

No Network drives after Windows Update

Network issues after update, no access to network drives after Winodws update.

Windows 10 clients no longer display network drives correctly in Windows Explorer. Access to NAS and servers with SMBv1 shares are no longer possible. This after feature update for Windows 10 version 2004 is installed.

Access to NAS and server interrupted after Update Build 19041.508 (2004)

Symptom

Network drives to Windows shares are no longer accessible after the feature update May 2020 was downloaded. With the Windows Update 2004 Build 19041.508. Access is no longer possible for standard users to share who use the SMB 1.0/CIFS network protocol.

Cause

Microsoft has changed the behavior for the SMB version 1 network protocol with the Windows 10 feature update 2004. The SMBv1 network protocol is no longer considered secure. Microsoft’s recommendation is to stop using the outdated SMB 1.0/CIFS protocol. See also – Windows 10: Unable to access SMBv1 share

Solution

The Registry Key ProviderFlags controls the recovery of network shares they use Server Message Block (SMB) version 1 when they are stored in the registry. The registry DWORD Key ProviderFlags can be add in the registry key [HKEY_CURRENT_USER\Network\] with regedit, or run the next line in a opened command prompt:

REG ADD "HKCU\Network\i" /v "ProviderFlags" /t REG_DWORD /d "1" /f
No network drives after Windows update. regedit providerflags
Illustration: Registry Key ProviderFlags

The network drive (i) is mapped to the share info on SERVER01, which uses the SMBv1 network protocol. The Key ProviderFlags is required if network drives are used that use devices with SMBv1; all network drives in the HKCU\Network branch must then be registered with the REG_DWORD ProviderFlags. The change requires a restart.

Solution: net use persistent:no

Another solution is using the /persistent:no parameter, where the network drive mapping is executed from login scripts. As by batch files on the logon server, or on a network without ADS, through a local logon script on the client. The windows network drives are created in the logon script using net use /persistent:no.

@echo off
net time \\SERVER01 /set /y
net use * /delete /y
net use i: \\SERVER01\info /persistent:no
net use j: \\SERVER01\data /persistent:no

This example deletes all network drives before they are mapped. But does not permanently store the network drives in the registry. So there is no further interruption that exists with the 2004 feature update for network drives that use network shares with use the SMBv1 network protocol.

Shutdown while press Shift Key

The computer may have to be shut down completely in order to trigger a cold start without a quick start. So that the windows update for the network drives are initialized. Press the Shift key when switching off the computer. At the same time when you click on Shutdown, a cold start takes place the next time you power on.