Straight to it: Windows 10, WSL 2 and Kali.

To me: Best of both worlds, but I do realize it is a subject of preference and passion. But, instead of getting into that bit - let's have a look at what that combination gives you!

WSL - or Windows Subsystem for Linux - started out as, in my opinion, a wonderful addition to the developer platform. It added the remaining tools you might be missing when running Windows.

Because, lets face it: When it comes to command line tooling Linux is the king.

Yes, you do have Python on Windows and likewise, but they are not as effortlessly available as they are in a Linux environment. Many battletested tools are at your fingertips when running Linux, while they require a potentially troublesome manual installation adventure on Windows.

Ok, so we have Linux on Windows 10 - sort of. It's kind of amputated; it's emulated, but runs most tools. But it doesn't give you full access over things like network interfaces - so, running nmap will be a problem.

You can install Kali through Windows Store! Who would have thought it just a couple of years ago?

Anyway, lets skip over WSL 1 as the level-up comes at you fast with WSL 2.

With WSL 2, you are running an actual Linux VM in the background. It runs on Windows 10 Home, even. As an example, Docker for Windows worked by using a "hidden" VM running on Hyper-V, but WSL 2 uses Microsoft's Virtual Machine Platform and runs a really lightweight VM that starts up in 2 seconds.

So, this gives you a proper Kali (or any other Linux distro) installation - kind of: Systemd doesn't really work, but you can run all the services if you start them manually. Or automatically with a script, naturally.

At the time of writing this, WSL 2 is only available on the Windows 10 Insider slow ring, but release is around the corner. I use it on my Surface Pro 7 and have no issues.

And now we arrive at the point of this post: Hack on the go!

By that I mean: Use your ultramobile laptop (In my case the Surface Pro 7), but still be able to run a full blown penetration test. I get native Windows tools when testing Windows targets, but also a proper Linux environment for all those tasty tools that work for non-Windows targets as well as Windows.

Let's add a raspberry on top: By installing tools like https://sourceforge.net/projects/vcxsrv/ you can also run GUI tools from WSL!
(remember to set export DISPLAY=<ip of Windows host>:0)

When installing Kali through the Windows Store, it is a barebone install - there are no tools installed. Go to https://tools.kali.org/kali-metapackages to find the packages you need and install them.

And, because this is an actual VM (very hidden away), you can run network tools and everything!

Hot tip: One thing I noticed, is that the lightweight VM uses dynamic memory and suddenly all of my memory "disappeared". To have more control over this, create a file named .wslconfig under c:\Users\<you>\ and set a memory limit like so:

[wsl2]
memory=6GB
swap=0
localhostForwarding=true

localhostForwarding=true makes sure that any services you run in WSL 2 are available to the Windows host through localhost which is very handy.

And this is the beauty of it - you don't have to deal with VM creation or network configurations. You install Kali (or any other Linux distro) from Windows Store and everything just works. By adding VcXsrv you also get Linux GUI apps.

There will be some limitations, of course. Some direct hardware interactions will be off-limits, but as a on-the-go solution this works really well :)

Controlling mount point, /etc/hosts etc

By default, WSL will autogenerate /etc/hosts for you based on the Windows equivalent (found in c:\windows\system32\drivers\etc\hosts).

If you want to disable this, create /etc/wsl.conf and add the following:

[network]
generateHosts = false

The default mount point for your host drive will be /mnt/c which can cause troubles if you use Docker for Windows (without WSL2 integration) and you want to mount volumes. Docker really likes /c for that - so, you can control where that drive is mounted by adding a few more lines to the previously mentioned /etc/wsl.conf:

[automount]
enabled = true
root = /                          # set this to the path you like
options = "metadata,umask=22"

Special tip to those who run HackTheBox  (or any VPN) through WSL

As you might be running OpenVPN through WSL (which you can with WSL 2), the VPN network is only availabe within WSL and not the Windows host.

If you want to make sure the box you are hacking is available to the Windows host, do something like

socat TCP4-LISTEN:4444,reuseaddr,fork TCP4:host.foo.com:80 which will give you access to the box using http://localhost:4444