qira/install.sh
Ivan Gotovchits 222d6da4f0 Add BAP as backend.
This PR introduces bap as a backend for QIRA.
The backend is made optional, but is enabled by default.

This backend allows one to disassemble instructions for all platforms,
supported by LLVM (at the time of writing it is about 25 targets).

Also, to some platforms BAP will provide BIL and/or target specific
instructions, lifted to first class python values, as opposed to
strings.

A new instruction class is introduces, that will use BIL if available to
infer destinations, as well as to infer registers touched or modified by
the instruction. Using, BIL allows us to determine instructions like
`pop {r0, pc}` as calls, that, as a consequence, allows us to build a
more correct CFG. As a drawback on ARM platform the built CFG is so big,
that it takes a considerable amount of time just to draw it.

Since BAP can provide a reasonable analysis for all platforms, including
those that at the time of writing still doesn't have a BIL support, the
static analysis in QIRA will be always turned on.

BAP is installed using opam, and BAP Python bindings a downloaded
directly from the git repository using pip.

As a free bonus, this PR will also fix Travis CI issue.
2015-01-29 09:21:05 -05:00

76 lines
2.2 KiB
Bash
Executable File

#!/bin/bash -e
# default is just pip, but on things like arch where python 3 is default, it's pip2
PIP="pip"
unamestr=$(uname)
if [[ "$unamestr" == 'Linux' ]]; then
# we need pip to install python stuff
# build for building qiradb and stuff for flask like gevent
if [ $(which apt-get) ]; then
echo "installing apt packages"
sudo apt-get update -qq
sudo apt-get -y install build-essential python-dev python-pip debootstrap libjpeg-dev zlib1g-dev unzip wget graphviz
# only python package we install globally
sudo $PIP install virtualenv
elif [ $(which pacman) ]; then
echo "installing pip"
sudo pacman -S base-devel python2-pip
PIP="pip2"
elif [ $(which yum) ]; then
sudo yum install python-pip python-devel gcc gcc-c++ python-virtualenv glib2-devel
fi
if [ $(qemu/qira-i386 > /dev/null; echo $?) == 1 ]; then
echo "QIRA QEMU appears to run okay"
else
echo "building QEMU"
./qemu_build.sh
fi
fi
# we install more than we strictly need here, because pip is so easy
# should this use sudo?
# can ./qiradb go in requirements?
echo "installing pip packages"
virtualenv venv
source venv/bin/activate
$PIP install --upgrade -r requirements.txt
# build capstone if we don't have it
if [ $(python -c "import capstone; exit(69 if (capstone.cs_version() == capstone.version_bind() and capstone.cs_version()[0] == 3) else 0)"; echo $?) == 69 ]; then
echo "capstone already installed, skipping"
else
./capstone_build.sh
fi
if [ -d bap -o "x$BAP" = "xdisable" ]; then
echo "Skipping BAP"
else
echo "Installing BAP"
export OPAMYES=1
export OPAMVERBOSE=1
export OPAMJOBS=4
echo 'yes' | sudo add-apt-repository ppa:avsm/ocaml42+opam12
sudo apt-get update -qq
sudo apt-get install -qq ocaml ocaml-native-compilers camlp4-extra opam
sudo apt-get install libgmp-dev llvm-3.4-dev time
opam init
opam install bap
$PIP install --upgrade git+git://github.com/BinaryAnalysisPlatform/bap.git
fi
echo "making symlink"
sudo ln -sf $(pwd)/qira /usr/local/bin/qira
echo "***************************************"
echo " Thanks for installing QIRA"
echo " Check out README for more info"
echo " Or just dive in with 'qira /bin/ls'"
echo " And point Chrome to localhost:3002"
echo " ~geohot"