diff --git a/bin/install_tool b/bin/install_tool index a807454..7fd4d6f 100755 --- a/bin/install_tool +++ b/bin/install_tool @@ -87,6 +87,7 @@ if [ -d ${DESTDIR} ] ; then fi fi +# Begin main tool selection case ${TOOL} in john) install_pkgs libssl-dev git build-essential yasm libgmp-dev libpcap-dev \ @@ -220,8 +221,28 @@ case ${TOOL} in src="https://github.com/trustedsec/ptf.git" git clone ${src} ${DESTDIR} ;; + pwndbg) + if ! which gdb > /dev/null 2>&1 ; then + echo 'No gdb available!' >/dev/stderr + exit 1 + fi + git clone --depth 1 -b stable https://github.com/pwndbg/pwndbg.git ${DESTDIR} + local PY_PACKAGES=${DESTDIR}/vendor + mkdir -p ${PY_PACKAGES} + local PYVER=$(gdb -batch -q --nx -ex 'pi import platform; print(".".join(platform.python_version_tuple()[:2]))') + local PYTHON=$(gdb -batch -q --nx -ex 'pi import sys; print(sys.executable)') + PYTHON="${PYTHON}${PYVER}" + ${PYTHON} -m pip install --target ${PY_PACKAGES} -Ur ${DESTDIR}/requirements.txt + ${PYTHON} -m pip install --target ${PY_PACKAGES} -U capstone unicorn + # capstone package is broken + cp ${PY_PACKAGES}/usr/lib/*/dist-packages/capstone/libcapstone.so ${PY_PACKAGES}/capstone + ;; *) echo "Unknown tool: ${TOOL}" >/dev/stderr + echo "Options:" >/dev/stderr + for opt in $(awk 'BEGIN {s=0;FS=")"};/main tool selection/{s=1};/^\s+\w+)$/{if(s==1){print $1}}' $0|sort); do + echo -e "\t${opt}" >/dev/stderr + done exit 1 ;; esac diff --git a/dotfiles/gdbinit b/dotfiles/gdbinit index c678f02..657e3d0 100644 --- a/dotfiles/gdbinit +++ b/dotfiles/gdbinit @@ -26,10 +26,10 @@ end python import sys import os.path -pwndbg = os.path.expanduser('~/.pwndbg/gdbinit.py') +pwndbg = os.path.expanduser('~/tools/pwndbg/gdbinit.py') peda = os.path.expanduser('~/.peda/peda.py') if os.path.isfile(pwndbg): - sys.path.insert(0, os.path.expanduser('~/.pwndbg/vendor')) + sys.path.insert(0, os.path.expanduser('~/tools/pwndbg/vendor')) gdb.execute('source {}'.format(pwndbg)) elif os.path.isfile(peda): gdb.execute('source {}'.format(peda)) diff --git a/install.sh b/install.sh index 64caad6..15956ff 100755 --- a/install.sh +++ b/install.sh @@ -102,24 +102,6 @@ add_bin_symlink() { ln -sf ${1} ${LINKNAME} } -# Custom version of pwndbg's installer -# TODO: move to install_tool.sh -install_pwndbg() { - if ! which gdb > /dev/null 2>&1 ; then - return 1 - fi - install_git -b stable https://github.com/pwndbg/pwndbg.git $HOME/.pwndbg - mkdir -p $HOME/.pwndbg/vendor - local PYVER=$(gdb -batch -q --nx -ex 'pi import platform; print(".".join(platform.python_version_tuple()[:2]))') - local PYTHON=$(gdb -batch -q --nx -ex 'pi import sys; print(sys.executable)') - PYTHON="${PYTHON}${PYVER}" - local PY_PACKAGES=$HOME/.pwndbg/vendor - ${PYTHON} -m pip install --target ${PY_PACKAGES} -Ur $HOME/.pwndbg/requirements.txt - ${PYTHON} -m pip install --target ${PY_PACKAGES} -U capstone unicorn - # capstone package is broken - cp ${PY_PACKAGES}/usr/lib/*/dist-packages/capstone/libcapstone.so ${PY_PACKAGES}/capstone -} - postinstall() { true } @@ -392,9 +374,6 @@ case $OPERATION in PKG_SET=${2:-minimal} install_pkg_set packages.${PKG_SET} ;; - pwndbg) - install_pwndbg - ;; test) # Do nothing, just sourcing set +o errexit