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
Red Team Revenge - Attacking Microsoft ATA
PPTX
Catch Me If You Can: PowerShell Red vs Blue
PDF
SpecterOps Webinar Week - Kerberoasting Revisisted
PPTX
Troopers 19 - I am AD FS and So Can You
PDF
Hunting for Privilege Escalation in Windows Environment
PDF
Red Team Methodology - A Naked Look
PDF
Not a Security Boundary
PDF
The Unintended Risks of Trusting Active Directory
Red Team Revenge - Attacking Microsoft ATA
Catch Me If You Can: PowerShell Red vs Blue
SpecterOps Webinar Week - Kerberoasting Revisisted
Troopers 19 - I am AD FS and So Can You
Hunting for Privilege Escalation in Windows Environment
Red Team Methodology - A Naked Look
Not a Security Boundary
The Unintended Risks of Trusting Active Directory

What's hot (20)

PDF
ReCertifying Active Directory
PDF
I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...
PDF
An ACE in the Hole - Stealthy Host Persistence via Security Descriptors
PDF
0wn-premises: Bypassing Microsoft Defender for Identity
PDF
APIsecure 2023 - OAuth, OIDC and protecting third-party credentials, Ed Olson...
PPTX
PSConfEU - Offensive Active Directory (With PowerShell!)
PPTX
Spring Security 3
PPTX
Abusing Microsoft Kerberos - Sorry you guys don't get it
PPTX
I Hunt Sys Admins
PPTX
(Ab)Using GPOs for Active Directory Pwnage
PPTX
Aws s3 security
PPTX
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
PPTX
Demo of security tool nessus - Network vulnerablity scanner
PDF
A Year in the Empire
PPTX
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
PDF
Racing The Web - Hackfest 2016
PDF
Introduction to red team operations
PDF
Siber Güvenlik ve Etik Hacking Sunu - 13
PDF
Certified Pre-Owned
ReCertifying Active Directory
I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...
An ACE in the Hole - Stealthy Host Persistence via Security Descriptors
0wn-premises: Bypassing Microsoft Defender for Identity
APIsecure 2023 - OAuth, OIDC and protecting third-party credentials, Ed Olson...
PSConfEU - Offensive Active Directory (With PowerShell!)
Spring Security 3
Abusing Microsoft Kerberos - Sorry you guys don't get it
I Hunt Sys Admins
(Ab)Using GPOs for Active Directory Pwnage
Aws s3 security
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
Demo of security tool nessus - Network vulnerablity scanner
A Year in the Empire
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
Racing The Web - Hackfest 2016
Introduction to red team operations
Siber Güvenlik ve Etik Hacking Sunu - 13
Certified Pre-Owned
Ad

Similar to Defending Your "Gold" (20)

PPTX
Windows Client Privilege Escalation-Shared.pptx
PPTX
Windows Privilege Escalation Techniques.pptx
PPTX
PowerUp - Automating Windows Privilege Escalation
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
Windows Client Privilege Escalation-Shared.pptx
Windows Privilege Escalation Techniques.pptx
PowerUp - Automating Windows Privilege Escalation
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
Ad

More from Will Schroeder (18)

PDF
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
PDF
Nemesis - SAINTCON.pdf
PDF
DerbyCon 2019 - Kerberoasting Revisited
PDF
Derbycon - The Unintended Risks of Trusting Active Directory
PDF
Ace Up the Sleeve
PDF
A Case Study in Attacking KeePass
PPTX
The Travelling Pentester: Diaries of the Shortest Path to Compromise
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
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
DerbyCon 2019 - Kerberoasting Revisited
Derbycon - The Unintended Risks of Trusting Active Directory
Ace Up the Sleeve
A Case Study in Attacking KeePass
The Travelling Pentester: Diaries of the Shortest Path to Compromise
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
Derbycon - Passing the Torch
Adventures in Asymmetric Warfare
Pwnstaller

Recently uploaded (20)

PDF
Connector Corner: Transform Unstructured Documents with Agentic Automation
PDF
Rapid Prototyping: A lecture on prototyping techniques for interface design
PDF
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
PDF
4 layer Arch & Reference Arch of IoT.pdf
PDF
The AI Revolution in Customer Service - 2025
PDF
SaaS reusability assessment using machine learning techniques
PDF
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
PDF
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
PPTX
agenticai-neweraofintelligence-250529192801-1b5e6870.pptx
PPTX
Internet of Everything -Basic concepts details
PDF
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
PPTX
SGT Report The Beast Plan and Cyberphysical Systems of Control
PDF
giants, standing on the shoulders of - by Daniel Stenberg
PDF
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
PPTX
MuleSoft-Compete-Deck for midddleware integrations
PDF
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
PDF
Early detection and classification of bone marrow changes in lumbar vertebrae...
PDF
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
PDF
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
PDF
A symptom-driven medical diagnosis support model based on machine learning te...
Connector Corner: Transform Unstructured Documents with Agentic Automation
Rapid Prototyping: A lecture on prototyping techniques for interface design
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
4 layer Arch & Reference Arch of IoT.pdf
The AI Revolution in Customer Service - 2025
SaaS reusability assessment using machine learning techniques
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
agenticai-neweraofintelligence-250529192801-1b5e6870.pptx
Internet of Everything -Basic concepts details
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
SGT Report The Beast Plan and Cyberphysical Systems of Control
giants, standing on the shoulders of - by Daniel Stenberg
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
MuleSoft-Compete-Deck for midddleware integrations
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
Early detection and classification of bone marrow changes in lumbar vertebrae...
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
A symptom-driven medical diagnosis support model based on machine learning te...

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!