Home
Calendar
Certifications
Columns
Features
Forum
Resources
Vitals
Latest Additions
April 2013 Free Giveaway Sponsor - eLearnSecurity
Human Intelligence to Navigate the Security Data Deluge
February 2013 Free Giveaway Winner of SANS CyberCon Training
Interview: Bugcrowd Founders on Herding Ninjas for Crowdsourced Bug Bounties
Network Forensics: The Tree in the Forest
March 2013 Free Giveaway Sponsor - Mile2
Book Review: Violent Python
February 2013 Free Giveaway Sponsor - SANS
Holiday 2012 Free Giveaway Winner of Metasploit Pro by Rapid7
Course Review: SANS FOR408 Computer Forensic Investigations – Windows In-Depth
The Security Consulting Sugar High
Tutorial: Fun with SMB on the Command Line
Interview: Ilia Kolochenko, CEO of High-Tech Bridge
October 2012 Free Giveaway Winner of LearningGate Training
The Broken: Assessing Corporate Security in 2012 to Make a Better 2013
EH-Net Login
Welcome Guest.
Username:
Password:
Remember me
Lost Password?
No account yet?
Register
Who's Online
We have 44 guests and 1 member online
You are here:
Home
Resources
Tutorials
Basic Priv Esculation for newbi
EH-Net
May 21, 2013, 06:09:42 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Go back to The Ethical Hacker Network Online Magazine
Home Page
Home
Help
Calendar
Login
Register
EH-Net
>
Resources
>
Tutorials
(Moderator:
don
) >
Basic Priv Esculation for newbi
Pages: [
1
]
2
Go Down
« previous
next »
Print
Author
Topic: Basic Priv Esculation for newbi (Read 10800 times)
0 Members and 1 Guest are viewing this topic.
Jamie.R
Sr. Member
Offline
Posts: 429
Basic Priv Esculation for newbi
«
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
Posts: 292
Re: Basic Priv Esculation for newbi
«
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
Cyber.spirit
Sr. Member
Offline
Posts: 351
The World is sick, Save your mind...
Re: Basic Priv Esculation for newbi
«
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
Posts: 607
Re: Basic Priv Esculation for newbi
«
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
Posts: 120
It's a UNIX system, I know this!
Re: Basic Priv Esculation for newbi
«
Reply #4 on:
August 29, 2012, 07:55:32 PM »
Quote from: Cyber.spirit 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
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
Posts: 129
Re: Basic Priv Esculation for newbi
«
Reply #5 on:
August 29, 2012, 08:53:25 PM »
Quote from: Cyber.spirit on August 29, 2012, 02:34:59 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
Posts: 429
Re: Basic Priv Esculation for newbi
«
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
Cyber.spirit
Sr. Member
Offline
Posts: 351
The World is sick, Save your mind...
Re: Basic Priv Esculation for newbi
«
Reply #7 on:
August 30, 2012, 05:57:26 AM »
Quote from: shadowzero on August 29, 2012, 07:55:32 PM
Quote from: Cyber.spirit 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
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.
Quote from: sternone on August 29, 2012, 08:53:25 PM
Quote from: Cyber.spirit on August 29, 2012, 02:34:59 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.
Quote from: Jamie.R 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.
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
Posts: 43
Re: Basic Priv Esculation for newbi
«
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!
Logged
sternone
Full Member
Offline
Posts: 129
Re: Basic Priv Esculation for newbi
«
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!!
Cyber.spirit
Sr. Member
Offline
Posts: 351
The World is sick, Save your mind...
Re: Basic Priv Esculation for newbi
«
Reply #10 on:
August 30, 2012, 08:39:30 AM »
Quote from: sternone 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.
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
Posts: 429
Re: Basic Priv Esculation for newbi
«
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
Posts: 120
It's a UNIX system, I know this!
Re: Basic Priv Esculation for newbi
«
Reply #12 on:
August 31, 2012, 07:29:39 AM »
Quote from: Cyber.spirit on August 30, 2012, 08:39:30 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
Posts: 76
Re: Basic Priv Esculation for newbi
«
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
Cyber.spirit
Sr. Member
Offline
Posts: 351
The World is sick, Save your mind...
Re: Basic Priv Esculation for newbi
«
Reply #14 on:
September 02, 2012, 12:47:59 AM »
Quote from: shadowzero on August 31, 2012, 07:29:39 AM
Quote from: Cyber.spirit on August 30, 2012, 08:39:30 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
« previous
next »
Jump to:
Please select a destination:
-----------------------------
EH-Net
-----------------------------
=> Calendar Of Events
===> ChicagoCon 2007
===> ChicagoCon 2008s
===> ChicagoCon 2008f
===> ChicagoCon 2009s
=> Ethical Hacktivism
=> News Items and General Discussion About EH-Net
===> Greetings
=> Special Events
-----------------------------
Ethical Hacking Discussions and Related Certifications
-----------------------------
=> General Certification
===> Networking
===> OS
===> Security
=> Compliance, Regulations & Standards
=> Control Systems
=> Cyber Warfare
=> Forensics
===> CCE / MCCE - (Master) Certified Computer Examiner
===> CHFI - Computer Hacking Forensic Investigator
===> EnCE - EnCase® Certified Examiner
===> GCFA - GIAC Certified Forensics Analyst
=> Hardware
=> Incident Response
===> CSIH - Computer Security Incident Handler
===> GCIH - GIAC Certified Incident Handler
=> Malware
===> Advisories
=> Mobile
=> Network Pen Testing
===> CEH - Certified Ethical Hacker
===> CPTC - Certified Penetration Testing Consultant
===> CPTE - Certified Penetration Testing Engineer
===> CSTA - Certified Security Testing Associate
===> eCPPT - eLearnSecurity Certified Professional Penetration Tester
===> ECSA - EC-Council Certified Security Analyst
===> GPEN - GIAC Certified Penetration Tester
===> OSCP - Offensive Security Certified Professional
=> Physical Security
=> Programming
=> Social Engineering
=> Web Applications
=> Wireless
===> CWNP Certs
===> GAWN - GIAC Assessing Wireless Networks
===> OSWP - Offensive Security Wireless Professional
=> Other
-----------------------------
Columns
-----------------------------
=> Editor-In-Chief
=> Andress
=> Gates
=> Haddix
=> Hadnagy
=> Heffner
=> Hoffman
=> Linn
=> RichM
=> Murray
=> J. Peltier
=> Weidman
=> Wilson
-----------------------------
Features
-----------------------------
=> /root
=> Book Reviews
=> Opinions
=> Skillz
===> Examples
===> May 06 - Star Hacks, Episode V: The Empire Hacks Back
===> July 06 - Hack Bill!
===> Sept 06 - Netcat in the Hat
===> Nov 06 - Hitch-Hackers Guide to the Galaxy
===> Dec 06 - A Christmas (Hacking) Story
===> Feb 07 - Charlottes Web Site
===> April 07 - Microsoft Office Space
===> June 07 - Serenity Hack
===> Oct 07 - Worst. Ethical. Hacker. Challenge. Ever.
===> Dec 07 - Frosty the Snow Crash
===> March 2008 - It Happened One Friday
===> Oct 2008 - Scooby Doo and the Crypto Caper
===> Dec 08 - Santa Claus Is Hacking to Town
===> Feb 2009 - Brady Bunch Boondoggle
===> July 2009 - Prison Break
===> October 2009 - SSHliders
===> December 2009 - Miracle on Thirty-Hack Street
===> December 2010 - The Nightmare Before Charlie Browns Christmas
-----------------------------
Resources
-----------------------------
=> Career Central
===> Looking For Work
===> Looking To Hire
=> Links to cool sites.
=> Mass Media
=> News from the Outside World
=> Tools
=> Tutorials
===> Tutorial Requests
Loading...
Exclusive Deal
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:
Great!
Better.
About the same.
Little worse.
FUBAR!
Recent Forum Topics
Programming
: Finished Python Course in Codecademy now what?
(13) by
securitian
Network Pen Testing
: Ruby on Rails Vulnerabilities/Attacks in BackTrack 5 r3
(0) by
SUdoctstudent
Network Pen Testing
: De-ICE 1.140 released!
(2) by
superkojiman
Network Pen Testing
: AIX Vulnerability Assessments
(1) by
3xban
General Certification
: CPT Practical Submission
(1) by
UNIX
OSCP - Offensive Security Certified Professional
: Failed my first attempt at the OSCP exam
(94) by
azmatt
Tools
: Social-Engineer Toolkit (SET) Version 5.0 “The Wild West” Released
(2) by
m0wgli
Malware
: EICAR?
(3) by
UKSecurityGuy
Advisories
: HTB23154: Multiple Vulnerabilities in Exponent CMS
(0) by
AndyP
Advisories
: HTB23153: Multiple Vulnerabilities in Jojo CMS
(0) by
AndyP
Advisories
: HTB23151: Cross-Site Request Forgery (CSRF) in UMI.CMS
(0) by
AndyP
Tutorials
: Need guidance
(8) by
r0ckm4n
OSCP - Offensive Security Certified Professional
: Class Scheduled 6/8 - Linux n00b
(7) by
Taemyks
OSCP - Offensive Security Certified Professional
: OSCP exam scheduled
(6) by
gbhat
Incident Response
: LinkedIn Forensics
(0) by
AFENTIS_Forensics
General Certification
: Red Team/Blue Team
(1) by
ajohnson
Career Central
: Starter cert?
(3) by
Grendel
Network Pen Testing
: Beginner Ethical Hacker
(1) by
m0wgli
Web Applications
: Nessus and Nikto
(4) by
Seen
Network Pen Testing
: Cracking salted MD5 hash
(4) by
n37sh@rk
CEH - Certified Ethical Hacker
: Passed my C|EH
(3) by
n37sh@rk
Mass Media
: EC-council hacked, irony at his best?
(0) by
j0rDy
Web Applications
: SQL Injection into an INSERT statement.
(6) by
eyenit0
Network Pen Testing
: Solution for sipXtapi INVITE Message CSeq Field Header Remote Overflow
(1) by
m0wgli
Web Applications
: dns
(2) by
H1t M0nk3y
Other
: BSides Boston
(0) by
3xban
Career Central
: InfoSec in Central, FL
(2) by
tturner
Web Applications
: Web vulnerability scanner
(4) by
H1t M0nk3y
EH-Net News Feeds
Latest Additions
Privacy Notice
for TDCC & All Properties
© 2013 The Ethical Hacker Network
Joomla!
is Free Software released under the GNU/GPL License.