mirror of https://github.com/pwndbg/pwndbg.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.6 KiB
Bash
67 lines
1.6 KiB
Bash
#!/bin/bash
|
|
set -ex
|
|
|
|
|
|
# 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
|
|
|
|
if uname -m | grep x86_64 > /dev/null; then
|
|
sudo apt-get install libc6-dbg:i386 || true
|
|
fi
|
|
fi
|
|
|
|
if ! hash gdb; then
|
|
echo 'Could not find gdb in $PATH'
|
|
exit
|
|
fi
|
|
|
|
# Update all submodules
|
|
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+="${PYVER}"
|
|
|
|
# Find the Python site-packages that we need to use so that
|
|
# GDB can find the files once we've installed them.
|
|
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
|
|
${PYTHON} -m ensurepip ${INSTALLFLAGS} --upgrade
|
|
fi
|
|
|
|
# Upgrade pip itself
|
|
${PYTHON} -m pip install ${INSTALLFLAGS} --upgrade pip
|
|
|
|
# Install Python dependencies
|
|
${PYTHON} -m pip install ${INSTALLFLAGS} -Ur requirements.txt
|
|
|
|
# Load Pwndbg into GDB on every launch.
|
|
if ! grep pwndbg ~/.gdbinit &>/dev/null; then
|
|
echo "source $PWD/gdbinit.py" >> ~/.gdbinit
|
|
fi
|