diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 1aa51dbdc..000000000 --- a/.gitmodules +++ /dev/null @@ -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 diff --git a/capstone b/capstone deleted file mode 160000 index 9edf92ccc..000000000 --- a/capstone +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9edf92cccd0bb0b77d19587015b9eaba2833d73c diff --git a/docs/requirements.txt b/docs/requirements.txt index 502429ec2..df0255c1c 100755 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -19,3 +19,5 @@ psutil>=3.1.0 python-ptrace>=0.8 six future +unicorn>=1.0.0 +capstone diff --git a/requirements.txt b/requirements.txt index f819babc9..e0d356644 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,5 @@ isort six future ROPgadget +unicorn>=1.0.0 +https://github.com/aquynh/capstone/archive/next.zip#subdirectory=bindings/python \ No newline at end of file diff --git a/setup.sh b/setup.sh index e788f3d8f..69c30110e 100755 --- a/setup.sh +++ b/setup.sh @@ -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 diff --git a/unicorn b/unicorn deleted file mode 160000 index 37bf1a9de..000000000 --- a/unicorn +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 37bf1a9de9e6469c003fc942dd7dc7324edbc275