Created
October 25, 2025 03:41
-
-
Save toratako/ae307224c40a0c2fe0c2d2f368e51907 to your computer and use it in GitHub Desktop.
Install bata24/gef on Arch Linux.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh -ex | |
| # Original: https://github.com/bata24/gef/blob/dev/install-uv.sh | |
| # License: https://github.com/bata24/gef/blob/dev/LICENSE | |
| # Modified for Arch Linux support. | |
| echo "[+] Configuration" | |
| GEF_REPO_URL="https://raw.githubusercontent.com/bata24/gef/dev/gef.py" | |
| GEF_REPO_BRANCH="dev" | |
| RP_VERSION="v2.1.4" | |
| RP_DOWNLOAD_URL="https://github.com/0vercl0k/rp/releases/download/${RP_VERSION}/rp-lin-clang.zip" | |
| PYTHON_LZO_COMMIT="b4e39df" | |
| VMLINUX_TO_ELF_REPO="https://github.com/marin-m/vmlinux-to-elf" | |
| PYTHON_LZO_REPO="https://github.com/clubby789/python-lzo@${PYTHON_LZO_COMMIT}" | |
| echo "[+] Initialize" | |
| GDBINIT_PATH="/root/.gdbinit" | |
| GEF_DIR="/root/.gef" | |
| GEF_PATH="${GEF_DIR}/gef.py" | |
| GEF_VENV_CONF_PATH="${GEF_DIR}/gef.venv.conf" | |
| GEF_VENV_PATH="${GEF_DIR}/.venv-gef" | |
| GEF_VENV_BIN_PATH="${GEF_VENV_PATH}/bin" | |
| echo "[+] User check" | |
| if [ "$(id -u)" != "0" ]; then | |
| echo "[-] Detected non-root user." | |
| echo "[-] INSTALLATION FAILED" | |
| exit 1 | |
| fi | |
| echo "[+] Check if another gef is installed" | |
| if [ -e "${GEF_PATH}" ]; then | |
| echo "[-] ${GEF_PATH} already exists. Please delete or rename." | |
| echo "[-] INSTALLATION FAILED" | |
| exit 1 | |
| fi | |
| echo "[+] Create .gef directory" | |
| if [ ! -e "${GEF_DIR}" ]; then | |
| mkdir -p "${GEF_DIR}" | |
| fi | |
| echo "[+] pacman" | |
| pacman -Sy --noconfirm | |
| pacman -S --noconfirm --needed gdb wget uv | |
| pacman -S --noconfirm --needed binutils python gcc make ruby git file colordiff imagemagick bpf file | |
| pacman -S --noconfirm --needed binwalk | |
| echo "[+] Setup venv" | |
| if [ ! -e "${GEF_VENV_PATH}" ]; then | |
| uv venv "${GEF_VENV_PATH}" | |
| fi | |
| . "${GEF_VENV_PATH}/bin/activate" | |
| echo "[+] pip3" | |
| uv pip install setuptools crccheck unicorn capstone ropper keystone-engine tqdm magika codext angr pycryptodome pillow pyzbar | |
| echo "[+] Install seccomp-tools" | |
| if [ -z "$(command -v seccomp-tools)" ]; then | |
| GEM_HOME="${GEF_VENV_PATH}" gem install seccomp-tools | |
| fi | |
| echo "[+] Install one_gadget" | |
| if [ -z "$(command -v one_gadget)" ]; then | |
| GEM_HOME="${GEF_VENV_PATH}" gem install one_gadget | |
| fi | |
| echo "[+] Install rp++" | |
| if [ "$(uname -m)" = "x86_64" ]; then | |
| if [ -z "$(command -v rp-lin)" ]; then | |
| wget -q "${RP_DOWNLOAD_URL}" -P /tmp | |
| unzip /tmp/rp-lin-clang.zip -d "${GEF_VENV_BIN_PATH}" | |
| rm /tmp/rp-lin-clang.zip | |
| fi | |
| fi | |
| echo "[+] Install vmlinux-to-elf" | |
| if [ -z "$(command -v vmlinux-to-elf)" ]; then | |
| uv pip install --upgrade lz4 zstandard "git+${PYTHON_LZO_REPO}" | |
| uv pip install --upgrade "git+${VMLINUX_TO_ELF_REPO}" | |
| fi | |
| echo "[+] Download gef" | |
| wget -q "${GEF_REPO_URL}" -O "${GEF_PATH}" | |
| if [ ! -s "${GEF_PATH}" ]; then | |
| echo "[-] Downloading ${GEF_PATH} failed." | |
| rm -f "${GEF_PATH}" | |
| echo "[-] INSTALLATION FAILED" | |
| exit 1 | |
| fi | |
| echo "[+] Setup gef" | |
| STARTUP_COMMAND="python sys.path.insert(0, \"${GEF_DIR}\"); from gef import *; Gef.main()" | |
| if [ ! -e "${GDBINIT_PATH}" ] || [ -z "$(grep "from gef import" "${GDBINIT_PATH}")" ]; then | |
| echo "${STARTUP_COMMAND}" >> "${GDBINIT_PATH}" | |
| fi | |
| echo "[+] Setup venv path hint file" | |
| GEF_VENV_SYS_PATH=$(python3 -c " | |
| import sys, subprocess | |
| try: | |
| gdb_output = subprocess.getoutput('gdb -q -nx -ex \"pi sys.path\" -ex q') | |
| gdb_paths = eval(gdb_output) | |
| diff_paths = set(sys.path) - set(gdb_paths) - set(['']) | |
| print(':'.join(diff_paths)) | |
| except: | |
| print(':'.join(sys.path)) | |
| ") | |
| echo "GEF_VENV_GEM_HOME=${GEF_VENV_PATH}" >> ${GEF_VENV_CONF_PATH} | |
| echo "GEF_VENV_SYS_PATH=${GEF_VENV_SYS_PATH}" >> ${GEF_VENV_CONF_PATH} | |
| echo "GEF_VENV_BIN_PATH=${GEF_VENV_BIN_PATH}" >> ${GEF_VENV_CONF_PATH} | |
| echo "[+] INSTALLATION SUCCESSFUL" | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment