Documentation Index
Fetch the complete documentation index at: https://docs.bytejmp.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
After a user runssudo and enters their password, a token is cached (default 15 minutes). If you have access to that user’s session, you can reuse the token without knowing the password.
Requirements
- User is in sudo group
- User has recently used sudo (token not expired)
- You have code execution as that user
ptrace_scopeallows process injection OR/proc/sys/kernel/yama/ptrace_scope= 0
Check ptrace_scope
| Value | Meaning |
|---|---|
0 | Any process can ptrace any other (exploitable) |
1 | Only parent can ptrace child |
2 | Only admin can ptrace |
3 | No ptrace at all |
Check Token Existence
sudo_inject
exploit.sh — Process Injection
Injects into a process owned by target user to activate sudo token:/tmp/sh — SUID shell:
exploit_v2.sh — No ptrace Required
Uses/proc/pid/mem instead of ptrace:
exploit_v3.sh — Via Shared Library
Loads shared library into user process:Manual Token Abuse
Write sudo_inject Token
If you can write to/var/run/sudo/ts/<username>:
write_sudo_token:
Timestamp Directory Permissions
Default:/var/run/sudo/ts/ owned by root with 0700.
If misconfigured (writable):
Sudo Timestamp Timeout
Check timeout:-1 = never expires (always exploitable if token exists).
Sudo Hijacking (PATH)
Create fakesudo in writable PATH directory:
sudo — either reuses token or captures password.
Persistent via .bashrc
Quick Reference
| Technique | Requirement |
|---|---|
| sudo_inject (ptrace) | ptrace_scope = 0, active sudo token |
| sudo_inject v2 (/proc/mem) | /proc/pid/mem readable |
| Write sudo token | Writable /var/run/sudo/ts/ |
| Sudo hijacking | Writable PATH dir, user runs sudo |