UnixDroid

Lesson 3 of 5 · 10 min

Build a safe hacking lab

Set up Kali Linux and a deliberately vulnerable target on one laptop, on a private network nobody else can reach.

You need something to practise on that you're allowed to attack. The safest answer is a lab inside your own laptop: two virtual machines that can talk to each other, but not to anyone else.

A laptop running VirtualBox with Kali Linux and Metasploitable 2 on a private host-only network
A laptop running VirtualBox with Kali Linux and Metasploitable 2 on a private host-only network

What you need

ItemWhyCost
A laptop with 8 GB RAM or moreRuns two VMs at the same time—
VirtualBoxRuns the virtual machinesFree
Kali Linux (VirtualBox image)Your attacker machineFree
Metasploitable 2A target that is broken on purposeFree

4 GB of RAM can work, but it will be slow. Also check that virtualisation (Intel VT-x or AMD-V) is turned on in your BIOS, otherwise VMs won't start.

Step 1: Install VirtualBox

Download it from virtualbox.org and install it like any other program.

Step 2: Check the private network

In VirtualBox, open File → Tools → Network Manager and go to the Host-only Networks tab. There should be one network there (called vboxnet0 on Linux and macOS, or VirtualBox Host-Only Ethernet Adapter on Windows) with its DHCP server switched on. If there isn't, click Create. Its default range is 192.168.56.0/24.

This network exists only inside your laptop. Machines on it can reach each other and your host, but not the internet.

Step 3: Add Kali Linux

Go to kali.org, open Virtual Machines, and download the VirtualBox image. It's a ready-made machine, so there's nothing to install. Extract the .7z file and double-click the .vbox file inside to add it to VirtualBox.

The default login is kali / kali. Change the password as soon as you're in:

passwd

Step 4: Add Metasploitable 2

Metasploitable 2 is made by Rapid7 and is packed with old, vulnerable software on purpose. Download it from SourceForge, extract the zip, then create a new VM in VirtualBox:

  • Type: Linux, Version: Other Linux (32-bit)
  • Memory: 512 MB
  • Hard disk: choose Use an existing virtual hard disk file and pick the Metasploitable.vmdk you extracted

The login is msfadmin / msfadmin.

Never put Metasploitable on a bridged network, and never give it internet access. It's built to be hacked, and anyone who can reach it could do exactly that.

Step 5: Put both machines on the private network

For each VM, open Settings → Network → Adapter 1, set Attached to to Host-only Adapter, and pick the network from step 2.

For Kali only, you can switch on Adapter 2 as NAT so it can still download updates. Don't do this for Metasploitable.

Step 6: Check they can see each other

Start both machines. On Metasploitable, find its IP address:

ifconfig

On Kali, use the newer command:

ip a

Look for addresses starting with 192.168.56.. Then, from Kali, ping the target (use your target's real IP):

ping -c 4 192.168.56.102

If you see four replies, your lab works.

Step 7: Take a snapshot

Before you do anything else, take a snapshot of both machines (Machine → Take Snapshot). If you break something while practising, you can go back to this clean state in seconds. Get into the habit of taking one before every exercise.

That's it. You now have a private, legal place to practise everything in this path.

Try it yourself
  1. Build the lab using the steps above.
  2. Write down the IP address of Kali and of Metasploitable.
  3. Ping Metasploitable from Kali and take a screenshot of the replies.
  4. Take a snapshot of both VMs and name it clean-start.
No Linux machine? Practise in the free online terminal

Quick check

What is the default username for Metasploitable 2?

Need a hint?

The password is the same as the username.

Finished this lesson?

Done lessons keep your daily streak going 🔥

0 day streak

0 lessons done

best 0 days

Log in to keep your streak on every device →