WSL v2 for Windows 10 an awesome technology
by 0x41 - January 15, 2020 at 09:29 PM
#1
Hi guys!

I'm testing the new WSL v2 (Windows Subsystem for Linux), and i want to share my experience with the community, cause this is awesome.

WARNING: Create a new VM to try this, Windows beta versions are unstable, and not ready for production.

Some tech background:

The first release of WSL allows you to run any compiled binary for Linux directly on Windows, through a subsystem that is responsible for translating Linux system calls to an equivalent Windows call. Two major limitations of WSL v1 are its performance involving disk operations, its compatibility with some specific system calls, and raw sockets support.

Given these issues, the Microsoft development team announced WLS 2 in November 2019, with a focus on improving disk performance and providing full compatibility with system calls on Linux, no longer translating these calls, but providing a Linux kernel within Windows!

How WSL 2 Works:

WSL 2 uses a completely different architecture than WSL 1. Instead of translating system calls, it directly uses an updated Linux kernel through a virtual machine. But we are not dealing with any virtual machine!

WSL 2 uses the latest virtualization technologies provided by Hyper-V to provide a lightweight, fast, and tightly integrated Windows virtual machine. With this it is possible to use all the advantages that WSL 1 brought, but now with full system compatibility, even to run Docker.

Thanks to the use of this virtual machine, performance with disk operations has increased dramatically. Previously, your files were stored directly on the system disk, now all files used by WSL 2 are inside a VHD format virtual disk, delivering up to 5 times more performance on operations like npm install on this new architecture.

Now the cool part:

Installation:

The WSL 2 installation process is very close to WSL 1. It is currently available on the Insider version of Windows 10, so you need to join the insider program (You can do that in windows settings, you just need to sign-up with your Microsoft account). It is scheduled to be released for the 2003 release of Windows 10 due to be released around April 2020.

To use WSL 2, we need to enable the Windows Subsystem for Linux feature and also Virtual Machine Platform. This can be done by running the following commands from a PowerShell window with Administrator permission:

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

If you already have a Linux distribution installed from the Microsoft Store, you can migrate that distribution to run within WSL 2 so you can use all of its enhancements. For example, if you have Ubuntu 18.04 installed, run the command below:

> wsl --set-version Ubuntu-18.04 2

Where Ubuntu-18.04 is your distribution (Can be Debian, Kali or even fedora).

To find out which distributions are installed, run the command:

> wsl --list --verbose

This will show you which distributions are installed, along with the version of WSL in use.

If you are using a clean installation of Windows, you can set the default version of WSL to its second version:

> wsl --set-default-version 2

The rest of the process is similar to WSL v1. You go to the Microsoft Store and choose the distribution you want.

Now is time to test some network tools. I chose nmap for being one of my favorite network tools and because it uses raw sockets, which were not available in the first version, and bang! It runs!

I'm now testing another common network tools, and improve some files and permissions in order to run more complex tools. I will update this thread when i made more advanced tests.

I hope this post can help those who wish to try this new version of WSL. Feel free to comment this thread and share your experience with this awesome technology!
Reply
#2
Yeah, with this addon i can do shit, that i comonly do with virtual machines
Reply
#3
(January 25, 2020 at 08:06 PM)nahe Wrote: Yeah, with this addon i can do shit, that i comonly do with virtual machines

Yeah, that's the point. The only problem by now with this insider preview are the network interfaces.
WSL v2 uses an hyper-v NAT-ed interface, so attacks like MITM can't be done.

Microsoft is planing to fix this adding a bridged interface in place of the NAT-ed one, so in a future we will have a more integrated system allowing us to connect to the same network that's Windows is connected (Like in WSL v1).

By now you can use port forward to redirect traffic from Windows to your Linux subsystem using the "netsh" command.

As example, if you need to connect back to your Metasploit listener, or any other network service you can use the following sentence:

> netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=4444 connectaddress=localhost connectport=4445

You can find more information about this issue on the Microsoft Github Repo.

https://github.com/microsoft/WSL/issues/4150
Reply
#4
Is it any good ? Am i going to file asleep when compiling ?
Reply
#5
Best thing ever. It's sooo fast. And I don't have to use horrible Linux Desktop
Reply
#6
(February 16, 2020 at 02:53 PM)dasdfsdfddf Wrote: Best thing ever. It's sooo fast. And I don't have to use horrible Linux Desktop

Well.in my case is faster than my Debian VM running on VMwre.
Reply
#7
Well, Myself i never tried it! seems like I am giving it a try Now! Thanks lan for the writing.
This forum account is currently banned. Ban Length: Permanent (N/A).
Ban Reason: https://raidforums.com/misc.php?action=help&hid=8 Rule 15
Reply
#8
(August 20, 2020 at 11:58 PM)inbo16 Wrote: Well, Myself i never tried it! seems like I am giving it a try Now! Thanks lan for the writing.

Give it a try, few things are changed by Microsoft from the date of the original post. In my vision they need to change a VERY important thing: Allow the hyper-v interface to connect directly to the network (Bridged). As solution by now is to use port-forwards.

If you need any help please let me know.
Reply
#9
(August 21, 2020 at 04:30 PM)0x41 Wrote:
(August 20, 2020 at 11:58 PM)inbo16 Wrote: Well, Myself i never tried it! seems like I am giving it a try Now! Thanks lan for the writing.

Give it a try, few things are changed by Microsoft from the date of the original post. In my vision they need to change a VERY important thing: Allow the hyper-v interface to connect directly to the network (Bridged). As solution by now is to use port-forwards.

If you need any help please let me know.

I appreciate it! Thank you very much!
This forum account is currently banned. Ban Length: Permanent (N/A).
Ban Reason: https://raidforums.com/misc.php?action=help&hid=8 Rule 15
Reply

 Users browsing this thread: 1 Guest(s)