SlideShare a Scribd company logo
Protecting Your Gold
Will Schroeder, Specter Ops
Standard Image Analysis With PowerShell
Agenda
• PowerUp
• Common Privesc Primitives
• Service (Binary) Permissions
• %PATH% hijacking
• Processes, Threads, and User Rights
• Autoruns
• Provisioning Leftovers/Grab Bag
• “Rotten Potato“
• Custom Software Analysis
• Discovery
• Delivery
• Exploitation
• C2 Installation
• Privilege Escalation
• Lateral Movement
• Data Collection
• Data Exfiltration
Cyber Kill Chain
Discovery Delivery Exploitation C2
Installation
Privilege
Escalation
Lateral
Movement
Data
Exfiltration
Data
Collection
Privilege Escalation
• Most attackers (and us) try to find a way
to escalate privileges to local
administrator/SYSTEM after initial access
is gained
• Everyone isn’t a local admin any more!
• The two main approaches tend to be
0day/exploits and the abuse of
misconfigurations
• You should examine your gold base system
images every time there’s a major change!
• A self-
contained
PowerShell
tool that
automates the
audit and
exploitation
of a number of
common
privilege
escalation
PowerUp
• Now part of PowerSploit
(.PrivescPowerUp.ps1)
• Strict Version 2 compatibility
• (Now) doesn’t start any additional
processes, nor does it depend on any
external binaries
• I.E. uses ChangeServiceConfig() instead of
“set Svc binPath= malicious command”
• Uses PSReflect for Win32 API access
PowerUp’s Approach
• Services are a defined Windows securable
object
• So we can use QueryServiceObjectSecurity()
• Services themselves sometimes have
misconfigured permissions (rare, but it
happens)
• More common are misconfigured permissions
on the binary associated with the service
• If an unprivileged user can replace the
binary for a service, they can gain code
execution when the service/machine restarts
• PowerUp:
Vulnerable Services
• When a Windows application tries to load
a particular .DLL, it searches specific
locations in a predefined order
1. The directory from which the application is
loaded
2. The 32-bit system directory
(C:WindowsSystem32)
3. The 16-bit system directory
(C:WindowsSystem)
4. The Windows directory (C:Windows)
5. The current working directory
6. Any directories that are listed in the PATH
environment variable
Sidenote: DLL Load Order
• When a process tries to load a DLL, there
is a predefined search order for the DLL
location
• The last search location is any folder in
%PATH%
• One service on Windows 7 (IKEEXT) tries
to load a DLL that doesn’t exist
(wlbsctrl.dll)
• Translation: if we can write to any
folder in %PATH% on a Windows 7 machine
(like C:Python27) we can escalate
%PATH% Hijacking
• Processes and threads are securable
objects as well
• Something we’re going to look more heavily
heavily into this year
• User Rights include specific privileges
Processes, Threads, and User
Rights
• Anything that’s set to automatically run
in a (potentially) elevated context is a
candidate for hijacking
• For the registry:
• Enumerate all autoruns in HKLM
• Check if the current user can modify any
binary or arguments for any discovered
autoruns
• PowerUp: Get-ModifiableRegistryAutoRun
• For scheduled tasks:
• Enumerate scheduled tasks where the current
user can modify any file in the associated
Hijacking Autoruns and Scheduled
Tasks
• We occasionally find left over
Unattended.xml answer files that have
passwords set for local account
provisioning
• PowerUp: Get-UnattendedInstallFile
• Some Group Policy Preference files
contain a decryptable cpassword attribute
(Get-GPPPassword…)
• These GPOs are sometimes cached on the host
• PowerUp: Get-CachedGPPPassword
Provisioning Leftovers
• If
[HKLM|HKCU|SOFTWAREPoliciesMicrosoftW
indowsInstallerAlwaysInstallElevated is
set, all .MSI files run elevated…
• PowerUp: Get-RegistryAlwaysInstallElevated
Misc. Grab-bag
• In late 2016, researchers from FoxGlove
Security released an attack called
“Rotten Potato”
• This allows you to escalate from a
service account (or any account with
SeImpersonatePrivilege) to SYSTEM
• It does this by abusing a bug class disclosed
by James Forshaw
• DCOM/RPC is tricked into authenticating with
NTLM to the same endpoint, and the resulting
token is impersonated from an account with
impersonation privileges
Rotten Potato
• Custom internal development is the most
common root cause of escalation vectors
we find
• Why? Security is hard! Same with a SDL!
• Part of our standard process is to search
for any custom/internally developed
software on any machines we gain initial
access to
• Bonus points if it’s C#!
• This is actually very similar to dynamic
malware analysis!
Custom Software Analysis
Analysis Demo
Summary
• Privilege escalation is sometime that most
actors attempt during their attack chain
• You should examine your gold image whenever
there’s a major modification!
• Misconfigurations are often unintentionally
introduced due to custom development or third-
party applications
• PowerUp automates the checks for most of
these misconfigurations
• You can analyze any custom-developed
software pretty easily using existing
malware dynamic analysis techniques!
• Now: 15 min break
• Grab a coffee
• Stay here to enjoy next presentation
• Change track and switch to another room
• Ask me questions or meet me in a breakout
session room afterwards
Next Steps...
Questions?
• Will Schroeder (@harmj0y)
• http://blog.harmj0y.net | will [at]
harmj0y.net
• Red teamer and offensive engineer for
Specter Ops
• Co-founder:
• Veil-Framework | Empire/EmPyre | BloodHound
• Developer of:
• PowerView | PowerUp | current PowerSploit
developer
• Microsoft CDM/PowerShell MVP
• Veteran trainer
About_Author

More Related Content

PPTX
Catch Me If You Can: PowerShell Red vs Blue
PDF
Ace Up the Sleeve
PPTX
(Ab)Using GPOs for Active Directory Pwnage
PDF
The Unintended Risks of Trusting Active Directory
PDF
ReCertifying Active Directory
PDF
Understanding Windows Access Token Manipulation
PDF
DerbyCon 2019 - Kerberoasting Revisited
PDF
Red Team Methodology - A Naked Look
Catch Me If You Can: PowerShell Red vs Blue
Ace Up the Sleeve
(Ab)Using GPOs for Active Directory Pwnage
The Unintended Risks of Trusting Active Directory
ReCertifying Active Directory
Understanding Windows Access Token Manipulation
DerbyCon 2019 - Kerberoasting Revisited
Red Team Methodology - A Naked Look

What's hot (20)

PDF
Fantastic Red Team Attacks and How to Find Them
PPTX
Abusing Microsoft Kerberos - Sorry you guys don't get it
PPTX
Pwning the Enterprise With PowerShell
PPTX
PSConfEU - Offensive Active Directory (With PowerShell!)
PDF
I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...
PPTX
Six Degrees of Domain Admin - BloodHound at DEF CON 24
PPTX
Here Be Dragons: The Unexplored Land of Active Directory ACLs
PDF
aclpwn - Active Directory ACL exploitation with BloodHound
PDF
Hunting for Privilege Escalation in Windows Environment
PPT
Top 10 Web Security Vulnerabilities (OWASP Top 10)
PDF
Derbycon - The Unintended Risks of Trusting Active Directory
PDF
64 Methods for Mimikatz Execution
 
PPTX
Evading Microsoft ATA for Active Directory Domination
PPTX
Red Team Revenge - Attacking Microsoft ATA
PPTX
PDF
Hunting for Credentials Dumping in Windows Environment
PDF
An ACE in the Hole - Stealthy Host Persistence via Security Descriptors
PPTX
Pentesting ReST API
PPTX
PowerUp - Automating Windows Privilege Escalation
PPTX
Command injection
Fantastic Red Team Attacks and How to Find Them
Abusing Microsoft Kerberos - Sorry you guys don't get it
Pwning the Enterprise With PowerShell
PSConfEU - Offensive Active Directory (With PowerShell!)
I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...
Six Degrees of Domain Admin - BloodHound at DEF CON 24
Here Be Dragons: The Unexplored Land of Active Directory ACLs
aclpwn - Active Directory ACL exploitation with BloodHound
Hunting for Privilege Escalation in Windows Environment
Top 10 Web Security Vulnerabilities (OWASP Top 10)
Derbycon - The Unintended Risks of Trusting Active Directory
64 Methods for Mimikatz Execution
 
Evading Microsoft ATA for Active Directory Domination
Red Team Revenge - Attacking Microsoft ATA
Hunting for Credentials Dumping in Windows Environment
An ACE in the Hole - Stealthy Host Persistence via Security Descriptors
Pentesting ReST API
PowerUp - Automating Windows Privilege Escalation
Command injection
Ad

Similar to Defending Your "Gold" (20)

PPTX
Windows Client Privilege Escalation-Shared.pptx
PPTX
Windows Privilege Escalation Techniques.pptx
PPTX
Windows advanced
PPTX
Bridging the Gap
PDF
James Forshaw, elevator action
PPTX
Bridging the Gap: Lessons in Adversarial Tradecraft
PDF
Defendign against agrduge and preparing exploitation man
PDF
Well, that escalated quickly! - a penetration tester's approach to privilege ...
PDF
1000 to 0
PPTX
Lannguyen-Detecting Cyber Attacks
PDF
Testing UAC on Windows 10
PPTX
Living off the land and fileless attack techniques
PPTX
Unquoted service path exploitation
PPTX
Windows Privilege Escalation
PDF
CONFidence 2018: Defending Microsoft Environments at Scale (Vineet Bhatia)
PDF
Lateral Movement - Hacker Halted 2016
PDF
Lateral Movement: How attackers quietly traverse your Network
PDF
Windows Security Internals 1 / converted Edition James Forshaw
PDF
MITRE ATT&CKcon 2018: ATT&CK as a Teacher, Travis Smith, Tripwire
PDF
Esage on non-existent 0-days, stable binary exploits and user interaction
Windows Client Privilege Escalation-Shared.pptx
Windows Privilege Escalation Techniques.pptx
Windows advanced
Bridging the Gap
James Forshaw, elevator action
Bridging the Gap: Lessons in Adversarial Tradecraft
Defendign against agrduge and preparing exploitation man
Well, that escalated quickly! - a penetration tester's approach to privilege ...
1000 to 0
Lannguyen-Detecting Cyber Attacks
Testing UAC on Windows 10
Living off the land and fileless attack techniques
Unquoted service path exploitation
Windows Privilege Escalation
CONFidence 2018: Defending Microsoft Environments at Scale (Vineet Bhatia)
Lateral Movement - Hacker Halted 2016
Lateral Movement: How attackers quietly traverse your Network
Windows Security Internals 1 / converted Edition James Forshaw
MITRE ATT&CKcon 2018: ATT&CK as a Teacher, Travis Smith, Tripwire
Esage on non-existent 0-days, stable binary exploits and user interaction
Ad

More from Will Schroeder (20)

PDF
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
PDF
Nemesis - SAINTCON.pdf
PDF
Certified Pre-Owned
PDF
SpecterOps Webinar Week - Kerberoasting Revisisted
PDF
Not a Security Boundary
PDF
A Case Study in Attacking KeePass
PPTX
The Travelling Pentester: Diaries of the Shortest Path to Compromise
PDF
A Year in the Empire
PDF
Trusts You Might Have Missed - 44con
PDF
Building an EmPyre with Python
PPTX
PSConfEU - Building an Empire with PowerShell
PDF
I Have the Power(View)
PPTX
Building an Empire with PowerShell
PPTX
Trusts You Might Have Missed
PPTX
Drilling deeper with Veil's PowerTools
PPTX
I hunt sys admins 2.0
PPTX
I Hunt Sys Admins
PPTX
Derbycon - Passing the Torch
PPTX
Adventures in Asymmetric Warfare
PPTX
Pwnstaller
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Nemesis - SAINTCON.pdf
Certified Pre-Owned
SpecterOps Webinar Week - Kerberoasting Revisisted
Not a Security Boundary
A Case Study in Attacking KeePass
The Travelling Pentester: Diaries of the Shortest Path to Compromise
A Year in the Empire
Trusts You Might Have Missed - 44con
Building an EmPyre with Python
PSConfEU - Building an Empire with PowerShell
I Have the Power(View)
Building an Empire with PowerShell
Trusts You Might Have Missed
Drilling deeper with Veil's PowerTools
I hunt sys admins 2.0
I Hunt Sys Admins
Derbycon - Passing the Torch
Adventures in Asymmetric Warfare
Pwnstaller

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation theory and applications.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
 
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Cloud computing and distributed systems.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Modernizing your data center with Dell and AMD
PDF
Machine learning based COVID-19 study performance prediction
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
 
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation theory and applications.pdf
MYSQL Presentation for SQL database connectivity
Spectral efficient network and resource selection model in 5G networks
Diabetes mellitus diagnosis method based random forest with bat algorithm
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
 
20250228 LYD VKU AI Blended-Learning.pptx
Cloud computing and distributed systems.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Modernizing your data center with Dell and AMD
Machine learning based COVID-19 study performance prediction
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Encapsulation_ Review paper, used for researhc scholars
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The AUB Centre for AI in Media Proposal.docx
 
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Unlocking AI with Model Context Protocol (MCP)
Building Integrated photovoltaic BIPV_UPV.pdf

Defending Your "Gold"

  • 1. Protecting Your Gold Will Schroeder, Specter Ops Standard Image Analysis With PowerShell
  • 2. Agenda • PowerUp • Common Privesc Primitives • Service (Binary) Permissions • %PATH% hijacking • Processes, Threads, and User Rights • Autoruns • Provisioning Leftovers/Grab Bag • “Rotten Potato“ • Custom Software Analysis
  • 3. • Discovery • Delivery • Exploitation • C2 Installation • Privilege Escalation • Lateral Movement • Data Collection • Data Exfiltration Cyber Kill Chain Discovery Delivery Exploitation C2 Installation Privilege Escalation Lateral Movement Data Exfiltration Data Collection
  • 4. Privilege Escalation • Most attackers (and us) try to find a way to escalate privileges to local administrator/SYSTEM after initial access is gained • Everyone isn’t a local admin any more! • The two main approaches tend to be 0day/exploits and the abuse of misconfigurations • You should examine your gold base system images every time there’s a major change!
  • 5. • A self- contained PowerShell tool that automates the audit and exploitation of a number of common privilege escalation PowerUp
  • 6. • Now part of PowerSploit (.PrivescPowerUp.ps1) • Strict Version 2 compatibility • (Now) doesn’t start any additional processes, nor does it depend on any external binaries • I.E. uses ChangeServiceConfig() instead of “set Svc binPath= malicious command” • Uses PSReflect for Win32 API access PowerUp’s Approach
  • 7. • Services are a defined Windows securable object • So we can use QueryServiceObjectSecurity() • Services themselves sometimes have misconfigured permissions (rare, but it happens) • More common are misconfigured permissions on the binary associated with the service • If an unprivileged user can replace the binary for a service, they can gain code execution when the service/machine restarts • PowerUp: Vulnerable Services
  • 8. • When a Windows application tries to load a particular .DLL, it searches specific locations in a predefined order 1. The directory from which the application is loaded 2. The 32-bit system directory (C:WindowsSystem32) 3. The 16-bit system directory (C:WindowsSystem) 4. The Windows directory (C:Windows) 5. The current working directory 6. Any directories that are listed in the PATH environment variable Sidenote: DLL Load Order
  • 9. • When a process tries to load a DLL, there is a predefined search order for the DLL location • The last search location is any folder in %PATH% • One service on Windows 7 (IKEEXT) tries to load a DLL that doesn’t exist (wlbsctrl.dll) • Translation: if we can write to any folder in %PATH% on a Windows 7 machine (like C:Python27) we can escalate %PATH% Hijacking
  • 10. • Processes and threads are securable objects as well • Something we’re going to look more heavily heavily into this year • User Rights include specific privileges Processes, Threads, and User Rights
  • 11. • Anything that’s set to automatically run in a (potentially) elevated context is a candidate for hijacking • For the registry: • Enumerate all autoruns in HKLM • Check if the current user can modify any binary or arguments for any discovered autoruns • PowerUp: Get-ModifiableRegistryAutoRun • For scheduled tasks: • Enumerate scheduled tasks where the current user can modify any file in the associated Hijacking Autoruns and Scheduled Tasks
  • 12. • We occasionally find left over Unattended.xml answer files that have passwords set for local account provisioning • PowerUp: Get-UnattendedInstallFile • Some Group Policy Preference files contain a decryptable cpassword attribute (Get-GPPPassword…) • These GPOs are sometimes cached on the host • PowerUp: Get-CachedGPPPassword Provisioning Leftovers
  • 13. • If [HKLM|HKCU|SOFTWAREPoliciesMicrosoftW indowsInstallerAlwaysInstallElevated is set, all .MSI files run elevated… • PowerUp: Get-RegistryAlwaysInstallElevated Misc. Grab-bag
  • 14. • In late 2016, researchers from FoxGlove Security released an attack called “Rotten Potato” • This allows you to escalate from a service account (or any account with SeImpersonatePrivilege) to SYSTEM • It does this by abusing a bug class disclosed by James Forshaw • DCOM/RPC is tricked into authenticating with NTLM to the same endpoint, and the resulting token is impersonated from an account with impersonation privileges Rotten Potato
  • 15. • Custom internal development is the most common root cause of escalation vectors we find • Why? Security is hard! Same with a SDL! • Part of our standard process is to search for any custom/internally developed software on any machines we gain initial access to • Bonus points if it’s C#! • This is actually very similar to dynamic malware analysis! Custom Software Analysis
  • 17. Summary • Privilege escalation is sometime that most actors attempt during their attack chain • You should examine your gold image whenever there’s a major modification! • Misconfigurations are often unintentionally introduced due to custom development or third- party applications • PowerUp automates the checks for most of these misconfigurations • You can analyze any custom-developed software pretty easily using existing malware dynamic analysis techniques!
  • 18. • Now: 15 min break • Grab a coffee • Stay here to enjoy next presentation • Change track and switch to another room • Ask me questions or meet me in a breakout session room afterwards Next Steps...
  • 20. • Will Schroeder (@harmj0y) • http://blog.harmj0y.net | will [at] harmj0y.net • Red teamer and offensive engineer for Specter Ops • Co-founder: • Veil-Framework | Empire/EmPyre | BloodHound • Developer of: • PowerView | PowerUp | current PowerSploit developer • Microsoft CDM/PowerShell MVP • Veteran trainer About_Author

Editor's Notes

  • #3: Not talking about UAC (not a security boundary : )
  • #4: Privileged == assume local administrator/SYSTEM Unprivileged == non-local admin
  • #5: Is your gold image infected?? Since I’ve been testing, there haven’t been any stock misconfigurations in Windows host images We don’t use 0days because of cost, complexity, and short lifetime
  • #6: One of the first scripts I ended up writing
  • #7: One of the first scripts I ended up writing
  • #8: Explain what a securable object is – can have ACLs applied to them Swap over and show code for vuln services
  • #10: IKEEXT – “IKE and AuthIP IPsec Keying Modules” service Also – as Matt mentioned, if you can replace python.exe or any other type of binary, can hijack execution if a prived user uses it Demo
  • #11: Demo
  • #12: Demo
  • #14: Demo
  • #15: SQL!
  • #16: Explain why we love C# Malware analysis type approaches-> Sysinternals (Procmon/Sysmon), Regshot, etc.
  • #17: -Show listing of C:\Temp\, show file that points to service -Enumerate service binary location, move over to dnSpy -Show clicking through to find alg, and porting alg to PS -Show PS generating password, and do a runas
  • #18: We use this on assessments all the time!