A short guide on building a Vagrant box from the Hacking: The Art of Exploitation, 2nd Edition LiveCD.
Create a new blank 32-bit Linux machine via VirtualBox UI (or console) and name it however you like. Insert the ISO file as a Live CD and boot.
Once up, install the OS via desktop icon. When prompted for user/pass, use "vagrant" for both. "Eject" the virtual CD and reboot.
The supplied /etc/apt/sources.list is stale, so update it to contain
the following:
# Required
deb http://old-releases.ubuntu.com/ubuntu/ feisty main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ feisty-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ feisty-security main restricted universe multiverse
# Optional
deb http://old-releases.ubuntu.com/ubuntu/ feisty-backports main restricted universe multiverse
Now install openssh:
$ sudo apt-get update
$ sudo apt-get install openssh-serverTo prevent Error opening terminal: xterm-256color when ssh-ing,
install ncurses-term which provides /usr/share/terminfo/x/xterm-256color:
$ sudo apt-get install ncurses-termFollow the procedure described here to provide an insecure SSH key pair.
Run visudo and allow passwordless sudo for the "vagrant" user. This
can be done with the following line in the configuration file:
vagrant ALL=(ALL) NOPASSWD: ALL
Set this option for root and the admin group as well.
Set root's password to "vagrant" too:
$ sudo su
$ passwdThe sudo binary itself is ancient and might present problems since
it doesn't support the -E switch which Vagrant depends on by
default.
We can build a newer one while we're at it:
$ wget ftp://ftp.sudo.ws/pub/sudo/sudo-1.8.16.tar.gz
$ tar xzvf sudo-1.8.16.tar.gz && cd sudo-1.8.16
$ ./configure && make
$ sudo make install
$ cd - && rm -rf sudo*Confirm that
$ sudo -Vreturns 1.8.16. You might need to start a new shell session.
Vagrant init a folder on host and set the machine id like described here.
Try booting the guest and connecting to it:
$ vagrant up
$ vagrant sshOn the guest, install VBoxGuestAdditions. You'll need to mount the iso, then
$ cd /media/cdrom
$ sh VBoxLinuxAdditions.runIt's expected to fail, due to warning flags unsupported by the old version of gcc. Instead of upgrading the toolchain, which may affect disassembling later, drop the warning flags.
On the guest machine, grep for the offending switches:
$ cd /opt/VBoxGuestAdditions-x.y.z
$ grep -nri no-declaration-after-statement .
$ grep -nri no-pie .
and remove them from the Makefiles. Now run:
$ sudo init/vboxadd setup
Reload the machine and try to share a folder.
In your Vagrantfile:
config.vm.synced_folder "src", "/home/vagrant/src"host$ mkdir src
guest$ cp booksrc srcThe box is usable right now, but you can package it from the host if you want to:
$ vagrant package --output hacking.box
$ vagrant box add hacking-box hacking.box
Then, to use it:
$ vagrant init hacking-box
$ vagrant up
$ vagrant ssh