-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgdb_weaponize.sh
executable file
·91 lines (71 loc) · 2.34 KB
/
gdb_weaponize.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
# Usage: bash gdb_weaponize.sh
# Inspired by "Pwndbg + GEF + Peda — One for all, and all for one" -- https://medium.com/bugbountywriteup/pwndbg-gef-peda-one-for-all-and-all-for-one-714d71bf36b8
G="\033[1;32m" # GREEN
Y="\033[1;33m" # YELLOW
R="\033[1;31m" # RED
NC="\033[0m" # NO COLOR
# --------------- Check for root privileges ----------------
if [[ $EUID -ne 0 ]]; then
printf "${Y}[!] Please run as root:\nsudo %s${NC}\n" "${0}"
exit 0
fi
# ------------ Check for required dependencies -------------
if ! which git >/dev/null 2>&1; then
printf "${Y}[-] Git not found! Aborting...{NC}\n"
exit 0
fi
# -------------------- Remove old stuff --------------------
rm -rf /opt/gdb_weaponize /usr/bin/gdb-* ~/.gdbinit
# ---------------------- Installation ----------------------
printf "${G}[+] Downloading PEDA...${NC}\n"
git clone https://github.com/longld/peda.git /opt/gdb_weaponize/peda
# echo "source /opt/gdb_weaponize/peda/peda.py" > ~/.gdbinit
printf "${G}[+] Downloading GEF...${NC}\n"
wget -O /opt/gdb_weaponize/gef.py https://github.com/hugsy/gef/raw/main/gef.py
# echo "source /opt/gdb_weaponize/gef.py" > ~/.gdbinit
printf "${G}[+] Downloading pwndbg...${NC}\n"
git clone https://github.com/pwndbg/pwndbg /opt/gdb_weaponize/pwndbg
cd /opt/gdb_weaponize/pwndbg
./setup.sh
cd ~
## echo "source /opt/gdb_weaponize/pwndbg/gdbinit.py" > ~/.gdbinit
printf "${G}[+] Creating $SUDO_USER/.gdbinit...${NC}\n"
cat << EOT > /home/$SUDO_USER/.gdbinit
define init-peda
source /opt/gdb_weaponize/peda/peda.py
end
document init-peda
Initializes the PEDA (Python Exploit Development Assistant for GDB) framework
endput
define init-gef
source /opt/gdb_weaponize/gef.py
end
document init-gef
Initializes GEF (GDB Enhanced Features)
end
define init-pwndbg
source /opt/gdb_weaponize/pwndbg/gdbinit.py
end
document init-pwndbg
Initializes PwnDBG
end
EOT
printf "${G}[+] Creating /usr/bin/gdb-peda...${NC}\n"
cat << EOT > /usr/bin/gdb-peda
#!/bin/sh
exec gdb -q -ex init-peda "\$@"
EOT
printf "${G}[+] Creating /usr/bin/gdb-gef...${NC}\n"
cat << EOT > /usr/bin/gdb-gef
#!/bin/sh
exec gdb -q -ex init-gef "\$@"
EOT
printf "${G}[+] Creating /usr/bin/gdb-pwndbg...${NC}\n"
cat << EOT > /usr/bin/gdb-pwndbg
#!/bin/sh
exec gdb -q -ex init-pwndbg "\$@"
EOT
printf "${G}[*] Setting permission bits...${NC}\n"
chmod +x /usr/bin/gdb-*
printf "${G}[+] Done${NC}\n"