Skip to content

Manage and access your Kali Linux or Parrot Security VM from the terminal (SSH support + file sharing, especially convenient during CTFs, Hack The Box, etc.) 🚀🔧

License

eikendev/hackenv

Repository files navigation

hackenv

Access your Kali Linux and Parrot Security instances with ease.

hackenv lets you comfortably manage your hacking environment from the terminal.

Build status  License 

🚀 Installation

The preferred way is to download the binary from the latest release.

Alternatively, install the required dependencies and build it yourself:

go install github.com/eikendev/hackenv/cmd/...@latest

🤘 Features

  • Support for Kali Linux and Parrot Security.
  • Create short-lived virtual machines within seconds.
  • Download the latest official live image conveniently.
  • Simple and intuitive command line interface.
  • Configure instant SSH access based on public-key authentication.
  • Set up a shared directory between host and guest.
  • Set the same keyboard layout in the guest as on the host.

📄 Usage

First, make sure you have the required dependencies installed. Also, you will need a bridge interface as described below. This can be as simple as running hackenv fix create-bridge (or ./bin/hackenv_createbridge).

Then, download an image using hackenv get. This will download a live image from the official mirrors. The download can take a while, so sit back and enjoy some tea.

⚠️ If you run SELinux, you must label the new image yourself. Check the section on file sharing for more information.

Next, run hackenv up to boot the virtual machine. Once this command is finished, the VM is running and fully configured. The VM will be short-lived (volatile), meaning any data and configuration stored outside the shared directory will be removed once the machine shuts down. This is by design and admittedly opinionated.

You can now start an SSH session with hackenv ssh or spin up a GUI with hackenv gui.

Note that by default, hackenv will operate with Kali Linux, and respectively download its image. If you want to operate with Parrot Security instead, specify hackenv --type=parrot, or check out the configuration.

File Sharing

hackenv will automatically set up a shared directory between the host and the virtual machine. On the host side the directory is ~/.local/share/hackenv/shared, while on the guest side it is located at /shared.

If SELinux denies access to the shared directory, you have to adjust the context of the directory. You can run hackenv fix apply-labels (or ./bin/hackenv_applylabels) if you are on Fedora or similar. The script will also relabel the downloaded images. If you add new files to the shared directory from outside, do not forget to label them as well.

Creating a Bridge Interface

hackenv uses a bridge so that you can reach the guest from the host for SSH, while the guest can access the Internet. You can create this bridge by running hackenv fix create-bridge (or ./bin/hackenv_createbridge). Note that this script will request privileges so it can create an interface.

Of course, please adapt the script to your specific needs. The interface is expected to have the name virbr0 by default, but this can be changed using command line flags.

⚙ Configuration

The tool currently does not support configuration via files. However, some options can be set using environment variables. Check out the help (--help) of a command to see what options support this.

For instance, to operate with Parrot Security by default, you can set $HACKENV_TYPE=parrot. If you work with both operating systems, then I recommend using shell aliases:

alias kali='hackenv --type=kali'
alias parrot='hackenv --type=parrot'

🥙 Dependencies

To build the binary yourself, you also need the development files of libvirt, usually called libvirt-dev or libvirt-devel.

💡 Alternatives

If you do not like this tool, the following options are worth checking out: