Introduced install possibility via python virtualenv and pip and switched pwntools and binjitsu to it

This commit is contained in:
Michael Rodler 2016-02-18 16:33:31 +01:00
parent b84c8f9b06
commit 254eaf71ec
8 changed files with 76 additions and 30 deletions

34
bin/ctf-tools-pip Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
set -e -o pipefail
PY_VERSION=2
if [[ "$0" =~ \.+pip3 ]]; then
PY_VERSION=3
fi
if [[ "$0" =~ \.+pip2 ]]; then
PY_VERSION=2
fi
CTF_TOOLS_VE="ctftools"
if [[ "PY_VERSION" -eq 3 ]]; then
CTF_TOOLS_VE="${CTF_TOOLS_VE}3"
fi
export WORKON_HOME=~/.virtualenvs
if [[ ! -d "$WORKON_HOME" ]]; then
mkdir -p "$WORKON_HOME"
fi
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source $(which virtualenvwrapper.sh)
if ! workon "$CTF_TOOLS_VE" 2>&1 1>/dev/null; then
echo "#### Creating python#PY_VERSION virtualenv '$CTF_TOOLS_VE' ####" >&2
# for some reason mkvirtualenv returns non-zero even if it
# succeeds?
mkvirtualenv -p $(which "python$PY_VERSION") "$CTF_TOOLS_VE" || true
echo "#### Switching to '$CTF_TOOLS_VE' virtualenv" >&2
workon "$CTF_TOOLS_VE" || (deactivate && workon "$CTF_TOOLS_VE")
fi
exec pip "$@"

1
bin/ctf-tools-pip3 Symbolic link
View file

@ -0,0 +1 @@
ctf-tools-pip

3
binjitsu/install Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash -e
ctf-tools-pip install --upgrade 'git+https://github.com/binjitsu/binjitsu.git'

17
binjitsu/install-root Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash -e
case "$DISTRI" in
"debian")
apt-add-repository -y ppa:pwntools/binutils
apt-get update
apt-get -y install binutils-.*-linux-gnu
;;
"archlinux")
pacman -Syu --noconfirm binutils
;;
*)
echo "Unknown distribution"
exit 1
;;
esac

3
binjitsu/uninstall Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash -e
ctf-tools-pip uninstall binjitsu

View file

@ -1,30 +1,4 @@
#!/bin/bash -e
# pwnutils
git clone --depth 1 https://github.com/Gallopsled/pwntools.git
cd pwntools
pip install -r requirements.txt
cd ..
# binutils
#curl https://ftp.gnu.org/gnu/binutils/binutils-2.25.tar.gz | tar xz
#mkdir binutils-build
#cd binutils-build
#export AR=ar
#export AS=as
#../binutils-2.25/configure --prefix=$(dirname $PWD)/binutils-inst --enable-multilib
#make -j $(nproc)
#make install
mkdir -p bin
cd bin
for i in $(yes n | pip uninstall pwntools | grep bin)
do
mv $i $(basename $i).real
cat <<END > $(basename $i)
#!/bin/bash
PATH=/usr/bin:\$PATH $PWD/$(basename $i).real "\$@"
END
chmod 755 $(basename $i)
done
cd ..
ctf-tools-pip install --upgrade 'git+https://github.com/Gallopsled/pwntools.git'

View file

@ -1,6 +1,17 @@
#!/bin/bash -e
case "$DISTRI" in
"debian")
apt-add-repository -y ppa:pwntools/binutils
apt-get update
apt-get -y install binutils-.*-linux-gnu
;;
"archlinux")
pacman -Syu --noconfirm binutils
;;
*)
echo "Unknown distribution"
exit 1
;;
esac

3
pwntools/uninstall Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash -e
ctf-tools-pip uninstall pwntools || true