Linux Prevesc

A checklist for linux privesc. Might be missing lots of things. Is mostly taken from https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/

Do you have a decent shell?

python -c 'import pty;pty.spawn("/bin/bash")'
python3 -c 'import pty;pty.spawn("/bin/bash")' 
echo os.system('/bin/bash') 
/bin/sh -i

To get tab completion working

ctrl+z
echo $TERM && tput lines && tput cols

stty raw -echo
fg

reset
export SHELL=bash 
export TERM=xterm-256color (screen when running tmux)
stty rows <num> columns <cols>

Or use Socat for a full reverse tty

socat file:`tty`,raw,echo=0 tcp-listen:12345

Initial Recon

Start by checking the version and distro of the machine for possible kernel exploits, and also the sudo permissions of whatever account you have if possible.

To do things quick, run the LinEnum script from Rebootuser.

https://github.com/rebootuser/LinEnum

Check for plaintext passwords with it

What users have shells on the box?

Anything in users home directories or mail?

Anything else in the environmental variables? symlinks?

Anything going on with the network? hidden services? logged in users?

Can you sniff traffic?

SUID Files, Root Services, and Other Files

Check for things running as root

Check the version of something that's installed

Any file-systems mounted or unmounted?

Then do suid/guid and other interesting files.

To create our own SUID binary

SGID (chmod 2000) - run as the group, not the user who started it.

SUID (chmod 4000) - run as the owner, not the user who started it.

Sticky bit - Only the owner of the directory or the owner of a file can delete or rename here.

Are any folders or files world writeable and executable?

Anything modified recently? To check for executables updated in August

To find anything modified in the last 10 minutes

Any writeable configuration files?

Or any files containing 'config'

To find a specific file

Files with passwords?

Find .conf files(recursive 4 levels) and output line number where the word 'password' is located

Or other sensitive files

Find all perl files ownd by rootme in /var/www

Scan for string in all files in a directory

Find password strings in memory

Cron

Look through these

This might not work but the for loop will list crontabs for a user.

This is a nice script from ihack4falafel to monitor cron and echo new processes

https://github.com/ihack4falafel/OSCP/blob/master/BASH/CronJobChecker.sh

Keys and Database Passwords

Quick check for current user private keys

Any private keys saved elsewhere?

Whats in var?

Any files with database information?

Default locations sometimes for good things

References

https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/

https://jivoi.github.io/2015/07/01/pentest-tips-and-tricks/

https://www.youtube.com/channel/UCa6eh7gCkpPo5XXUDfygQQA

https://bitvijays.github.io/LFC-VulnerableMachines.html#linux-privilege-escalation

https://github.com/lucyoa/kernel-exploits

https://github.com/SecWiki/linux-kernel-exploits

Last updated

Was this helpful?