I wanted to give some idea of commands we can run to get information that may help us to escalate our privileges and then give really basic example to show what I mean.
Who are you?
Linux Command: id
Where are you?
What version of Linux is running?
What can you do?
Find all files and directories that are owned by you
find / -user `whoami` -ls 2> /dev/null
List (running) processes/cronjobs
ls -R /etc/periodic/
List Listeners/Sockets/Open files in general
List users & groups
Find SUID/SGID binaries
find / \( -perm -2000 -or -perm -4000 \) -ls 2> /dev/null
Find files that have been accessed/modified/changed recently (e.g. in past 60 Minutes)
find / -type f -amin 60 -ls 2> /dev/null
find / -type f -mmin 60 -ls 2> /dev/null
find / -type f -cmin 60 -ls 2> /dev/null
List files in /tmp
ls -al /tmp/
See logfiles in /var/log
ls -al /var/log
Read other users' bash history
Find files with interesting extensions
find / -name "*.cfg" -or -name "*.config" -or -name "*.txt" -ls 2> /dev/null
Basic Example of usage:
We have been given a box to pen testing so we have taken the same process as most pen testing and done information gathering and run nmap scans.
- The only two ports that are open are 80 and 22
- We use Firefox to see if there any web page.
- We find there is a pretty simple web page that contains some information including email address.
- We then take these email address and produce a user list to use with hydra to brute force the ssh.
- After around 5 mins we get the username as john and passwords as password123.
- We then ssh into the box as the john using his password.
- We now want to try escalate our privileges so we can dump the shadow file and try to crack the other users password.
- We start with our basic privilege list above until we run find / \( -perm -2000 -or -perm -4000 \) -ls 2> /dev/null this tells us that the find command is running at suid
- We can use this to get a root shell by running find . -exec /bin/sh\; this will give us a euid of 0 meaning root.
- We can now use this to cat the /etc/shadow or ant other root task we want to complete on the box.
Please note this very basic example and depending on the system we may not want dump the hashes. I have just used this as its a very simple concept to explain.
http://g0tmi1k.blogspot.co.uk/2011/08/b ... ation.html
I'm an InterN0T'er