Cyber Security Lab Setup in Linux using KVM (Part 1)

aj-tap
5 min readDec 13, 2022

--

Nowadays, learning cyber security is more accessible than it was in the past. Tryhackme, Hackthebox, and other cyber security training platforms provide browser-based access to their machine without configuring an environment. But creating a Cyber Security Home Lab Environment is one way to go deeper and improve learning and practice your skills.

In this article, I’ll describe the steps I took, the problems I ran into, and the solutions I discovered in building a cyber security lab environment.

Who is this article for?

  • Users who favor Linux based distribution as their host operating system.
  • Looking for Virtual box alternative.
  • For those who prefer hands-on, experiential learning. Setting up own penetration, malware analysis environment.
  • Basic foundation of networking terminology, computers, cyber security concepts and formidable research skills.

Host Operating System

I’m avid fan of FOSS (Free and Open Source Software) because it has transparency and respects your privacy. This is one of reason I choose a Linux based OS. For this setup, I chose Fedora Silver Blue because it is not only secure out of the box. Unlike other distributions, the operating system is immutable. This means that not only is application installation isolated from the core file system, but the ability for malicious applications to compromise your system is significantly reduced.

In a nutshell, here are my reasons why I chose Silver Blue:

  • FOSS: Linux source code is available to all, and anyone is free to use, study, and modify it. This principle allows others to contribute to the development and improvement of software in the same way that a community does.
  • Performance: Less RAM is used and is faster than Windows, which is crucial in this setup.
  • Immutable: more stable, less prone to bugs, and easier to test and develop.
  • Hybrid/image: usage of rpm-ostree package management allows you to upgrade/rollback. The advantages are when you upgrade to a newer version of Firefox and reboot into the new bootable root. However, if the image upgrade didn’t go as planned, you can revert to the previous image and keep the most recent version of Firefox.
  • Customization: Without a doubt, Linux is the most customizable operating system on the planet. because you can do more than just change themes and icon packs The entire desktop environment can be replaced.

Installing Fedora Silver Blue:

Prerequisite:

  • The Silver blue image or other Linux based distribution.
  • Fedora Media Writer
  • A USB Flash drive with at least 3GB space available.
  1. Get a copy of an image.
  2. Verify the copy of the image.
  3. Get Fedora Media Writer or BalenaEtcher then flash OS image in USB stick.

4. Boot into the USB Stick and enter install Fedora.

5. Choose a keyboard layout, language support, and time & date. Set the storage configuration to automatic partitioning . And then begin installation.

6. Depending on your hardware, the installation process could take up to 10 minutes.

7. After installation, restart the system.

8. The initial setup screen will appear. Create your account by following the setup instructions. Remember to enable third-party repositories.

9. You’ve set up Silver blue! Check out this awesome documentation to learn more about how to install apps and how Fedora silver blue works.

Virtualization Software

Don’t get me wrong but Oracle Virtual Box is an excellent virtualization tool. It’s very dependable, multi-platform, and the user interface is well-designed and simple.

However, it is not entirely open source. Some of its components are proprietary, such as the extension pack. Furthermore, I’d like to point out that in order to build Oracle Virtual Box, you must use the proprietary Open Watcom compiler. What about VMware Workstation? You need to purchase a license to use features such as snapshots and network customization, which are important in our lab setup.

This is where KVM/QEMU comes into play. KVM lets you turn your Linux box into a hypervisor without setting up or messing around. It falls between between type 1 and type 2 hypervisors. Thus, it is more faster and better virtualization. It has also advanced options like CPU pinning and GPU passthrough.

Installing KVM/QEMU in Silver Blue:

  1. Open a terminal and generate a rpm repo metadata.
rpm-ostree refresh-md

2. Install KVM and Virtual machine manager for GUI-based virtual machine management.


rpm-ostree install virt-install virt-manager virt-viewer libvirt qemu-kvm libguestfs-tools virt-top

3. Reboot, then using nano text editor. Add to the bottom of your qemu.conf to run KVM with regular non-root user.

 nano /etc/libvirt/qemu.conf
user = "<Replace-this-with-your-username>"
group = "<Replace-this-with-your-username>"

4. You’ve install KVM and Virtual Machine Manager. You can now create your virtual machine boxes.

Conclusion

We’ve installed our host operating system as well as Virtualization software. You can begin tinkering and creating your penetration testing environment. In the next part, we will set up our own malware analysis lab.

--

--