Setting up VirtualBox as a pentest lab (Debian) 11-17-2016, 03:55 AM
#1
VirtualBox is a powerful tool for all aspects of computer engineering - hardware and software. That said, it's especially useful for pentesters and those who want to run local servers, given the right knowledge.
I'll be doing a tutorial on creating a Debian Linux (Ubuntu, Kali, Mint, Raspbian, etc...) VirtualBox VM and setting up a host-to-guest connection so you can access your test servers from your host OS.
I'm using Debian 8.6.0 as my distro of choice, but you can use anything that's based on it for the purposes of the networking structure.
First and foremost, download a bootable ISO for whatever distro you choose (Debian's is available here) to use and we can get started making the virtual machine.
Once you've downloaded the iso, start VirtualBox and click the "new" button. Give your VM a name and choose the appropriate type (usually Linux -> Debian (64-bit), but Ubuntu has its own because it's cool like that).
After naming the VM, you'll be prompted for the memory size, which you can scale based on how much RAM you have in your computer (2 GB [2048 MB] usually does the trick).
Once you've specified the machine's memory size, you'll be asked about storage. Select "Create a virtual hard disk now" (probably the default option), then VDI for the type on the following page. On the third disk page it is VERY IMPORTANT that you select dynamically allocated storage unless you want a giant file with next to nothing in it sitting on your disk.
On the fourth and final disk page, leave the name as-is and set the size of the virtual disk (I usually use 32 GB, but it's more or less arbitrary and can be changed through the CLI later).
Now that we've created our VM, it's time to install the iso we downloaded earlier. Right-click your new VM, select settings, and go to the "storage" tab. Under "Controller: IDE" click the empty disk, then click the disk on the side to choose your image.
![[Image: 6cd1f9fce6f64dc68838aff4c03599a0.png]](http://image.prntscr.com/image/6cd1f9fce6f64dc68838aff4c03599a0.png)
After all that, we can finally start the machine and install the OS. Most (if not all) Debian distros have an easy-to-follow graphical install, so I shouldn't need to explain much.
While your VM's operating system is installing, you can save some time by creating and configuring the network adapter.
On the main VirtualBox page, select file -> preferences and navigate to the "network" tab. Under the "host-only networks" heading, click the circuit board with a plus to create a new adapter.
![[Image: e49bcae5cd89494c8782759dbbf55a3f.png]](http://image.prntscr.com/image/e49bcae5cd89494c8782759dbbf55a3f.png)
After creating the adapter, select it and click the screwdriver to edit its properties. Change the IPv4 address to anything in the 192.168.x.x range (the last number is more or less arbitrary, I usually set it to 1) and set the mask to 255.255.255.0 if it isn't already.
![[Image: ce0e56a79ba04fcebd4226c5716c81a7.png]](http://image.prntscr.com/image/ce0e56a79ba04fcebd4226c5716c81a7.png)
After setting the IP, navigate to the DHCP Server tab and uncheck "enable server" if it's checked.
Once you've rebooted your VM to make sure everything works as it should, shut it down, open its preferences in VirtualBox (right-click -> settings), and go to network.
Leave Adapter 1 as is (the default NAT adapter gives the VM a "wired" connection), and go to the Adapter 2 tab. Check "Enable Network Adapter" and select "Host-only Adapter" under "Attached to", then select the adapter we made in the last step under "Name".
Now start your VM and run the following command to open your network config file for editing:
This is where it gets tricky. The eth0 interface is the NAT one we left alone, and it should look like this in the interfaces file:
The eth1 interface (the host-only one we configured) should look like this:
Extemely important note: The address up to the last dot (192.168.42) is the exact same as the host-only adapter we configured on the host OS. That noted, we need to make sure of a few things:
Set up a quick app, configure what you need to, and point your browser to the IP you configured in interfaces.
![[Image: 5bb1a8a1d87846f8990cae84428de896.png]](http://image.prntscr.com/image/5bb1a8a1d87846f8990cae84428de896.png)
Pentest labs and development instances are essential to developers that test web applications for vulnerabilities. Without one or both, two things could happen. You could:
a) accidentally destroy your production server due to a vulnerability (which leads to lots of unhappy people and a pissed off programmer)
or b) get busted and criminally charged for poking around on someone else's server without proper permission
I'll be doing a tutorial on creating a Debian Linux (Ubuntu, Kali, Mint, Raspbian, etc...) VirtualBox VM and setting up a host-to-guest connection so you can access your test servers from your host OS.
The setup
I'm using Debian 8.6.0 as my distro of choice, but you can use anything that's based on it for the purposes of the networking structure.
First and foremost, download a bootable ISO for whatever distro you choose (Debian's is available here) to use and we can get started making the virtual machine.
Creating the VM
Once you've downloaded the iso, start VirtualBox and click the "new" button. Give your VM a name and choose the appropriate type (usually Linux -> Debian (64-bit), but Ubuntu has its own because it's cool like that).
After naming the VM, you'll be prompted for the memory size, which you can scale based on how much RAM you have in your computer (2 GB [2048 MB] usually does the trick).
Once you've specified the machine's memory size, you'll be asked about storage. Select "Create a virtual hard disk now" (probably the default option), then VDI for the type on the following page. On the third disk page it is VERY IMPORTANT that you select dynamically allocated storage unless you want a giant file with next to nothing in it sitting on your disk.
On the fourth and final disk page, leave the name as-is and set the size of the virtual disk (I usually use 32 GB, but it's more or less arbitrary and can be changed through the CLI later).
Now that we've created our VM, it's time to install the iso we downloaded earlier. Right-click your new VM, select settings, and go to the "storage" tab. Under "Controller: IDE" click the empty disk, then click the disk on the side to choose your image.
![[Image: 6cd1f9fce6f64dc68838aff4c03599a0.png]](http://image.prntscr.com/image/6cd1f9fce6f64dc68838aff4c03599a0.png)
After all that, we can finally start the machine and install the OS. Most (if not all) Debian distros have an easy-to-follow graphical install, so I shouldn't need to explain much.
Configuring the adapter (host)
While your VM's operating system is installing, you can save some time by creating and configuring the network adapter.
On the main VirtualBox page, select file -> preferences and navigate to the "network" tab. Under the "host-only networks" heading, click the circuit board with a plus to create a new adapter.
![[Image: e49bcae5cd89494c8782759dbbf55a3f.png]](http://image.prntscr.com/image/e49bcae5cd89494c8782759dbbf55a3f.png)
After creating the adapter, select it and click the screwdriver to edit its properties. Change the IPv4 address to anything in the 192.168.x.x range (the last number is more or less arbitrary, I usually set it to 1) and set the mask to 255.255.255.0 if it isn't already.
![[Image: ce0e56a79ba04fcebd4226c5716c81a7.png]](http://image.prntscr.com/image/ce0e56a79ba04fcebd4226c5716c81a7.png)
After setting the IP, navigate to the DHCP Server tab and uncheck "enable server" if it's checked.
Configuring the adapter (vm)
Once you've rebooted your VM to make sure everything works as it should, shut it down, open its preferences in VirtualBox (right-click -> settings), and go to network.
Leave Adapter 1 as is (the default NAT adapter gives the VM a "wired" connection), and go to the Adapter 2 tab. Check "Enable Network Adapter" and select "Host-only Adapter" under "Attached to", then select the adapter we made in the last step under "Name".
Now start your VM and run the following command to open your network config file for editing:
Code:
sudo nano /etc/network/interfacesThis is where it gets tricky. The eth0 interface is the NAT one we left alone, and it should look like this in the interfaces file:
Code:
auto eth0
iface eth0 inet dhcpThe eth1 interface (the host-only one we configured) should look like this:
Code:
auto eth1
iface eth1 inet static
address 192.168.42.68
netmask 255.255.255.0
network 192.168.42.0
broadcast 192.168.42.255- The last number in the "address" parameter must be different than that in the host-only adapter (in our case, it can't be 1)
this is the address that the host can connect to
- The last number in the "network" parameter must be zero
- The last number in the "broadcast" parameter must be 255
Code:
sudo systemctl restart networkingRun your new pentest lab
Set up a quick app, configure what you need to, and point your browser to the IP you configured in interfaces.
![[Image: 5bb1a8a1d87846f8990cae84428de896.png]](http://image.prntscr.com/image/5bb1a8a1d87846f8990cae84428de896.png)
Why should I do this?
Pentest labs and development instances are essential to developers that test web applications for vulnerabilities. Without one or both, two things could happen. You could:
a) accidentally destroy your production server due to a vulnerability (which leads to lots of unhappy people and a pissed off programmer)
or b) get busted and criminally charged for poking around on someone else's server without proper permission
(This post was last modified: 11-17-2016, 04:08 AM by Inori.)
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.
don't have much in the first place, who feel the new currents and ride them the farthest.















![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)
![[Image: inkexplosion.jpg]](http://i0.wp.com/techverse.net/wp-content/uploads/2013/09/inkexplosion.jpg)





