# πŸ“Œ How to Install GDB-PEDA (Python 3) – Clean, Modern, and Not Painful <small>Running into ImportError: No module named six.moves while installing gdb-peda? β†’ Here’s the quick fix! </small> --- ## 1. Install GDB + basic dependencies ```yaml sudo apt update sudo apt install -y gdb python3-six python3-dev git ``` - `gdb` β†’ the main debugger - `python3-six` β†’ required by PEDA - `python3-dev` β†’ needed so GDB embeds Python3 correctly - `git` β†’ for cloning PEDA ### 2. Clone PEDA ```yaml cd ~ git clone https://github.com/longld/peda.git ~/peda ``` ### 3. Check module `six` & sys.path cα»§a Python trong GDB ```yaml gdb -ex "python import sys; print('PYTHON', sys.version) ; print('PATH', sys.path)" -ex quit ``` ### 4. Force PEDA to use Python 3 + fix sys.path + load `six` - Replace shebang in `peda.py` (force python3): ```yaml sed -i '1s|.*|#!/usr/bin/env python3|' ~/peda/peda.py ``` - Create a clean `~/.gdbinit` (no spam warnings, guarantee six loads, and load PEDA): ```yaml cp -v ~/.gdbinit ~/.gdbinit.bak 2>/dev/null || true cat > ~/.gdbinit <<'GDBFIX' python import sys, warnings warnings.filterwarnings("ignore") for p in ( '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/usr/local/lib/python3.12/dist-packages', '/usr/lib/python3/dist-packages' ): if p not in sys.path: sys.path.append(p) try: import six except Exception as e: print("Warning: cannot import six:", e) end source ~/peda/peda.py GDBFIX ``` <span style="font-size: 0.70em;">Just paste this whole thing into your terminal and hit Enter.</span> ### 5. Verify that GDB loads Python3, six, and PEDA ```yaml gdb -ex "python import sys; print('GDB-PY', sys.version)" -ex quit gdb -ex "python import six; print('six ok', six.__version__)" -ex quit # then run GDB normally gdb /bin/ls ``` If everything is correct β†’ you’ll see this prompt:: ``` gdb-peda$ ``` --- # If you're lazy 😴 πŸ‘‰ Just save this script as a `.sh` file β†’ `chmod +x *.sh` β†’ run it: ```swift #!/bin/bash set -e echo "[*] Installing GDB + Python3-six + Git ..." sudo apt update -y sudo apt install -y gdb python3-six git echo "[*] Cloning PEDA ..." if [ ! -d "$HOME/peda" ]; then git clone https://github.com/longld/peda.git ~/peda else echo "[*] ~/peda exists, skip cloning." fi echo "[*] Fixing shebang to force Python3 ..." sed -i '1s|.*|#!/usr/bin/env python3|' ~/peda/peda.py echo "[*] Backing up old ~/.gdbinit if exists ..." cp -v ~/.gdbinit ~/.gdbinit.bak 2>/dev/null || true echo "[*] Writing new ~/.gdbinit ..." cat > ~/.gdbinit <<'GDBFIX' python import sys, warnings warnings.filterwarnings("ignore") for p in ( '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/usr/local/lib/python3.12/dist-packages', '/usr/lib/python3/dist-packages' ): if p not in sys.path: sys.path.append(p) try: import six except Exception as e: print("Warning: cannot import six:", e) end source ~/peda/peda.py GDBFIX echo "[+] Done!" ``` <span style="font-size: 0.70em;">But honestly, I'd still recommend doing it manually β€” this script was cooked by ChatGPT 🀑</span>