43
Memory Forensics An introduction 1 Thursday, February 28, 2013

Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox Yara

Embed Size (px)

Citation preview

Page 1: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Memory ForensicsAn introduction

1Thursday, February 28, 2013

Page 2: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

DISCLAIMER

• Speak only for myself

• These are opinions, not facts

• I could be wrong about anything

• Use at your own risk

2Thursday, February 28, 2013

Page 3: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

About Me

• On corporate security team

• Analyze malware as a hobby

• Not an expert by any stretch

• Goal for talk:

• Introduce concepts, show fun demos

3Thursday, February 28, 2013

Page 4: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Agenda

• Introduction

• Concepts

• Acquisition methods (demo!)

• Analysis (demo!)

• Wrap-up

• Links, links, links

4Thursday, February 28, 2013

Page 5: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Agenda

• Introduction

• Concepts

• Acquisition methods (demo!)

• Analysis (demo!)

• Wrap-up

• Links, links, links

5Thursday, February 28, 2013

Page 6: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Types of Forensics

• Disk/filesystem

• Network/signals

• Memory/volatile

6Thursday, February 28, 2013

Page 7: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Why Memory?

• Unpacked binary

• Observe behavior

• Encryption keys

• Memory-only malware

• Memory-only artifacts

7Thursday, February 28, 2013

Page 8: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Agenda

• Introduction

• Concepts

• Acquisition methods (demo!)

• Analysis (demo!)

• Wrap-up

• Links, links, links

8Thursday, February 28, 2013

Page 9: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

What Does Memory Look Like?

• Objects: Linked lists, structs, mapped files

• Process lists, sockets, file handles, jump tables, registry hives

• Memory pages-different access privileges

• Process space, global & local variables

9Thursday, February 28, 2013

Page 10: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

http://www.cs.uleth.ca/~holzmann/C/system/memorylayout.gif10Thursday, February 28, 2013

Page 12: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

http://technet.microsoft.com/en-us/library/cc776371(v=ws.10).aspx

12Thursday, February 28, 2013

Page 13: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

http://upload.wikimedia.org/wikipedia/commons/5/5b/Linux_kernel_map.png13Thursday, February 28, 2013

Page 14: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Sidebar...

• Security pros need deeper knowledge

• than other tech pros

• Ex: Developer, how inputs are handled

• Ex: Sysadmin, how kernel & filesystem work

14Thursday, February 28, 2013

Page 15: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Agenda

• Introduction

• Concepts

• Acquisition methods (demo!)

• Analysis (demo!)

• Wrap-up

• Links, links, links

15Thursday, February 28, 2013

Page 16: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Software

• Access raw device

• Install custom driver/kernel module

• Swap file on disk

• Hibernation image on disk

• hiberfil.sys (Win)

• sleepimage (OSX)

16Thursday, February 28, 2013

Page 17: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Examples

• Memoryze & Memoryze for the Mac

• LiME

• F-Response

• FTK Imager

• DumpIt

• FastDump Pro

http://www.forensicswiki.org/wiki/Tools:Memory_Imaging

17Thursday, February 28, 2013

Page 18: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Direct Memory Access

“Systems may be vulnerable to a DMA attack by an external device if they have a FireWire, ExpressCard,

Thunderbolt, or other expansion port that, like PCI and PCI-Express in general, hooks up attached devices directly

to the physical address space.”

http://en.wikipedia.org/wiki/DMA_attack

18Thursday, February 28, 2013

Page 21: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

http://osarena.net/hacks-guides/tresor-profilaxte-to-linux-sas-apo-tis-cold-boot-epithesis.html

21Thursday, February 28, 2013

Page 22: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

DEMO (click me!)Build LiMECreate Volatility profileDump memory over TCPFind bash history

22Thursday, February 28, 2013

Page 23: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Important Notes!

• Don’t build LiME or mem profile on victim!

• Use virtual machine with same OS/kernel

• Build module & profile ahead of time

• if you can (speed up response)

• Requires gcc, gdb, make, etc

23Thursday, February 28, 2013

Page 24: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Agenda

• Introduction

• Concepts

• Acquisition methods (demo!)

• Analysis (demo!)

• Wrap-up

• Links, links, links

24Thursday, February 28, 2013

Page 25: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Suspicious Signs

• Handles to other processes

• Missing from one or more process list

• Has injected sections

• Holds suspicious mutex

25Thursday, February 28, 2013

Page 26: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

DKOM

• Direct Kernel Object Manipulation

• Unlink process from _EPROCESS list

• CSRSS process also has handles

• and internal list

Ligh, M.H., Adair, S., Hartstein, B., & Richard, M. (2011) Malware Analyst’s Cookbook and DVD. Indianapolis: Wiley.

26Thursday, February 28, 2013

Page 27: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Process Injection

• Process Environment Block

• Command line & arguments

• Three lists of the loaded DLLs

• Could unlink list, but VAD has map

• Tampering w/VAD requires rootkit

Ligh, M.H., Adair, S., Hartstein, B., & Richard, M. (2011) Malware Analyst’s Cookbook and DVD. Indianapolis: Wiley.

27Thursday, February 28, 2013

Page 28: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Misc

• Process hollowing (similar to injection)

• Start legit binary in suspended thread

• Replace the image, resume thread

• Mutex

• Ensure only one copy of malware runs

• or avoid concurrency w/specific prog

28Thursday, February 28, 2013

Page 30: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

DEMO (click me!)

(Not shown: Creating the collector)

Collect artifacts to net shareImport artifacts to RedlineDiscover injected memoryLocate events in timeline

30Thursday, February 28, 2013

Page 31: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Agenda

• Introduction

• Concepts

• Acquisition methods (demo!)

• Analysis (demo!)

• Wrap-up

• Links, links, links

31Thursday, February 28, 2013

Page 32: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Wrap-up

• Memory forensics offer unique advantages

• Concealment techniques leave a trail

• Tools can help, but knowledge is required

• Study system internals

• Many free tools & guides exist

• Barrier to entry is low!

32Thursday, February 28, 2013

Page 33: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Pop Quiz

33Thursday, February 28, 2013

Page 34: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Pop Quiz

• Name one interface for DMA attack

33Thursday, February 28, 2013

Page 35: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Pop Quiz

• Name one interface for DMA attack

• What does DKOM stand for?

33Thursday, February 28, 2013

Page 36: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Pop Quiz

• Name one interface for DMA attack

• What does DKOM stand for?

• Name a software memory acquisition tool

33Thursday, February 28, 2013

Page 37: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Agenda

• Introduction

• Concepts

• Acquisition methods (demo!)

• Analysis (demo!)

• Wrap-up

• Links, links, links

34Thursday, February 28, 2013

Page 38: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

http://www.quickmeme.com/meme/3otxsn/

N

BLERGS

35Thursday, February 28, 2013

Page 39: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Malware Analyst’s Cookbook and DVDhttp://www.malwarecookbook.com/

Practical Malware Analysishttp://practicalmalwareanalysis.com/

APTish Attack via Metasploithttp://www.sysforensics.org/

SEMPERSECURUShttp://sempersecurus.blogspot.com/

DeepEnd Researchhttp://www.deependresearch.org/

contagio malware dumphttp://contagiodump.blogspot.com/

Journey Into Incident Responsehttp://journeyintoir.blogspot.com/

Windows Incident Responsehttp://windowsir.blogspot.com/

Linux Sleuthinghttp://linuxsleuthing.blogspot.com/

Memory Forensicshttp://memoryforensics.blogspot.com/

SecurityXplodedhttp://securityxploded.com/malware-memory-forensics.php

Gustavo Duartehttp://duartes.org/gustavo/blog/

Forensics Wikihttp://www.forensicswiki.org/

DigitalFIREhttp://digitalfire.ucd.ie/

36Thursday, February 28, 2013

Page 40: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

http://www.webdesignhot.com/free-vector-graphics/electric-tools-vector-set/

37Thursday, February 28, 2013

Page 41: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Memoryzehttp://www.mandiant.com/resources/download/memoryze

Redlinehttp://www.mandiant.com/resources/download/redline

Volatilityhttps://www.volatilesystems.com/default/volatility

Cuckoo Sandboxhttp://www.cuckoosandbox.org/

Yarahttp://code.google.com/p/yara-project/

Memoryze for the Machttp://www.mandiant.com/resources/download/mac-memoryze

LiMEhttps://code.google.com/p/lime-forensics/

Inceptionhttp://www.breaknenter.org/projects/inception/

38Thursday, February 28, 2013

Page 42: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Thanks!

39Thursday, February 28, 2013

Page 43: Memory Forensics -  · Memory Forensics An introduction ... Practical Malware Analysis ... Cuckoo Sandbox  Yara

Brian Keeferhttp://rants.effu.se

https://twitter.com/chort0https://alpha.app.net/chort

http://www.SMTPS.netchort0 on Freenode

Slides: http://www.SMTPS.net/pub/presentations/CCSF_Mem_Forensics.pdf

40Thursday, February 28, 2013