Image
 
linkedin_logo.png rss_logo.jpg
twitter_logo.png youtube_logo.jpg
Latest Additions
 
EH-Net Login
Welcome Guest.






Lost Password?
No account yet? Register
Who's Online
We have 34 guests online
 
Advertisement

You are here: Home arrow Resourcesarrow Tutorialsarrow Basic Priv Esculation for newbi
EH-Net
May 25, 2013, 04:57:29 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Go back to The Ethical Hacker Network Online Magazine Home Page
 
   Home   Help Calendar Login Register  
Pages: [1] 2   Go Down
  Print  
Author Topic: Basic Priv Esculation for newbi  (Read 10877 times)
0 Members and 1 Guest are viewing this topic.
Jamie.R
Sr. Member
****
Offline Offline

Posts: 429


View Profile
« on: August 29, 2012, 01:40:23 PM »

When we first gain access to a Linux box there is a good chance that we have gotten a low level account. The next step is usually to escalate our privileges (give us access to more than we have now) up so we can view things like the shadow file. Or maybe there are certain tool we want to run to attack another system and need to be root to run these tools.

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?
pwd

What version of Linux is running?
uname -a

What can you do?
sudo -l

Find all files and directories that are owned by you
find / -user `whoami` -ls 2> /dev/null

List (running) processes/cronjobs
ps aux
cat /etc/crontab
crontab -e
ls -R /etc/periodic/

List Listeners/Sockets/Open files in general
lsof -i
netstat -an

List users & groups
cat /etc/passwd
cat /etc/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
cat /home/*/.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.

Recommended Reading:
https://en.wikipedia.org/wiki/Setuid
https://en.wikipedia.org/wiki/User_identifier
http://g0tmi1k.blogspot.co.uk/2011/08/basic-linux-privilege-escalation.html

Logged

OSWP | Hackingdojo Nidan | eCPPT
Dark_Knight
Sr. Member
****
Offline Offline

Posts: 292


View Profile WWW
« Reply #1 on: August 29, 2012, 02:24:46 PM »

You guys can also check this:
http://www.room362.com/blog/2012/8/25/post-exploitation-command-lists-request-to-edit.html
Logged

CEH, OSCP, GPEN, GWAPT, GCIA
http://sector876.blogspot.com
fred
Sr. Member
****
Offline Offline

Posts: 351


The World is sick, Save your mind...


View Profile
« Reply #2 on: August 29, 2012, 02:34:59 PM »

thank u jamie r like always good article i knew some of these technics but i have a question. I hack the ftp admin account then how can i esculate my priv? Its a linux server
Logged

ICS Academy Network Security Certified
3xban
Hero Member
*****
Offline Offline

Posts: 608


View Profile WWW
« Reply #3 on: August 29, 2012, 05:11:12 PM »

Nice write up.  Fast read full of useful info!
Logged

Certs: GCWN
(@)Dewser
shadowzero
Full Member
***
Offline Offline

Posts: 120


It's a UNIX system, I know this!


View Profile
« Reply #4 on: August 29, 2012, 07:55:32 PM »

thank u jamie r like always good article i knew some of these technics but i have a question. I hack the ftp admin account then how can i esculate my priv? Its a linux server

Read the above article and the links it points to. Privilege escalation isn't an exact science. It depends a lot on what's on the server and what you have access to. The only way to get anywhere is to enumerate, test, fail, try again.
Logged
sternone
Full Member
***
Offline Offline

Posts: 129


View Profile
« Reply #5 on: August 29, 2012, 08:53:25 PM »

I hack the ftp admin account then how can i esculate my priv? Its a linux server

If you hacked the ftp admin account you are already escalated.

Logged

Try harder....hmpf!!
Jamie.R
Sr. Member
****
Offline Offline

Posts: 429


View Profile
« Reply #6 on: August 30, 2012, 03:52:37 AM »

shadowzero excatly this why I tired to keep this simple with small example as if you never done any priv before its like where do you start.

sternone That is ture but most people with commom sense would make it so you can never login via ftp or ssh as root. You will login as a normal user then esculate your priv using sudo.
Logged

OSWP | Hackingdojo Nidan | eCPPT
fred
Sr. Member
****
Offline Offline

Posts: 351


The World is sick, Save your mind...


View Profile
« Reply #7 on: August 30, 2012, 05:57:26 AM »

thank u jamie r like always good article i knew some of these technics but i have a question. I hack the ftp admin account then how can i esculate my priv? Its a linux server

Read the above article and the links it points to. Privilege escalation isn't an exact science. It depends a lot on what's on the server and what you have access to. The only way to get anywhere is to enumerate, test, fail, try again.
I hack the ftp admin account then how can i esculate my priv? Its a linux server

If you hacked the ftp admin account you are already escalated.


shadowzero excatly this why I tired to keep this simple with small example as if you never done any priv before its like where do you start.

sternone That is ture but most people with commom sense would make it so you can never login via ftp or ssh as root. You will login as a normal user then esculate your priv using sudo.

i just can log on to the ftp service. not to the machine remotely the ftp account is valid only for this service if could log on remotely escalating privilege was so easy 
Logged

ICS Academy Network Security Certified
Novice hacker
Newbie
*
Offline Offline

Posts: 43


View Profile
« Reply #8 on: August 30, 2012, 06:49:36 AM »

Great tutorial! Very easy to understand, and I just can't wait for the next one!  Smiley
Logged
sternone
Full Member
***
Offline Offline

Posts: 129


View Profile
« Reply #9 on: August 30, 2012, 07:59:58 AM »

Quote
i just can log on to the ftp service. not to the machine remotely the ftp account is valid only for this service if could log on remotely escalating privilege was so easy 

No, if you hacked the ftp service and you hacked the root account of the ftp service then you are already escalated for that service.
Logged

Try harder....hmpf!!
fred
Sr. Member
****
Offline Offline

Posts: 351


The World is sick, Save your mind...


View Profile
« Reply #10 on: August 30, 2012, 08:39:30 AM »

Quote
i just can log on to the ftp service. not to the machine remotely the ftp account is valid only for this service if could log on remotely escalating privilege was so easy 

No, if you hacked the ftp service and you hacked the root account of the ftp service then you are already escalated for that service.

for that service of-course but i want to get os level access any idea??
Logged

ICS Academy Network Security Certified
Jamie.R
Sr. Member
****
Offline Offline

Posts: 429


View Profile
« Reply #11 on: August 31, 2012, 03:23:47 AM »

As mention above it really does depend on lot of factors when doing priv escalation. That is why I used a really basic senario it just case looking on the box seeing what you can do.

Where can you write too what scripts are running ?

Is there a script that called clean.py being run by root that located in a file you can write too?

If so just replace the file with a simple script to run shell.

It depends on so many things so its hard to give advice. I would just go thought the links provided and see what you can do. There are also tools like Linux priv checker.

http://pentestmonkey.net/blog/unix-privesc-check-update-1-2
 
Logged

OSWP | Hackingdojo Nidan | eCPPT
shadowzero
Full Member
***
Offline Offline

Posts: 120


It's a UNIX system, I know this!


View Profile
« Reply #12 on: August 31, 2012, 07:29:39 AM »

for that service of-course but i want to get os level access any idea??



We don't know anything about the server you're accessing and you haven't given us any information about it other than you've got an ftp account.

Can you write files anywhere? Can you login as the same user using a different service? Are there other services running? Are there files you can download? Have you done enough enumeration and research?

Just because you've got access to one service, doesn't mean you can escalate it to a privileged user. It could be a dead end.
Logged
jjwinter
Jr. Member
**
Offline Offline

Posts: 76


View Profile
« Reply #13 on: August 31, 2012, 08:35:00 AM »

Thanks for the tutorial, as a newbie I found it very helpful. I haven't setup a linux box in my lab to practice on yet, I'd like to try something like this.
Logged
fred
Sr. Member
****
Offline Offline

Posts: 351


The World is sick, Save your mind...


View Profile
« Reply #14 on: September 02, 2012, 12:47:59 AM »

for that service of-course but i want to get os level access any idea??



We don't know anything about the server you're accessing and you haven't given us any information about it other than you've got an ftp account.

Can you write files anywhere? Can you login as the same user using a different service? Are there other services running? Are there files you can download? Have you done enough enumeration and research?

Just because you've got access to one service, doesn't mean you can escalate it to a privileged user. It could be a dead end.


Shadowzero, i ran a brute force attack against admin account and i hacked it. So i can read, write, del files but i cant logon using that account to other services as i mentioned the server is Linux
« Last Edit: September 02, 2012, 09:52:23 AM by Cyber.spirit » Logged

ICS Academy Network Security Certified
Pages: [1] 2   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!
Page created in 0.081 seconds with 23 queries.
 
Exclusive Deal

sansfire13_245x90_cw90.jpg
SANSFIRE 2013
June 15 - 22

5% Off w/ Code: EHN_5

SANS Deals 4 EH-Netters
5% OFF Any SANS Course in Any Format!
Coupon Code: EHN_5 Including SANS Rocky Mountain 2013 & SANS Boston 2013
Polls
Compared to this year, 2013 will be:
 
Recent Forum Topics
EH-Net News Feeds
Latest Additions
 
         
Advertisement

© 2013 The Ethical Hacker Network
Joomla! is Free Software released under the GNU/GPL License.