Skip to content

Instantly share code, notes, and snippets.

@SunnyRaj
Last active September 29, 2017 16:12
Show Gist options
  • Save SunnyRaj/2718865397d09eea152714dacda03bc9 to your computer and use it in GitHub Desktop.
Save SunnyRaj/2718865397d09eea152714dacda03bc9 to your computer and use it in GitHub Desktop.
CRIMES 4.9 install script with support for Remus
#!/bin/bash
####################################################
# CRIMES 4.9 install script with support for Remus #
# NOT YET TESTED - Use gcc-6 #
####################################################
set -e
CRIMESDIR=""
LIBVMIDIR=""
verify_install() {
set +e
res=`sudo xen-detect > /dev/null 2>&1 `
if [ $? == 0 ]
then
echo -e "ERROR! Xen already installed"
echo -e "Xen is already installed on this machine. Installing over the"
echo -e "current version will cause problems. If you really want to do this,"
echo -e "please comment out line 186 in this script and re-run."
exit 3
fi
set -e
}
install_dependencies() {
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install -y grub-customizer
sudo apt-get install -y wget git bcc bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools pciutils-dev build-essential make gcc clang libc6-dev libc6-dev-i386 linux-libc-dev zlib1g-dev python python-dev python-twisted python-gevent python-setuptools libncurses5-dev patch libvncserver-dev libssl-dev libsdl-dev iasl libbz2-dev e2fslibs-dev git-core uuid-dev ocaml libx11-dev bison flex ocaml-findlib xz-utils gettext libyajl-dev libpixman-1-dev libaio-dev libfdt-dev cabextract libglib2.0-dev autoconf automake libtool check libjson-c-dev libfuse-dev libsystemd-dev checkpolicy liblzma-dev
}
remus_dependencies() {
# Dependencies for Remus network buffering
sudo apt-get install -y libnl-3-200-dbg libnl-cli-3-200 libnl-genl-3-200 libnl-nf-3-200 libnlopt0 libnlopt-guile0 libnl-route-3-dev libnl-3-200 libnl-3-dev libnl-cli-3-dev libnl-genl-3-dev libnl-nf-3-dev libnlopt-dev libnl-route-3-200 libnl-utils
}
clone_crimes_repo() {
cd $HOME
GITREPO="https://github.com/SunnyRaj/crimes-4.9.git"
git clone $GITREPO
BASE=`basename $GITREPO`
CRIMESDIR="${BASE%.*}"
cd $CRIMESDIR
}
clone_libvmi_repo() {
cd $HOME
LIBVMIREPO="https://github.com/libvmi/libvmi.git"
git clone $LIBVMIREPO
BASE=`basename $LIBVMIREPO`
LIBVMIDIR="${BASE%.*}"
}
build_install_libvmi() {
cd $LIBVMIDIR
./autogen.sh
./configure --disable-kvm
make -j$(nproc)
sudo sh -c "make install -j$(nproc)"
}
build_install_memevents () {
cd $HOME
cd $CRIMESDIR/tools/
git fetch
git checkout -b memevents origin/memevents
sudo sh -c "make clean -j$(nproc)"
sudo sh -c "make -j$(nproc)"
sudo sh -c "make install -j$(nproc)"
}
xen_postinstall() {
echo ""
echo "Create the Xen bridge for networking. To do so, assure the /etc/network/interfaces file looks like this:"
echo "
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
# Change em1 to whatever interface the system has
iface em1 inet manual
auto xenbr0
iface xenbr0 inet dhcp
bridge_ports em1
"
echo "[ENTER] to continue: "
read ENT
echo ""
echo "Then, log into the server using X11 forwarding and run \"sudo grub-customizer\""
echo "Select Linux with Xen as the default kernel to boot"
echo "[ENTER] to continue: "
read ENT
}
build_install_xen() {
echo "****************************************"
echo "********** Installing Xen 4.9 **********"
echo "****************************************"
sleep 1
# Build and install
./configure --enable-githttp
make -j$(nproc) dist-xen
make -j$(nproc) dist-tools
sudo sh -c "make -j$(nproc) install-xen"
sudo sh -c "make -j$(nproc) install-tools"
# Set up Dom0 to have AltP2m Support
sudo sh -c "echo \"GRUB_CMDLINE_XEN_DEFAULT=\\\"altp2m=1\\\"\" >> /etc/default/grub"
# Link the libraries
sudo sh -c "echo \"/usr/local/lib\" > /etc/ld.so.conf.d/xen.conf"
sudo /sbin/ldconfig
# Setup XenFS in fstab file
sudo sh -c "echo \"\" >> /etc/fstab"
sudo sh -c "echo \"#XenFS\" >> /etc/fstab"
sudo sh -c "echo \"none /proc/xen xenfs defaults,nofail 0 0\" >> /etc/fstab"
# Setup Xen kernel modules to load upon boot
sudo sh -c "echo \"xen-evtchn\" >> /etc/modules"
sudo sh -c "echo \"xen-privcmd\" >> /etc/modules"
# Setup init scripts
sudo sh -c "update-rc.d xencommons defaults 19 18"
sudo sh -c "update-rc.d xendomains defaults 21 20"
sudo sh -c "update-rc.d xen-watchdog defaults 22 23"
echo ""
echo "************************************************"
echo "********** Finished Instaling Xen 4.9 **********"
echo "************************************************"
}
main()
{
verify_install
install_dependencies
remus_dependencies
clone_crimes_repo
build_install_xen
clone_libvmi_repo
build_install_libvmi
build_install_memevents
xen_postinstall
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment