No WSL After 2 Day

 

Description

No WSL After 2 Day ! OR No Windows System Linux After Today !

This document explains how to install a virtual Linux system on your Windows machine without relying on WSL.

Final result

2021-12-14_15-52-47

Download

Below are the software and application names mentioned in this document:

Windows Terminal Preview

VirtualBox

Kali Linux

Setting our virual machine using VirtualBox

After downloading and installing Windows Terminal and VirtualBox, the next step is to extract the Kali Linux OVA Image file and import it into VirtualBox. It is not necessary to modify any settings at this stage; simply leave everything as the default settings.

2021-12-14_16-49-33

2021-12-14_17-46-38

Once the image has been successfully imported, proceed to modify some machine settings by right-clicking on the machine, selecting ‘Settings,’ and following the steps shown in the accompanying screenshots below

1) In the advanced tab let’s choose Bidirectional for both of Shared Clipboard & Drag'nDrop

2021-12-14_18-22-37

2) We recommend allocating 2 CPUs and 2 GB of RAM for the system’s base memory and processor.

2021-12-14_18-26-39

2021-12-14_18-26-52

3) For the network, select ‘NAT,’ as this is a required configuration.

2021-12-14_18-28-52

4) Share a folder from your windows to the linux machine, In my case I shared my WIN desktop and mounted to /root/Desktop/Windows/. Be sure to select the Make Permanent option to ensure the folder remains accessible.

2021-12-14_18-30-38

After that you set everything click OK and Ð congrats! Your machine is ready.

Great ! Now let’s run our virtual machine in normal mode …

2021-12-14_18-36-38

Default creds: kali/kali

2021-12-14_18-40-09

We need this to check only if our VM is working fine and also to check the network settings.

2021-12-14_18-44-16

Creating a new ssh key for root and copy it to windows

** Note: You can skip this step and directly add your public key to the /root/.ssh/authorized_keys file. Make sure to set the correct file permissions by running the following command: chmod 600 /root/.ssh/authorized_keys.

This method is intended for beginners who are unfamiliar with generating SSH keys and for intermediate users who are unsure how to modify the permissions for the id_rsa file in Windows. **

Let’s generate a new ssh key for any user, I always like to be root.

So by going to terminal and type sudo su - then ssh-keygen and pressing Enter few times to generate the key, this will automatically save both the private and public keys in /root/.ssh/id_rsa

2021-12-14_18-52-07

After that let’s copy id_rsa.pub to authorized_keys by typing: cp id_rsa.pub authorized_keys, then changing the file permissions using chmod to set the access mode to 600 chmod 600 authorized_keys.

And then copy the private key cat /root/.ssh/id_rsa

2021-12-14_18-51-41

And paste it into your Windows Desktop Directory

2021-12-14_19-21-39

It’s important to also change the permissions of the id_rsa file in Windows.

Please save the code in a file with a .cmd or .bat extension, and then execute it.

@echo Changing id_rsa Permission
icacls .\id_rsa /inheritance:r
icacls .\id_rsa /grant:r "%username%":"(R)"
@pause

Awesome! Now let’s add this line to our C:\Windows\System32\drivers\etc\hosts file

127.0.0.1 kali.box

Return to VirtualBox and access the settings for the Kali machine. Navigate to the ‘Network’ category and click on ‘Advanced’

2021-12-14_19-03-25

Next, select ‘Port Forwarding’

2021-12-14_19-03-54

And follow the steps in this screenshot -

2021-12-14_19-06-29

This rule enables direct connection from the Windows machine to the SSH port of the Kali VM.

Return to the machine and modify the sshd_config file to allow root logins nano /etc/ssh/sshd_config

2021-12-14_19-45-27

Let’s change this line to

PermitRootLogin yes

After modifying the sshd_config file, restart the SSH service and enable it if it was not enabled by default.

2021-12-14_20-11-16

Commands:

# To restart SSH
systemctl restart ssh

# To enable SSH
systemctl enable ssh

Setting our Windows Terminal

Now after that everything is set in our Kali virtual machine … Let’s go to the Windows Terminal and create a new profile

2021-12-14_20-25-07

Now follow the steps shown in the screenshot below

2021-12-14_20-26-49

The command line:

ssh.exe -i id_rsa [email protected]

Note: Starting directory must be where we have our SSH id_rsa private key.

After you set everything as shown click ‘Save’ and then go to startup and choose your new profile as the Default profile . Don’t forget to click on ‘Save’.

2021-12-14_20-32-52

After restarting the Windows Terminal, it will automatically run the SSH command and connect you to your Kali VM.

2021-12-14_20-35-28

type yes and click Enter

2021-12-14_21-30-12

To open the shell directly on our shared Desktop, we can add in the end of the file ~/.zshrc the mounted point (path) we set earlier

cd /root/Desktop/Windows
# or
cd ~/Desktop/Windows

2021-12-14_21-32-12


Make it run at startup and headless

Go to C:\Users\Username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup, replace the value ‘Username’ with your computer username and create a new file. Let’s name it kali_vbox.bat

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "Kali-Linux-2021.4-vbox-amd64" --type headless

First check if VBoxManage.exe is in the right path and the "Kali-Linux-2021.4-vbox-amd64" value we can get from the box Name in the settings.

2021-12-14_21-43-12

Congratulations! The Linux VM will now run in the background and you can use everything on your Windows desktop as if you were working on Linux.

2021-12-14_21-37-02

Additional Port Forwarding in my own configuration

2021-12-14_19-08-49

The first IP is the IP address of my THM VPN, which I connect to using my Windows machine. I use this rule when playing a machine in THM or HTB, but I need to update the IP each time if I am not using a VIP membership.

The 2nd IP 10.0.2.15 is the default IP address for the NAT network adapter.


Thanks

Finally, I would like to thank leeloo1313 for the encouragement and help in writing this setup guide.