Use "pip" versions of Capstone and Unicorn (#176)

* Use Pip version of Unicorn

* Remove capstone submodule

* Allow installation to the user site-packages for Darwin, since SIP prevents installation to the system site-packages

* Add helper functions and fix Python calls

* Remove duplicated code (rebase issues?)
pull/172/merge
Zach Riggle 9 years ago committed by GitHub
parent edf4737c91
commit 8ee0208cb7

8
.gitmodules vendored

@ -1,8 +0,0 @@
[submodule "capstone"]
path = capstone
url = https://github.com/aquynh/capstone
branch = next
[submodule "unicorn"]
path = unicorn
url = https://github.com/unicorn-engine/unicorn
branch = master

@ -1 +0,0 @@
Subproject commit 9edf92cccd0bb0b77d19587015b9eaba2833d73c

@ -19,3 +19,5 @@ psutil>=3.1.0
python-ptrace>=0.8
six
future
unicorn>=1.0.0
capstone

@ -7,3 +7,5 @@ isort
six
future
ROPgadget
unicorn>=1.0.0
https://github.com/aquynh/capstone/archive/next.zip#subdirectory=bindings/python

@ -1,7 +1,26 @@
#!/bin/bash
set -ex
if uname | grep -i Linux &>/dev/null; then
# Helper functions
linux() {
uname | grep -i Linux &>/dev/null
}
osx() {
uname | grep -i Darwin &>/dev/null
}
PYTHON=''
INSTALLFLAGS=''
if osx || [ "$1" == "--user" ]; then
INSTALLFLAGS="--user"
else
PYTHON="sudo "
fi
if linux; then
sudo apt-get update || true
sudo apt-get -y install gdb python-dev python3-dev python-pip python3-pip libglib2.0-dev libc6-dbg
@ -20,34 +39,26 @@ git submodule update --init --recursive
# Find the Python version used by GDB.
PYVER=$(gdb -batch -q --nx -ex 'pi import platform; print(".".join(platform.python_version_tuple()[:2]))')
PYTHON=$(gdb -batch -q --nx -ex 'pi import sys; print(sys.executable)')
PYTHON="${PYTHON}${PYVER}"
PYTHON+=$(gdb -batch -q --nx -ex 'pi import sys; print(sys.executable)')
PYTHON+="${PYVER}"
# Find the Python site-packages that we need to use so that
# GDB can find the files once we've installed them.
SITE_PACKAGES=$(gdb -batch -q --nx -ex 'pi import site; print(site.getsitepackages()[0])')
if linux && [ -z "$INSTALLFLAGS" ]; then
SITE_PACKAGES=$(gdb -batch -q --nx -ex 'pi import site; print(site.getsitepackages()[0])')
INSTALLFLAGS="--target ${SITE_PACKAGES}"
fi
# Make sure that pip is available
if ! ${PYTHON} -m pip -V; then
sudo ${PYTHON} -m ensurepip --upgrade
${PYTHON} -m ensurepip ${INSTALLFLAGS} --upgrade
fi
# Upgrade pip itself
sudo ${PYTHON} -m pip install --upgrade pip
${PYTHON} -m pip install ${INSTALLFLAGS} --upgrade pip
# Install Python dependencies
sudo ${PYTHON} -m pip install --target ${SITE_PACKAGES} -Ur requirements.txt
# Install both Unicorn and Capstone
for directory in capstone unicorn; do
pushd $directory
UNICORN_QEMU_FLAGS="--python=$(which python2)" ./make.sh
sudo UNICORN_QEMU_FLAGS="--python=$(which python2)" ./make.sh install
cd bindings/python
sudo ${PYTHON} setup.py install
popd
done
${PYTHON} -m pip install ${INSTALLFLAGS} -Ur requirements.txt
# Load Pwndbg into GDB on every launch.
if ! grep pwndbg ~/.gdbinit &>/dev/null; then

@ -1 +0,0 @@
Subproject commit 37bf1a9de9e6469c003fc942dd7dc7324edbc275
Loading…
Cancel
Save