Kali linux после windows

Kali linux после windows

Windows Subsystem for Linux (WSL) has two different versions, “WSL 1” and “WSL 2”. WSL 2 is the preferred and default option when installing WSL. This is because WSL 2 uses the actual Linux kernel inside a Hyper-V virtual machine (managed by WSL). WSL 1 uses a “translation layer” which is similar to WINE.

We recommend using Windows 11 as it is simpler, however if you are using Window 10 it is still possible but requires additional steps in places. To make Windows 10 easier, having the machine as up-to-date as possible will help — as of the time of writing this, November 2022 patches.

If installing in a Virtual Machine, make sure to allow for “nested VM” (nested virtualization allows for a “VM in a VM”).

Quick Method

Our recommended method to get Kali running on WSL 2:

  1. Restart when prompt
  2. Download and install the WSL 2 Linux Kernel from here: aka.ms/wsl2kernel
  3. Restart
  4. Open a command prompt and run:
  1. 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
  2. Run kali to finish the initial setup of creating a new user

Windows Version

Windows 11 users have an easier time and can go straight to installing WSL, however if you are using Windows 10 you will need to check your OS build/version. The minimum requirements for WSL is different and needs either to match or be higher than:

  • WSL 1: Build: 16215 , Version: 1703 (June 2017)
  • WSL 2 (x64): Build: 18362.1049 , Version: 1903 (Codename: 19H1 — May 2019)
    • Recommended — Build: 19041 , Version: 2004 (Codename: 20H1 — May 2020)

    The reason why Windows 10 20H1 is recommended, is due to the WSL helper-script already pre-installed, allowing for quick command line installation. By having an updated Windows 10 version, the WSL helper-script will also pull in updates from the Microsoft store. The reason why Windows 11 is preferred over Windows 10, is due to internal hardcoded URLs which have not yet been back ported which hopefully will be addressed soon.

    Check Version

    We can check our build version by pressing WIN+R and then typing in winver . We will be shown a pop-up like this:

    Windows 10 Version

    What we are looking for is the number after OS Build. Our build is 18363 (with a minor build: 418 ). This means we can use either WSL 1 or WSL 2 (but will require some manual steps)!

    Install WSL 1

    There is a hard requirement to enable WSL via Window’s “Optional Features”. However, you can optionally update WSL by using the Microsoft Store: Windows Subsystem for Linux, to expand its functionality and bug fixes.

    There are a few ways to install WSL (WSL 1 or WSL 2):

    • WSL helper-script (Simplest)
      • Requires Windows 10 20H1 (Build: 19041 , Version: 2004 ) or higher
      • Will also install WSL 2
      • November 2022 patches gives a better experience

      Depending on your Windows version and patches, will have an affect on your installation experience.

      WSL helper-script

      This is the easiest way to install, but you do have to have Windows 10 20H1 (Build: 19041 , Version: 2004 ) or higher, otherwise when trying to follow, you will get: ‘wsl’ is not recognized as an internal or external command, operable program or batch file. .

      This WSL helper-script method will install WSL and Kali (unlike the other methods). It will cover both WSL 1 and WSL 2, which means it will enable Hyper-V VM & setup the WSL kernel. The down side is to it, if you are using Windows 10 before November 2022 patches, due to a known issue this method will install an out-dated version of Kali on WSL (Kali 2019.2). The November 2022 patches will make the helper-script also include pulling from the Microsoft store (both WSL and Kali).

      Inside a Administrator command prompt, run the following command which will setup WSL if it has not already and install Kali WSL:

      After rebooting the box, logging back in, a terminal window should hopefully open up if everything was successful:

      You can then setup a user and then you are in:

      [email protected]:~$ uname -a Linux DESKTOP-AJVAG8O 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 GNU/Linux [email protected]:~$ 

      NOTE: You will not see anything when typing the password.

      Due to a known issue with Windows 10 before November 2022 patches, this method may install an out-dated version of Kali on WSL (Kali 2019.2). It is recommended to then re-install Kali from the Microsoft Store. Later versions, including Windows 11 are unaffected.

      Dism

      Using an Administrator command prompt, run the following commands:

      As we will want WSL 2 later, we run the first command with VirtualMachinePlatform now. This is not required for WSL 1, and can be removed in the command.

       C:\Windows\system32>dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all Deployment Image Servicing and Management tool Version: 10.0.18362.1 Image Version: 10.0.18363.418 Enabling feature(s) [==========================100.0%==========================] The operation completed successfully. Restart Windows to complete this operation. Do you want to restart the computer now? (Y/N) 

      And then reboot when prompted!

      PowerShell

      At an Administrator PowerShell prompt, run the following command to install from optional features:

      As we will want WSL 2 later, we will also include VirtualMachinePlatform now. This is not required for WSL 1, and can be removed in the command.

       Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux,VirtualMachinePlatform Do you want to restart the computer to complete this operation now? [Y] Yes [N] No [?] Help (default is "Y"): 

      And then reboot when prompted!

      Manually Upgrade WSL 1 to WSL 2

      VM Platform:

      If we installed WSL either by PowerShell or Dism, we may have already installed the VirtualMachinePlatform feature (which is Hyper-V). Otherwise, you will need to run as administrator: dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

      WSL Linux Kernel:

      Next we still need is to manually install the WSL Linux kernel update. This can be downloaded from:

      After installing (with administrator privileges), reboot the machine.

      WSL Default Version:

      We can now set any WSL distributions which is installed after this point to be WSL 2 by running the following in a command prompt:

      wsl --install --distribution kali-linux [. ] 

      Now when we install Kali, it will be WSL 2.

      Upgrade WSL Distributions:

      However, if we have previously installed Kali WSL 1, we can upgrade it by doing:

       C:\Users\Win>wsl --set-version kali-linux 2 Conversion in progress, this may take a few minutes. For information on key differences with WSL 2 please visit https://aka.ms/wsl2 Conversion complete. C:\Users\Win> C:\Users\Win>wsl --list --verbose NAME STATE VERSION * kali-linux Stopped 2 C:\Users\Win> C:\Users\Win>kali [. ] 

      WSL in Microsoft Store

      You need to have enable Microsoft’s Windows Subsystem Linux optional features for this to work, as this is for updating WSL, rather than installing it. The Microsoft Store means, you are on the latest versions, as updates are issued outside of the Window’s update cycle (“Patch Tuesday”).

      It does require you to make sure your Windows up-to-date in order for this to work (with update patches applied not OS upgrades).

      Windows 10 years, if you have November 2022 patches applied, wsl —install becomes a shortcut to the Microsoft Store (both WSL and Kali).

      After having enabled the optional feature, go to the Microsoft Store, search for Windows Subsystem for Linux and click “Install”:

      Windows 10 WSL Store

      It is not a requirement to sign-in. You may also get UAC prompt during installation.

      After it has downloaded & installed, you will need to reboot.

      This will get your machine ready for WSL 1. For WSL 2, you still need the enable Hyper-V & WSL kernel.

      Install Kali WSL

      Once WSL 1 or WSL 2 has been setup, there are a few ways you can install Kali on WSL:

      NOTE: It is NOT recommend to try and overwrite install methods to switch. Please do wsl —unregister kali-linux first.

      Kali in Microsoft Store

      You can use either the graphical Microsoft Store, or you can pull directly down via PowerShell.

      Windows 10 years, if you have November 2022 patches applied, wsl —install becomes a shortcut to the Microsoft Store (both WSL and Kali).

      By going to the Microsoft Store: Kali Linux, click “Install”. After it has finished downloading, clicking “Launch” should finish installation of creating a new user:

      NOTE: You will not see anything when typing the password.

      Store + PowerShell

      The quick way of doing it is to run:

       Invoke-WebRequest -Uri https://aka.ms/wsl-kali-linux-new -OutFile .\kali-linux.AppxBundle -UseBasicParsing -TimeoutSec 1800 PS C:\Users\Win> PS C:\Users\Win> Add-AppxPackage .\kali-linux.AppxBundle 

      WSL helper-script (–install)

      Due to a known issue with Windows 10 before November 2022 patches, this method may install an out-dated version of Kali on WSL (Kali 2019.2). It is recommended to use “Microsoft Store. Later versions, including Windows 11 are unaffected.

      Using a command line prompt:

      C:\Users\Win>wsl --install --distribution kali-linux Downloading: Kali Linux Rolling Installing: Kali Linux Rolling Kali Linux Rolling has been installed. Launching Kali Linux Rolling. C:\Users\Win> 

      And like before, a terminal window should hopefully open up:

      Installing, this may take a few minutes. Please create a default UNIX user account. The username does not need to match your Windows username. For more information visit: https://aka.ms/wslusers Enter new UNIX username: kali New password: Retype new password: passwd: password updated successfully Installation successful! [email protected]:~$ uname -a Linux DESKTOP-AJVAG8O 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 GNU/Linux [email protected]:~$ [email protected]:~$ id uid=1000(kali) gid=1000(kali) groups=1000(kali),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev) [email protected]:~$ [email protected]:~$ grep VERSION= /etc/*release /etc/os-release:VERSION="2019.2" [email protected]:~$ 

      NOTE: You will not see anything when typing the password.

      Import rootfs

      We can use our WSL build-scripts to generate a rootfs which can be imported to WSL. As creating the rootfs is out of scope for this guide we will already assume it has been created.

      First thing is to copy over to the machine:

        C:\Users\Win\Downloads>wsl --list --verbose Windows Subsystem for Linux has no installed distributions. Distributions can be installed by visiting the Microsoft Store: https://aka.ms/wslstore C:\Users\Win\Downloads> 

      Next we import the rootfs, giving it a name of kali-wsl , storing data in ./wsl-test and importing from .\kali-linux-rolling-wsl-rootfs-amd64.tar.gz :

       C:\Users\Win\Downloads>dir [. ] 05/04/2023 21:13 . 05/04/2023 21:13 .. 05/04/2023 21:11 217,859,650 kali-linux-rolling-wsl-rootfs-amd64.tar.gz 05/04/2023 21:13 wsl-test 1 File(s) 217,859,650 bytes 3 Dir(s) 39,582,310,400 bytes free C:\Users\Win\Downloads> 

      The final stage now is to use it:

       C:\Users\Win\Downloads>wsl --distribution kali-wsl ┏━(Message from Kali developers) ┃ ┃ This is a minimal installation of Kali Linux, you likely ┃ want to install supplementary tools. Learn how: ┃ ⇒ https://www.kali.org/docs/troubleshooting/common-minimum-setup/ ┃ ┗━(Run: “touch ~/.hushlogin” to hide this message) ┌──(root㉿DESKTOP-AJVAG8O)-[/mnt/c/Users/Win/Downloads] └─# uname -a Linux DESKTOP-AJVAG8O 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 GNU/Linux ┌──(root㉿DESKTOP-AJVAG8O)-[/mnt/c/Users/Win/Downloads] └─# id uid=1000(kali) gid=1000(kali) groups=1000(kali),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),100(users) ┌──(root㉿DESKTOP-AJVAG8O)-[/mnt/c/Users/Win/Downloads] └─# 

      Import AppxBundle

      We can use our WSL build-scripts to generate a WSL app which can be imported to WSL. As creating the AppxBundle is out of scope for this guide we will already assume it has been created.

      Because it is self-signed certificate, run the Install.ps1 to setup the machine.

      Running Kali WSL

      After everything has been setup and installed, you can run Kali by doing either:

      • Command prompt: kali (Our shortcut)
      • Command prompt: wsl —distribution kali-linux
      • Command prompt: wsl (if the OS is set to default: wsl —setdefault kali-linux )
      • Start menu: Kali Linux
      • Windows Terminal (if installed)

      Troubleshooting

      If something does not go right, do not panic. Instead, find the answers to:

Оцените статью
Adblock
detector