SlideShare uma empresa Scribd logo
1 de 44
Fundamentals of
Linux Privilege
Escalation
Introduction
❖ Elliott Cutright
❖ Sr. Red Team for a Fortune 10 in Richmond VA
❖ Professional Red Team for 6 years
❖ Linux and Web Applications
❖ Past worked in Threat Intelligence and Systems Admin
and a 24 x 7 x 365 DOD SOC
Disclaimer
The views and opinions expressed here are
those of Elliott Cutright only and in no way
represent the views, positions or opinions -
expressed or implied - of my employer or
anyone else.
Setup
❖ This is NOT how to get in
❖ How do we go from low privileges to high privileges
❖ Webshells, Stolen SSH Keys, etc
❖ We do not know the user's password
❖ Everything in this talk is something I have done or seen
in the real world on real production machines; This is not
THEORY, it's FACT
Method 1:
Exploits
Exploits
❖ Most take advantage of a flaw in the Linux Kernel
❖ Easier because reliable exploit code is widely available
❖ Be careful, if unreliable good chance you will crash
system as you might see in the demo
❖ Generally low skill set can achieve grand results
Exploits
❖ Identify OS and Kernel Version
❖ Enumerate tools to build exploit (gcc, python, perl, etc)
❖ Get the exploit to the system
❖ Execute Exploit
❖ …
❖ ROOT
Exploit - ID System
❖ Determine kernel version
❖ uname -a
❖ Linux ubuntu-demo 3.8.0-19-generic #30-Ubuntu
SMP Wed May 1 16:36:13 UTC 2013 i686 i686 i686
GNU/Linux
❖ Linux cent-demo 2.6.18-8.el5 #1 SMP Thu Mar 15
19:57:35 EDT 2007 i686 i686 i386 GNU/Linux
Exploit - ID System
❖ OS Release
❖ Ubuntu - cat /etc/lsb-release
❖ DISTRIB_ID=Ubuntu
❖ DISTRIB_RELEASE=13.04
❖ DISTRIB_CODENAME=raring
❖ DISTRIB_DESCRIPTION="Ubuntu 13.04”
❖ RedHat/CENT - cat /etc/redhat-release
❖ CentOS release 5 (Final)
Exploit - Get the file on the
Server
❖ Any means available
❖ curl/wget
❖ NetCat
❖ FTP
❖ SCP/SFTP
❖ SMB
❖ TFTP
❖ Copy/Paste - for source code
❖ DNS TXT Records - for source code
Exploit - Where To Hide It?
❖ Directories starting with a ‘.’ are hidden on Linux
Filesystem
❖ /tmp/.nothinghere/exploit.c
❖ /tmp/…/exploit.c
❖ Verify you can run commands from your directory
❖ mount
❖ /dev/vda3 on /tmp type ext4 (rw,noexec)
Exploit - ID Build System
❖ gcc -v
❖ Using built-in specs.
❖ COLLECT_GCC=gcc
❖ Target: i686-linux-gnu
❖ Configured with: ../src/configure ……..
❖ gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1)
❖ python -V
❖ Python 2.4.3
Exploit - ID Build System
❖ gcc -v
❖ -bash: gcc: command not found
❖ Common on Servers
❖ python -V
❖ -bash: /usr/bin/python: No such file or directory
❖ RARE
Exploit - Building The Exploit
❖ Most exploits have build directions in the headers
❖ Most common method
❖ gcc exploit.c -o exploit
❖ ./exploit
Exploit - Build Local
❖ If GCC is not present, build a VM or VPS with the exact
matching kernel and OS (Ex. Ubuntu 13.10 with Kernel
3.8.0-19-generic)
❖ Once build on your local system, move the compiled
exploit to your target system
❖ WARNING: This is not the preferred method and can
have unexpected results…but may work in a pinch
CVE-2009-2692 - sock_sendpage() exploit
https://www.youtube.com/watch?v=65w7ROFbdqc
Demo
Protect/Detect
❖ Patching
❖ No Really…Install Patches
❖ Limit locations for code execution
❖ GRSecurity, if you are up to it
❖ You need to be really comfortable with Linux for this one
❖ Adds significant overhead to updating as you have to
rebuild for EVERY kernel version
Method 2:
File Permissions
World Readable/Writeable
❖ These are files that anyone can read or write
❖ Easy to find
❖ find / -perm -2 ! -type l -ls
❖ My Ubuntu box had 1,681 files and folder and its a
basic install of 14.04
Dangers
❖ ANYONE can read or write these files
❖ While that is by design for some files, others it adds a
great deal of risk
❖ Config Files
❖ Websites /Application source code
❖ Scripts run by init or cron
❖ Commands/Scripts used by admins
Protect/Detect
❖ World Read/Write is normal part of the filesystem
❖ Issues arise when users/admins/scripts start changing
permissions
❖ stop using `chmod 777` please
❖ Audit on a semi-regular basis for overly permissive files
and folders
SetUID and SetGID
❖ SetUID - SET User ID upon execution
❖ SetGUID - SET Group ID upon execution
❖ Allows you to run programs as another user upon
execution
❖ Generally executed as elevated privilege user (root)
SetUID Risks
❖ Binaries run with elevated privileges can access
privileged information
❖ SetUID on ‘ls’ will allow you to list directories you
otherwise wouldn’t have rights to
❖ SetUID on ‘vim’ will allow you to edit files you
otherwise wouldn’t have rights to
SetUID Risks
❖ Buffer overflow exploits or command injection flaws in
SetUID applications will result in the attacker running
code with the elevated privileges
Find SetUID
❖ ls -l /bin/ls
❖ -rwxr-xr-x 1 root root 108708 Jan 17 2013 /bin/ls
❖ dir:owner:group:world
❖ ls -al /bin/ping
❖ -rwsr-sr-x 1 root root 34780 Oct 2 2012 /bin/ping
Find SetUID
❖ sudo find / -xdev ( -perm -4000 ) -type f -print0 -exec ls
-l {} ;
❖ note: sudo is not required, you just wont be able to
check directories you don't have permissions to
Exploiting SetUID
❖ Use the functionality of the tool in unintended ways for
elevated privileges (more on this idea later)
❖ Find an application that has public exploit or start fuzzing
on your own
❖ Command Injection
Protect/Detect
❖ While setUID is 100% required under normal operations
we see admins overusing it
❖ It is not a fix all
❖ Understand the Risk vs Reward when setting setUID on
an application; Do audits for these apps
Method 3:
Permissive
SUDO
SUDO
❖ su do
❖ note: `su` does not mean SuperUser, it is Substitute
User
❖ Allows you to run commands as elevated user with your
user password rather than a shared root (BAD!)
password
/etc/sudoers
❖ Config file for sudo
❖ Limits what users and groups can run what commands
❖ ex:
❖ rootALL=(ALL:ALL) ALL
❖ %sudo ALL=(ALL) NOPASSWD:ALL
/etc/sudoers
❖ Can allow for very granular configurations
❖ User_Alias FULLTIMERS = millert, mikef, dowdy
❖ Host_Alias SERVERS = master, mail, www, ns
❖ Cmnd_Alias SHUTDOWN = /usr/sbin/shutdown
❖ Cmnd_Alias REBOOT = /usr/sbin/reboot
❖ FULLTIMERS ALL = NOPASSWD: ALL
❖ mikef ALL, !SERVERS = ALL
Concerns
❖ With great power, comes great responsibility
❖ sudo will allow you to shoot yourself in the foot
❖ THINK about the commands you allow via sudo
Problems?
❖ Why are these commands an issue?
❖ vi/vim
❖ more/less/cat
❖ echo
❖ nmap
Find Exec
Demo
Protect/Detect
❖ Again, Risk vs Reward of allowing sudo
❖ The more specific you can be in config, the better
❖ Know what the application you are allowing CAN do
Method 4:
PATH issues
Linux PATH
❖ An environment variable that contains the location of
executables
❖ printenv
❖ PATH=/usr/local/rvm/gems/ruby-1.9.3-
p448/bin:/usr/local/rvm/gems/ruby-1.9.3-
p448@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-
p448/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin
:/usr/sbin:/usr/bin:/sbin:/bin
Linux PATH
❖ ruby -v
❖ ruby 1.9.3p448 (2013-06-27 revision 41675) [i686-
linux]
❖ which ruby
❖ /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby
Linux PATH Issues
❖ What would happen if the ‘.’ was prepended to the path?
❖ Where would it look for ruby first?
❖ What if a script was calling ruby?
❖ As root…….
Attack Path Example
❖ Sysadmin has ‘.’ in his path
❖ Email and say you can’t list the files in your home dir
❖ Make bash script called ‘ls’ that sends a reverse shell
and hides itself from the admin
❖ Admin logs in as root
❖ Goes to your home dir and runs ls
❖ Shell
ls reverse shell
Demo
Protect/Detect
❖ Don't put ‘.’ in your path….just don't
❖ No Risk vs Reward here, Risk will almost always
outweigh the reward
Questions? e: elliott.cutright@gmail.com
t: @nullthreat

Mais conteúdo relacionado

Mais procurados

PowerShell for Cyber Warriors - Bsides Knoxville 2016
PowerShell for Cyber Warriors - Bsides Knoxville 2016PowerShell for Cyber Warriors - Bsides Knoxville 2016
PowerShell for Cyber Warriors - Bsides Knoxville 2016Russel Van Tuyl
 
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating FrameworksJSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating FrameworksMario Heiderich
 
Building an Empire with PowerShell
Building an Empire with PowerShellBuilding an Empire with PowerShell
Building an Empire with PowerShellWill Schroeder
 
Privilege escalation from 1 to 0 Workshop
Privilege escalation from 1 to 0 Workshop Privilege escalation from 1 to 0 Workshop
Privilege escalation from 1 to 0 Workshop Hossam .M Hamed
 
Reverse proxies & Inconsistency
Reverse proxies & InconsistencyReverse proxies & Inconsistency
Reverse proxies & InconsistencyGreenD0g
 
Windows Privilege Escalation
Windows Privilege EscalationWindows Privilege Escalation
Windows Privilege EscalationRiyaz Walikar
 
Attack and Mitigation for Insecure Deserialization
Attack and Mitigation for Insecure DeserializationAttack and Mitigation for Insecure Deserialization
Attack and Mitigation for Insecure DeserializationSukhpreet Singh
 
Understanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryUnderstanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryDaniel Miessler
 
Top 10 Web Security Vulnerabilities (OWASP Top 10)
Top 10 Web Security Vulnerabilities (OWASP Top 10)Top 10 Web Security Vulnerabilities (OWASP Top 10)
Top 10 Web Security Vulnerabilities (OWASP Top 10)Brian Huff
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Amit Tyagi
 
ColdFusion for Penetration Testers
ColdFusion for Penetration TestersColdFusion for Penetration Testers
ColdFusion for Penetration TestersChris Gates
 
Ninja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for BeginnersNinja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for BeginnersChang W. Doh
 
Dangling DNS records takeover at scale
Dangling DNS records takeover at scaleDangling DNS records takeover at scale
Dangling DNS records takeover at scaleChandrapal Badshah
 
aclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundaclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundDirkjanMollema
 
Introduction to Dynamic Malware Analysis ...Or am I "Cuckoo for Malware?"
Introduction to Dynamic Malware Analysis   ...Or am I "Cuckoo for Malware?"Introduction to Dynamic Malware Analysis   ...Or am I "Cuckoo for Malware?"
Introduction to Dynamic Malware Analysis ...Or am I "Cuckoo for Malware?"Lane Huff
 
NETWORK PENETRATION TESTING
NETWORK PENETRATION TESTINGNETWORK PENETRATION TESTING
NETWORK PENETRATION TESTINGEr Vivek Rana
 
OWASP A4 XML External Entities (XXE)
OWASP A4 XML External Entities (XXE)OWASP A4 XML External Entities (XXE)
OWASP A4 XML External Entities (XXE)Michael Furman
 

Mais procurados (20)

NTLM
NTLMNTLM
NTLM
 
PowerShell for Cyber Warriors - Bsides Knoxville 2016
PowerShell for Cyber Warriors - Bsides Knoxville 2016PowerShell for Cyber Warriors - Bsides Knoxville 2016
PowerShell for Cyber Warriors - Bsides Knoxville 2016
 
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating FrameworksJSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
 
Building an Empire with PowerShell
Building an Empire with PowerShellBuilding an Empire with PowerShell
Building an Empire with PowerShell
 
Privilege escalation from 1 to 0 Workshop
Privilege escalation from 1 to 0 Workshop Privilege escalation from 1 to 0 Workshop
Privilege escalation from 1 to 0 Workshop
 
Unsecuring SSH
Unsecuring SSHUnsecuring SSH
Unsecuring SSH
 
Reverse proxies & Inconsistency
Reverse proxies & InconsistencyReverse proxies & Inconsistency
Reverse proxies & Inconsistency
 
Windows Privilege Escalation
Windows Privilege EscalationWindows Privilege Escalation
Windows Privilege Escalation
 
WAFs.pptx
WAFs.pptxWAFs.pptx
WAFs.pptx
 
Attack and Mitigation for Insecure Deserialization
Attack and Mitigation for Insecure DeserializationAttack and Mitigation for Insecure Deserialization
Attack and Mitigation for Insecure Deserialization
 
Understanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryUnderstanding Cross-site Request Forgery
Understanding Cross-site Request Forgery
 
Top 10 Web Security Vulnerabilities (OWASP Top 10)
Top 10 Web Security Vulnerabilities (OWASP Top 10)Top 10 Web Security Vulnerabilities (OWASP Top 10)
Top 10 Web Security Vulnerabilities (OWASP Top 10)
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
 
ColdFusion for Penetration Testers
ColdFusion for Penetration TestersColdFusion for Penetration Testers
ColdFusion for Penetration Testers
 
Ninja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for BeginnersNinja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for Beginners
 
Dangling DNS records takeover at scale
Dangling DNS records takeover at scaleDangling DNS records takeover at scale
Dangling DNS records takeover at scale
 
aclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundaclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHound
 
Introduction to Dynamic Malware Analysis ...Or am I "Cuckoo for Malware?"
Introduction to Dynamic Malware Analysis   ...Or am I "Cuckoo for Malware?"Introduction to Dynamic Malware Analysis   ...Or am I "Cuckoo for Malware?"
Introduction to Dynamic Malware Analysis ...Or am I "Cuckoo for Malware?"
 
NETWORK PENETRATION TESTING
NETWORK PENETRATION TESTINGNETWORK PENETRATION TESTING
NETWORK PENETRATION TESTING
 
OWASP A4 XML External Entities (XXE)
OWASP A4 XML External Entities (XXE)OWASP A4 XML External Entities (XXE)
OWASP A4 XML External Entities (XXE)
 

Semelhante a Fundamentals of Linux Privilege Escalation

Aide 2014 - Fundamentals of Linux Privilege Escalation
Aide 2014 - Fundamentals of Linux Privilege EscalationAide 2014 - Fundamentals of Linux Privilege Escalation
Aide 2014 - Fundamentals of Linux Privilege Escalationnullthreat
 
bh-us-02-murphey-freebsd
bh-us-02-murphey-freebsdbh-us-02-murphey-freebsd
bh-us-02-murphey-freebsdwebuploader
 
Introduction to Linux Privilege Escalation Methods
Introduction to Linux Privilege Escalation MethodsIntroduction to Linux Privilege Escalation Methods
Introduction to Linux Privilege Escalation MethodsBishop Fox
 
Check Your Privilege (Escalation)
Check Your Privilege (Escalation) Check Your Privilege (Escalation)
Check Your Privilege (Escalation) Bishop Fox
 
Linux advanced privilege escalation
Linux advanced privilege escalationLinux advanced privilege escalation
Linux advanced privilege escalationJameel Nabbo
 
Linux security quick reference guide
Linux security quick reference guideLinux security quick reference guide
Linux security quick reference guideCraig Cannon
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linuxplarsen67
 
Unix Security
Unix SecurityUnix Security
Unix Securityreplay21
 
Death matchtournament del2014
Death matchtournament del2014Death matchtournament del2014
Death matchtournament del2014Nabil Munawar
 
SANS @Night There's Gold in Them Thar Package Management Databases
SANS @Night There's Gold in Them Thar Package Management DatabasesSANS @Night There's Gold in Them Thar Package Management Databases
SANS @Night There's Gold in Them Thar Package Management DatabasesPhil Hagen
 
Red Hat Linux 5 Hardening Tips - National Security Agency
Red Hat Linux 5 Hardening Tips - National Security AgencyRed Hat Linux 5 Hardening Tips - National Security Agency
Red Hat Linux 5 Hardening Tips - National Security Agencysanchetanparmar
 
Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)Ata Rehman
 
Linux privilege escalation 101
Linux privilege escalation 101Linux privilege escalation 101
Linux privilege escalation 101Rashid feroz
 
BackTrack 4 R2 - SFISSA Presentation
BackTrack 4 R2 - SFISSA PresentationBackTrack 4 R2 - SFISSA Presentation
BackTrack 4 R2 - SFISSA PresentationJorge Orchilles
 
Python on FreeBSD
Python on FreeBSDPython on FreeBSD
Python on FreeBSDpycontw
 
CEHv10 M0 Introduction.pptx
CEHv10 M0 Introduction.pptxCEHv10 M0 Introduction.pptx
CEHv10 M0 Introduction.pptxYasserOuda2
 

Semelhante a Fundamentals of Linux Privilege Escalation (20)

Aide 2014 - Fundamentals of Linux Privilege Escalation
Aide 2014 - Fundamentals of Linux Privilege EscalationAide 2014 - Fundamentals of Linux Privilege Escalation
Aide 2014 - Fundamentals of Linux Privilege Escalation
 
bh-us-02-murphey-freebsd
bh-us-02-murphey-freebsdbh-us-02-murphey-freebsd
bh-us-02-murphey-freebsd
 
File000127
File000127File000127
File000127
 
Introduction to Linux Privilege Escalation Methods
Introduction to Linux Privilege Escalation MethodsIntroduction to Linux Privilege Escalation Methods
Introduction to Linux Privilege Escalation Methods
 
Check Your Privilege (Escalation)
Check Your Privilege (Escalation) Check Your Privilege (Escalation)
Check Your Privilege (Escalation)
 
Linux advanced privilege escalation
Linux advanced privilege escalationLinux advanced privilege escalation
Linux advanced privilege escalation
 
Linux security quick reference guide
Linux security quick reference guideLinux security quick reference guide
Linux security quick reference guide
 
Linux Hardening - nullhyd
Linux Hardening - nullhydLinux Hardening - nullhyd
Linux Hardening - nullhyd
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linux
 
Unix Security
Unix SecurityUnix Security
Unix Security
 
Death matchtournament del2014
Death matchtournament del2014Death matchtournament del2014
Death matchtournament del2014
 
Aide
AideAide
Aide
 
SANS @Night There's Gold in Them Thar Package Management Databases
SANS @Night There's Gold in Them Thar Package Management DatabasesSANS @Night There's Gold in Them Thar Package Management Databases
SANS @Night There's Gold in Them Thar Package Management Databases
 
Red Hat Linux 5 Hardening Tips - National Security Agency
Red Hat Linux 5 Hardening Tips - National Security AgencyRed Hat Linux 5 Hardening Tips - National Security Agency
Red Hat Linux 5 Hardening Tips - National Security Agency
 
Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)
 
Linux privilege escalation 101
Linux privilege escalation 101Linux privilege escalation 101
Linux privilege escalation 101
 
BackTrack 4 R2 - SFISSA Presentation
BackTrack 4 R2 - SFISSA PresentationBackTrack 4 R2 - SFISSA Presentation
BackTrack 4 R2 - SFISSA Presentation
 
Python on FreeBSD
Python on FreeBSDPython on FreeBSD
Python on FreeBSD
 
Ch23 system administration
Ch23 system administration Ch23 system administration
Ch23 system administration
 
CEHv10 M0 Introduction.pptx
CEHv10 M0 Introduction.pptxCEHv10 M0 Introduction.pptx
CEHv10 M0 Introduction.pptx
 

Último

Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Standkumarajju5765
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersDamian Radcliffe
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.soniya singh
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Call Girls in Nagpur High Profile
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...Neha Pandey
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)Damian Radcliffe
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024APNIC
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 

Último (20)

Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 

Fundamentals of Linux Privilege Escalation

  • 2. Introduction ❖ Elliott Cutright ❖ Sr. Red Team for a Fortune 10 in Richmond VA ❖ Professional Red Team for 6 years ❖ Linux and Web Applications ❖ Past worked in Threat Intelligence and Systems Admin and a 24 x 7 x 365 DOD SOC
  • 3. Disclaimer The views and opinions expressed here are those of Elliott Cutright only and in no way represent the views, positions or opinions - expressed or implied - of my employer or anyone else.
  • 4. Setup ❖ This is NOT how to get in ❖ How do we go from low privileges to high privileges ❖ Webshells, Stolen SSH Keys, etc ❖ We do not know the user's password ❖ Everything in this talk is something I have done or seen in the real world on real production machines; This is not THEORY, it's FACT
  • 6. Exploits ❖ Most take advantage of a flaw in the Linux Kernel ❖ Easier because reliable exploit code is widely available ❖ Be careful, if unreliable good chance you will crash system as you might see in the demo ❖ Generally low skill set can achieve grand results
  • 7. Exploits ❖ Identify OS and Kernel Version ❖ Enumerate tools to build exploit (gcc, python, perl, etc) ❖ Get the exploit to the system ❖ Execute Exploit ❖ … ❖ ROOT
  • 8. Exploit - ID System ❖ Determine kernel version ❖ uname -a ❖ Linux ubuntu-demo 3.8.0-19-generic #30-Ubuntu SMP Wed May 1 16:36:13 UTC 2013 i686 i686 i686 GNU/Linux ❖ Linux cent-demo 2.6.18-8.el5 #1 SMP Thu Mar 15 19:57:35 EDT 2007 i686 i686 i386 GNU/Linux
  • 9. Exploit - ID System ❖ OS Release ❖ Ubuntu - cat /etc/lsb-release ❖ DISTRIB_ID=Ubuntu ❖ DISTRIB_RELEASE=13.04 ❖ DISTRIB_CODENAME=raring ❖ DISTRIB_DESCRIPTION="Ubuntu 13.04” ❖ RedHat/CENT - cat /etc/redhat-release ❖ CentOS release 5 (Final)
  • 10. Exploit - Get the file on the Server ❖ Any means available ❖ curl/wget ❖ NetCat ❖ FTP ❖ SCP/SFTP ❖ SMB ❖ TFTP ❖ Copy/Paste - for source code ❖ DNS TXT Records - for source code
  • 11. Exploit - Where To Hide It? ❖ Directories starting with a ‘.’ are hidden on Linux Filesystem ❖ /tmp/.nothinghere/exploit.c ❖ /tmp/…/exploit.c ❖ Verify you can run commands from your directory ❖ mount ❖ /dev/vda3 on /tmp type ext4 (rw,noexec)
  • 12. Exploit - ID Build System ❖ gcc -v ❖ Using built-in specs. ❖ COLLECT_GCC=gcc ❖ Target: i686-linux-gnu ❖ Configured with: ../src/configure …….. ❖ gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1) ❖ python -V ❖ Python 2.4.3
  • 13. Exploit - ID Build System ❖ gcc -v ❖ -bash: gcc: command not found ❖ Common on Servers ❖ python -V ❖ -bash: /usr/bin/python: No such file or directory ❖ RARE
  • 14. Exploit - Building The Exploit ❖ Most exploits have build directions in the headers ❖ Most common method ❖ gcc exploit.c -o exploit ❖ ./exploit
  • 15. Exploit - Build Local ❖ If GCC is not present, build a VM or VPS with the exact matching kernel and OS (Ex. Ubuntu 13.10 with Kernel 3.8.0-19-generic) ❖ Once build on your local system, move the compiled exploit to your target system ❖ WARNING: This is not the preferred method and can have unexpected results…but may work in a pinch
  • 16. CVE-2009-2692 - sock_sendpage() exploit https://www.youtube.com/watch?v=65w7ROFbdqc Demo
  • 17. Protect/Detect ❖ Patching ❖ No Really…Install Patches ❖ Limit locations for code execution ❖ GRSecurity, if you are up to it ❖ You need to be really comfortable with Linux for this one ❖ Adds significant overhead to updating as you have to rebuild for EVERY kernel version
  • 19. World Readable/Writeable ❖ These are files that anyone can read or write ❖ Easy to find ❖ find / -perm -2 ! -type l -ls ❖ My Ubuntu box had 1,681 files and folder and its a basic install of 14.04
  • 20. Dangers ❖ ANYONE can read or write these files ❖ While that is by design for some files, others it adds a great deal of risk ❖ Config Files ❖ Websites /Application source code ❖ Scripts run by init or cron ❖ Commands/Scripts used by admins
  • 21. Protect/Detect ❖ World Read/Write is normal part of the filesystem ❖ Issues arise when users/admins/scripts start changing permissions ❖ stop using `chmod 777` please ❖ Audit on a semi-regular basis for overly permissive files and folders
  • 22. SetUID and SetGID ❖ SetUID - SET User ID upon execution ❖ SetGUID - SET Group ID upon execution ❖ Allows you to run programs as another user upon execution ❖ Generally executed as elevated privilege user (root)
  • 23. SetUID Risks ❖ Binaries run with elevated privileges can access privileged information ❖ SetUID on ‘ls’ will allow you to list directories you otherwise wouldn’t have rights to ❖ SetUID on ‘vim’ will allow you to edit files you otherwise wouldn’t have rights to
  • 24. SetUID Risks ❖ Buffer overflow exploits or command injection flaws in SetUID applications will result in the attacker running code with the elevated privileges
  • 25. Find SetUID ❖ ls -l /bin/ls ❖ -rwxr-xr-x 1 root root 108708 Jan 17 2013 /bin/ls ❖ dir:owner:group:world ❖ ls -al /bin/ping ❖ -rwsr-sr-x 1 root root 34780 Oct 2 2012 /bin/ping
  • 26. Find SetUID ❖ sudo find / -xdev ( -perm -4000 ) -type f -print0 -exec ls -l {} ; ❖ note: sudo is not required, you just wont be able to check directories you don't have permissions to
  • 27. Exploiting SetUID ❖ Use the functionality of the tool in unintended ways for elevated privileges (more on this idea later) ❖ Find an application that has public exploit or start fuzzing on your own ❖ Command Injection
  • 28. Protect/Detect ❖ While setUID is 100% required under normal operations we see admins overusing it ❖ It is not a fix all ❖ Understand the Risk vs Reward when setting setUID on an application; Do audits for these apps
  • 30. SUDO ❖ su do ❖ note: `su` does not mean SuperUser, it is Substitute User ❖ Allows you to run commands as elevated user with your user password rather than a shared root (BAD!) password
  • 31. /etc/sudoers ❖ Config file for sudo ❖ Limits what users and groups can run what commands ❖ ex: ❖ rootALL=(ALL:ALL) ALL ❖ %sudo ALL=(ALL) NOPASSWD:ALL
  • 32. /etc/sudoers ❖ Can allow for very granular configurations ❖ User_Alias FULLTIMERS = millert, mikef, dowdy ❖ Host_Alias SERVERS = master, mail, www, ns ❖ Cmnd_Alias SHUTDOWN = /usr/sbin/shutdown ❖ Cmnd_Alias REBOOT = /usr/sbin/reboot ❖ FULLTIMERS ALL = NOPASSWD: ALL ❖ mikef ALL, !SERVERS = ALL
  • 33. Concerns ❖ With great power, comes great responsibility ❖ sudo will allow you to shoot yourself in the foot ❖ THINK about the commands you allow via sudo
  • 34. Problems? ❖ Why are these commands an issue? ❖ vi/vim ❖ more/less/cat ❖ echo ❖ nmap
  • 36. Protect/Detect ❖ Again, Risk vs Reward of allowing sudo ❖ The more specific you can be in config, the better ❖ Know what the application you are allowing CAN do
  • 38. Linux PATH ❖ An environment variable that contains the location of executables ❖ printenv ❖ PATH=/usr/local/rvm/gems/ruby-1.9.3- p448/bin:/usr/local/rvm/gems/ruby-1.9.3- p448@global/bin:/usr/local/rvm/rubies/ruby-1.9.3- p448/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin :/usr/sbin:/usr/bin:/sbin:/bin
  • 39. Linux PATH ❖ ruby -v ❖ ruby 1.9.3p448 (2013-06-27 revision 41675) [i686- linux] ❖ which ruby ❖ /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby
  • 40. Linux PATH Issues ❖ What would happen if the ‘.’ was prepended to the path? ❖ Where would it look for ruby first? ❖ What if a script was calling ruby? ❖ As root…….
  • 41. Attack Path Example ❖ Sysadmin has ‘.’ in his path ❖ Email and say you can’t list the files in your home dir ❖ Make bash script called ‘ls’ that sends a reverse shell and hides itself from the admin ❖ Admin logs in as root ❖ Goes to your home dir and runs ls ❖ Shell
  • 43. Protect/Detect ❖ Don't put ‘.’ in your path….just don't ❖ No Risk vs Reward here, Risk will almost always outweigh the reward