+ All Categories
Home > Technology > SANS DFIR Prague: PowerShell & WMI

SANS DFIR Prague: PowerShell & WMI

Date post: 21-Jan-2018
Category:
Upload: joe-slowik
View: 483 times
Download: 5 times
Share this document with a friend
39
Transcript
Page 1: SANS DFIR Prague: PowerShell & WMI
Page 2: SANS DFIR Prague: PowerShell & WMI
Page 3: SANS DFIR Prague: PowerShell & WMI

• Quick Background• Malicious Possibilities• Real-World Examples• Detection & Defense

Page 4: SANS DFIR Prague: PowerShell & WMI

• Joe Slowik, Adversary Hunter• Current: Dragos Adversary Hunter• Previous:

• Los Alamos National Lab: IR Lead• US Navy: Information Warfare Officer• University of Chicago: Philosophy Drop-Out

Page 5: SANS DFIR Prague: PowerShell & WMI

• Scripting and interactive language• Introduced in 2006, integral to Win7+

since 2009• Full access to COM & WMI for system

administration

Page 6: SANS DFIR Prague: PowerShell & WMI

• WMI = Windows Management Instrumentation

• Interactive and scriptable framework for local and remote administration

• Frequently accessed via PowerShell

Page 7: SANS DFIR Prague: PowerShell & WMI

http://oversitesentry.com/wp-content/uploads/2015/08/wmiarchitecture.png

Page 8: SANS DFIR Prague: PowerShell & WMI

http://kevinpelgrims.com/blog/files/images/2010/02/powershell_rsm.png

Page 9: SANS DFIR Prague: PowerShell & WMI

http://www.opentechguides.com/how-to/article/powershell/132/get-system-info-remotely.html

Page 10: SANS DFIR Prague: PowerShell & WMI

https://4sysops.com/wp-content/uploads/2013/03/WBEMTest-Translate-into-PowerShell.png

Page 11: SANS DFIR Prague: PowerShell & WMI

http://www.freeiconspng.com/img/17209

• PowerShell is a powerful, useful tool for network administration

• Widely used in Windows Enterprise environments

Page 12: SANS DFIR Prague: PowerShell & WMI

• WMI enables significant access to review and modify system data

• Access via PowerShell allows for scripting and automated possibilities

Page 13: SANS DFIR Prague: PowerShell & WMI
Page 14: SANS DFIR Prague: PowerShell & WMI

• PowerShell’s ubiquity adds a significant capability to potential attacker

• Enhances ability to ‘live off the land’• Expands initial infection vectors

Page 15: SANS DFIR Prague: PowerShell & WMI

Command Use

-EncodedCommand Accepts Base64-encoded input for execution within PowerShell

(New-Object System.New.Webclient).DownloadFile()

Download a file from a remote location; can be piped to Start-Process to execute

-ExecutionPolicy Bypass Circumvent system limits on script execution

-WindowStyle Hidden Hide the command window from the user

-Invoke-Expression Execute arbitrary code or commands

Page 16: SANS DFIR Prague: PowerShell & WMI

DeliveryVectors

VBA

VBS

BAT

JS

Registry

Startup.lnk

Page 17: SANS DFIR Prague: PowerShell & WMI

https://adsecurity.org/wp-content/uploads/2016/02/PowerShell-Detection-NetWebClientDownload.jpg

Page 18: SANS DFIR Prague: PowerShell & WMI

• WMI is also ubiquitous, potent ‘dual-use’• Can enable:• Complex exploitation, persistence of

infected host• New vectors to pivot within network

Page 19: SANS DFIR Prague: PowerShell & WMI

• PsExec-like remote execution• Malicious file/script storage• Persistence when combined with file or

registry activity

Page 20: SANS DFIR Prague: PowerShell & WMI

• Pentesting frameworks• Crimeware/Commodity malware• APT

Page 21: SANS DFIR Prague: PowerShell & WMI
Page 22: SANS DFIR Prague: PowerShell & WMI
Page 23: SANS DFIR Prague: PowerShell & WMI

• Malicious VBA decodes to PowerShell• Retrieves, then executes ransomware

payload

Page 24: SANS DFIR Prague: PowerShell & WMI
Page 25: SANS DFIR Prague: PowerShell & WMI

• WMI filter retrieved on schedule• Returns base64-encoded PowerShell• PowerShell re-launches backdoor

https://www.fireeye.com/blog/threat-research/2017/03/dissecting_one_ofap.html

Page 26: SANS DFIR Prague: PowerShell & WMI
Page 27: SANS DFIR Prague: PowerShell & WMI

https://www.carbonblack.com/wp-content/uploads/2015/12/PS7.png

Page 28: SANS DFIR Prague: PowerShell & WMI

CMD•Command

execution

•Execution Parameters

PowerShell• Interactive and

Scripts

• Flags, Modifiers, full Visibility

WMI• Log Events

• Correlate with Other Activity

Page 29: SANS DFIR Prague: PowerShell & WMI

What is required to

achieve ‘bad’?

Process Execution

PersistenceEncodeDecode

DownloadUpload

Page 30: SANS DFIR Prague: PowerShell & WMI

• Sysinternals Sysmon• Windows Loggging Service (WLS)• WMI Logging via WMI Subscription• PowerShell Logging• Proprietary Host-based Security

Page 31: SANS DFIR Prague: PowerShell & WMI

• WLS incorporates PowerShell logging natively• Otherwise:

• Windows 7+• Powershell 5.0+• Enable logging!

• See: • https://www.fireeye.com/blog/threat-

research/2016/02/greater_visibilityt.html

Page 32: SANS DFIR Prague: PowerShell & WMI

• Sysinternals Sysmon – latest version includes WMI visibility• But logging/alerting will need to be

tuned• DIY via WMI Subscription creation• Otherwise – commercial products

Page 33: SANS DFIR Prague: PowerShell & WMI

Establish Visibility

Baseline ‘Normal’

Identify Malicious

Create Alerts & Alarms

Develop Response

Page 34: SANS DFIR Prague: PowerShell & WMI

• What PowerShell/WMI scripts are used in ‘normal’ network administration?

• What commands never have legitimate use?

• What – if any – items require whitelisting?

Page 35: SANS DFIR Prague: PowerShell & WMI
Page 36: SANS DFIR Prague: PowerShell & WMI

wmic /node:REMOTESYSTEM process call create “EVIL_COMMAND”

SELECT * FROM Win32_BIOS WHERE SerialNumber LIKE “%VMware%”

$BADTHING=New-ObjectManagement.ManagementClass($REMOTESYSTEM,

[String]::Empty,$null)

$BADTHING[‘__CLASS’]=’Evil_Malware’

$BADTHING.Properties.Add(‘SomethingEvil’,[Management.CimType]

::String,$False)

$BADTHING.Properties[‘SomethingEvil’].Value =$PAYLOAD

$EvilClass.Put()

Page 37: SANS DFIR Prague: PowerShell & WMI
Page 38: SANS DFIR Prague: PowerShell & WMI

• Create Event Consumer: performs action when triggered by event

• Pair with Event Filter: events of interest• Filter to Consumer Binding: bind filter to

consumer• Export results to log file, data store• Credit: https://www.fireeye.com/blog/threat-

research/2016/08/wmi_vs_wmi_monitor.html

Page 39: SANS DFIR Prague: PowerShell & WMI

Recommended