Skip to content

Instantly share code, notes, and snippets.

@mbrownnycnyc
Last active June 14, 2022 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbrownnycnyc/c8142a58a1629142db3544cee974fd8c to your computer and use it in GitHub Desktop.
Save mbrownnycnyc/c8142a58a1629142db3544cee974fd8c to your computer and use it in GitHub Desktop.
a working Kali in WSL. Why? Kali in vmware player took three times as long to complete a `-p- -A -sC` nmap scan of vulnversity on tryhackme. I'm hoping this WSL 2 is faster. If it isn't, then I will try WSL 1, and if that fails, then I will just build a box on Digital Ocean.
  1. run in powershell as admin:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
wsl --set-default-version 1
  1. search the windows store for kali and install, or:
Invoke-WebRequest -Uri https://aka.ms/wsl-kali-linux-new -OutFile Kali.appx -UseBasicParsing
Add-AppxPackage .\Kali.appx
  1. run kali, set the user and exit.
  2. Verify that kali is installed on WSL 1:
kali #go through initial installation
wsl -l -v
  1. download WSL 2 latest kernel and install: https://docs.microsoft.com/en-us/windows/wsl/wsl2-kernel
  2. Install virtual machine platform, which allows WSL 2 virtual machines:
#if required, you must enable virtualization support in your machine's BIOS (you can access the UEFI BIOS on Windows 10 easily by running `shutdown -r -o`)
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -all
bcdedit /set hypervisorlaunchtype auto
reboot -r -o -f -t 0
#go into the UEFI BIOS.  This will force a /full/ reboot and is required after changing the hypervisorlaunchtype.
  1. migrate the kali WSL distro from WSL 1 to WSL 2:
wsl --set-version kali-linux 2
wsl -l -v
  1. update kali:

sudo apt full-upgrade -y
sudo apt update
sudo apt full-upgrade -y
[ -f /var/run/reboot-required ] && sudo reboot -f
  1. install a desktop environment:
sudo apt install -y kali-win-kex
sudo apt install -y kali-defaults kali-root-login kali-linux-default
# continue through and pick reasonable answers (probably defaults)
#run win-kex in full mode (suggest that you use virtual desktops, so you can easily switch between a Windows 10 desktop and kali)
kex --win -s
#run win-kex in seamless mode, with the xfce task pane
kex --sl --s

quick ref

Exiting the process (in this case kali) will not kill the distribution.

  • list running distros
wsl --list --running
  • terminate kali
wsl -t kali-linux
  • set a distribution as the default wsl
wsl -s kali-linux
  • if there are problems, cycle through this to clean up processes
kex --win -s --wtstart
# hit ctrl-c to kill the process
# then type N
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment