Catch Me If You Can: PowerShell Red vs Blue

Offensive Engineer
May. 14, 2017
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
1 of 39

More Related Content

What's hot

AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does ItAMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does ItNikhil Mittal
Ace Up the SleeveAce Up the Sleeve
Ace Up the SleeveWill Schroeder
Not a Security BoundaryNot a Security Boundary
Not a Security BoundaryWill Schroeder
PSConfEU - Offensive Active Directory (With PowerShell!)PSConfEU - Offensive Active Directory (With PowerShell!)
PSConfEU - Offensive Active Directory (With PowerShell!)Will Schroeder
PowerShell for Practical Purple TeamingPowerShell for Practical Purple Teaming
PowerShell for Practical Purple TeamingNikhil Mittal
Hunting Lateral Movement in Windows InfrastructureHunting Lateral Movement in Windows Infrastructure
Hunting Lateral Movement in Windows InfrastructureSergey Soldatov

Viewers also liked

Obfuscating The EmpireObfuscating The Empire
Obfuscating The EmpireRyan Cobb
PuppetConf 2017: Inviting Windows to the Puppet Party- Chris Kittell & Derek ...PuppetConf 2017: Inviting Windows to the Puppet Party- Chris Kittell & Derek ...
PuppetConf 2017: Inviting Windows to the Puppet Party- Chris Kittell & Derek ...Puppet
A Case Study in Attacking KeePassA Case Study in Attacking KeePass
A Case Study in Attacking KeePassWill Schroeder
BSides London 2017 - Hunt Or Be HuntedBSides London 2017 - Hunt Or Be Hunted
BSides London 2017 - Hunt Or Be HuntedAlex Davies
Invoke-Obfuscation nullcon 2017Invoke-Obfuscation nullcon 2017
Invoke-Obfuscation nullcon 2017Daniel Bohannon
WMI for Penetration Testers - Arcticcon 2017WMI for Penetration Testers - Arcticcon 2017
WMI for Penetration Testers - Arcticcon 2017Alexander Polce Leary

Similar to Catch Me If You Can: PowerShell Red vs Blue

DevoxxUK 2016: "DevOps: Microservices, containers, platforms, tooling... Oh y...DevoxxUK 2016: "DevOps: Microservices, containers, platforms, tooling... Oh y...
DevoxxUK 2016: "DevOps: Microservices, containers, platforms, tooling... Oh y...Daniel Bryant
Presentation infra and_datacentrre_dialogue_v2Presentation infra and_datacentrre_dialogue_v2
Presentation infra and_datacentrre_dialogue_v2Claus Cramon Houmann
DevOps and the cloud: all hail the (developer) king - Daniel Bryant, Steve PooleDevOps and the cloud: all hail the (developer) king - Daniel Bryant, Steve Poole
DevOps and the cloud: all hail the (developer) king - Daniel Bryant, Steve PooleJAXLondon_Conference
Defcon 22-wesley-mc grew-instrumenting-point-of-sale-malwareDefcon 22-wesley-mc grew-instrumenting-point-of-sale-malware
Defcon 22-wesley-mc grew-instrumenting-point-of-sale-malwarePriyanka Aash
JAXLondon 2015 "DevOps and the Cloud: All Hail the (Developer) King"JAXLondon 2015 "DevOps and the Cloud: All Hail the (Developer) King"
JAXLondon 2015 "DevOps and the Cloud: All Hail the (Developer) King"Daniel Bryant
Defining DevSecOpsDefining DevSecOps
Defining DevSecOpsUchit Vyas ☁

Similar to Catch Me If You Can: PowerShell Red vs Blue(20)

More from Will Schroeder

ReCertifying Active DirectoryReCertifying Active Directory
ReCertifying Active DirectoryWill Schroeder
Certified Pre-OwnedCertified Pre-Owned
Certified Pre-OwnedWill Schroeder
SpecterOps Webinar Week - Kerberoasting RevisistedSpecterOps Webinar Week - Kerberoasting Revisisted
SpecterOps Webinar Week - Kerberoasting RevisistedWill Schroeder
DerbyCon 2019 - Kerberoasting RevisitedDerbyCon 2019 - Kerberoasting Revisited
DerbyCon 2019 - Kerberoasting RevisitedWill Schroeder
Derbycon - The Unintended Risks of Trusting Active DirectoryDerbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active DirectoryWill Schroeder
The Unintended Risks of Trusting Active DirectoryThe Unintended Risks of Trusting Active Directory
The Unintended Risks of Trusting Active DirectoryWill Schroeder

Recently uploaded

Supplier Sourcing_Cathy.pptxSupplier Sourcing_Cathy.pptx
Supplier Sourcing_Cathy.pptxCatarinaTorrenuevaMa
Unleashing Innovation: IoT Project with MicroPythonUnleashing Innovation: IoT Project with MicroPython
Unleashing Innovation: IoT Project with MicroPythonVubon Roy
Understanding Wireguard, TLS and Workload IdentityUnderstanding Wireguard, TLS and Workload Identity
Understanding Wireguard, TLS and Workload IdentityChristian Posta
How to use the Cataloguing Code Ethics at your day job : a hands-on workshop ...How to use the Cataloguing Code Ethics at your day job : a hands-on workshop ...
How to use the Cataloguing Code Ethics at your day job : a hands-on workshop ...CILIP MDG
Future of SkillsFuture of Skills
Future of SkillsAlison B. Lowndes
Webinar: Discover the Power of SpiraTeam - A Jira Alternative To Revolutioniz...Webinar: Discover the Power of SpiraTeam - A Jira Alternative To Revolutioniz...
Webinar: Discover the Power of SpiraTeam - A Jira Alternative To Revolutioniz...Inflectra

Catch Me If You Can: PowerShell Red vs Blue

Editor's Notes

  1. Will show the evolution of offense and the defensive projects and mitigations that have been implemented in response Will not cover ALL tools, just ones I think are “evolutionary” relevant Focus only on “legitimate”/open-source offensive capabilities -> won’t cover crimeware/etc.
  2. Quote- Microsoft Office365 red teaming whitepaper Access to .NET/the API, can stay off of disk, can reassemble malicious binaries in memory, etc. Explain what led us to PowerShell
  3. “The Version 2 problem” – explain why we care about it from the offensive perspective
  4. https://www.youtube.com/watch?v=JKlVONfD53w Talked some about execution policy Main contribution - PowerDump
  5. Built by Matt Graeber Eventually repurposed into open source offensive toolsets like Metasploit
  6. Both coded by Joe Bialek Mainly built so every binary didn’t have to be recoded into pure PowerShell https://github.com/PowerShellMafia/PowerSploit/blob/dev/CodeExecution/Invoke-ReflectivePEInjection.ps1 https://github.com/PowerShellMafia/PowerSploit/blob/dev/Exfiltration/Invoke-Mimikatz.ps1
  7. Invoke-Mimikatz that creates a golden ticket for the parent domain and then DCSyncs the krbtgt of the root
  8. https://github.com/PowerShellMafia/PowerSploit/blob/dev/Recon/PowerView.ps1 https://gallery.technet.microsoft.com/Net-Cease-Blocking-Net-1e8dcb5b https://gallery.technet.microsoft.com/SAMRi10-Hardening-Remote-48d94b5b   https://github.com/davehull/Kansa - Incident response collection cmdlets (Dave Hull) https://github.com/Invoke-IR/Uproot - IDS via WMI Event Subscriptions https://github.com/mattifestation/PowerShellArsenal - Reverse engineering
  9. https://github.com/mattifestation/PSReflect Why not use Add-Type? Explain… Swap over- show PowerView code before and after
  10. Twitter thread about “can we run PowerShell without powershell.exe” PowerForensics – explain CreateFile() approach to avoid native APIs http://www.sixdub.net/?p=367#more-367 https://github.com/PowerShellEmpire/PowerTools/tree/master/PowerPick/SharpPick https://github.com/leechristensen/UnmanagedPowerShell
  11. https://github.com/EmpireProject/PSInject $Code = ' [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms"); [System.Windows.Forms.MessageBox]::Show("This is PS code! Current proc: $(Get-Process -Id $PID)"); ' $Encoded = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($Code)) Start-Process notepad Invoke-PSInject -ProcName notepad -PoshCode $Encoded
  12. Command Line Version Parameter – “-version 2” Hosting Applications Compiled using V2 Reference Assemblies – “the “Windows PowerShell” classic event log has event ID 400. This is the “Engine Lifecycle” event, and includes the Engine Version.”
  13. Released a month before Empire was slated to be released – gave me an existential freakout! -Better transcription with Start-Transcript and automatic transcription options -Deep script block logging -AMSI
  14. -Transcription allows for automatic recording of PowerShell sessions -Module logging records pipeline execution details as PowerShell executes, including variable initialization and command invocations. -Module logging will record portions of scripts, some de-obfuscated code, and some data formatted for output.  -Script block logging records blocks of code as they are executed by the PowerShell engine, thereby capturing the full contents of code executed by an attacker, including scripts and commands. Including code AFTER it was de-obfuscated! These suspicious blocks are logged at the “warning” level in EID 4104, unless script block logging is explicitly disabled. This feature ensures that some forensic data is logged for known-suspicious activity, even if logging is not enabled https://github.com/PowerShell/PowerShell/blob/02b5f357a20e6dee9f8e60e3adb9025be3c94490/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs#L1612-L1660
  15. PowerShellEmpire – talked about last year https://github.com/EmpireProject/Empire
  16. 2015- “Measure-VariableObfuscation” which relies on PowerShellArsenal to create “Obfuscation Metrics” for scripts
  17. And system.management.automation.ni.dll – why the wildcard https://github.com/PowerShellMafia/CimSweep https://github.com/BloodHoundAD/BloodHound https://gist.github.com/mattifestation/7fe1df7ca2f08cbfa3d067def00c01af
  18. ipmo .\Invoke-Obfuscation.psd1 Invoke-Obfuscation SET SCRIPTBLOCK function Invoke-Stuff { Get-Process }; Invoke-Stuff token all 1 clip (Show you executing it in a powershell window) back back STRING 3 clip (Show you executing it in a powershell window) back encoding 6 clip (Show you executing it in a powershell window) back launcher rundll++ 0 clip (run in cmd.exe)
  19. Matt Graeber will speak on this on day 3 (device guard) Device Guard force PS into constrained language mode - https://msdn.microsoft.com/powershell/reference/5.1/Microsoft.PowerShell.Core/about/about_Language_Modes No reflection, add-type, limits New-Object(e.g. no creating arbitrary COM objects) https://github.com/ChrisTruncer/WMImplant
  20. https://gist.github.com/jaredcatkinson/23905d34537ce4b5b1818c3e6405c1d2
  21. After this, you should WANT attackers to use PowerShell! Try and block the attacker, but if he still gets in, we want to be able to detect and see what he did
  22. 42:00