Skip to content Skip to sidebar Skip to footer

Tutorial Fix Bug Install PWNDBG di Kali Linux

GNU debugger (gdb) adalah program debugger yang digunakan pada system linux, biasanya di gunakan untuk mendebug application atau program di system linux. Disini yang kita gunakan adalah pwndbg fungsi pwndbg ini mempermudahkita dalam menggunakan fungsi-fungsi dalam debugger.

Untuk tutorial installasinya kalian dapat melakukan uninstall default gdb bawaan linux terlebih dahulu, agar dapat mempermudah konfigurasi pwngdb kepasa sistem gdb default.

 


Jalankan perintah uninstall gdb default:

$ sudo apt-get remove --purge gdb

$ sudo rm -rf /usr/share/gdb

Selanjutnya kita akan melakukan git clone dan installasi pwndbgnya:

$ sudo su

$ cd # agar menuju directory root

$ git clone https://github.com/pwndbg/pwndbg

$ cd pwndbg

Sebelum melakukan installasi kita akan rubah script setup.sh nya, kalian dapat mengcopy script yang sudah saya rubah seperti dibawah:

#!/bin/bash

set -ex


# If we are a root in a Docker container and `sudo` doesn't exist

# lets overwrite it with a function that just executes things passed to sudo

# (yeah it won't work for sudo executed with flags)

if [ -f /.dockerenv ] && ! hash sudo 2>/dev/null && whoami | grep root; then

    sudo() {

        ${*}

    }

fi


# Helper functions

linux() {

    uname | grep -i Linux &>/dev/null

}

osx() {

    uname | grep -i Darwin &>/dev/null

}


install_apt() {

    sudo apt-get update || true

    sudo apt-get install -y git gdb python3-dev python3-pip python3-setuptools libglib2.0-dev libc6-dbg


    if uname -m | grep x86_64 > /dev/null; then

        sudo dpkg --add-architecture i386 || true

        sudo apt-get update || true

        sudo apt-get install -y libc6-dbg:i386 || true

    fi

}


install_dnf() {

    sudo dnf update || true

    sudo dnf -y install gdb gdb-gdbserver python-devel python3-devel python-pip python3-pip glib2-devel make

    sudo dnf -y debuginfo-install glibc

}


install_xbps() {

    sudo xbps-install -Su

    sudo xbps-install -Sy gdb gcc python-devel python3-devel python-pip python3-pip glibc-devel make

    sudo xbps-install -Sy glibc-dbg

}


install_swupd() {

    sudo swupd update || true

    sudo swupd bundle-add gdb python3-basic make c-basic

}


install_zypper() {

    sudo zypper refresh || true

    sudo zypper install -y gdb gdbserver python-devel python3-devel python2-pip python3-pip glib2-devel make glibc-debuginfo


    if uname -m | grep x86_64 > /dev/null; then

        sudo zypper install -y glibc-32bit-debuginfo || true

    fi

}


install_emerge() {

    emerge --oneshot --deep --newuse --changed-use --changed-deps dev-lang/python dev-python/pip sys-devel/gdb

}


PYTHON=''

INSTALLFLAGS=''


if osx || [ "$1" == "--user" ]; then

    INSTALLFLAGS="--user"

else

    PYTHON="sudo "

fi


if linux; then

    distro=$(grep "^ID=" /etc/os-release | cut -d'=' -f2 | sed -e 's/"//g')


    case $distro in

        "ubuntu")

            install_apt

            ;;

        "fedora")

            install_dnf

            ;;

        "clear-linux-os")

            install_swupd

            ;;

        "opensuse-leap")

            install_zypper

            ;;

        "arch")

            echo "Install Arch linux using a community package. See:"

            echo " - https://www.archlinux.org/packages/community/any/pwndbg/"

            echo " - https://aur.archlinux.org/packages/pwndbg-git/"

            exit 1

            ;;

        "manjaro")

            echo "Pwndbg is not avaiable on Manjaro's repositories."

            echo "But it can be installed using Arch's AUR community package. See:"

            echo " - https://www.archlinux.org/packages/community/any/pwndbg/"

            echo " - https://aur.archlinux.org/packages/pwndbg-git/"

            exit 1

            ;;

        "void")

            install_xbps

            ;;

        "gentoo")

            install_emerge

            if ! hash sudo 2>/dev/null && whoami | grep root; then

                sudo() {

                    ${*}

                }

            fi

            ;;

        *) # we can add more install command for each distros.

            echo "\"$distro\" is not supported distro. Will search for 'apt' or 'dnf' package managers."

            if hash apt; then

                install_apt

            elif hash dnf; then

                install_dnf

            else

                echo "\"$distro\" is not supported and your distro don't have apt or dnf that we support currently."

                exit

            fi

            ;;

    esac

fi


if ! hash gdb; then

    echo "Could not find gdb in $PATH"

    exit

fi


# Update all submodules

git submodule update --init --recursive


# Find the Python version used by GDB.

PYVER=$(gdb -batch -q --nx -ex 'pi import platform; print(".".join(platform.python_version_tuple()[:2]))')

PYTHON+=$(gdb -batch -q --nx -ex 'pi import sys; print(sys.executable)')

PYTHON+="${PYVER}"


# Find the Python site-packages that we need to use so that

# GDB can find the files once we've installed them.

if linux && [ -z "$INSTALLFLAGS" ]; then

    SITE_PACKAGES=$(gdb -batch -q --nx -ex 'pi import site; print(site.getsitepackages()[0])')

    INSTALLFLAGS="${SITE_PACKAGES}"

fi


# Make sure that pip is available

if ! ${PYTHON} -m pip -V; then

    ${PYTHON} -m ensurepip --target "${INSTALLFLAGS}" --upgrade

fi


# Upgrade pip itself

${PYTHON} -m pip install --target "${INSTALLFLAGS}" --upgrade pip


# Install Python dependencies

${PYTHON} -m pip install --target "${INSTALLFLAGS}" -Ur requirements.txt


# Load Pwndbg into GDB on every launch.

if ! grep pwndbg ~/.gdbinit &>/dev/null; then

    echo "source $PWD/gdbinit.py" >> ~/.gdbinit

fi

Lalu save dan sekarang kita jalankan dengan perintah:

./setup.sh

Setelah proses install selesai kita akan membuat file tersendiri pada directory /usr/bin, gunakan script dibawah dan save dengan nama pwngdb:

#!/bin/sh

exec gdb -q -ex init-pwndbg "$@"

Lanjutkan dengan merubah permission ke execute:

$ chmod +x /usr/bin/pwngdb

Kita akan test dengan printah pwngdb pada terminal, jika sukses makan akan sepreti dibawah.



Note: jika mengalami error saat menjalankan pwngdb seperti dibawah, silahkan ganti script di /root/pwndbg/pwndbg/command/context.py dengan script disini.




Author
Author “Yes I'm seeking for someone, to help me. So that some day I will be the someone to help some other one.”

Post a Comment for "Tutorial Fix Bug Install PWNDBG di Kali Linux"