How To Install Kali Linux On Virtualbox

How To Install Kali Linux On Virtualbox

Reading time1 min
#Linux#Cybersecurity#Virtualization#KaliLinux#PenetrationTesting#VirtualBox

Practical Deployment: Kali Linux in a VirtualBox VM for Penetration Testing


Running penetration tests on production hosts is irresponsible and risky. Instead, isolate your toolkit with Kali Linux inside a VirtualBox VM—segregating potentially dangerous activity from your daily driver. Here’s a cookbook approach for experienced engineers who need a controlled Kali environment.


Requirements

  • Host: Windows 10/11, macOS (Ventura/Monterey), or any mainstream Linux distribution
  • Hardware: Minimum 4GB RAM (8GB+ preferred), 2 CPU cores, 20GB+ free disk space
  • VirtualBox (tested against v7.x as of 2024-06)
  • Latest Kali Linux installer ISO (download from kali.org)

Note: Hyper-V conflicts with VirtualBox on Windows. Disable it via “Windows Features” if needed.


1. Install VirtualBox

Oracle VirtualBox installation is straightforward—accept defaults, but watch for network driver prompts on Windows:

# On Ubuntu/Debian:
sudo apt update && sudo apt install virtualbox

# On Mac:
brew install --cask virtualbox

On Windows, expect UAC elevation and VirtualBox NDIS6 driver installation—approve when prompted, or networking will be broken in VMs.
Known issue: On macOS, you may need to allow third-party kernel extensions via Security & Privacy after install.


2. Fetch Kali Linux ISO

Download the current 64-bit “Installer” ISO from kali.org.
Verify the SHA256 checksum:

sha256sum kali-linux-2024.2-installer-amd64.iso

Compare to official signatures. Integrity matters—toolchain supply-chain attacks are not hypothetical.


3. Virtual Machine Configuration

Launch VirtualBox, select New. Name: Kali-2024.2 (for version tracking—update names as needed).

  • Type: Linux
  • Version: Debian (64-bit) (since Kali is Debian-based)
  • RAM: Allocate 4096MB for practical use; do not go below 2048MB or heavy tools (e.g., Burp Suite) will crawl.
  • Processors: 2+ vCPUs for responsive experience; adjust upward if host allows.

Disk provisioning:

  • Create a VDI disk
  • Dynamically allocated (unless you need guaranteed disk I/O performance, in which case preallocate)
  • Disk size: 32GB is realistic for tool installation and capture files. 20GB is absolute minimum—expect /var to fill up quickly.

4. VM Settings: Optimization & Integration

Open VM Settings, address the following:

  • System > Processor:
    Increase to 2–4 CPU cores (if host capacity allows). Enable VT-x/AMD-V if available.

  • Display:
    Set video memory to 128MB; enable 3D acceleration (improves XFCE/GNOME performance, slight overhead).

  • Network:
    Default is NAT. For lab environments requiring multi-VM attack scenarios, switch to Bridged Adapter or configure a Host-only network. Caveat: NAT simplifies outbound connectivity but limits inbound/test lab scenarios.

  • Storage:
    Mount the Kali ISO:

    • Under "Controller: IDE", select "Empty", then choose the ISO file.
    • Gotcha: Forgetting to unmount after install will lead to the installer running again post-reboot.

5. Kali Installation

With the VM started:

  1. Boot menu: Select Graphical install.
  2. Installer walkthrough:
    • Language, region, keyboard layout—set as needed.
    • Hostname suggestion: kali-vm (avoid duplicating names if running multiple VMs).
    • User: Avoid setting root as the main account; use a standard user with sudo privileges for current Kali releases.
  3. Partitioning:
    • “Guided – use entire disk.”
    • Storage configuration is local to the VM’s .vdi file—host disks are unaffected.
  4. Software selection:
    • Default tools are installed.
    • Optional: Uncheck “large” collections if you’re resource constrained, but this impairs workflow.
  5. Install GRUB to the primary virtual disk. If asked, select /dev/sda.

6. Post-Install Checklist

Before starting tool configuration, complete:

  • Eject ISO:
    VM window: Devices → Optical Drives → Remove disk from virtual drive. Otherwise, the installer reboots every launch—a common beginner error.

  • Update package mirror (some ISPs block Kali repos):
    If apt update yields 404s, check /etc/apt/sources.list for correct entries:

    deb http://http.kali.org/kali kali-rolling main non-free contrib
    
  • System update:

    sudo apt update && sudo apt full-upgrade -y
    sudo reboot
    
  • Guest Additions:
    Enables drag-and-drop, resizable display, and seamless mode.

    sudo apt install -y build-essential dkms linux-headers-$(uname -r)
    # Then in VM window:
    Devices → Insert Guest Additions CD image
    # Mount and run the script inside the VM
    

    Watch logs for:

    VirtualBox Guest Additions: Kernel modules successfully installed and loaded.
    

    Retest screen resizing and shared clipboard.
    Known issue: Sometimes the display scaling still isn’t perfect—log out and back in.


7. Baseline Security & Lab Tooling

  • Take Snapshot immediately post-install.
  • Install essential pentest tooling, e.g.:
    sudo apt install -y nmap wireshark burpsuite metasploit-framework
    
  • For network lab environments, enable “Host-Only” networking, then use multiple Kali/Metasploitable VMs on an internal, non-routed segment.

Example: Internal Lab Network Topology

[ Host ]
   |
[ NAT/Bridged ]
   |
-------------------------
|      Host-Only Adapter |
-------------------------
   |             |
[Kali]      [Metasploitable]

Kali sees Metasploitable, but they’re isolated from production LAN.


Field Notes

  • Performance: Expect moderate overhead vs bare-metal, but the tradeoff is safety.
  • Alternate Approach: Prebuilt Kali VMs (.ova) are available, but ISOs allow granular customization and audit.
  • Known bug: VirtualBox + Windows 11 host: drag-and-drop between host and VM can break after Win10 → Win11. No fix as of 2024-06 except CLI file transfer or use of shared folders.

Kali on VirtualBox is the standard dev/test methodology for good reasons: flexible setups, isolated blast radius, easy snapshot rollback. Coupled with strong networking configurations (NAT for outbound, Bridged/Host-Only for complex labs), it delivers a reproducible platform for learning and professional-grade assessment.


For details on automating Kali deployments via VBoxManage CLI, or integrating with CI pipelines (e.g., pre-provisioned test VMs in a hybrid lab), reach out.