hunting in the dark - unc cybersecurity symposium 2016

65
Hunting in the Dark Ryan Kazanciyan, Chief Security Architect October 5, 2016

Upload: ryan-kazanciyan

Post on 15-Apr-2017

233 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Hunting in the DarkRyan Kazanciyan, Chief Security Architect

October 5, 2016

Page 2: Hunting in the Dark - UNC Cybersecurity Symposium 2016

whoami

Copyright 2016 Tanium Inc. All rights reserved.2

Page 3: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Examining an environment, on a proactive or reactive basis, for evidence of malicious activity –

without specific investigative leads

Page 4: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Goals and success criteria

Copyright 2016 Tanium Inc. All rights reserved.4

• Functional at enterprise-scale• Complementary to IOC & threat feed detection• Repeatable over time

Page 5: Hunting in the Dark - UNC Cybersecurity Symposium 2016

My focus for this presentation

Copyright 2016 Tanium Inc. All rights reserved.5

• Endpoint-centric• Widely-available data• Techniques, not specific tools

Page 6: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Common Pitfalls

Page 7: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Distinguishing normal, interesting, and bad

Page 8: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Analysts often radically underestimate the noise level of an enterprise environment

Page 9: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Your applications are noisy

Copyright 2016 Tanium Inc. All rights reserved.9

• Different OS versions and add-ons • User-installed applications• Random / GUID file names & paths• Temporary artifacts of software installers• Updates & patches

“How many unique PE files (EXEs, DLLs, drivers) have been loaded across all my systems?”

Page 10: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Your users are noisy

Copyright 2016 Tanium Inc. All rights reserved.10

• Maintenance and administration scripts• Ad-hoc troubleshooting• Service and application accounts• Misunderstood native OS behavior

“How often do my privileged accounts authenticate across the environment?

Page 11: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Overwhelming yourself with data, “just in case”…

Page 12: Hunting in the Dark - UNC Cybersecurity Symposium 2016

You cannot capture everything, constantly

Copyright 2016 Tanium Inc. All rights reserved.12

• OS-level telemetry• Application-level telemetry• Data at-rest• Volatile memory

Page 13: Hunting in the Dark - UNC Cybersecurity Symposium 2016

We’ve been through this already…

Copyright 2016 Tanium Inc. All rights reserved.13

Expectation Reality

Page 14: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Falling victim to tunnel vision on “important assets”

Page 15: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Defender bias

Copyright 2016 Tanium Inc. All rights reserved.15

“…whatmaybecriticaltoyou…maynotbethe‘crownjewels’fromtheperspectiveoftheadversary...”

“You'llfindyourselfhunkereddowninyourMaginotLinebunkers,awaitingthatfinalassault,onlytobe

mystifiedwhenitneverseemstocome.”– HarlanCarvey

Source:http://windowsir.blogspot.com)

Page 16: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Hacking is graph traversal

Copyright 2016 Tanium Inc. All rights reserved.16

Page 17: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Practical example: BloodHound

Copyright 2016 Tanium Inc. All rights reserved.17

• Graph analysis of AD relationships

• Identify pathways to privilege escalation

https://github.com/adaptivethreat/BloodHound

Page 18: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Developing a sustainable hunting strategy

Page 19: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Structuring the process

Copyright 2016 Tanium Inc. All rights reserved.19

ExternalIOCs&reputation

data

HomegrownIOCs&ad-hocsearches

Targetedhunting

workflows

Continuous&automated

analysis

Page 20: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Success criteria

Copyright 2016 Tanium Inc. All rights reserved.20

• Establish useful baselines• Implement repeatable & scalable tasks• Track “hit rate” vs. level of effort• Drive towards automation

Page 21: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Focusing on High-Value Data

Page 22: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Prioritizing your efforts

Copyright 2016 Tanium Inc. All rights reserved.22

• What are the “lowest common denominators” across intrusions?

• What evidence do they leave behind?

• What easily-observable outlier conditions do they create?

Page 23: Hunting in the Dark - UNC Cybersecurity Symposium 2016

MITRE’s “ATT^CK” framework

Copyright 2016 Tanium Inc. All rights reserved.23

https://attack.mitre.org/wiki/Technique_Matrix

Page 24: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Collecting and Managing the Data

Page 25: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Assess your visibility

Copyright 2016 Tanium Inc. All rights reserved.25

• What’s available?• At what scale?• How much post-

processing?• What’s available ad-

hoc?• What may require

“data lakes”?

Page 26: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Mitigating the “Long Tail”

Page 27: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Group your systems, group your data

Copyright 2016 Tanium Inc. All rights reserved.27

Page 28: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Practical Examples

Page 29: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Hunting for Lateral Command Execution

Page 30: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Lateral command execution

Copyright 2016 Tanium Inc. All rights reserved.30

Page 31: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Example: Duqu 2.0 and Scheduled Tasks

Copyright 2016 Tanium Inc. All rights reserved.31

“Inaddition tocreatingservicestoinfectothercomputersintheLAN,attackerscanalsousetheTaskScheduler tostart‘msiexec.exe’remotely.TheusageofTaskSchedulerduring Duquinfectionsforlateralmovementwasalsoobservedwiththe2011version...”

Source:https://securelist.com/files/2015/06/The_Mystery_of_Duqu_2_0_a_sophisticated_cyberespionage_actor_returns.pdf

Page 32: Hunting in the Dark - UNC Cybersecurity Symposium 2016

What was the shared IOC?

32

Page 33: Hunting in the Dark - UNC Cybersecurity Symposium 2016

How could we do better?

Page 34: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Hunting tasks with event logs

Copyright 2016 Tanium Inc. All rights reserved.34

• 106 (Task Registered)• 129 (Created Task Process)• 200 (Action Started)• 201 (Action Completed)

Event IDs to harvest

• TaskName (What’s the task called?)• UserContext (Who registered it?)• ActionName (What did it run?)

Fields to filter & stack

Microsoft-Windows-TaskScheduler/Operational.evtx

Page 35: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Stack and search workflow

Copyright 2016 Tanium Inc. All rights reserved.35

Page 36: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Stack and search workflow

Copyright 2016 Tanium Inc. All rights reserved.36

Page 37: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Copyright 2016 Tanium Inc. All rights reserved.37

Page 38: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Copyright 2016 Tanium Inc. All rights reserved.38

Page 39: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Revisiting our example: Duqu 2.0

Copyright 2016 Tanium Inc. All rights reserved.39

• How common are remotely registered tasks with ActionName=“msiexec.exe”

• By user? By time? By endpoints?• Could you have found this proactively, without any leads?

Source:Kaspersky

Page 40: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Interesting blind spot: COM handler tasks

Copyright 2016 Tanium Inc. All rights reserved.40

• Cannot examine or edit in Task Viewer UI

• ActionName is a descriptive string

• How do you know what this loads?

Page 41: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Mapping COM handler to associated DLL

Copyright 2016 Tanium Inc. All rights reserved.41

Page 42: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Attacker limitations

Copyright 2016 Tanium Inc. All rights reserved.42

• Must import task configuration XML file if using COM

schtasks /Create /XML c:\EvilTask.xml/TN Microsoft\Windows\CertificateServicesClient\EvilTask

• Cannot modify existing tasks without breaking hash– Stored in the registry– Stuxnet exploited weak task hash algorithm in older versions of Windows

Page 43: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Other approaches to scheduled task analysis

Copyright 2016 Tanium Inc. All rights reserved.43

• Examine configurations for “at-rest” tasks

• Detect anomalous tasks as they are created

Page 44: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Stacking “current” tasks: Command lines

Copyright 2016 Tanium Inc. All rights reserved.44

Page 45: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Stacking “current” tasks: Full metadata

Copyright 2016 Tanium Inc. All rights reserved.45

Page 46: Hunting in the Dark - UNC Cybersecurity Symposium 2016

“In-motion” remote task creation

Copyright 2016 Tanium Inc. All rights reserved.46

Page 47: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Hunting for Services

Page 48: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Windows Services

Copyright 2016 Tanium Inc. All rights reserved.48

• Common persistence mechanism for long-running malware

• Loading mechanism for short-lived tools

• Installation and usage leaves behind evidence– Registry– Service control manager– Event logs

Page 49: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Examples from the wild

Copyright 2016 Tanium Inc. All rights reserved.49

Duqu 2.0(Kaspersky)

BlackEnergy installingWinPCAP (ArborNetworks)

CosmicDuke (F-Secure)

Page 50: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Service activity in event logs

Copyright 2016 Tanium Inc. All rights reserved.50

Page 51: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Stacking service creation events

Copyright 2016 Tanium Inc. All rights reserved.51

• “Who created which services?”• “When and where?”• ServiceName + ImagePath + User from EID 7045• Use time and hostname to further sub-filter

Example / Case Study: Harvesting PsExec service events

Page 52: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Blind spots and noise

Copyright 2016 Tanium Inc. All rights reserved.52

• Attackers can install services without calling CreateService– Avoids generating event log entry– Still may leave evidence in registry

• Many 3rd party applications install services• Noise over time

Page 53: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Stack analysis of current services

Copyright 2016 Tanium Inc. All rights reserved.53

Page 54: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Further persistence analysis

Copyright 2016 Tanium Inc. All rights reserved.54

Page 55: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Stack Analysis of Process Trees

Page 56: Hunting in the Dark - UNC Cybersecurity Symposium 2016

What are process trees?

Copyright 2016 Tanium Inc. All rights reserved.56

Page 57: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Another example

Copyright 2016 Tanium Inc. All rights reserved.57

Page 58: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Finding interesting trees in forests

Copyright 2016 Tanium Inc. All rights reserved.58

• Attackers often use native OS commands

• Attackers often exploit or leverage native OS services

• Both should result in outlier process lineages

Page 59: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Sources of data

Copyright 2016 Tanium Inc. All rights reserved.59

• For each running process, record:– ImageName (or ImagePath) – Parent name (or path)

• Options in Windows– Process auditing (native, optional setting)– Sysmon (free Microsoft SysInternals driver)

• Post-processing to “flatten” and stack

Page 60: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Example: cmd.exe as child

Copyright 2016 Tanium Inc. All rights reserved.60

Page 61: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Example: svchost.exe as parent

Copyright 2016 Tanium Inc. All rights reserved.61

Page 62: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Interesting targets

Copyright 2016 Tanium Inc. All rights reserved.62

• Shells & interpreters– cmd.exe– powershell.exe– cscript.exe– wscript.exe– mshta.exe– rundll32.exe

• Tools for lateral movement– net.exe– at.exe

– schtasks.exe / taskeng.exe– wmic.exe / wmiprvse.exe

• Commonly “hijacked” processes– svchost.exe– w3wp.exe– iexplore.exe– winword.exe– excel.exe

Page 63: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Conclusion

Page 64: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Next steps

Copyright 2016 Tanium Inc. All rights reserved.64

• Pick one of these techniques and practice!• Learn the “noise” of your own environment• Incorporate into red-vs-blue team exercises• Ensure endpoint tools enable rapid search and harvesting

– Volatile activity– Data “at-rest”– Historical telemetry

Page 65: Hunting in the Dark - UNC Cybersecurity Symposium 2016

Thankyou!

ryan.kazanciyan [at]tanium.com@ryankaz42