trace surfing - ekoparty · trace surfing a tale of data structure recovering and other yerbas by...

63
Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc.

Upload: others

Post on 04-Dec-2019

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Trace SurfingA tale of data structure recovering and other yerbas

By Agustin Gianni – Immunity Inc.

Page 2: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Problem Statement

Given a memory trace, what information does the trace gives us about the underlying data

structures?

Page 3: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Road map

● Investigation of previous approaches● Realization that they kind of suck● Enlightenment phase how can we improve→

Page 4: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Introduction

● What is a memory trace? ● A memory trace is a collection of all the memory

accesses performed by an application.– Both reads and writes

● How can I obtain a memory trace?● Binary Instrumentation

– pintool – DynamoRIO

● Full system emulation– QEMU– BOCHS

Page 5: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Example Memory Trace

# White listed image `calc.exe` # Loading hooks from file hooks.hks # Loaded hook alloc:test_custom_alloc:00000774:0:my_alloc_ # Loaded hook free:test_custom_alloc:000007b6:0:my_free_ L:calc.exe:0x003a0000:0x0045ffff # Thread 0x0 started # Instrumented malloc at 0x75619cee # Instrumented free at 0x75619894 # Instrumented realloc at 0x7561b10d # Instrumented calloc at 0x7561c456 W:0x003a76c6:0x01d125e0:0x01d125e0:0x00000004:0x0000000f W:0x003a76cc:0x01d125e0:0x01d125e4:0x00000004:0x0000000f … F:0x003b8f9a I:0x003b8f9a:0x00000031:0x00000000 F:0x003b8fdc I:0x003b8fdc:0x00000031:0x00000000 # Thread 0x1 did not finish but application exited.

Page 6: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Introduction

● Why do we care about recovering data structures?● Large binaries are a pain to reverse

– Specially Object Oriented Code● Virtual Function Tables and friends

● Makes reverse engineering happier● Saves time

● Why not?● Computers got fast enough to trace every single

memory access

Page 7: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

HexRays – With data types

Page 8: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Introduction

● Has anyone approached the problem?● Dynamic analysis

– Howard: Dynamic Excavator for Reverse Engineering Data Structures

– Rewards: DDE, Dynamic Data Structure Excavation● Static analysis

– WYSINWYX: What You See Is Not What You eXecute● Based on abstract interpretation, blah, blah, blah!

Page 9: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

The Rewards / Howard approach

● Trace every single memory access● Heap● Stack

● Define type sinks● System Calls● Library Calls● Special purpose instructions

– For instance, string manipulation instructions on Intel architecture.

● Propagate recovered types● Analyze the memory trace

Page 10: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Type Sinks

● A type sink is a function, syscall or instruction that we know which types it is taking

● System calls and standard libraries are the more verbose● For instance:

– ssize_t read(int fd, void *buf, size_t count);– Leaks four types: ssize_t, int, void *, size_t– Also we can extract semantics

● We know that 'fd' is a descriptor● 'buf' is a buffer● Etc.

Page 11: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Type Sinks

● Instructions can also leak types● Intel String Operations

– CMPS, INS, LODS, MOVS, OUTS, SCAS, STOS● Intel Floating Point Instructions

– FADD, FDIV, FMUL, and so on.● Jumps

– JG / JL Signed Integers→– JA / JB Unsigned Integers→

● Memory dereferences– Data dereferences leak half a type

● We just know the dereferenced address is a pointer

– Indirect calls leak function pointer types● We know that the dereferenced address contains a pointer to a function.

Page 12: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

What do we want to recognize?

● Things to recognize:● Structures / Classes● Arrays● Pointers

● How?● Study how the memory is accessed

Page 13: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Identifying Pointers

● Pointers are 'easy' to detect● Just see what instructions dereference memory● The dereferenced argument must be a valid pointer

– Otherwise the program would crash● Problem

– We cannot yet know the type of the pointer– If we are lucky enough, and by lucky I mean that we have

sufficient code coverage, we will identify the type of the pointer.

Page 14: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Warning : we are entering the terrain of the incomplete and unsound assumptions.

Page 15: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Absolute correctness

● Do we really care about absolute correctness? ● Hint I don't→● Even if we could automatically identify a fraction of

the types correctly, that saves us work.● Eventually decisions/corrections must be done

● Inconsistent typing is detected by humans● We are not aiming to solve unsolvable problems

● We cannot get back what is not there– Compilation is not bidirectional

● Although Rolf may argue this I've been told ;)

Page 16: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Identifying Structures

● Typically structure fields are accessed in an indirect way● This depends heavily on the compiler and the

optimization level.● Often, access patterns will be similar.

● Example● Let A be a base pointer● *(A + 0) is the first field● *(A + 8) is the second field● And so on

Page 17: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Identifying Structures

● What we want to do is to detect indirect memory addresses.● We can obtain this from a memory trace

● But …● What if A was not a structure

– Let A be an array– *(A + 0) is the first element– *(A + 8) is the second element– And … we are screwed

● Also, sometimes structure fields are accessed directly– There is no base pointer

Page 18: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Identifying Structures

● There is no way we can decide, with certainty, whether a pointer points to a structure or an array● We have to make unsound assumptions● Rely on compiler specific constructs● Heuristics● And why not a bit of magic

● In the end, manual work needs to be done● Still, less work than reversing manually

Page 19: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Identifying Structures

● To distinguish between arrays and structures we use some heuristics● Memory accesses are generally scattered

– Example:● Access field at offset 0x00● Then offset 0x10● And so on

● Size of the access is generally heterogeneous– Example:

● Access field 2 which is an integer● Then access field 3 which is a short integer● Etc.

Page 20: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Identifying Structures - Example

● Memory accesses● 1 – DWORD● 2 – DWORD● 3 – WORD● 4 – WORD● 5 – DWORD● 6 – BYTE● 7 – WORD

6

2

3

5

6

7

1

4

Page 21: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Identifying Structures

● There are a considerable amount of cases where this will fail● The most trivial cases

– Initializing a structure with “memset”– Copying a structure with “memcpy”

● How do we solve this– If we have more than one access pattern, favor the more

irregular

Page 22: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Identifying Arrays

● We can identify arrays by watching memory accesses on loops● There are two cases

– Sequential memory accesses– Random memory accesses

Page 23: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Identifying Arrays

● Sequential memory accesses● Let A be a pointer● We are on a loop● A is dereferenced at loop cycle one.● B is generated also at loop cycle one.● Next iteration● B is dereferenced.● A is likely an array pointer

Page 24: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Identifying Arrays

● Random memory accesses● If all the accesses are of the same size we have a

hint that we are dealing with an array.● But it is also likely that it could be an structure.● This is getting hairy.

Page 25: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

So, where are we?

Page 26: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Where are we?

● Detecting whether a pointer points to an array or a structure is essentially an educated guess.● We need to further “educate” ourselves● We need to have stronger assumptions that we can rely on.

● Tracing stack memory accesses is tricky● What about address reutilization

– We need to tag every address with a TAG to differentiate two identical addresses accessed in different times

● Tracing all memory accesses is painfully slow● We are interested in large binaries

Page 27: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Are we screwed then?

● Not really● We need to make our analysis a little bit more

specific● Hence less complete● But more accurate

● It is all about giving up a bit of generality for a bit more of accuracy

Page 28: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Looking for better waves

Page 29: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Focus on Heap Objects

● Why?● Heap objects are shared. We like data that is shared

– It leads to good things from an vulnerability research point● We have more information

– “malloc” like functions give us the size of the chunks● It is easier to track heap memory

– Hook allocation routines and tag the returned memory with a unique id– Hook also deallocation routines to keep track of valid memory chunks

Page 30: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Object Oriented Code

● Objects are basically structures with methods● Each object method needs to somehow reference its underlying object.● Objects of a given class share a set of common characteristics

● Most of them come from the heap● Or at least those object with shared state information

● So if we focus on objects, the problem is a bit less complicated● We are dealing with structures of know size● Now the whole address space is reduced to a fraction of its size

– Just analyze the .heap● Keeping track of the life of a heap memory region is simple

– Hook the allocation routine The block is alive→– Hook the free routine The block is dead→

Page 31: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

How to detect objects?

● Not every single heap chunk is an object● Heuristics!

● Take advantage of calling conventions– Visual Studio: will set the 'ecx' register to the 'this' pointer– GCC 32 bits: pushes as the first method argument the object – GCC 64 bits: 'rsi' is set to the 'this' pointer

● So we mark every tracked heap chunk that is on “ecx”, “rsi” or the first argument of a function as a possible object

● The object must be used inside the potential method

Page 32: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

How to detect methods

● There is no sound way● We have to trust our heuristics

● Which are better than most Anti-Virus heuristics :P● We are going to miss some methods

● The dynamic nature of a trace makes us rely on code coverage.● We are going to mark some functions as methods

● Sometimes the this pointer remains spuriously in 'ecx'

Page 33: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

So, how are we now?

Page 34: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

We are doing better!

● We can detect “interesting objects”● We know its size● We know where they are being used

● What else we need to do?● Detect fields● Detect relationships with other types

– Inheritance– Composition

Page 35: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Detecting Object Fields

● We already have all heap memory accesses in our trace● If the memory access is to one of our interesting objects we

save the access offset and size● Since we only track interesting objects the analysis is much

quicker● We can implement the algorithms used by Howard/Rewards

● If we have information from type sinks, we can propagate it

Page 36: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Detecting methods

● On each function call check if ECX points to a heap object.● If true

– Mark the chunk as interesting– Save the access offset for future usage

● Mark the function as interesting● Does this function get called again with the same

conditions?– That is, the same function gets called with a chunk of the

same size as the 'this' parameter

Page 37: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

How far can we go?

Page 38: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

How far can we go?

● With all the collected traces we can obtain quite a lot of information● Class Hierarchy● Virtual Function Tables● Types!● Bonus (not really related with type inference)

– Code coverage information– Indirect branch resolution

Page 39: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

How can we achieve this?How can we achieve this?

Page 40: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Virtual Function Tables

● Useful to help IDA Pro to discover more functions

● For each write to an interesting chunk● Is the value written referring to .text ?

– Is [value] also in .text?● This is for sure a Virtual Function Table

– If not, it is just a field update

Page 41: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Types

● Type reconstruction algorithm is divided in three phases● First Analysis Pass (FAP)

– Pun intended● Second Analysis Pass (SAP)● Third Analysis Pass (TAP)

Page 42: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

First Analysis Pass

● For each function● Get all its interesting chunks

– That is chunks that were passed as the 'this' argument● Mark the whole chunk as a composite type

– Set the composite type size to the size of the chunk● If 'this' does not point to the first byte of the chunk,

get the offset– Divide the composite chunk in two types at the calculated

offset● Repeat the process with all the methods that used

the chunk and subdivide the composite type

Page 43: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

First Analysis Pass

Composite Type

Chunk

chunk_address = Aecx_address = A + 0

Composite Type

TypeAOffset = 0

In this case, TypeA fills the whole composite type

Page 44: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

First Analysis Pass

Composite Type

Chunk

chunk_address = Aecx_address = A + C

Composite Type

TypeA

TypeBOffset = C

In this case there are two types, we recognize this because there were twomethods called with 'this' pointing at the same memory chunk but ata different offset.

Page 45: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

First Analysis Pass – continued

● Add the current function to a list of methods● For each write to the interesting chunk

● Add a field at the offset of the write● Mark the field with the corresponding basic type

according to the write size– For instance, a write of four bytes is marked as

“uint32_t”

Page 46: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

First Analysis Pass – continued

● Collect a set of constraints● For each chunk that was received as the 'this'

argument build a map from the method address to a list of all the types created.

● This will be later used build relationships between types and subsequent merging of identical types

method_at_0xcafecafe

Type_A

Type_B

Type_C

Size = X_1

Size = X_1

Size = X_2

Page 47: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Second Analysis Pass

● Merge similar types● Cheat by first using the type constraints collected on the FAP phase

● How do we define similar?● They have the same size

– Equal types with differing sizes will be addressed in the third pass● They have equivalent fields

– That is, at offset O there is a type T of size S in both types● They share a set of methods

– How many? ● Let N be the number of methods in Type1● Let M be the number of methods in Type2● Let S be the number of shared methods● SimilarityIndex(N,M,S) = (S / (N+M)) * 100 ● If SimilarityIndex > SimilarityThreshold then they are similar

Page 48: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Third Analysis Pass

● There are types that share methods and fields but they differ in size

● What is going on?● There are two possible scenarios

– Type2 in inherits from Type1● len(Type2) > len(Type1) most of the times

– The type has an internal buffer● This is the case of for example strings in some browsers

Page 49: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Inheritance / Composition

● A simple inheritance relationship is translated into a composition of structures

Page 50: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Inheritance / Composition

ClassAField1Field2Field3Field4

ClassB

Field1Field2Field3

ClassAField1Field2Field3Field4

ClassAField1Field2Field3Field4

Page 51: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Inheritance / Composition

● Two classes of different size use the same method● The bigger one is likely the child class● The smallest one is likely the parent class● This heuristic can fail

● Say that we have a dynamically allocated buffer inside a class– Rare, weird, but it can and will happen

● Failure will generate an extra type but the relationships between the types will still be interesting and can be detected by a human once the information is imported into IDA Pro

Page 52: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Hard example :)

StringClass

StringMetadatauint32_t len

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA…AAAAAAAAAAAAAAA???????????????

● Example string class that will contain metadata and contents on the same chunk of memory

● Other recurring complex examples are hash tables

Page 53: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Increasing accuracyIncreasing accuracy

Page 54: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Increasing accuracy

● Accuracy of our approach is directly related with code coverage● The more code coverage, the more accuracy

● Increasing code coverage● The “smart” way

– We can tweak Klee (requires source code)– We can code our version of SAGE

● ???● Profit

● The “other” way– Fuzz the application like a 15 year old– Gather a set of input files (if possible) and calculate the set of files that gets the

maximum coverage

Page 55: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Static Analysis

● How can we further validate our results?● Detecting calling convention

● We have collected a fair amount of information, how can we propagate this information?● Propagating the type information into basic blocks

not executed on the trace● Or we can be lazy and let HexRays decompiler to do

it for us :)

Page 56: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Calling convention detection

● A spurious function calls can happen when a non method function is called on a method

● The function call can receive the 'this' pointer of the previous method call

● We avoid this case by ruling out all the function calls that do not behave as thiscall

Page 57: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Calling convention detection

● Given a function get its CFG

● Obtain a DAG (direct acyclic graph)

● Do a topological sort

● Assume ECX is a 'this' pointer

● Add it to a list of 'this' aliases● For each basic block

● If instruction kills any of the 'this' aliases● If the alias list is empty return “not thiscall”

● If the instruction aliases one of the 'this' pointers● Add the new alias to the list

● If the instruction accesses memory using one of the aliases of 'this' then the function is likely 'thiscall'

Page 58: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Calling convention detection

● This can fail too● Generally it gives a correct answer in 90% of

the analyzed function● These results were validated by analyzing binaries

with symbols available● In practice this information allows us to detect

spurious functions detected as methods of a class

Page 59: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Example: calc.exe types

Page 60: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Example: calc.exe types

Page 61: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Example: calc.exe types

Page 62: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

References

● http://www.pintool.org/

● http://www.dynamorio.org/

● http://wiki.qemu.org/Main_Page

● http://bochs.sourceforge.net/

● http://www.few.vu.nl/~asia/publications

● http://www.cs.purdue.edu/homes/xyzhang/reverse.html

● http://pages.cs.wisc.edu/~reps/

Page 63: Trace Surfing - Ekoparty · Trace Surfing A tale of data structure recovering and other yerbas By Agustin Gianni – Immunity Inc. Problem Statement Given a memory trace, what information

Thanks to

● Juliano Rizzo● Nicolas Waisman● Pablo Sole● Sean Heelan● Topo Muñiz