What is WSL?
Windows Subsystem for Linux (WSL) is a feature of Windows that allows you to run a Linux environment on your Windows machine, without the need for a separate virtual machine or dual booting. WSL is designed to provide a seamless and productive experience for developers who want to use both Windows and Linux at the same time. (https://learn.microsoft.com/en-us/windows/wsl/about)
So basically WSL allows us to install a Linux terminal inside of Windows and interact with the file system — for example, we can run commands only available for Kali users, but on files that are present in the Windows’ file system, eliminating the need for setting up and transferring files/data between the Virtual Machine and a host system.
Installing WSL boils down to the following steps:
1) Open a administrator command prompt and run:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all
2) Restart when prompt
3) Download and install the WSL 2 Linux Kernel from here: aka.ms/wsl2kernel
4) Restart
5) Open a command prompt and run:
wsl — set-default-version 2
6) Install from the Microsoft Store: Kali Linux
NOTE: If there is an existing Kali WSL 1, upgrade it by running: wsl — set-version kali-linux 2
7) Run kali to finish the initial setup of creating a new user
(https://www.kali.org/docs/wsl/wsl-preparations/)
TROUBLESHOOTING:
Getting the WslRegisterDistribution failed with error 0x8007019e?
win + r
appwiz.cpl
Turn Windows features on or off,
Check: Windows Subsystem for Linux
Okay, now my new Kali is installed, what can I do with it?
First, we need to run:
sudo apt update
sudo apt full-upgrade -y
Next, we are still not going to have all the utilities that we’re used to, so browse to:
https://www.kali.org/docs/general-use/metapackages/
browse to this site, and select the metapackage that is of interest to you, I suggest kali-linux-default or kali-linux-large;
sudo apt install kali-linux-large -y
This will install pentesting tools, so that you can run nmap, sqlmap, nikto, hydra, hashcat, or any other program in your toolset, as well as create, and edit files, manipulate or organise the filesystem structure (using grep/sed/awk on files, etc.)
In my opinion, Kali WSL completes the Windows system, giving it linux utilities that just make your life easier.
Some further tips:
1) Easily create aliases for frequently used commands:
alias example=’your-desired-command -and -the -switches -it -uses’
append above to ~/.bashrc
after its done, remember to execute:
source ~/.bashrc
so that the new settings load
now try the new alias, for me, the go to is creating SSH tunnels with the use of one command
1a) update the /etc/hosts file, so that you can set up IP:hostname pairs
execute below, so /etc/hosts doesn’t get flushed every time:
sudo echo “[network]” >> /etc/hosts ; sudo echo “generateHosts = false” >> /etc/hosts
now, either open /etc/hosts with
sudo nano /etc/hosts
or, input your values with the echo command:
sudo echo “ip-value hostname” >> /etc/hosts
2) make an alias for accessing the Windows Desktop directory with the use of one command:
sudo echo “alias win-desktop=’cd /mnt/c/users/kpawlo/Desktop’” >> ~/.bashrc
source ~/.bashrc
try the new alias and see your cwd change to the Windows Desktop
For more complex operations invloving the GUI, please see this install guide from kali.org:
https://www.kali.org/docs/wsl/win-kex/
