410 likes | 948 Views
PowerShell Security best practices. Lee Holmes | @ Lee_Holmes Principal SDE |Windows PowerShell | Microsoft. Security geek Developer on the Windows PowerShell team since V1 Author of the Windows PowerShell Cookbook, PowerShellCookbook.com, and Windows PowerShell Pocket Reference
E N D
PowerShell Security best practices Lee Holmes | @Lee_Holmes Principal SDE |Windows PowerShell | Microsoft
Security geek • Developer on the Windows PowerShell team since V1 • Author of the Windows PowerShell Cookbook, PowerShellCookbook.com, and Windows PowerShell Pocket Reference • @Lee_Holmes & leeholmes.com/blog About Me
What about Execution Policy? • PowerShell Remoting • Scripts Executables • Dealing with Forensics PowerShell the ShellOperational Security
PowerShell the ShellOperational Security – Execution Policy Not a user restriction Not a magical form of Antimalware
You Remoting Host Files PowerShell the ShellOperational Security – PowerShell Remoting Understanding the Double-Hop problem Authentication: Kerberos vs. CredSSP – Pass the Hash? Accessing Remote Resources
PowerShell the ShellOperational Security – Scripts Executables Moving to Post-Exploitation defense “I want to secure my system against C++ attacks” Making sense of holistic system lockdown
PowerShell the ShellOperational Security – Dealing with Forensics @HackingDave @ObscureSec / @Mattifestation “Living off the Land” @JosephBialek “Reflective DLL Injection”
Preventing unrestricted admin access System-wide Transcripts Automatic Module logging Detecting attacks on mitigations PowerShell the ShellOperational Security – Dealing with Forensics
Script Encryption / Obfuscation • Avoiding Code Injection • Avoiding Hard-Coded Secrets PowerShell the LanguageScripting Security
PowerShell the LanguageScripting Security - Script Encryption / Obfuscation
PowerShell the LanguageScripting Security - Script Encryption / Obfuscation Answer: Don’t.
When dealing with dynamic commands or parameters, it’s common to fall back to old programming practices: system(), eval(), exec() Maybe Invoke-Expression? PowerShell the LanguageScripting Security - Preventing Code Injection
PowerShell the LanguageScripting Security – Avoiding Code Injection
PowerShell the LanguageScripting Security – Avoiding Code Injection Parameters support variables Commands support splatting Invocation supports indirection
PowerShell the LanguageScripting Security – Avoiding Code Injection But I REALLY need to!
PowerShell the LanguageScripting Security – Avoiding Code Injection But I REALLY need to!
PowerShell the LanguageScripting Security - Avoiding Hard-Coded Secrets Data protection through Windows’ Data Protection API (DPAPI)
PowerShell the LanguageScripting Security - Avoiding Hard-Coded Secrets Export / Import CliXml ConvertFrom / ConvertToSecureString
Reflective DLL Loading with PowerShell: http://www.youtube.com/watch?v=OAd68_SYQc8 • Living off the Land: http://www.youtube.com/watch?v=j-r6UonEkUw • Get-Help about_Group_Policy_Settingshttp://technet.microsoft.com/en-us/library/jj149004.aspx • Constrained PowerShell Endpointshttp://www.youtube.com/watch?v=kmjJLKlL1Wg • PowerShell Language Specification: http://www.microsoft.com/en-us/download/details.aspx?id=36389 • Composing Command Arguments: http://www.powershellcookbook.com/recipe/XoMw/run-programs-scripts-and-existing-tools Resources