diff --git a/scripts/gef.sh b/scripts/gef.sh index 4c6e8a4e9..6c97f9905 100755 --- a/scripts/gef.sh +++ b/scripts/gef.sh @@ -2,16 +2,9 @@ set -e -curl_found=0 -wget_found=0 - # check dependencies -if [ "$(command -v curl)" ]; then - curl_found=1 -elif [ "$(command -v wget)" ]; then - wget_found=1 -else - echo "The installer requires cURL or wget installed." +if [ ! "$(command -v python3)" ]; then + echo "GEF requires Python3 installed." exit 1 fi @@ -20,24 +13,13 @@ if [ -f "${HOME}/.gdbinit" ]; then mv "${HOME}/.gdbinit" "${HOME}/.gdbinit.old" fi -if [ $wget_found -eq 1 ]; then - # Get the tag of the latest stable - tag=$(wget -q -O- "https://api.github.com/repos/hugsy/gef/tags" | grep "name" | head -1 | sed -e 's/"name": "\([^"]*\)",/\1/' -e 's/ *//') - - # Download the file - wget -q "https://github.com/hugsy/gef/raw/${tag}/gef.py" -O "${HOME}/.gef-${tag}.py" -elif [ $curl_found -eq 1 ]; then - # Get the tag of the latest stable - tag=$(curl -s "https://api.github.com/repos/hugsy/gef/tags" | grep "name" | head -1 | sed -e 's/"name": "\([^"]*\)",/\1/' -e 's/ *//') - - # Download the file - curl --silent --location --output "${HOME}/.gef-${tag}.py" "https://github.com/hugsy/gef/raw/${tag}/gef.py" -fi +tag=$(python3 -c 'import urllib.request as r,json as j; x=j.loads(r.urlopen("https://api.github.com/repos/hugsy/gef/tags").read()); print(x[0]["name"])') +python3 -c "import urllib.request as r; x=r.urlopen('https://github.com/hugsy/gef/raw/${tag}/gef.py').read(); print(x.decode('utf-8'))" > ${HOME}/.gef-${tag}.py if [ -f "${HOME}/.gef-${tag}.py" ]; then echo "source ~/.gef-${tag}.py" > ~/.gdbinit exit 0 else echo "GEF was not properly downloaded" - exit 1 + exit 2 fi