WSL (Windows Subsystem for Linux)

WSL is a feature of Windows that allows developers to run a Linux environment without the need for a separate virtual machine or dual booting.

wslu - A collection of utilities for WSL

ATTENTION!

Built-in versions of wslu in Ubuntu are no longer supported by me.

If you have problems, please check whther you are using the PPA version of wslu. If not, please report to the Ubuntu WSL team; However, the PPA version of wslu will address most issue that come from the built-in version.

This is a collection of utilities for the Windows Subsystem for Linux (WSL), such as converting Linux paths to Windows paths or creating Linux application shortcuts on the Windows Desktop.

PPA version of wslu

Parrot Security OS on WSL (Windows 10 FCU or later)

based on wsldl

screenshot

Requirements

Install

1. Download installer zip / Here

2. Extract all files in zip file to same directory

3. Run Parrot.exe to Extract rootfs and Register to WSL

Exe filename is using to the instance name to register. If you rename it you can register with a diffrent name and have multiple installs.

How-to-Use(for Installed Instance)

exe Usage

Usage :
    <no args>
      - Open a new shell with your default settings.

    run <command line>
      - Run the given command line in that distro. Inherit current directory.

    runp <command line (includes windows path)>
      - Run the path translated command line in that distro.

    config [setting [value]]
      - `--default-user <user>`: Set the default user for this distro to <user>
      - `--default-uid <uid>`: Set the default user uid for this distro to <uid>
      - `--append-path <on|off>`: Switch of Append Windows PATH to $PATH
      - `--mount-drive <on|off>`: Switch of Mount drives

    get [setting]
      - `--default-uid`: Get the default user uid in this distro
      - `--append-path`: Get on/off status of Append Windows PATH to $PATH
      - `--mount-drive`: Get on/off status of Mount drives
      - `--lxguid`: Get WSL GUID key for this distro

    backup [contents]
      - `--tgz`: Output backup.tar.gz to the current directory using tar command
      - `--reg`: Output settings registry file to the current directory

    clean
      - Uninstall the distro.

    help
      - Print this usage message.

How to uninstall instance

>Parrot.exe clean

WSL notes

Rebuilding kernel with kvm support

This instructions are based on microhobby.com.br

  1. Clone source
git clone https://github.com/microsoft/WSL2-Linux-Kernel.git
cd WSL2-Linux-Kernel
  1. Reconfigure kernel

Enable kvm, as described here https://wiki.gentoo.org/wiki/QEMU#Kernel

make menuconfig KCONFIG_CONFIG=Microsoft/config-wsl
  1. Build kernel
make KCONFIG_CONFIG=Microsoft/config-wsl -j8
  1. Copy kernel
cp vmlinux /mnt/c/Users/<seuUser>/
  1. Copy .wslconfig file to user home

Starting WSL with KVM support

  1. Copy run-wsl.bat, attach.wdbg and patch_wsl_nested.js to same folder
  2. Fix path in attach.wdbg
  3. Open admin powershell in that folder
  4. Run ./run-wsl.bat and follow instructions

Move WSL

Bash, batch and PowerShell script to move WSL 1 and WSL 2 distros VHDX file to a different location.

Interactive Example

Usage

Bash

Use with git bash for Windows or similiar.

Interactive way

1) ./move-wsl 2) Select your distro 3) Enter your target (i.e. /d/wsl target/ubuntu)

Explicit way

1) Get a list of WSL distros: wsl -l 2) Move your image: ./move-wsl [NAME] [LOCATION]

Example: ./move-wsl docker-desktop /d/docker

PowerShell

Interactive way of moving wsl for Windows PowerShell.

1) ./move-wsl.ps1 2) Select your distro 3) Enter your target (i.e. D:\wsl target\ubuntu)

Batch

This is a lightweight version which can also be used from Windows CMD.

1) Get a list of WSL distros: wsl -l 2) Move your image: move-wsl.bat [NAME] [LOCATION]

Example: move-wsl.bat docker-desktop "D:\wsl files\docker"

Moving Docker WSL

Before moving Docker WSL make sure to stop the Docker service. Otherwise Docker will crash and you may need to reset it to factory defaults.

Default user was switched to root when moving a distro

Set your default user inside your distro by adding the following configuration to your /etc/wsl.conf.

[user]
default=YOUR_USERNAME

If the file doesn't exist create it manually. Then exit your distro, terminate it (wsl -t YOUR_DISTRO) and start it again. For further options see Microsoft Docs.

Some distributions also allow settings the default user via command line with YOUR_DISTRO config --default-user YOUR_USER (e.g. ubuntu config --default-user johndoe). Make sure to shutdown your distro before (wsl -t YOUR_DISTRO).

Standard distro switched when moving it

Since we need to unregister to import it with the same name, the standard distro can be switched. Just set your standard distro again:

wsl -s YOUR_DISTRO

WSL version was switched when moving distro

On import the distro will be registered with the current default WSL version. You can set your default WSL version with wsl --set-default-version <Version>. When the WSL version was accidentally changed while moving, you can set the version with wsl --set-version <Distro> <Version>.

Minimal WSL2 systemd script

This is a simple script to perform a minimal installation of @diddledan's one-script-wsl2-systemd for Insiders.

This script only includes the following: - add systemd support - add classic snap support

The script should be running as root.

That's it.

ubuntu-wsl2-systemd-script

Script is unsupported and will no longer be maintained, but will be up here because it is used by quite some people.

Script to enable systemd support on current Ubuntu WSL2 images from the Windows store.

I am not responsible for broken installations, fights with your roommates and police ringing your door ;-).

Instructions from the snapcraft forum turned into a script. Thanks to Daniel on the Snapcraft forum!

Usage

You need git to be installed for the commands below to work. Use

sudo apt install git
to do so.

Run the script and commands

git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script/
bash ubuntu-wsl2-systemd-script.sh
# Enter your password and wait until the script has finished

Then restart the Ubuntu shell and try running systemctl

systemctl
If you don't get an error and see a list of units, the script worked.

Have fun using systemd on your Ubuntu WSL2 image. You may use and change and distribute this script in whatever way you'd like.

How to Install KALI LINUX [Distro WSL version]

  1. INSTALL WSL 2

  2. Upgrade WSL to latest vesion

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
systeminfo | find "System Type"
wsl --list --verbose
wsl --set-default-version 2
  1. INSTALL GUI
wsl --install -d kali-linux

SET PASSWORD & USERNAME (OPTIONAL)

wsl -d kali-linux -u username
passwd root
wsl --shutdown
wsl --setdefault Kali-linux
wsl -d kali-linux -u username
kali config --default-user username
sudo apt update && sudo apt upgrade -y
sudo apt install kali-desktop-xfce -y
sudo apt install -y kali-linux-large
sudo apt-get install kali-linux-default
- or

wget https://gitlab.com/kalilinux/build-scripts/kali-wsl-chroot/-/raw/master/xfce4.sh
chmod+x xfce4.sh
sudo./x fce4.sh
  1. XRDP
sudo apt install xrdp -y
sudo service xrdp start

Optional Installation

docker pull kalilinux/kali-rolling
docker run --tty --interactive kalilinux/kali-rolling /bin/bash
sudo apt update && sudo apt -y install kali-linux-headless
git clone https://github.com/RoliSoft/WSL-Distribution-Switcher.git
cd WSL-Distribution-Switcher
python get-prebuilt.pykalilinux/kali-linux-docker
python install.pyrootfs_kalilinux_kali-linux-docker_latest.tar.gz
lxrun/set default user root
https://github.com/belherdigital/documentation-oe.git

Optional Configuration

- /etc/ssl/openssl.cnf
- /etc/ssl/kali.cnf
- /etc/samba/smb.conf
- /etc/ssh/ssh_config.d/kali-wide-compat.conf
- regenerate-ssh-host-keys
- /etc/ssh
sudo systemctl disable regenerate-ssh-host-keys.service

Optional Addition

/etc/apt/sources.list
grep -v '#' /etc/apt/sources.list | sort -u
echo "deb http://http.kali.org/kali kali-rolling main contrib non-free" | sudo tee /etc/apt/sources.list
echo "deb http://http.kali.org/kali kali-last-snapshot main contrib non-free" | sudo tee /etc/apt/sources.list
echo "deb http://http.kali.org/kali kali-experimental main contrib non-free" | sudo tee /etc/apt/sources.list.d/kali-experimental.list
echo "deb http://http.kali.org/kali kali-bleeding-edge main contrib non-free" | sudo tee /etc/apt/sources.list.d/kali-bleeding-edge.list

Remove Optional addition

sudo rm /etc/apt/sources.list.d/kali-experimental.list
sudo rm /etc/apt/sources.list.d/kali-bleeding-edge.list
echo "deb-src http://http.kali.org/kali kali-rolling main contrib non-free" | sudo tee -a /etc/apt/sources.list
cat /etc/apt/sources.list
sudo tee /etc/apt/sources.list.d/kali-bleeding-edge.list
sudo rm -f /etc/apt/sources.list.d/kali-bleeding-edge.list
sudo apt install gitleaks/kali-bleeding-edge
sudo apt install gitleaks/kali-rolling
echo "deb http://http.kali.org/kali kali-rolling main non-free contrib" | sudo tee /etc/apt/sources.list
sudo apt update && sudo apt -y full-upgrade
cp -i /etc/skel/.bashrc ~/
cp -i /etc/skel/.zshrc ~/
chsh -s /bin/zsh
[ -f /var/run/reboot-required ] && sudo reboot -f

grep VERSION /etc/os-release

wget http://http.kali.org/kali/pool/main/k/kali-archive-keyring/kali-archive-keyring_2022.1_all.deb
sudo dpkg -i kali-archive-keyring_2022.1_all.deb
rm kali-archive-keyring_2022.1_all.deb
sudo apt-get update

`sudo apt -f update`
`sudo apt install -y kali-linux-headless`

System

kali-linux-core: Base Kali Linux System – core items that are always included
kali-linux-headless: Default install that doesn’t require GUI
kali-linux-default: “Default” desktop (amd64/i386) images include these tools
kali-linux-arm: All tools suitable for ARM devices
kali-linux-nethunter: Tools used as part of Kali NetHunter

Tools

kali-tools-gpu: Tools which benefit from having access to GPU hardware
kali-tools-hardware: Hardware hacking tools
kali-tools-crypto-stego: Tools based around Cryptography & Steganography
kali-tools-fuzzing: For fuzzing protocols
kali-tools-802-11: 802.11 (Commonly known as “Wi-Fi”)
kali-tools-bluetooth: For targeting Bluetooth devices
kali-tools-rfid: Radio-Frequency IDentification tools
kali-tools-sdr: Software-Defined Radio tools
kali-tools-voip: Voice over IP tools
kali-tools-windows-resources: Any resources which can be executed on a Windows hosts
kali-linux-labs: Environments for learning and practising on
kali-tools-information-gathering: Used for Open Source Intelligence (OSINT) & information gathering
kali-tools-vulnerability: Vulnerability assessments tools
kali-tools-web: Designed doing web applications attacks
kali-tools-database: Based around any database attacks
kali-tools-passwords: Helpful for password cracking attacks – Online & offline
kali-tools-wireless: All tools based around Wireless protocols – 802.11, Bluetooth, RFID & SDR
kali-tools-reverse-engineering: For reverse engineering binaries
kali-tools-exploitation: Commonly used for doing exploitation
kali-tools-social-engineering: Aimed for doing social engineering techniques
kali-tools-sniffing-spoofing: Any tools meant for sniffing & spoofing
kali-tools-post-exploitation: Techniques for post exploitation stage
kali-tools-forensics: Forensic tools – Live & Offline
kali-tools-reporting: Reporting tools

Others

kali-linux-large: Our previous default tools for amd64/i386 images
kali-linux-everything: Every metapackage and tool listed here
kali-desktop-live: Used during a live session when booted from the image

Desktop environments/Window managers

kali-desktop-core: Any key tools required for a GUI image
kali-desktop-e17: Enlightenment (WM)
kali-desktop-gnome: GNOME (DE)
kali-desktop-i3: i3 (WM)
kali-desktop-kde: KDE (DE)
kali-desktop-lxde: LXDE (WM)
kali-desktop-mate: MATE (DE)
kali-desktop-xfce: Xfce (WM)

Installing Parrot distribution in WSL2


Based on script by the4rchangel.

To install the distribution you need a base. This may be Kali Linux or Ubuntu. To install, use the following instructions:

  1. Install the Kali Linux or Ubuntu distribution from the Microsoft Store.
  2. Update available repositories, install the update and the gnupg, git utility. You can do this with the command:
sudo apt update
apt upgrade -y 
apt install gnupg git -y
  1. Clone this repository and run the script with the command:
git clone https://github.com/Prodject/ParrotWSL.git 
cd ParrotWSL 
chmod a+x parrot-wsl.sh ./parrot-wsl.sh
  1. During installation, you must select the distribution version (home, security, etc.)

  2. Add a folder with ParrotOS to Windows Defender exceptions (Kali Linux). You can open the folder with Parrot OS using the command "explorer.exe ."

  3. You can install the full version of the system with the command:

sudo apt install parrot-tools-full
  1. All done)

neofetch

Note: if you run the parrot-wsl-mirror.sh file, then during the installation process you can select a mirror for your location.

Environment


By default, mate environment is set, but if you are using X410 in Windowed Apps mode, you will not be able to use this mode. In this case, it is recommended to install XFCE, you can install from script additions wsl.post.sh

Parrot-on-Docker

![alt text](https://softwarereviews.s3.amazonaws.com/production/logos/offerings/6116/original/ParrotSecurity_logo.png?1582749483)

ParrotOS on WSL2

Here's the thing... I went scouring the Internet to find some way to put ParrotOS on WSL2 and I found a couple of scripts, another couple of guides; but the apt sources were old, the tools were deprecated, and there were just a lot of tweaks/further debugging that needed to be done in order to get the thing right speed. Plus, you had to start with an Ubuntu/Debian/Kali distro anyway which to me didn't seem like the right answer.

As much as I would like to take credit for this super straight-forward simple way of installing... really any distro your little heart desires {yea you, I'm talking about your little heart buddy}, I just ganked this from the Microsoft documentation found here. So I shant toot my own horn. I don't know why it took me so damn long to read the documentation but I figured I'm not the only one, so here we are.

What's that? Shut the Fv*k up and get on with it? Right Right Right... my bad.

Prerequisites

  1. There are a million and one guides out there on how to install WSL2. Like this one, that one, or this other(for those of you who like the motion picture formats). So if you don't have that done, it's kinda necessary.
  2. Next
  3. You need to Head over to the Website of Docker and follow thier guide on setting up Docker Desktop with WSL2 backend. There are obvious workarounds for this which... I suppose may be worth getting into later but for now, if you can, do the do and install the thing.
  4. Meat & Potatoes

Get yourself a hot-n-ready tar'd ParrotOS


Now I imagine that there are a ton of ways to go about this. ~~Heck, I even did you a solid and got one here for ya.~~ But for the sake of learnin you one, we'll go through the steps anyway.


So the easiest way ~~(besides getting yours here)~~ to get a ParrotOS tar file of the entire image is to compress a container. I highly encourage you to head over to the ParrotSec website to view their latest Downloads. Here is their official Docker documentation where you will find 2 containers. Again - I highly recommend that you go check it out.


  1. Open your WSL2 CLI (bash or whatevs) in a distro you've already got installed.

  2. In WSL you are going to start Docker

sudo service docker start
3. Pick one of the following container templates and spin it up. + I recommend rolling up the smallest image since you will be able to update and customize once everything is installed

Core Template:

Parrot.run/Core

Core system with just the Parrot basics. You can use it as a start point to create your custom containers. This image is multiarch, and works for amd64, arm64 and armhf architectures.

Launch the container

  docker run -t parrotsec/core bash
Security Template

Parrot.run/sec

This container includes a huge collection of tools that can be used via command line from inside a docker container. Some tools with graphical interface were excluded for obvious reasons. This container ships with the following metapackages: -parrot-cloud

Launch the container

  docker run -t parrotsec/security bash
  1. Get the image's container ID and save it as a variable

  dockerContainerID=$(docker container ls -a | grep -i parrot | awk '{print $1}')
5. Export your image to the Windows file system

  docker export $dockerContainerID > /mnt/c/temp/ParrotOS.tar

All that so you can import the tar file as an image into WSL2


Import ParrotOS tar file into WSL


  1. Open yourself a powershell instance and get to your directory and make a folder to install your Distro.

      cd
      mkdir WSLdistro
    

  2. move into your new directory Import your tar file into WSL2. Syntax is important here '''wsl --import

  cd WSLdistro
  wsl --import ParrotSec .\ "C:\temp\ParrotOS.tar"
  1. Check installed distros
  wsl -l -v
  1. Launch that nizbich
  wsl -d ParrotOS

Extras in this Repository

Check out the Docs folder. There are a few things in there which help out post import. Some dot files, and wsl config files. If they help, cool, if not.. no sweat.

WSL Pentesting

Interesting Files

cat /etc/wsl.conf


Escape WSL to Windows Host Machine

If we’are currently on WSL machine, we can access to the host Windows machine as below.

cd /mnt/c/

If /mnt/c/ is empty, we need to mount the folder by running the following command.

cd /

# -t: Limit the set of filesystem types
# drvfs: A plugin for WSL
# C: : Specify the Windows root
mount -t drvfs C: /mnt/c