Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gef.sh is now works on Ubuntu 21.04 (Hirsute Hippo) #699 #700

Merged
merged 1 commit into from
Aug 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions scripts/gef.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,39 @@
set -e

branch="master"
test "$1" == "dev" && branch="dev"
if [ "$1" = "dev" ]; then
branch="dev"
echo "set branch to dev"
fi

# check dependencies
if [ `which curl` ]; then
curl_found=1
elif [ `which wget` ]; then
wget_found=1
else
echo "Please install cURL or wget and run again"
exit 1
fi

# Backup gdbinit if any
test -f "${HOME}/.gdbinit" && mv "${HOME}/.gdbinit" "${HOME}/.gdbinit.old"
if [ -f "${HOME}/.gdbinit" ]; then
mv "${HOME}/.gdbinit" "${HOME}/.gdbinit.old"
fi

if [ $wget_found -eq 1 ]; then
# Get the hash of the commit
ref=$(wget -q -O- https://api.github.com/repos/hugsy/gef/git/ref/heads/${branch} | grep '"sha"' | tr -s ' ' | cut -d ' ' -f 3 | tr -d "," | tr -d '"')

# Get the hash of the commit
ref=$(curl --silent https://api.github.com/repos/hugsy/gef/git/ref/heads/${branch} | grep '"sha"' | tr -s ' ' | cut -d ' ' -f 3 | tr -d "," | tr -d '"')
# Download the file
wget -q "https://github.com/hugsy/gef/raw/${branch}/gef.py" -O "${HOME}/.gef-${ref}.py"
elif [ $curl_found -eq 1 ]; then
# Get the hash of the commit
ref=$(curl --silent https://api.github.com/repos/hugsy/gef/git/ref/heads/${branch} | grep '"sha"' | tr -s ' ' | cut -d ' ' -f 3 | tr -d "," | tr -d '"')

# Download the file
curl --silent --location --output "${HOME}/.gef-${ref}.py" "https://github.com/hugsy/gef/raw/${branch}/gef.py"
# Download the file
curl --silent --location --output "${HOME}/.gef-${ref}.py" "https://github.com/hugsy/gef/raw/${branch}/gef.py"
fi

# Create the new gdbinit
echo "source ~/.gef-${ref}.py" > ~/.gdbinit
Expand Down