Deploy Kali using VirtualBox CMD line
Assuming you have already installed the Virtualbox application, you can use the command line to easily deploy a Kali VM image. The example here is using one of the pre-built virtual machines downloaded from the Kali.org website.
The files are provided within a 7z archive, so can extracted using the 7zr utility:
7zr x kali-linux-2023.1-virtualbox-amd64.7z
When extracted we have both a vbox file and a vdi file.
kali-linux-2023.1-virtualbox-amd64.vbox
kali-linux-2023.1-virtualbox-amd64.vdi
To register the Kali VM, we simply use the VboxManage cmd line utility.
VBoxManage registervm ~/VBox/kali/kali-linux-2023.1-virtualbox-amd64.vbox
Now that it is registered, I need to change a few items to suit my environment. I want my Kali VM to have bridged access to my local network so that it is in my local subnet rather than simply being on a Natt'd network within the Virtualbox host machine. I also wish for Kali to be able to use this interface in promiscious mode so need to enable that as well. In my example below my Virtualbox hosts main network adapter is eno1.
vboxmanage modifyvm kali-linux-2023.1-virtualbox-amd64 \
--nic1 bridged \
--bridgeadapter1 eno1 \
--nicpromisc1 allow-all
Next, I want to enable the VRDE server, which provides a RDP interface to the Virtualbox VM guest machine. This will provide access to the virtual machine itself, rather than access to the running guest os. This means I do not need xrdp to be installed in the guest kali os.
Please remember though that the VRDE functionality is only available through the use of the Virtualbox Extension Pack. You will need to comply with the license restrictions and install the appropriate Extension Pack for this to work. More details available from Oracle VM VirtualBox Extension Pack Personal Use and Evaluation License.
To enable VRDE from the command line simply:
vboxmanage modifyvm kali-linux-2023.1-virtualbox-amd64 \
--vrde on \
--vrdeport 13389
Finally I wish to rename the VM to simply Kali rather than the default "kali-linux-2023.1-virtualbox-amd64". I will also disable the audio as I do not require it.
vboxmanage modifyvm kali-linux-2023.1-virtualbox-amd64 \
--name Kali \
--audio none
All those CMD line options could have been specified on a single command, but has been broken out here for simplicity. All that now remains is to start and connect to the Kali VM.
vboxheadless -s Kali
I can now simply use a RDP client to connect to my VirtualBox host machine's IP address on port 13389 which we specified earlier. This will present us with the Kali Desktop at the machine level as you can see below, with Kali still booting up.
A short while later, I'm presented with the Kali login box.
The last thing I want to confirm is that the eth0 in Kali is able to see local traffic. To do this I started with the following options
tcpdump -qnti eth0 -c 20 ip host 8.8.8.8
Then to generate some traffic, on the VirtualBox host machine I simply pinged the IPv4 8.8.8.8 address and I could see the traffic withing my Kali VM.
Obviously normal factors apply about what traffic is visible depending on your local network setup etc. There you go though, Kali deployed as a VirtualBox Virtual Machine with RDP capability and local network access.