mirror of
https://github.com/pwndbg/linux-exploit-dev-env.git
synced 2026-11-13 18:59:53 -10:00
39 lines
865 B
Bash
Executable File
39 lines
865 B
Bash
Executable File
#!/bin/bash
|
|
|
|
CWD=$(dirname -- "$0")
|
|
ROOT_DIR=$CWD/..
|
|
OUT_DIR=$ROOT_DIR/out
|
|
GDB_FILE=$OUT_DIR/.gdb
|
|
GDBINIT=$CWD/gdbinit.gdb
|
|
|
|
ptrace_scope=$(cat /proc/sys/kernel/yama/ptrace_scope)
|
|
if [[ $ptrace_scope -ne 0 && $(id -u) -ne 0 ]]; then
|
|
cat << EOF
|
|
WARNING: You are not running as root and ptrace_scope is not set to zero. If you
|
|
run into issues when using pwndbg or gdb-pt-dump, rerun this script as root, or
|
|
alternatively run the following command:
|
|
|
|
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
|
|
|
|
EOF
|
|
fi
|
|
|
|
IFS=" " read -r ARCH ACK < $GDB_FILE
|
|
|
|
if [[ "$ACK" -eq 1 ]]; then
|
|
LINUX_OUT=$OUT_DIR/ack/common/$ARCH
|
|
else
|
|
LINUX_OUT=$OUT_DIR/linux/$ARCH
|
|
fi
|
|
|
|
OUTPUT=$(mktemp)
|
|
sed "s|##LINUX_OUT##|${LINUX_OUT}|g" "$GDBINIT" > "$OUTPUT"
|
|
|
|
if [[ $ARCH == "x86_64" ]]; then
|
|
GDB=gdb
|
|
else
|
|
GDB=gdb-multiarch
|
|
fi
|
|
|
|
exec "${GDB}" -q -ex "source ${OUTPUT}" "$@"
|