forked from pwndbg/pwndbg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·66 lines (51 loc) · 1.59 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/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