Friday, May 13, 2011

Back Track 5 on VirtualBox

One of the best ways to keep my mind off my health is to dig into tech and write about it. I can't begin to say how excited I am about the release of BackTrack 5. It has really come a long way and from the days of WHAX and Auditor. I would first like to thank the developers for all of their hard work.

As much as I would love to run it as my primary operating system I have a work supplied laptop and I am required to run Windows 7. Still that does  not mean I can't run it in a VM. That's where VirtualBox comes in. This tutorial is VirtualBox and BackTrack 5 specific it is done on Windows 7. Your mileage may vary on OS X and Linux.

Requirements:
Working VirtualBox installation: http://www.virtualbox.org/
BackTrack 5 iso: http://www.backtrack-linux.org/downloads/  <-Download the Torrent and Please keep seeding!

I'm using the 32bit KDE version.

Installing BackTrack 5
Start up VirtualBox and Click on the New Button in the upper left hand side of the Window. Or just press Ctrl-N
.  
Be a good user and read the blurb then Click Next
Give the new VM a good name Maybe BackTrack 5. For the Operating System drop down box select: Linux. For the Version drop down box select: Ubuntu. Then click Next.
Select the amount of RAM you want allocated to the VM and click Next.
You will want to create a new Hard Disk. I am going with the default 8GB. Make sure you have Book Hard Disk checked and click Next.
Read about the Hard Disk Wizard and click Next. Now select if you want a dynamic or static sized hard disk. I went with a Dynamic 8GB disk (for the tutorial) but if you intend on using the VM a lot I would consider making it at least 15GB. If you also intend to make a lot of use of the VM I would also partition the disk into at least a /boot, /home and / partitions. I might come back and go over that but I don’t have the time right now. Select your hard disk size then click Next. Now read the Summary and make sure all the info is right. If it is click on Finish. Once you do this VirtualBox will create the hard disk, If you chose a large static drive it could take a while.

The Wizard will now kick you back into the main VirtualBox window. You should also see your new VM in the list on the left hand side of the window.
in_VB
Now we need to get the VM set up to boot the BacktTrack iso.
  1. Right Click on the VM or click on it and press CTRL-S.
  2. When the Settings window comes up click on Storage. The one issue I have with VirtualBox after working with VMWare is that mounting an External CD or DVD is not that intuitive.
  3. First under IDE Controller click on the picture of the CD that says Empty.
  4. Now in the upper right hand corner click on the CD icon and select: Choose a Virtual CD/DVD Disk File. This will bring up an explorer window. Now find the BackTrack 5 iso you downloaded earlier click on it and then click Open.
  5. When the window closes click on OK at the bottom of the Settings window.
settings
Luckily the default boot settings for VirtualBox will boot the CD before the hard disk. So we won’t need to screw around with the boot order.
We are now ready to boot the VM. Click on the Back Track 5 VM and the click the Start button at  the top of the window.
A new Window will open and you will come to the BackTrack 5 boot screen. We will go with the default and select: BackTrack Text – Default Boot Text Mode
First Boot
You will now be brought to the command line. To get to the GUI/xserver you will need to type startx and then press Enter.
startx
In the upper left hand side of the window now click on Install BackTrack. This will open up the BackTrack hard disk installation dialog box.
  1. Select your language and click Forward
  2. Select your Location/Time Zone and click Forward
  3. Select your keyboard preference US, Dvorak etc and click Forward
  4. Now you can specify partitions is you want or you can be lazy like me and just install to the whole disk by selecting: Erase and use the entire disk.  Then click Forward.
disk_space
The VM will now be ready to install. Go over the summary and make sure everything is in order. Then click on the Install button. The install takes a while so go and get a well deserved beverage, preferably one with a lot of caffeine.
waiting
When the install is done you should shut down the Virtual Machine by clicking Restart Now and then clicking the close button in the upper right hand side of the window. and select: Power off the machine.
Now remove the iso from the CD/DVD drive by going into the settings for the VM, Selecting storage. Clicking on the BackTrack-5 iso then under Attributes select Host Drive ‘D:’ <- In my case it was D: it may be different depending on your setup. Then click OK. Or select Remove virtual disk from drive.
Now Click on the VM again and click the Start button.
At the login screen type in: root for the username and toor for the password. These are the default passwords for all BackTrack releases. So since just about everybody and their mother knows them it would be prudent for the first thing you do is to change the root password. Do this by typing:
   1: passwd
Now enter your new password make sure to keep it in a safe place if you decide to write it down. I suggest against writing it down and store it in KeePass.
You should also install any updates by using apt-get or aptitude. I’m a little old school and have apt-get ingrained in my head so that is what you will be getting.

   1:apt-get update
now
   1:apt-get –y upgrade

Installing VirtualBox Guest Additions

The VirtualBox Guest Additions are a set of kernel extensions and configuration changes that will make the BackTrack install a bit more user and GUI friendly. It allows for screen resizing as well as the ability to automatically move the cursor from the VM to the Host OS without having to press the release cursor short cut.
Before we can install the Guest Additions we will need to get the kernel sources installed and configured on the VM. Do this by running:
   1:prepare-kernel-sources
   2:cd /usr/src/linux
   3:cp -rf include/generated/* include/linux/
FYI - The above was taken verbatim from the Backtrack-Linux wiki. I want to make sure to give credit where credit is due. They have a great wiki over there and I highly suggest looking at their tutorials.
You will need the following environment variable as well KERN_DIR. To get it in place type:
   1: KERN_DIR=/usr/src/linux
   2: export KERN_DIR
 
Now that the prerequisites are met we can install the Guest Additions. Let’s do it from the GUI. Start the xserver with
   1: startx
In the upper left hand of the VM window click on Devices –> Install Guest Additions. This will mount a virtual CD drive that contains the Guest Additions script. Mine was mounted under:
/media/VBOXADDITIONS_4.0.4_69151/
An easy way to do this is to click on the USB symbol in the lower right hand side of the BackTrack VM and click on VBOXADDITIONS_4.0.0.xxxxx under Optical Disc. This will open it up in Dolphin. Now you can click on the VBoxLinuxAdditions.run shell script.
additions
This will compile and install the Guest Additions. When the script is done press Return/Enter to close the shell. Now restart your VM.
That should be it, You should now be all set up to run BackTrack 5 inside VirtualBox.
If you have any issues or find any error with the tutorial let me know and I'll do what I can to fix it ASAP. Enjoy!

7 comments:

Lord said...

i did this and had a problem with the box additions
the program dolphin didn't open up
i installed btrack5 on my macbook pro in a oracle vbox everything worked perfectly except the box additions

Peter said...

Lord,
did you try to open the Dolphin program (you have to do it manually) in BackTrack? It's on the lower left menu bar, the file cabinet. From there you should see the VBOX cd on the left.

cutting-edge-interest said...

I'm also on a mac and the instructions didn't work for me, so I I used this command

cp /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso Desktop/VBoxGuestAdditions.iso

to copy the iso to my desktop where virtualbox could see it. I then mounted it like a normal cd in virtualbox and ran the shell script.

Unknown said...

Lord,

Sorry for not getting back to you sooner. My doctors messed up a procedure and I ended up in the hospital again. I have noticed that sometimes the Guest Additions cd will not mount the first time you try to mount it. Try going to Devices –> Install Guest Additions again. There are a few different ways to proceed from here. First you can try to open up Dolphin by clicking on the little file cabinet icon in the lower left hand side of the screen (in the GUI). If it is mounted you should see the CD named VBOXADDITIONS_4.0.0_69151(or something similar). Make sure to follow my directions on setting the KERN_DIR variable. Double click on it and then double click on VBoxLinuxAdditions.run to run the installer.

You can also do this vi the command line. Open up a terminal window and type in:

cd /media/

then type

ls

This should show you a few directories on named cdrom/ and another named VBOXADDITIONS_4.0.4_69151 (the last 5 digits may differ) if you don;t see the VBOXADDITIONS folder go the Devices -> Install Guest Additions again and then try to do a ls again to see if it was mounted. Once you see the VBOXADDITIONS folder type

cd VBOXADDITIONS_4.0.0_69151

now type

./VBoxLinuxAdditions.run


This will run the script to compile the Guest Additions.

Now Reboot and the Guest Additions will be available to the Backtrack VM.

--ian

Unknown said...

cutting-edge-interest,

Thanks for sharing your workaround for OS X.

--ian

EnlightenMe said...

I have been following your steps and I am hitting a snag after I mount the iso... I go to start the VM and I get a box that says "Virtual Box Error- Failed to open a session for the virtual machine Back Track 5". Do you think you could hep me out?

Unknown said...

Ev,

Looking at the error and doing some searching it looks like it may be a permissions issue with your VirtualBox install folder. I saw some references to the same error here: http://goo.gl/Mahmj Hopefully that post can get you on the right track.

--ian