SlideShare a Scribd company logo
Introduction to Linux
Privilege Escalation Methods
KATE BROUSSARD
Senior Security Analyst
February 22, 2019
Introduction
ROADMAP FOR THE NEXT HOUR
• Priv esc definition + Framing
• Easy mode
• Sneaky mode
• Boss mode
• Summary
• Resources
OUTLINE
Senior Security analyst at Bishop Fox
kbroussard@bishopfox.com
Twitter handle: @grazhacks
KATE BROUSSARD
PRIVILEGE ESCALATION
AND SO WE BEGIN
Definition
• Using privileges of various agents to
gain access to resources
When does it come into play?
Framing
• Who’s doing the execution?
• What are their privileges?
Two ways to escalate:
1. You’re the agent
your current user permissions are
sufficient to execute the command &
do the thing
2. Something else is the agent
you get something else to execute the
command under THEIR permissions,
which are sufficient to do the thing
Privilege Escalation
DEFINITION AND FRAMING
EASY MODE
SO YOU’RE IN THE SERVER – NOW WHAT?
whoami
id
pwd cat /etc/shadow
vs. cat /etc/passwd
cd /root
WHO ARE YOU? WHERE ARE YOU? ARE YOU REALLY REALLY LUCKY?
Before Anything Else
CHECK YOUR PRIVILEGE
• Where do you have read access?
/home/
/usr/share/
ENV
• Where do you have write access?
/home/USER/.ssh
/root/
/etc/crontab
https://www.gq.com/story/netflix-carmen-sandiego-hero-weird
Permission
CHECK YOUR PRIVILEGE
sudo –l
• What commands can you execute?
• Do you need a password?
sudo
MAKE ME A SANDWICH
https://xkcd.com/838/ - Incident
sudo –l
• What commands can you execute?
• Do you need a password?
cat /etc/sudoers
cat /etc/group
sudo
MAKE ME A SANDWICH
sudo Exploit - Python
SUDO MAKE ME A SANDWICH
sudo python –c ‘import pty;
pty.spawn(“/bin/bash”);’
New shell spawned by python also runs
under root permissions
Credential Reuse
WE ARE CREATURES OF HABIT
Password reuse is RAMPANT
• web application passwords
• known compromised passwords
for specific users
• common/default credentials
nmap port scan or ps auf to see what’s up
https://imgs.xkcd.com/comics/password_reuse.png
.bash_history
LEAKED INFORMATION
• Any passwords entered into history?
• Any interesting files or directories?
cat .bash_history vs history
/var/log
LEAKED INFORMATION
• Are any credentials stored in logs?
• Any other useful information?
1. Who/where are you
2. What can you see/modify with
current permissions?
3. Look for:
1. sudo permissions
2. Credential Reuse
3. Leaked info from:
1. cat .bash_history
2. /var/log files
Two ways to escalate:
1. You’re the agent
your current user permissions are
sufficient to execute the command
& do the thing
2. Something else is the agent
you get something else to execute
the command under THEIR
permissions, which are sufficient
to do the thing
Easy Mode
RECAP
SNEAKY MODE
FIND AND EXPLOIT SOME MISCONFIGURATIONS
SUID/SGID bits
CHECK THEIR PRIVILEGE
• What is the SUID/SGID bit?
• How to find a SUID/SGID binary?
• What runs as the root user?
find / -perm -u=s [-type f] 2>/dev/null
find / -perm -4000 [-type f] 2>/dev/null
• What runs in the root group?
find / -perm -g=s [-type f] 2>/dev/null
find / -perm -2000 [-type f] 2>/dev/null
SUID/SGID bits
CHECK THEIR PRIVILEGE
What are “normal” SUID programs vs
ones that are exploitable?
Standard Linux utility?
Try shell escape or command option argument
Custom script to make an admin’s life easy?
Try PATH=. (especially if the script makes a call
to an alias)
Also watch for wildcards
Binary Shell escape
less !cmd
more !cmd
:!cmd
vi :! cmd
mysql system cmd
! cmd
AND MANY MORE
https://www.mariowiki.com/File:Koopa_Troopa_Artwork_-_Super_Mario_3D_World.png
INTENTIONAL OPTION TO EXECUTE COMMANDS
Shell Escapes
Binary Option
find -exec CMD ;
awk ‘{system(“CMD”)}’
AND MANY MORE
Cmd option arguments
INTENTIONAL OPTION TO
EXECUTE COMMANDS
Exploit:
1. create a temporary file with shell cmd
2. open nano with temp file set as spell-check
reference
3. run spell-check to execute cmd under root
permissions
SUID Exploit
TRICKING AN EXECUTABLE
INTO SPAWNING A SHELL
Path is an environment variable telling the
OS where to look for an aliased binary
Instead of typing /bin/ls every time,
you can just type ls
USE CASE: Prank the Admin
• Bill knows that his supervisor Sue has
her PATH = .
• Writes a script to prank her, names it ls,
sticks it in his /home/BILL/ directory
• Asks Sue why ls isn’t working in his ~
• Sue runs ls in /home/BILL/ and executes
the prank script instead of /bin/ls binary
Path = .
START LOOKING HERE
Custom script on the web server might
execute call to aliased program
calling cat $FILE instead of /bin/cat $FILE
If it runs under root privs, you can exploit it
Path = .
START LOOKING HERE
USE CASE: helperSH Exploit
• helperSH is a custom script on the web
server that makes life easy for an admin;
SUID as root
• Command within the script executes
something recognizable (like ps)
• In writeable dir, make new file
echo “/bin/sh” > ps
• Set own PATH = .
• Execute script from writeable dir
Path = .
START LOOKING HERE
USE CASE: helperSH Exploit
• helperSH is a custom script on the web
server that makes life easy for an admin;
SUID as root
• Command within the script executes
something recognizable (like ps)
• In writeable dir, make new file
echo “/bin/sh” > ps
• Set own PATH = .
• Execute script from writeable dir
When using * wildcard, Unix shell interprets
–FILENAME as command option argument
Meaning you can
submit command options
through file name
when running a wildcard process
Look for wildcards in
custom scripts, cron jobs, executables
Wildcards
COMMAND OPTION ARGUMENTS AS FILENAMES
CHOWN EXAMPLE
files in a given dir include:
.FileRef.php
--reference=.FileRef.php
when root executes the following:
chown –R nobody:nobody *.php
becomes:
chown –R nobody:nobody --reference=.FileRef.php
User:group permissions of .FileRef.php are
mapped onto every file in the directory
When using * wildcard, Unix shell interprets
–FILENAME as command option argument
Meaning you can
submit command options
through file name
when running a wildcard process
Look for wildcards in
custom scripts, cron jobs, executables
Wildcards
COMMAND OPTION ARGUMENTS AS FILENAMES
NOTE
EXPLOIT BELOW DELETES THE FILESYSTEM
cd /tmp
echo “blah” > “-rf /*”
rm *
When rm * gets to –rf /* file, command becomes
rm –rf /*
Which recursively deletes everything on the
filesystem, starting at /
Sneaky Mode
RECAP
Two ways to escalate:
● You’re the agent – your current user
permissions are sufficient to execute the
command & do the thing
● Something else is the agent – you get
something else to execute the command
under THEIR permissions, which are
sufficient to do the thing
SUID/SGID bits
1. Shell escapes
2. Cmd option arguments
3. PATH = .
Wildcards
BOSS MODE
THESE WILL TAKE SOME TIME TO GET
RIGHT
Cron jobs are cmds executed on a schedule
Almost always run under root permissions
• /etc/cron.allow & /etc/cron.deny specify user privs
Cron takes a file; file tells it what to execute
and when
• /etc/crontab
Related: at, batch (one-time execution)
cron
PRIVILEGE IS A CRONIC PROBLEM
How to exploit?
1. Overwrite /etc/crontab
2. Write to a cron dir (priv misconfig)
3. If the what is vulnerable, might be able to
modify or hit something downstream
4. Cron jobs may also have wildcards
cron
PRIVILEGE IS A CRONIC PROBLEM
How to exploit?
1. Overwrite /etc/crontab
2. Write to a cron dir (priv misconfig)
3. If the what is vulnerable, might be able to
modify or hit something downstream
4. Cron jobs may also have wildcards
cron
PRIVILEGE IS A CRONIC PROBLEM
How to exploit?
1. Overwrite /etc/crontab
2. Write to a cron dir (priv misconfig)
3. If the what is vulnerable, might be able to
modify or hit something downstream
4. Cron jobs may also have wildcards
cron
PRIVILEGE IS A CRONIC PROBLEM
How to exploit?
1. Overwrite /etc/crontab
2. Write to a cron dir (priv misconfig)
3. If the what is vulnerable, might be able
to modify or hit something downstream
4. Cron jobs may also have wildcards
Magic bullet: what if we just compromise
the server OS itself??!
Downside: there might be exploits that
you need to grab & compile & debug
NOTE: not-small risk of bricking the
server
Kernel Exploits
HOPE YOU LIKE DEBUGGING IN C
LSB_RELEASE -A
UNAME -A
Boss Mode
RECAP
Two ways to escalate:
● You’re the agent – your current user
permissions are sufficient to execute the
command & do the thing
● Something else is the agent – you get
something else to execute the command
under THEIR permissions, which are
sufficient to do the thing
Cron jobs
1. /etc/crontab
2. writeable cron dir
3. affect process downstream
Kernel exploits
THAT’S ONE IN THE BANK
LET ME SUM UP
Summary
ONE HOUR IN ONE SLIDE
Easy mode
• Who are you?
• Where are you?
• What can you do?
Sneaky mode
• SUID/SGID bits:
shell escapes, cmd option args, PATH = .
• Wildcards
Boss mode
• Cron jobs
• Kernel exploits
Typical goal once in server:
persistence + privilege escalation
• Are you the agent?
Drop into a root shell & give yourself
persistence
• Is something else the agent?
Need an intermediate step – get something
to help you out
Resources & Contact
I’M REAL FRIENDLY
kbroussard@bishopfox.com
@grazhacks on Twitter
SLIDE DECK
PRACTICE VM
• https://payatu.com/guide-linux-privilege-escalation/
• http://www.securitysift.com/download/linuxprivchecker.py
• https://exploit-db.com
• https://www.linode.com/docs/tools-reference/linux-users-and-groups/
• https://resources.infosecinstitute.com/privilege-escalation-linux-live-examples/
• https://www.hackingarticles.in/exploiting-wildcard-for-privilege-escalation/
• https://percussiveelbow.github.io/linux-privesc/
Thank you!
Questions?

More Related Content

What's hot

Hunting for Privilege Escalation in Windows Environment
Hunting for Privilege Escalation in Windows EnvironmentHunting for Privilege Escalation in Windows Environment
Hunting for Privilege Escalation in Windows Environment
Teymur Kheirkhabarov
 
What is Penetration & Penetration test ?
What is Penetration & Penetration test ?What is Penetration & Penetration test ?
What is Penetration & Penetration test ?
Bhavin Shah
 
Abusing Symlinks on Windows
Abusing Symlinks on WindowsAbusing Symlinks on Windows
Abusing Symlinks on Windows
OWASP Delhi
 
Not a Security Boundary
Not a Security BoundaryNot a Security Boundary
Not a Security Boundary
Will Schroeder
 
Introduction to red team operations
Introduction to red team operationsIntroduction to red team operations
Introduction to red team operations
Sunny Neo
 
NETWORK PENETRATION TESTING
NETWORK PENETRATION TESTINGNETWORK PENETRATION TESTING
NETWORK PENETRATION TESTING
Er Vivek Rana
 
Nmap basics
Nmap basicsNmap basics
Fantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find ThemFantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find Them
Ross Wolf
 
Windows Forensic 101
Windows Forensic 101Windows Forensic 101
Windows Forensic 101
Digit Oktavianto
 
Basic security & info
Basic security & infoBasic security & info
Basic security & info
Tola LENG
 
Le fasi di un Penetration testing
Le fasi di un Penetration testingLe fasi di un Penetration testing
Le fasi di un Penetration testing
Alessandra Zullo
 
Lateral Movement with PowerShell
Lateral Movement with PowerShellLateral Movement with PowerShell
Lateral Movement with PowerShell
kieranjacobsen
 
Level Up! - Practical Windows Privilege Escalation
Level Up! - Practical Windows Privilege EscalationLevel Up! - Practical Windows Privilege Escalation
Level Up! - Practical Windows Privilege Escalation
jakx_
 
CNIT 126 11. Malware Behavior
CNIT 126 11. Malware BehaviorCNIT 126 11. Malware Behavior
CNIT 126 11. Malware Behavior
Sam Bowne
 
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 EditionGoing Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Soroush Dalili
 
Nmap and metasploitable
Nmap and metasploitableNmap and metasploitable
Nmap and metasploitable
Mohammed Akbar Shariff
 
Database Firewall with Snort
Database Firewall with SnortDatabase Firewall with Snort
Database Firewall with Snort
Narudom Roongsiriwong, CISSP
 
ModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEA
ModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEAModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEA
ModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEA
NGINX, Inc.
 
Thick Client Penetration Testing.pdf
Thick Client Penetration Testing.pdfThick Client Penetration Testing.pdf
Thick Client Penetration Testing.pdf
SouvikRoy114738
 
OS Security 2009
OS Security 2009OS Security 2009
OS Security 2009
Deborah Obasogie
 

What's hot (20)

Hunting for Privilege Escalation in Windows Environment
Hunting for Privilege Escalation in Windows EnvironmentHunting for Privilege Escalation in Windows Environment
Hunting for Privilege Escalation in Windows Environment
 
What is Penetration & Penetration test ?
What is Penetration & Penetration test ?What is Penetration & Penetration test ?
What is Penetration & Penetration test ?
 
Abusing Symlinks on Windows
Abusing Symlinks on WindowsAbusing Symlinks on Windows
Abusing Symlinks on Windows
 
Not a Security Boundary
Not a Security BoundaryNot a Security Boundary
Not a Security Boundary
 
Introduction to red team operations
Introduction to red team operationsIntroduction to red team operations
Introduction to red team operations
 
NETWORK PENETRATION TESTING
NETWORK PENETRATION TESTINGNETWORK PENETRATION TESTING
NETWORK PENETRATION TESTING
 
Nmap basics
Nmap basicsNmap basics
Nmap basics
 
Fantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find ThemFantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find Them
 
Windows Forensic 101
Windows Forensic 101Windows Forensic 101
Windows Forensic 101
 
Basic security & info
Basic security & infoBasic security & info
Basic security & info
 
Le fasi di un Penetration testing
Le fasi di un Penetration testingLe fasi di un Penetration testing
Le fasi di un Penetration testing
 
Lateral Movement with PowerShell
Lateral Movement with PowerShellLateral Movement with PowerShell
Lateral Movement with PowerShell
 
Level Up! - Practical Windows Privilege Escalation
Level Up! - Practical Windows Privilege EscalationLevel Up! - Practical Windows Privilege Escalation
Level Up! - Practical Windows Privilege Escalation
 
CNIT 126 11. Malware Behavior
CNIT 126 11. Malware BehaviorCNIT 126 11. Malware Behavior
CNIT 126 11. Malware Behavior
 
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 EditionGoing Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
 
Nmap and metasploitable
Nmap and metasploitableNmap and metasploitable
Nmap and metasploitable
 
Database Firewall with Snort
Database Firewall with SnortDatabase Firewall with Snort
Database Firewall with Snort
 
ModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEA
ModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEAModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEA
ModSecurity and NGINX: Tuning the OWASP Core Rule Set - EMEA
 
Thick Client Penetration Testing.pdf
Thick Client Penetration Testing.pdfThick Client Penetration Testing.pdf
Thick Client Penetration Testing.pdf
 
OS Security 2009
OS Security 2009OS Security 2009
OS Security 2009
 

Similar to Introduction to Linux Privilege Escalation Methods

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 escalation
Jameel Nabbo
 
Linux privesc.pptx
Linux privesc.pptxLinux privesc.pptx
Linux privesc.pptx
SouvikRoy114738
 
Fundamentals of Linux Privilege Escalation
Fundamentals of Linux Privilege EscalationFundamentals of Linux Privilege Escalation
Fundamentals of Linux Privilege Escalation
nullthreat
 
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
nullthreat
 
Server quickstart47 linux
Server quickstart47 linuxServer quickstart47 linux
Server quickstart47 linux
kb_exchange_hk
 
Shared Coursework in Cyber Security Instructions Manual .docx
Shared Coursework in Cyber Security Instructions Manual .docxShared Coursework in Cyber Security Instructions Manual .docx
Shared Coursework in Cyber Security Instructions Manual .docx
edgar6wallace88877
 
Using filesystem capabilities with rsync
Using filesystem capabilities with rsyncUsing filesystem capabilities with rsync
Using filesystem capabilities with rsync
Hazel Smith
 
Death matchtournament del2014
Death matchtournament del2014Death matchtournament del2014
Death matchtournament del2014
Nabil Munawar
 
Linux commands-effectiveness
Linux commands-effectivenessLinux commands-effectiveness
Linux commands-effectiveness
Rubizza
 
1000 to 0
1000 to 01000 to 0
1000 to 0
Sunny Neo
 
Linux automated tasks
Linux automated tasksLinux automated tasks
Linux automated tasks
yarden hanan
 
Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)
Jun Hong Kim
 
Debugging Network Issues
Debugging Network IssuesDebugging Network Issues
Debugging Network Issues
Apcera
 
The Ultimate IBM and Lotus on Linux Workshop for Windows Admins
The Ultimate IBM and Lotus on Linux Workshop for Windows AdminsThe Ultimate IBM and Lotus on Linux Workshop for Windows Admins
The Ultimate IBM and Lotus on Linux Workshop for Windows Admins
Bill Malchisky Jr.
 
Unix Shell Scripting
Unix Shell ScriptingUnix Shell Scripting
Unix Shell Scripting
Mustafa Qasim
 
Sandy Report
Sandy ReportSandy Report
Sandy Report
sandeepkumar907
 
Sandy Report
Sandy ReportSandy Report
Sandy Report
sandeepkumar907
 
Linux week 2
Linux week 2Linux week 2
Linux week 2
Vinoth Sn
 
Volatility101
Volatility101Volatility101
Volatility101
April Mardock CISSP
 

Similar to Introduction to Linux Privilege Escalation Methods (20)

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 privesc.pptx
Linux privesc.pptxLinux privesc.pptx
Linux privesc.pptx
 
Fundamentals of Linux Privilege Escalation
Fundamentals of Linux Privilege EscalationFundamentals of Linux Privilege Escalation
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 Escalation
 
Server quickstart47 linux
Server quickstart47 linuxServer quickstart47 linux
Server quickstart47 linux
 
Shared Coursework in Cyber Security Instructions Manual .docx
Shared Coursework in Cyber Security Instructions Manual .docxShared Coursework in Cyber Security Instructions Manual .docx
Shared Coursework in Cyber Security Instructions Manual .docx
 
Using filesystem capabilities with rsync
Using filesystem capabilities with rsyncUsing filesystem capabilities with rsync
Using filesystem capabilities with rsync
 
Death matchtournament del2014
Death matchtournament del2014Death matchtournament del2014
Death matchtournament del2014
 
Linux commands-effectiveness
Linux commands-effectivenessLinux commands-effectiveness
Linux commands-effectiveness
 
1000 to 0
1000 to 01000 to 0
1000 to 0
 
Linux automated tasks
Linux automated tasksLinux automated tasks
Linux automated tasks
 
Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)
 
Debugging Network Issues
Debugging Network IssuesDebugging Network Issues
Debugging Network Issues
 
The Ultimate IBM and Lotus on Linux Workshop for Windows Admins
The Ultimate IBM and Lotus on Linux Workshop for Windows AdminsThe Ultimate IBM and Lotus on Linux Workshop for Windows Admins
The Ultimate IBM and Lotus on Linux Workshop for Windows Admins
 
Unix Shell Scripting
Unix Shell ScriptingUnix Shell Scripting
Unix Shell Scripting
 
Sandy Report
Sandy ReportSandy Report
Sandy Report
 
Sandy Report
Sandy ReportSandy Report
Sandy Report
 
Linux week 2
Linux week 2Linux week 2
Linux week 2
 
Volatility101
Volatility101Volatility101
Volatility101
 

More from Bishop Fox

OWASP LA – SharePoint Hacking – 22Feb2012 – Slides.PDF
OWASP LA – SharePoint Hacking – 22Feb2012 – Slides.PDFOWASP LA – SharePoint Hacking – 22Feb2012 – Slides.PDF
OWASP LA – SharePoint Hacking – 22Feb2012 – Slides.PDF
Bishop Fox
 
InfoSec World 2016 – RFIDiggity – Pentester Guide to Hacking HF/NFC and UHF...
	 InfoSec World 2016 – RFIDiggity – Pentester Guide to Hacking HF/NFC and UHF...	 InfoSec World 2016 – RFIDiggity – Pentester Guide to Hacking HF/NFC and UHF...
InfoSec World 2016 – RFIDiggity – Pentester Guide to Hacking HF/NFC and UHF...
Bishop Fox
 
InfoSec World 2013 – W4 – Using Google to Find Vulnerabilities in Your IT Env...
InfoSec World 2013 – W4 – Using Google to Find Vulnerabilities in Your IT Env...InfoSec World 2013 – W4 – Using Google to Find Vulnerabilities in Your IT Env...
InfoSec World 2013 – W4 – Using Google to Find Vulnerabilities in Your IT Env...
Bishop Fox
 
DEFCON 20 (2012) – Tenacious Diggity – 29July2012 – Slides.PDF
DEFCON 20 (2012) – Tenacious Diggity – 29July2012 – Slides.PDFDEFCON 20 (2012) – Tenacious Diggity – 29July2012 – Slides.PDF
DEFCON 20 (2012) – Tenacious Diggity – 29July2012 – Slides.PDF
Bishop Fox
 
SpellCheckV2 Rules
SpellCheckV2 RulesSpellCheckV2 Rules
SpellCheckV2 Rules
Bishop Fox
 
Smarter Home Invasion With ZigDiggity
Smarter Home Invasion With ZigDiggitySmarter Home Invasion With ZigDiggity
Smarter Home Invasion With ZigDiggity
Bishop Fox
 
Hacking Exposed EBS Volumes
Hacking Exposed EBS Volumes Hacking Exposed EBS Volumes
Hacking Exposed EBS Volumes
Bishop Fox
 
Ghost in the Browser: Broad-Scale Espionage with Bitsquatting
 Ghost in the Browser: Broad-Scale Espionage with Bitsquatting Ghost in the Browser: Broad-Scale Espionage with Bitsquatting
Ghost in the Browser: Broad-Scale Espionage with Bitsquatting
Bishop Fox
 
Ferris Bueller’s Guide to Abuse Domain Permutations
Ferris Bueller’s Guide to Abuse Domain PermutationsFerris Bueller’s Guide to Abuse Domain Permutations
Ferris Bueller’s Guide to Abuse Domain Permutations
Bishop Fox
 
Penetration Testing Resource Guide
Penetration Testing Resource Guide Penetration Testing Resource Guide
Penetration Testing Resource Guide
Bishop Fox
 
Network Penetration Testing Toolkit - Nmap, Netcat, and Metasploit Basics
Network Penetration Testing Toolkit - Nmap, Netcat, and Metasploit BasicsNetwork Penetration Testing Toolkit - Nmap, Netcat, and Metasploit Basics
Network Penetration Testing Toolkit - Nmap, Netcat, and Metasploit Basics
Bishop Fox
 
How Perceptual Analysis Helps Bug Hunters
How Perceptual Analysis Helps Bug HuntersHow Perceptual Analysis Helps Bug Hunters
How Perceptual Analysis Helps Bug Hunters
Bishop Fox
 
Getting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at Scale
Getting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at ScaleGetting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at Scale
Getting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at Scale
Bishop Fox
 
Evolving Cyber Adversary Simulation: How Red Teaming Benefits Organizations
Evolving Cyber Adversary Simulation: How Red Teaming Benefits OrganizationsEvolving Cyber Adversary Simulation: How Red Teaming Benefits Organizations
Evolving Cyber Adversary Simulation: How Red Teaming Benefits Organizations
Bishop Fox
 
ASU Cybersecurity Symposium - Breaking Into a Career of Breaking In
ASU Cybersecurity Symposium - Breaking Into a Career of Breaking In ASU Cybersecurity Symposium - Breaking Into a Career of Breaking In
ASU Cybersecurity Symposium - Breaking Into a Career of Breaking In
Bishop Fox
 
CactusCon 2018 - Anatomy of an AppSec Program
CactusCon 2018 - Anatomy of an AppSec Program CactusCon 2018 - Anatomy of an AppSec Program
CactusCon 2018 - Anatomy of an AppSec Program
Bishop Fox
 
Preparing a Next Generation IT Strategy
Preparing a Next Generation IT StrategyPreparing a Next Generation IT Strategy
Preparing a Next Generation IT Strategy
Bishop Fox
 
Lord of the Bing: Taking Back Search Engine Hacking From Google and Bing
Lord of the Bing: Taking Back Search Engine Hacking From Google and BingLord of the Bing: Taking Back Search Engine Hacking From Google and Bing
Lord of the Bing: Taking Back Search Engine Hacking From Google and Bing
Bishop Fox
 
Pulp Google Hacking
Pulp Google HackingPulp Google Hacking
Pulp Google Hacking
Bishop Fox
 
Black Hat USA - CloudBots Harvesting Crypto Coins Like a Botnet Farmer
Black Hat USA - CloudBots Harvesting Crypto Coins Like a Botnet FarmerBlack Hat USA - CloudBots Harvesting Crypto Coins Like a Botnet Farmer
Black Hat USA - CloudBots Harvesting Crypto Coins Like a Botnet Farmer
Bishop Fox
 

More from Bishop Fox (20)

OWASP LA – SharePoint Hacking – 22Feb2012 – Slides.PDF
OWASP LA – SharePoint Hacking – 22Feb2012 – Slides.PDFOWASP LA – SharePoint Hacking – 22Feb2012 – Slides.PDF
OWASP LA – SharePoint Hacking – 22Feb2012 – Slides.PDF
 
InfoSec World 2016 – RFIDiggity – Pentester Guide to Hacking HF/NFC and UHF...
	 InfoSec World 2016 – RFIDiggity – Pentester Guide to Hacking HF/NFC and UHF...	 InfoSec World 2016 – RFIDiggity – Pentester Guide to Hacking HF/NFC and UHF...
InfoSec World 2016 – RFIDiggity – Pentester Guide to Hacking HF/NFC and UHF...
 
InfoSec World 2013 – W4 – Using Google to Find Vulnerabilities in Your IT Env...
InfoSec World 2013 – W4 – Using Google to Find Vulnerabilities in Your IT Env...InfoSec World 2013 – W4 – Using Google to Find Vulnerabilities in Your IT Env...
InfoSec World 2013 – W4 – Using Google to Find Vulnerabilities in Your IT Env...
 
DEFCON 20 (2012) – Tenacious Diggity – 29July2012 – Slides.PDF
DEFCON 20 (2012) – Tenacious Diggity – 29July2012 – Slides.PDFDEFCON 20 (2012) – Tenacious Diggity – 29July2012 – Slides.PDF
DEFCON 20 (2012) – Tenacious Diggity – 29July2012 – Slides.PDF
 
SpellCheckV2 Rules
SpellCheckV2 RulesSpellCheckV2 Rules
SpellCheckV2 Rules
 
Smarter Home Invasion With ZigDiggity
Smarter Home Invasion With ZigDiggitySmarter Home Invasion With ZigDiggity
Smarter Home Invasion With ZigDiggity
 
Hacking Exposed EBS Volumes
Hacking Exposed EBS Volumes Hacking Exposed EBS Volumes
Hacking Exposed EBS Volumes
 
Ghost in the Browser: Broad-Scale Espionage with Bitsquatting
 Ghost in the Browser: Broad-Scale Espionage with Bitsquatting Ghost in the Browser: Broad-Scale Espionage with Bitsquatting
Ghost in the Browser: Broad-Scale Espionage with Bitsquatting
 
Ferris Bueller’s Guide to Abuse Domain Permutations
Ferris Bueller’s Guide to Abuse Domain PermutationsFerris Bueller’s Guide to Abuse Domain Permutations
Ferris Bueller’s Guide to Abuse Domain Permutations
 
Penetration Testing Resource Guide
Penetration Testing Resource Guide Penetration Testing Resource Guide
Penetration Testing Resource Guide
 
Network Penetration Testing Toolkit - Nmap, Netcat, and Metasploit Basics
Network Penetration Testing Toolkit - Nmap, Netcat, and Metasploit BasicsNetwork Penetration Testing Toolkit - Nmap, Netcat, and Metasploit Basics
Network Penetration Testing Toolkit - Nmap, Netcat, and Metasploit Basics
 
How Perceptual Analysis Helps Bug Hunters
How Perceptual Analysis Helps Bug HuntersHow Perceptual Analysis Helps Bug Hunters
How Perceptual Analysis Helps Bug Hunters
 
Getting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at Scale
Getting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at ScaleGetting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at Scale
Getting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at Scale
 
Evolving Cyber Adversary Simulation: How Red Teaming Benefits Organizations
Evolving Cyber Adversary Simulation: How Red Teaming Benefits OrganizationsEvolving Cyber Adversary Simulation: How Red Teaming Benefits Organizations
Evolving Cyber Adversary Simulation: How Red Teaming Benefits Organizations
 
ASU Cybersecurity Symposium - Breaking Into a Career of Breaking In
ASU Cybersecurity Symposium - Breaking Into a Career of Breaking In ASU Cybersecurity Symposium - Breaking Into a Career of Breaking In
ASU Cybersecurity Symposium - Breaking Into a Career of Breaking In
 
CactusCon 2018 - Anatomy of an AppSec Program
CactusCon 2018 - Anatomy of an AppSec Program CactusCon 2018 - Anatomy of an AppSec Program
CactusCon 2018 - Anatomy of an AppSec Program
 
Preparing a Next Generation IT Strategy
Preparing a Next Generation IT StrategyPreparing a Next Generation IT Strategy
Preparing a Next Generation IT Strategy
 
Lord of the Bing: Taking Back Search Engine Hacking From Google and Bing
Lord of the Bing: Taking Back Search Engine Hacking From Google and BingLord of the Bing: Taking Back Search Engine Hacking From Google and Bing
Lord of the Bing: Taking Back Search Engine Hacking From Google and Bing
 
Pulp Google Hacking
Pulp Google HackingPulp Google Hacking
Pulp Google Hacking
 
Black Hat USA - CloudBots Harvesting Crypto Coins Like a Botnet Farmer
Black Hat USA - CloudBots Harvesting Crypto Coins Like a Botnet FarmerBlack Hat USA - CloudBots Harvesting Crypto Coins Like a Botnet Farmer
Black Hat USA - CloudBots Harvesting Crypto Coins Like a Botnet Farmer
 

Recently uploaded

Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
sandeepmenon62
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
campbellclarkson
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
VictoriaMetrics
 
Microsoft-Power-Platform-Adoption-Planning.pptx
Microsoft-Power-Platform-Adoption-Planning.pptxMicrosoft-Power-Platform-Adoption-Planning.pptx
Microsoft-Power-Platform-Adoption-Planning.pptx
jrodriguezq3110
 
Refactoring legacy systems using events commands and bubble contexts
Refactoring legacy systems using events commands and bubble contextsRefactoring legacy systems using events commands and bubble contexts
Refactoring legacy systems using events commands and bubble contexts
Michał Kurzeja
 
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdfTheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
Ortus Solutions, Corp
 
Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.
KrishnaveniMohan1
 
What is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdfWhat is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdf
kalichargn70th171
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
dhavalvaghelanectarb
 
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery FleetStork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
Vince Scalabrino
 
Hands-on with Apache Druid: Installation & Data Ingestion Steps
Hands-on with Apache Druid: Installation & Data Ingestion StepsHands-on with Apache Druid: Installation & Data Ingestion Steps
Hands-on with Apache Druid: Installation & Data Ingestion Steps
servicesNitor
 
Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
Alina Yurenko
 
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Ortus Solutions, Corp
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
Paul Brebner
 
Hyperledger Besu 빨리 따라하기 (Private Networks)
Hyperledger Besu 빨리 따라하기 (Private Networks)Hyperledger Besu 빨리 따라하기 (Private Networks)
Hyperledger Besu 빨리 따라하기 (Private Networks)
wonyong hwang
 
How GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdfHow GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdf
Zycus
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
kalichargn70th171
 

Recently uploaded (20)

Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
 
Microsoft-Power-Platform-Adoption-Planning.pptx
Microsoft-Power-Platform-Adoption-Planning.pptxMicrosoft-Power-Platform-Adoption-Planning.pptx
Microsoft-Power-Platform-Adoption-Planning.pptx
 
Refactoring legacy systems using events commands and bubble contexts
Refactoring legacy systems using events commands and bubble contextsRefactoring legacy systems using events commands and bubble contexts
Refactoring legacy systems using events commands and bubble contexts
 
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdfTheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
 
Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.
 
What is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdfWhat is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdf
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
 
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery FleetStork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
 
Hands-on with Apache Druid: Installation & Data Ingestion Steps
Hands-on with Apache Druid: Installation & Data Ingestion StepsHands-on with Apache Druid: Installation & Data Ingestion Steps
Hands-on with Apache Druid: Installation & Data Ingestion Steps
 
Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
 
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
 
Hyperledger Besu 빨리 따라하기 (Private Networks)
Hyperledger Besu 빨리 따라하기 (Private Networks)Hyperledger Besu 빨리 따라하기 (Private Networks)
Hyperledger Besu 빨리 따라하기 (Private Networks)
 
How GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdfHow GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdf
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
 

Introduction to Linux Privilege Escalation Methods

  • 1. Introduction to Linux Privilege Escalation Methods KATE BROUSSARD Senior Security Analyst February 22, 2019
  • 2. Introduction ROADMAP FOR THE NEXT HOUR • Priv esc definition + Framing • Easy mode • Sneaky mode • Boss mode • Summary • Resources OUTLINE Senior Security analyst at Bishop Fox kbroussard@bishopfox.com Twitter handle: @grazhacks KATE BROUSSARD
  • 4. Definition • Using privileges of various agents to gain access to resources When does it come into play? Framing • Who’s doing the execution? • What are their privileges? Two ways to escalate: 1. You’re the agent your current user permissions are sufficient to execute the command & do the thing 2. Something else is the agent you get something else to execute the command under THEIR permissions, which are sufficient to do the thing Privilege Escalation DEFINITION AND FRAMING
  • 5. EASY MODE SO YOU’RE IN THE SERVER – NOW WHAT?
  • 6. whoami id pwd cat /etc/shadow vs. cat /etc/passwd cd /root WHO ARE YOU? WHERE ARE YOU? ARE YOU REALLY REALLY LUCKY? Before Anything Else CHECK YOUR PRIVILEGE
  • 7. • Where do you have read access? /home/ /usr/share/ ENV • Where do you have write access? /home/USER/.ssh /root/ /etc/crontab https://www.gq.com/story/netflix-carmen-sandiego-hero-weird Permission CHECK YOUR PRIVILEGE
  • 8. sudo –l • What commands can you execute? • Do you need a password? sudo MAKE ME A SANDWICH https://xkcd.com/838/ - Incident
  • 9. sudo –l • What commands can you execute? • Do you need a password? cat /etc/sudoers cat /etc/group sudo MAKE ME A SANDWICH
  • 10. sudo Exploit - Python SUDO MAKE ME A SANDWICH sudo python –c ‘import pty; pty.spawn(“/bin/bash”);’ New shell spawned by python also runs under root permissions
  • 11. Credential Reuse WE ARE CREATURES OF HABIT Password reuse is RAMPANT • web application passwords • known compromised passwords for specific users • common/default credentials nmap port scan or ps auf to see what’s up https://imgs.xkcd.com/comics/password_reuse.png
  • 12. .bash_history LEAKED INFORMATION • Any passwords entered into history? • Any interesting files or directories? cat .bash_history vs history
  • 13. /var/log LEAKED INFORMATION • Are any credentials stored in logs? • Any other useful information?
  • 14. 1. Who/where are you 2. What can you see/modify with current permissions? 3. Look for: 1. sudo permissions 2. Credential Reuse 3. Leaked info from: 1. cat .bash_history 2. /var/log files Two ways to escalate: 1. You’re the agent your current user permissions are sufficient to execute the command & do the thing 2. Something else is the agent you get something else to execute the command under THEIR permissions, which are sufficient to do the thing Easy Mode RECAP
  • 15. SNEAKY MODE FIND AND EXPLOIT SOME MISCONFIGURATIONS
  • 16. SUID/SGID bits CHECK THEIR PRIVILEGE • What is the SUID/SGID bit? • How to find a SUID/SGID binary? • What runs as the root user? find / -perm -u=s [-type f] 2>/dev/null find / -perm -4000 [-type f] 2>/dev/null • What runs in the root group? find / -perm -g=s [-type f] 2>/dev/null find / -perm -2000 [-type f] 2>/dev/null
  • 17. SUID/SGID bits CHECK THEIR PRIVILEGE What are “normal” SUID programs vs ones that are exploitable? Standard Linux utility? Try shell escape or command option argument Custom script to make an admin’s life easy? Try PATH=. (especially if the script makes a call to an alias) Also watch for wildcards
  • 18. Binary Shell escape less !cmd more !cmd :!cmd vi :! cmd mysql system cmd ! cmd AND MANY MORE https://www.mariowiki.com/File:Koopa_Troopa_Artwork_-_Super_Mario_3D_World.png INTENTIONAL OPTION TO EXECUTE COMMANDS Shell Escapes
  • 19. Binary Option find -exec CMD ; awk ‘{system(“CMD”)}’ AND MANY MORE Cmd option arguments INTENTIONAL OPTION TO EXECUTE COMMANDS
  • 20. Exploit: 1. create a temporary file with shell cmd 2. open nano with temp file set as spell-check reference 3. run spell-check to execute cmd under root permissions SUID Exploit TRICKING AN EXECUTABLE INTO SPAWNING A SHELL
  • 21. Path is an environment variable telling the OS where to look for an aliased binary Instead of typing /bin/ls every time, you can just type ls USE CASE: Prank the Admin • Bill knows that his supervisor Sue has her PATH = . • Writes a script to prank her, names it ls, sticks it in his /home/BILL/ directory • Asks Sue why ls isn’t working in his ~ • Sue runs ls in /home/BILL/ and executes the prank script instead of /bin/ls binary Path = . START LOOKING HERE
  • 22. Custom script on the web server might execute call to aliased program calling cat $FILE instead of /bin/cat $FILE If it runs under root privs, you can exploit it Path = . START LOOKING HERE USE CASE: helperSH Exploit • helperSH is a custom script on the web server that makes life easy for an admin; SUID as root • Command within the script executes something recognizable (like ps) • In writeable dir, make new file echo “/bin/sh” > ps • Set own PATH = . • Execute script from writeable dir
  • 23. Path = . START LOOKING HERE USE CASE: helperSH Exploit • helperSH is a custom script on the web server that makes life easy for an admin; SUID as root • Command within the script executes something recognizable (like ps) • In writeable dir, make new file echo “/bin/sh” > ps • Set own PATH = . • Execute script from writeable dir
  • 24. When using * wildcard, Unix shell interprets –FILENAME as command option argument Meaning you can submit command options through file name when running a wildcard process Look for wildcards in custom scripts, cron jobs, executables Wildcards COMMAND OPTION ARGUMENTS AS FILENAMES CHOWN EXAMPLE files in a given dir include: .FileRef.php --reference=.FileRef.php when root executes the following: chown –R nobody:nobody *.php becomes: chown –R nobody:nobody --reference=.FileRef.php User:group permissions of .FileRef.php are mapped onto every file in the directory
  • 25. When using * wildcard, Unix shell interprets –FILENAME as command option argument Meaning you can submit command options through file name when running a wildcard process Look for wildcards in custom scripts, cron jobs, executables Wildcards COMMAND OPTION ARGUMENTS AS FILENAMES NOTE EXPLOIT BELOW DELETES THE FILESYSTEM cd /tmp echo “blah” > “-rf /*” rm * When rm * gets to –rf /* file, command becomes rm –rf /* Which recursively deletes everything on the filesystem, starting at /
  • 26. Sneaky Mode RECAP Two ways to escalate: ● You’re the agent – your current user permissions are sufficient to execute the command & do the thing ● Something else is the agent – you get something else to execute the command under THEIR permissions, which are sufficient to do the thing SUID/SGID bits 1. Shell escapes 2. Cmd option arguments 3. PATH = . Wildcards
  • 27. BOSS MODE THESE WILL TAKE SOME TIME TO GET RIGHT
  • 28. Cron jobs are cmds executed on a schedule Almost always run under root permissions • /etc/cron.allow & /etc/cron.deny specify user privs Cron takes a file; file tells it what to execute and when • /etc/crontab Related: at, batch (one-time execution) cron PRIVILEGE IS A CRONIC PROBLEM How to exploit? 1. Overwrite /etc/crontab 2. Write to a cron dir (priv misconfig) 3. If the what is vulnerable, might be able to modify or hit something downstream 4. Cron jobs may also have wildcards
  • 29. cron PRIVILEGE IS A CRONIC PROBLEM How to exploit? 1. Overwrite /etc/crontab 2. Write to a cron dir (priv misconfig) 3. If the what is vulnerable, might be able to modify or hit something downstream 4. Cron jobs may also have wildcards
  • 30. cron PRIVILEGE IS A CRONIC PROBLEM How to exploit? 1. Overwrite /etc/crontab 2. Write to a cron dir (priv misconfig) 3. If the what is vulnerable, might be able to modify or hit something downstream 4. Cron jobs may also have wildcards
  • 31. cron PRIVILEGE IS A CRONIC PROBLEM How to exploit? 1. Overwrite /etc/crontab 2. Write to a cron dir (priv misconfig) 3. If the what is vulnerable, might be able to modify or hit something downstream 4. Cron jobs may also have wildcards
  • 32. Magic bullet: what if we just compromise the server OS itself??! Downside: there might be exploits that you need to grab & compile & debug NOTE: not-small risk of bricking the server Kernel Exploits HOPE YOU LIKE DEBUGGING IN C LSB_RELEASE -A UNAME -A
  • 33. Boss Mode RECAP Two ways to escalate: ● You’re the agent – your current user permissions are sufficient to execute the command & do the thing ● Something else is the agent – you get something else to execute the command under THEIR permissions, which are sufficient to do the thing Cron jobs 1. /etc/crontab 2. writeable cron dir 3. affect process downstream Kernel exploits
  • 34. THAT’S ONE IN THE BANK LET ME SUM UP
  • 35. Summary ONE HOUR IN ONE SLIDE Easy mode • Who are you? • Where are you? • What can you do? Sneaky mode • SUID/SGID bits: shell escapes, cmd option args, PATH = . • Wildcards Boss mode • Cron jobs • Kernel exploits Typical goal once in server: persistence + privilege escalation • Are you the agent? Drop into a root shell & give yourself persistence • Is something else the agent? Need an intermediate step – get something to help you out
  • 36. Resources & Contact I’M REAL FRIENDLY kbroussard@bishopfox.com @grazhacks on Twitter SLIDE DECK PRACTICE VM • https://payatu.com/guide-linux-privilege-escalation/ • http://www.securitysift.com/download/linuxprivchecker.py • https://exploit-db.com • https://www.linode.com/docs/tools-reference/linux-users-and-groups/ • https://resources.infosecinstitute.com/privilege-escalation-linux-live-examples/ • https://www.hackingarticles.in/exploiting-wildcard-for-privilege-escalation/ • https://percussiveelbow.github.io/linux-privesc/