Терминал kali linux на windows 10

Уже некоторое время в Windows 10 присутствует возможность установить различные дистрибутивы Linux с помощью компонента «Подсистема Windows для Linux» или WSL, однако лишь в виде терминала без графического интерфейса. Начиная с Windows 10 2004 WSL обновился до версии 2.0, благодаря чему появились новые возможности и, в рамках этих возможностей появилась Kali Linux для WSL2 с поддержкой графического интерфейса или Win-Kex.

В этой инструкции подробно об установке графического интерфейса Kali Linux в Windows 10 версии 2004 или новее, а также дополнительная информация, например, о том, как включить русский язык интерфейса в установленной системе.

Установка Kali Linux с графическим интерфейсом в Windows 10

Порядок установки Kali Linux с графическим интерфейсом (GUI) для подсистемы Windows для Linux будет состоять из следующих шагов (напоминаю: необходима версия Windows 10 2004 или новее):

  1. Включите компонент «Подсистема Windows для Linux». Сделать это можно в Панель управления — Программы и компоненты — Включение или отключение компонентов Windows. После установки перезагрузите компьютер.
    Установка подсистемы Windows для Linux

  2. Этот шаг можно пропустить, если у вас включены компоненты Hyper-V, иначе запустите Windows PowerShell от имени администратора (можно сделать через правый клик по кнопке «Пуск» и выполните команду
    dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
  3. Скачайте и установите обновление ядра Linux WSL2 со страницы https://docs.microsoft.com/ru-ru/windows/wsl/wsl2-kernel
  4. Перезагрузите компьютер, запустите PowerShell от имени администратора и выполните команду
    wsl --set-default-version 2
  5. Зайдите в магазин приложений Windows Store, используйте поиск чтобы найти и установить Kali Linux.
    Установка Kali Linux из Windows Store

  6. После завершения установки в PowerShell от имени администратора выполните команду:
    wsl --set-version kali-linux 2
  7. Запустите Kali Linux (пункт будет доступен в меню «Пуск»), выполните первоначальную настройку (имя пользователя и пароль), после чего по порядку выполните следующие команды (требуется подключение к Интернету, последний шаг может занять много времени.
    sudo apt update
    sudo apt dist-upgrade
    sudo apt install -y kali-win-kex
  8. В ходе выполнения последней команды вам будет предложено выбрать клавиатуру. Я оставил значения по умолчанию, но, возможно, стоило выбрать русскую, так как в дальнейшем при включении русского языка интерфейса в ряде случаев кириллица не отрисовывается (не знаю, есть ли связь, лишь предположение).
  9. По завершении установки введите команду kex для запуска Kali Linux с графическим интерфейсом. При первом запуске вам будет предложено создать отдельный пароль, можно от этого отказаться.
Kali Linux с графическим интерфейсом в Windows 10

В результате запустится Kali Linux с графическим интерфейсом в полноэкранном режиме. Для выхода из полноэкранного режима можете вызвать меню клавишей F8 и отключить опцию «Full Screen».

Если вам потребуется включить русский язык интерфейса для Kali Linux, у меня сработал следующий метод:

  1. В графическом интерфейсе Kali Linux запускаем терминал, вводим команду
    sudo dpkg-reconfigure locales
  2. Выбираем ru_RU UTF-8 на двух экранах (отметку ставим пробелом, переключаемся на кнопку Ok клавишей Tab).
  3. Закрываем окно терминала и окно графического интерфейса, в терминале из которого мы запускали графический интерфейс вводим kex stop (если приглашение ввода не отображается, попробуйте изменить размер окна — у меня встретился такой баг).
  4. Снова запускаем kex — в результате интерфейс будет на русском языке.
    Kali Linux WSL2 на русском языке

А в целом, хотя я еще и не придумал, для чего мне это использовать (возможно, попробую запускать пакеты от bitnami для экспериментов с сайтами), но на первый взгляд всё работает исправно и быстро: быстрее, чем в виртуальной машине.

How to Install Kali Linux in Windows Subsystem for Linux (WSL)

Step 1: Enable WSL in Windows 10

To enable WSL in Windows 10, open PowerShell as an administrator and run the following command:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Step 2: Install WSL

To install WSL, open a new PowerShell window as an administrator and run the following command:

Step 3: Set WSL 2 as Default

To set WSL 2 as the default version of WSL, open PowerShell as an administrator and run the following command:

wsl --set-default-version 2

Step 4: Install Kali Linux

To install Kali Linux, run the following command in a PowerShell window:

wsl --install -d kali-linux

Step 5: Install Kali Linux Desktop Environment (Optional)

To install the Kali Linux desktop environment (XFCE), run the following command:

sudo apt install kali-win-kex -y

Or u can use, kali-tweaks to install as per ur requirement.

Step 6: Start Kali Linux Desktop Environment (Optional)

To start the Kali Linux desktop environment (XFCE), run the following command:

Step 7: Install Zsh Shell (Optional)

To install the Zsh shell, run the following command:

Step 8: Set Zsh as the Default Shell (Optional)

To set Zsh as the default shell, run the following command:

Step 8: If you have the space, why not install “Kali with the lot”? (Optional)

Here, run the following command:

sudo apt install -y kali-linux-large

That’s it! You should now have Kali Linux installed in WSL with optional GUI and Zsh shell support. Your computer has now become a lethal weapon! 💣🚀💥

Table of Contents

This article will explain how you can install Kali Linux directly inside your Windows 10 without having to run the Kali setup. This will save you a lot of time that is required to setup a Kali VM in Windows and you won’t have to go through fixing the errors which can encounter during Kali installation.

Install WSL2 in Windows 10

This article assumes you have already installed WSL2 in your Windows 10. The more information about WSL2 and its installation steps are covered in following article:

Windows Subsystem for Linux (WSL)

If you have not installed WSL2, please check this article first and then come back here to start setting up your Kali Linux environment.

Install Kali Linux

  1. To install Kali Linux (or any other GNU/Linux distribution), open Run dialog (Windows key + R), then type “ms-windows-store:” without quotes and hit enter. This will launch Microsoft Store app.
  2. Click on the search, type “Linux” and hit enter. You will see all the popular Linux apps.

ms-windows-store

    1. Select Kali Linux and click on Install (or Get) button. If it asks you to login with Microsoft account, just click on No, thanks. This will start downloading and installing the Kali Linux which could take a while.

download-kali

  1. To launch the Kali linux, click on start and type “Kali” to search.

launch-kali

Tip: The most recently installed app “Kali Linux” will probably be displayed on top of start menu.

  1. Click on “Kali Linux” and it will display a terminal window with a text “Installing, this may take a few minutes”. This will happen only for the first time.
    1. Once done, you will be asked to type a user name and then set a password. After typing password twice, you will be logged in to your Kali Linux environment. This is just a minimal installation of Kali linux. In the next step, we will convert the minimal installation to full including GUI and tools.

initialize-kali

    1. The good thing is that your Windows C: drive is automatically mounted to /mnt/c directory in Kali linux. So you can browse and seamlessly transfer the files across Windows and Kali. Take a look at the following image:

kali-terminal

  1. Now that we have a mimimal Kali install running in a terminal. We can run commands in terminal to convert it into full GUI. The sudo apt update && sudo apt install kali-desktop-xfce -y command will do that. But instead of installing XFCE desktop environment, we will install Kali Desktop Experience for Windows (aka Win-KeX).
  1. Now why would we install Win-KeX instead of XFCE which is default desktop environment for Kali Linux? Because “Win-KeX” offers a Kali Desktop Experience for WSL2 which is tightly integrated with Windows. It provides following features:
    • Window Mode: Starts a Kali Linux desktop in a dedicated window
    • Seamless Mode: Share the Windows desktop between Windows and Kali apps
    • Shared clipboard: Allows copy/paste between Windows and Kali Linux apps
    • Multi-session support: Supports Root and regular user sessions
    • Sound support

    Leave the terminal window open and proceed to the next step in order to install Win-KeX.

Amazon Music Disney Promo

Install Win-KeX in Kali Linux

  1. Type the following commands in terminal and hit enter. When prompted, enter the password you set in Step 5.
    sudo apt update -y && sudo apt install kali-win-kex -y

    It could take a while depending upon the speed of your computer and internet connection. Wait for installation to finish.

Run Win-KeX in Kali Linux

WSL2 allows you to run Win-KeX in three modes.

  • Window Mode: Window mode helps keeping the Windows and Kali environments visually apart. Kali linux will run in a dedicated window. To start Win-KeX in Window mode with sound support, type the following command in terminal and hit enter:
    win-kex --win -s
  • Enhanced Session Mode (ARM only): Enhanced Session Mode runs the Kali Linux desktop session in a separate window using protocols and clients native to Windows. This is supported on ARM devices only. To start Win-KeX in Enhanced Session Mode with sound support, type the following command and hit enter:
    win-kex --esm --ip -s
  • Seamless mode: Seamless Mode runs a Kali Linux panel on the screen top of the Windows desktop. It removes the visual segregation between linux and window apps which provides a great platform to run a penetration tests in Kali Linux and copy the results straight into a Windows app. To start Win-KeX in Seamless mode with sound support, type the following command and hit enter:
    win-kex --sl -s

Now you know How to run Kali Linux in WSL2 without having to install and maintain a VM in VirtualBox or Hyerp-V. But wait a minute; When you want to start Kali Linux, you will have to repeat following two steps every time:

  • Open cmd.exe (or PowerShell console) in Windows and then type wsl -d kali-linux command
  • And then type win-kex --sl -s command to run WinKex in seamless mode

If you don’t want to repeat these steps every time, proceed to the next step of this article.

Install Windows Terminal

  1. Open Run dialog (Windows key + R), then type “ms-windows-store:” without quotes and hit enter. This will launch Microsoft Store app.
  2. Click on the search, type “Windows Terminal” and hit enter.
    1. Click on Windows Terminal app from search results and click on Install (or Get) button. If it asks you to login with Microsoft account, just click on No, thanks. This will start downloading and installing the Windows Terminal app.

windows-terminal

  1. We will now create a shortcut in Windows Terminal which will help us start the Kali Linux automatically in just a single click.
    Now launch Windows Terminal app and press “Ctrl + ,” keys simultaneously to open terminal settings. It will open “settings.json” file in “Code Writer” app so don’t freak out.
    1. In settings.json file, look for the lines marked with Red box in image, copy the marked section and then paste it right below (as marked by the Green box)

adjust-terminal-settings

Look at the “commandline” argument’s value. This is the actual command which will run Kali Linux in seamless mode when you click on Windows Terminal shortcut. You can download the kali icon from here.

If you want to run Kali in Window mode, set the “commandline” value to wsl -d kali-linux kex --wtstart -s . You must slightly change the “guid” value marked with Blue underline otherwise you won’t see the new shortcut in Windows Terminal. You can also change other values if you like and then save the file.

    1. Now close the Windows Terminal and launch it again. Then click on the dropdown icon and choose the Kali Win-KeX option to launch it.

view-kali-shortcut.png

    1. This will launch Kali Win-KeX in seamless mode and you will see a new window running Kali desktop.

launch-kali-win-kex.png

That’s it. Now you’re running Kali Linux in Windows 10 in seamless mode where you can change through apps opened in Windows as well as Kali Linux by pressing “Alt + Tab ” or “ Windows logo + Tab ” keys.

If you want to close the Kali window, just close the Kali Win-KeX tab in Windows Terminal.

Tip: Closing the Kali Win-KeX tab in Windows Terminal doesn’t actually terminate the “kali-linux” WSL distribution. You can run wsl -l -v command in cmd.exe or PowerShell console and you will still see it Running.

To terminate the WSL instance, you need to run wsl -t kali-linux command manually as shown in image below.

terminate-kali-linux.png

Fixing Errors in Kali Linux

  1. If you see a message saying Started Win-KeX SL on Windows Terminal but don’t see any Window for Kali Linux, it is most likely that your Windows Firewall or Antivirus Firewall is blocking the application. You need to add the following application to trusted apps list in your Firewall.
    \\wsl$\kali-linux\usr\lib\win-kex\VcXsrv\vcxsrv.exe
  2. If you see an error like Failed to execute child process “dbus-launch” (No such file or directory). You need to connect to Kali linux by running “wsl -d kali-linux” command in cmd.exe (or PowerShell console) and then execute the following commands:
    sudo service xrdp stop
    sudo apt-get install dbus-x11
    sudo service xrdp start
    

The Windows Subsystem for Linux lets developers run a GNU/Linux environment including most command-line tools, etc. direct on Windows, unmodified, without the overhead of an ordinary virtual machine or dual-boot system.

Uses of WSL: 

  • Pick your preferred GNU/Linux distributions from the Microsoft Store.
  • Run basic command-line tools, for example, grep, sed, awk, or other ELF-64 doubles.
  • Run Bash shell and GNU/Linux command-line applications like tmux, emacs, SSHD, MySQL, and also could use the language compilers.
  • Summon Windows applications utilizing a Unix-like command-line shell.
  • Summon GNU/Linux applications on Windows.

WSL 2

WSL 2 is another form of the Windows Subsystem for Linux engineering that controls the Windows Subsystem for Linux to run ELF64 Linux binaries on Windows. Its essential objectives are to build file system execution, just as including full framework call compatibility. This new design changes how these Linux binaries associate with Windows and your PC’s equipment, yet at the same time gives a similar client experience as in WSL 1 (the current broadly accessible version).

Requirements For WSL 2:

  • WSL 2 is only accessible in Windows 10, Version 1903, Build 18362, or higher.
  • On the off chance that you are on Windows 10 form 1903 or 1909 ensure your minor build number is 1049 or higher.
  • Running Windows 10, refreshed to version 2004 or higher, version 19041, for ARM64 systems.
  • WSL 2 will work with VMWare 15.5.5+ and VirtualBox 6+.

Verifying the System Compatibility:

Step 1: Hold on the Windows logo key (on the keyboard) + R to open the run dialogue, and then type in the following command and select OK.

winver

Step 2: If your OS builds version is not compatible, then we have to update the Windows.

Step 3: For updating, Click on the Windows logo in the bottom left corner of your screen and then type in the following command and press enter:

check for updates

Step 4: Now, select the “Check for updates” option from the menu listed, and then a dialog box will appear.

Step 5: Click on the “Check for Updates” button on the screen, and after successful completion of the update, “restart” your machine. But, if you don’t get any information regarding the update then, after doing a restart/s you will be prompted an update.

Setting up WSL:

Step 1: Click on the Windows logo in the bottom left corner of your screen and then type in the following command:

powershell

Now, when the list appears in the menu, Right-Click on the “Windows Power Shell” option and chooses “Run as administrator”.

Step 2: Now, once the Power Shell is opened and ready to use, type the following command and hit enter:

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

Step 3: Restart your machine.

Step 4: After the restart, again run the “Windows PowerShell” in the administrator mode, and then type in the following command:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Step 5: Now, type in the next command:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Step 6: Now, again restart your machine.

Step 7: In order to update the kernel packages visit https://aka.ms/wsl2kernel, download the kernel package and install the same.

Step 8: In order to activate WSL 2 execute the following command in Windows Powershell running the same in administrator mode.

wsl --set-default-version 2

Installing and Setting up Kali Linux CLI:

Step 1: Hit the Windows logo button on your keyboard, and then type in the following command and then, choose the “Microsoft Store” option from the menu.

microsoft store

Step 2: Once the Microsoft store opens, search for “Kali Linux” in the search bar.

Step 3: On the Kali Linux page, click on the “Get” option in order to download the Kali Linux app.

Step 4: Once the Kali Linux app is downloaded, close the Microsoft-Store.

Step 5: Click on the Windows logo in the bottom left corner of your screen and then type in the following command and press enter:

Kali Linux

Step 6: After opening the Kali Linux app, the distribution will be installed in few seconds completely.

Step 7: Then, type in the credentials that you want to set in for the login purpose. Now, you will be able to use the Kali Linux easily in the command-line prompt and also execute the basic commands without an error.

Note: The base image does not contain any tool, or a graphical interface in order to keep the image small, however, it can be downloaded and installed via “apt” commands easily.

Setting Up Kali Linux(GUI):

Step 1: Open the Kali Linux app and login with your credentials.

Step 2: Type in the following command and hit enter:

sudo apt update && sudo apt upgrade -y

Step 3: After the successful completion of the above command, type the following command and hit Enter:

sudo apt upgrade && sudo apt install kali-win-kex -y

Step 4: Now, once the above command is completed installing, then type in the following:

kex

This will initiate the process to open up the GUI environment of the Kali Linux distribution installed.

Important: 

1. Now, whenever we have to close the GUI opened, then we will press the “fn” key with “f8” in order to select the “exit viewer” option. 

2. Then, after exiting the viewer type in the following command in order to completely close the running services: 

kex stop

3. Thereafter, whenever we want to start the GUI Kali Linux environment then we will firstly open the Kali Linux app, and then type in the following commands by sequence: [or else you will get an error.]

kex stop [In any case you forgot to stop the kex services running before.]
kex

Note: The above GUI setup will work on Kali Linux versions 2020.3 or later.

Время на прочтение2 мин

Количество просмотров81K

image

 
С введением подсистемы Windows для Linux (WSL) в Windows 10 появились новые возможности, такие как поддержка Linux дистрибутивов, в частности Ubuntu. В этой статье я расскажу, как с помощью этой подсистемы подключить Kali LInux в Windows среде не используя системы виртуализации.

Хотя работы Kali на Windows может быть не оптимальна из-за различных ограничений, все еще существует множество ситуаций, когда Kali Linux может быть необходим для использования совместно с Windows 10. Например это может быть консолидация рабочих областей, особенно если Windows является вашей основной рабочей средой. Также может быть полезна стандартизация инструментов и сценариев для работы в нескольких средах, быстрый перенос инструментов командной строки для тестирования проникновения в Linux для Windows и т. д.

Для того, чтобы установить Kali необходимо выполнить несколько шагов. В первую очередь необходимо включить и установить Windows Subsystem for Linux Command Reference — запустить powershell оболочку с правами администратора, выполнить команду и перезагрузить вашу машину:

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

После перезагрузки необходимо установить Ubuntu-environment:

lxrun /install

Далее вам необходимо установить WSL Distribution Switcher. Эта программа предназначена для переключения подсистемы Linux для использования различных дистрибутивов Linux. Образы rootfs в настоящее время загружаются из репозиториев Docker Hub в виде исходников или prebuilt-сборок.

(Для клонирования проекта с git-репозитория необходимо установить git-клиент на Windows 10, например отсюда: https://git-scm.com/download/win, а также установить python для Windows).

git clone https://github.com/RoliSoft/WSL-Distribution-Switcher.git
cd WSL-Distribution-Switcher
python get-prebuilt.py kalilinux/kali-linux-docker
python install.py rootfs_kalilinux_kali-linux-docker_latest.tar.gz
lxrun /setdefaultuser root

Теперь, когда Kali-environment развернут на вашей Windows 10 вы можете вызвать его с помощью команды:

bash

Далее вам необходимо обновить Kali Linux и установить кириллическую локализацию (при необходимости):

export LANG=C
apt-get update && apt-get dist-upgrade

После развертывания Kali-environment мы можем установить необходимые утилиты и использовать их из Windows:


Таким простым способом вы получите современный дистрибутив для тестирования на проникновение в вашей Windows среде без запуска систем виртуализации, перезагрузок и прочего. Также, необходимо учесть, что из такой среды у вас не будут нормально работать утилиты по работе с железом, для вардрайвинга и т.д.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Как правильно настроить wifi адаптер на windows 10
  • Webstorm download for windows
  • Удаление символьной ссылки windows
  • Node js windows server 2003
  • Windows xp x64 sp3 russian