Top Banner
CATCH AND RELEASE: A NEW LOOK AT DETECTING AND MITIGATING HIGHLY OBFUSCATED EXPLOIT KITS BY MOHAMED SAHER AND AHMED GARHY
101

Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

Jul 25, 2015

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

CATCH AND RELEASE: A NEW LOOK AT DETECTING AND MITIGATING HIGHLY OBFUSCATED EXPLOIT KITS

BY MOHAMED SAHER AND AHMED GARHY

Page 2: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

AGENDA Our Intent

Rethinking Evasions

Domain of the Problem

Current Problem

Problem with Current Solutions

Solution #1 First Method

Solution #2 Second Method

Page 3: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OUR INTENT Is this function malicious?

function Translate(objects, offset, size) {

var length = 4;

for (var i = 0; i < size; i++) {

var r = rc.substr(0, length);

if(offset > 0) {

r = r.substr(offset) + r.substr(0, offset);

}

objects[i] = r.substr(0, r.length);

}

}

Page 4: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OUR INTENT Is this function malicious?

function Translate(objects, offset, size) {

var length = 4;

for (var i = 0; i < size; i++) {

var r = rc.substr(0, length);

if(offset > 0) {

r = r.substr(offset) + r.substr(0, offset);

}

objects[i] = r.substr(0, r.length);

}

} Without understanding the context on how a function is used, it is

very difficult to determine if it is malicious or not

Page 5: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OUR INTENT What about this script?

<script>

var a = '%25%33%43%69%66%72%61%6d%65 ...';

var b = unescape(unescape(a));

var spray = new Function(unescape(b));

</script>

Page 6: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OUR INTENT What about this script?

<script>

var a = '%25%33%43%69%66%72%61%6d%65 ...';

var b = unescape(unescape(a));

var spray = new Function(unescape(b));

</script> An “expert’s eye” can probably determine it looks suspicious.

The two are actually equal to each other

Page 7: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OUR INTENT What about this script?

<script>

var a = '%25%33%43%69%66%72%61%6d%65 ...';

var b = unescape(unescape(a));

var spray = new Function(unescape(b));

</script> An “expert’s eye” can probably determine it looks suspicious.

The two are actually equal to each other

Our intent is to allow an attack using the first example script, without depending on obfuscating like the second example script, and propose a more superior method for detecting both

Page 8: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Page 9: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Use a message oriented architecture (MOA) to split the attack into disparate self contained messages – we refer to this as “units of work”

Page 10: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Use a message oriented architecture (MOA) to split the attack into disparate self contained messages – we refer to this as “units of work”

This is a variation of the “script splitting” technique except a message exists within a local scope and is destroyed after it serves its purpose

Page 11: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Use a message oriented architecture (MOA) to split the attack into disparate self contained messages – we refer to this as “units of work”

This is a variation of the “script splitting” technique except a message exists within a local scope and is destroyed after it serves its purpose

Does not require DOM manipulation to hide “magic strings”

Page 12: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Use a message oriented architecture (MOA) to split the attack into disparate self contained messages – we refer to this as “units of work”

This is a variation of the “script splitting” technique except a message exists within a local scope and is destroyed after it serves its purpose

Does not require DOM manipulation to hide “magic strings” Avoid the “magic redirect IFRAME” that can be a trigger for some

analyzers

Page 13: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Page 14: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

An artifact that can be parsed or scanned for patterns, characteristics, and definitions does not exist

Page 15: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

An artifact that can be parsed or scanned for patterns, characteristics, and definitions does not exist

An alternative to loading JavaScript in “clear text”

Page 16: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

An artifact that can be parsed or scanned for patterns, characteristics, and definitions does not exist

An alternative to loading JavaScript in “clear text” Load one message at a time, forcing each message to be

analyzed independently – remember “units of work”

Page 17: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

An artifact that can be parsed or scanned for patterns, characteristics, and definitions does not exist

An alternative to loading JavaScript in “clear text” Load one message at a time, forcing each message to be

analyzed independently – remember “units of work” Web Sockets are a perfect candidate for both MOA and

bypassing HTTP from a web environment

Page 18: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Page 19: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Two components involved, client and server

Client

Listen

Invoke

Page 20: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Two components involved, client and server

Client

Listen

Invoke

Server

State

Send

Page 21: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Two components involved, client and server For each accepted connection from a client, server maintains a

state machine

Page 22: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Two components involved, client and server For each accepted connection from a client, server maintains a

state machine Messages are essentially commands and do not depend on each

other – remember “units of work”

Page 23: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Two components involved, client and server For each accepted connection from a client, server maintains a

state machine Messages are essentially commands and do not depend on each

other – remember “units of work” Client evaluates message, invokes message, and destroys it

Page 24: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Page 25: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Only client control flow is that of the client listening and invoking a message

Page 26: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Only client control flow is that of the client listening and invoking a message

Order of messages not guaranteed by server. Server may send NOP messages as part of an attack to trick certain analyzers

Page 27: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Only client control flow is that of the client listening and invoking a message

Order of messages not guaranteed by server. Server may send NOP messages as part of an attack to trick certain analyzers

“Monkey patch” functions dynamically evaluated in messages to trick certain analyzers

Page 28: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Getting creative in transport format

Page 29: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Getting creative in transport format

Web Sockets are simple TCP pipes, so data can be represented on the wire in an application specific way

Page 30: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Getting creative in transport format

Web Sockets are simple TCP pipes, so data can be represented on the wire in an application specific way

No longer restricted to sending JavaScript in clear text

Page 31: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Getting creative in transport format

Web Sockets are simple TCP pipes, so data can be represented on the wire in an application specific way

No longer restricted to sending JavaScript in clear text Create custom binary format

Page 32: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Getting creative in transport format

Web Sockets are simple TCP pipes, so data can be represented on the wire in an application specific way

No longer restricted to sending JavaScript in clear text Create custom binary format Send message in binary on the wire

0100100001100101011011000110110001101111001000000100100001100001011011010110001001110101011100100110011100100001

Page 33: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Getting creative in transport format

Web Sockets are simple TCP pipes, so data can be represented on the wire in an application specific way

No longer restricted to sending JavaScript in clear text Create custom binary format Send message in binary on the wire Simply looking at a binary message won't give hints about what its

contents are – is it an audio file, an image, even text?

Page 34: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Getting creative in transport format

Web Sockets are simple TCP pipes, so data can be represented on the wire in an application specific way

No longer restricted to sending JavaScript in clear text Create custom binary format Send message in binary on the wire Simply looking at a binary message won't give hints about what its contents are

– is it an audio file, an image, even text? To even begin to understand a binary message, its format specification needs

to be known beforehand or else it is a very challenging problem in its own

Page 35: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Getting creative in transport format

Confusing the Context

Page 36: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Getting creative in transport format

Confusing the Context

Remember this function?function Translate(objects, offset, size) {

var length = 4;

for (var i = 0; i < size; i++) {

var r = rc.substr(0, length);

if(offset > 0) {

r = r.substr(offset) + r.substr(0, offset);

}

objects[i] = r.substr(0, r.length);

}

}

Page 37: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

RETHINKING EVASIONS Designing a new architecture

Avoiding HTTP

Avoiding client side state

Limit control flow and function call hierarchy

Getting creative in transport format

Confusing the Context

Remember this function?function Translate(objects, offset, size) {

var length = 4;

for (var i = 0; i < size; i++) {

var r = rc.substr(0, length);

if(offset > 0) {

r = r.substr(offset) + r.substr(0, offset);

}

objects[i] = r.substr(0, r.length);

}

} Now that we get this from our binary format, we again ask the question, how do you determine if it is

malicious?

Page 38: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DOMAIN OF THE PROBLEM How can we define a malicious website?

Page 39: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DOMAIN OF THE PROBLEM How can we define a malicious website?

How can we detect a malicious website?

Page 40: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DOMAIN OF THE PROBLEM How can we define a malicious website?

How can we detect a malicious website?

How can we detect obfuscation?

Page 41: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DOMAIN OF THE PROBLEM How can we define a malicious website?

How can we detect a malicious website?

How can we detect obfuscation?

How can we identify obfuscation used for malicious purposes?

Page 42: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DOMAIN OF THE PROBLEM How can we define a malicious website?

How can we detect a malicious website?

How can we detect obfuscation?

How can we identify obfuscation used for malicious purposes?

How can we categorize what is malicious and what is not?

Page 43: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

CURRENT PROBLEM Exploits delivered at some point relies on JavaScript

Page 44: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

CURRENT PROBLEM Exploits delivered at some point relies on JavaScript

JavaScript is continuously getting obfuscated with more complexity

Page 45: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

CURRENT PROBLEM Exploits delivered at some point relies on JavaScript

JavaScript is continuously getting obfuscated with more complexity

Current solutions are way behind in technology

Page 46: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

PROBLEMS WITH CURRENT SOLUTIONS Relies heavily on invocative functions that are not a

concrete base to be malicious (fromCharCode, eval, unescape, etc.) and have plenty of legitimate use cases

Page 47: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

PROBLEMS WITH CURRENT SOLUTIONS Relies heavily on invocative functions that are not a

concrete base to be malicious (fromCharCode, eval, unescape, etc.) and have plenty of legitimate use cases

DOM and CSS selectors

Page 48: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

PROBLEMS WITH CURRENT SOLUTIONS Relies heavily on invocative functions that are not a

concrete base to be malicious (fromCharCode, eval, unescape, etc.) and have plenty of legitimate use cases

DOM and CSS selectors Client side proxies for client-server interaction

Page 49: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

PROBLEMS WITH CURRENT SOLUTIONS Relies heavily on invocative functions that are not a

concrete base to be malicious (fromCharCode, eval, unescape, etc.) and have plenty of legitimate use cases

DOM and CSS selectors Client side proxies for client-server interaction Client side template engines

Page 50: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

PROBLEMS WITH CURRENT SOLUTIONS Relies heavily on invocative functions that are not a

concrete base to be malicious (fromCharCode, eval, unescape, etc.) and have plenty of legitimate use cases

Limited sets of characteristics

Page 51: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

PROBLEMS WITH CURRENT SOLUTIONS Relies heavily on invocative functions that are not a

concrete base to be malicious (fromCharCode, eval, unescape, etc.) and have plenty of legitimate use cases

Limited sets of characteristics

Probabilistic decisions is directly proportional with the characteristics extracted

Page 52: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

TYPES OF APPROACHES Dynamic analysis of embedded JS

Page 53: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

TYPES OF APPROACHES Dynamic analysis of embedded JS

Static analysis of extracted JS (Method #1)

Page 54: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

TYPES OF APPROACHES Dynamic analysis of embedded JS

Static analysis of extracted JS (Method #1)

Static analysis of extracted JS (Method #2)

Page 55: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DYNAMIC ANALYSIS AdHoc Forwarding

Page 56: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DYNAMIC ANALYSIS AdHoc Forwarding

Create a middle layer between the browser and the JS engine

Page 57: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DYNAMIC ANALYSIS AdHoc Forwarding

Create a middle layer between the browser and the JS engine

Analyze the CFG of the scripts being executed

Page 58: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DYNAMIC ANALYSIS AdHoc Forwarding

Create a middle layer between the browser and the JS engine

Analyze the CFG of the scripts being executed Analyze a call hierarchy of functions order

Page 59: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DYNAMIC ANALYSIS AdHoc Forwarding

Create a middle layer between the browser and the JS engine

Analyze the CFG of the scripts being executed Analyze a call hierarchy of functions order Analyze certain combination of functions used including

known highly risky ones

Page 60: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DYNAMIC ANALYSIS AdHoc Forwarding

Browser Automation

Page 61: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DYNAMIC ANALYSIS AdHoc Forwarding

Browser Automation

Attach to IE process

Page 62: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DYNAMIC ANALYSIS AdHoc Forwarding

Browser Automation

Attach to IE process Use shdocvw.dll to automate COM callbacks

Page 63: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DYNAMIC ANALYSIS AdHoc Forwarding

Browser Automation

Attach to IE process Use shdocvw.dll to automate COM callbacks Capture events while they trigger and manipulate them

Page 64: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DYNAMIC ANALYSIS AdHoc Forwarding

Browser Automation

Attach to IE process Use shdocvw.dll to automate COM callbacks Capture events while they trigger and manipulate them Analyze in the same manner as AdHoc Forwarding

Page 65: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DYNAMIC ANALYSIS AdHoc Forwarding

Browser Automation

Browser In-Memory Injection

Page 66: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DYNAMIC ANALYSIS AdHoc Forwarding

Browser Automation

Browser In-Memory Injection

Inject JS in DOM to monitor events

Page 67: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

DYNAMIC ANALYSIS AdHoc Forwarding

Browser Automation

Browser In-Memory Injection

Inject JS in DOM to monitor events Use a JS Debugger (FireBug or other)

Page 68: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

STATIC ANALYSIS (METHOD 1) Extract local scripts

Page 69: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

STATIC ANALYSIS (METHOD 1) Extract local scripts

Extract remote scripts

Page 70: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

STATIC ANALYSIS (METHOD 1) Analyze the script and categorize them based on certain

criteria

Page 71: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

STATIC ANALYSIS (METHOD 1) Analyze the script and categorize them based on certain

criteria

Web page encoding

Page 72: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

STATIC ANALYSIS (METHOD 1) Analyze the script and categorize them based on certain

criteria

Web page encoding Detecting current language used and extracting features

Page 73: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

STATIC ANALYSIS (METHOD 1) Analyze the script and categorize them based on certain

criteria

Web page encoding Detecting current language used and extracting features Check the WHOIS for the web page

Page 74: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

STATIC ANALYSIS (METHOD 1) Analyze the script and categorize them based on certain

criteria

Web page encoding Detecting current language used and extracting features Check the WHOIS for the web page

Determine probabilistically to which category it belongs to

Page 75: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

SHANNON’S ENTROPY Formula

Page 76: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

SHANNON’S ENTROPY Formula

We use Shannon’s Entropy to determine the entropy of the file only as a side-effect and not a main criteria to determine the decision whether it was malicious or not

Page 77: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

NAÏVE BAYESIAN A machine-learning technique that can be used to predict

to which category a particular data case belongs

Page 78: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

NAÏVE BAYESIAN A machine-learning technique that can be used to predict to

which category a particular data case belongs

Given the above formula’: An event A is INDEPENDENT from event B if the conditional probability is the same as the marginal probability

Page 79: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

LAPLACIAN SMOOTHING To avoid having a 0 joint in any partial probability we use

the add-one smoothing technique

Page 80: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

LAPLACIAN SMOOTHING To avoid having a 0 joint in any partial probability we use

the add-one smoothing technique.

Given an observation x = (x1, …, xd) from a multinomial distribution with N trials and parameter vector θ = (θ1, …, θd), a "smoothed" version of the data gives the estimator

where α > 0 is the smoothing parameter (α = 0 corresponds to no smoothing)

Page 81: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

STATIC ANALYSIS (METHOD 2) How is JS executed/handled?

Page 82: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

STATIC ANALYSIS (METHOD 2) How is JS executed/handled?

1. The code is scanned for all function(s) declaration. Each declaration is executed by creating a function object and a named reference to that function is created so that the function can be called from within a statement.

Page 83: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

STATIC ANALYSIS (METHOD 2) How is JS executed/handled?

1. The code is scanned for all function(s) declaration. Each declaration is executed by creating a function object and a named reference to that function is created so that the function can be called from within a statement.

2. The statements are evaluated and executed by order as they appear on the page after fully loaded.

Page 84: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

JS EXAMPLE #1

<script>

DoNothing();

function DoNothing() {

return;

}

</script>

This works

Page 85: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

JS EXAMPLE #2

<script>

DoNothing();

</script>

<script>

function DoNothing() {

return;

}

</script>

This does not works

Page 86: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

JS EXAMPLE #3

<script>

function DoNothing() {

return;

}

</script>

<script>

DoNothing();

</script>

This works

Page 87: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

JS EXAMPLE #3

<script>

// assuming that DoNothing is not defined

DoNothing();

alert(1);

</script>

This does not works

Page 88: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

JS EXAMPLE #3

<script>

// assuming that DoNothing is not defined

DoNothing();

</script>

<script>

alert(1);

</script>

This works

Page 89: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

STATIC ANALYSIS (METHOD 2) Semantic analysis to focus on “what does this mean”

Page 90: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

STATIC ANALYSIS (METHOD 2) Semantic analysis to focus on “what does this mean”

Optimizer-Compiler for JS which focuses on structure other than extracted invocative functions

Page 91: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OPTIMIZER-COMPILER The following describes the architecture of any ordinary

compiler and the current compiler as well

Lexer Parser Translator OptimizerTokens AST IR

Page 92: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OPTIMIZER-COMPILER At this phase the optimizer tries to optimize the JS input

based on optimization theories after the AST was generated and converted into an IR

Optimizer

Hidden Classes

Page 93: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OPTIMIZER-COMPILER At this phase the optimizer tries to optimize the JS input

based on optimization theories after the AST was generated and converted into an IR

Optimizer

Hidden Classes

Type Inference

Page 94: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OPTIMIZER-COMPILER At this phase the optimizer tries to optimize the JS input

based on optimization theories after the AST was generated and converted into an IR

Optimizer

Hidden Classes

Type Inference

Inline Caches

Page 95: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OPTIMIZER-COMPILER At this phase the optimizer tries to optimize the JS input

based on optimization theories after the AST was generated and converted into an IR

Optimizer

Hidden Classes

Type Inference

Inline Caches

Function Synthesis

Page 96: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OPTIMIZER-COMPILER At this phase the optimizer tries to optimize the JS input

based on optimization theories after the AST was generated and converted into an IR

Optimizer

Hidden Classes

Type Inference

Inline Caches

Function Synthesis

Inline Expansion

Page 97: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OPTIMIZER-COMPILER At this phase the optimizer tries to optimize the JS input

based on optimization theories after the AST was generated and converted into an IR

Optimizer

Hidden Classes

Type Inference

Inline Caches

Function Synthesis

Inline Expansion

Loop Invariant Code Motion

Page 98: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OPTIMIZER-COMPILER At this phase the optimizer tries to optimize the JS input

based on optimization theories after the AST was generated and converted into an IR

Optimizer

Hidden Classes

Type Inference

Inline Caches

Function Synthesis

Inline Expansion

Loop Invariant Code Motion

Constant Folding

Page 99: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OPTIMIZER-COMPILER At this phase the optimizer tries to optimize the JS input

based on optimization theories after the AST was generated and converted into an IR

Optimizer

Hidden Classes

Type Inference

Inline Caches

Function Synthesis

Inline Expansion

Loop Invariant Code Motion

Constant Folding

Copy Propagation

Page 100: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OPTIMIZER-COMPILER At this phase the optimizer tries to optimize the JS input

based on optimization theories after the AST was generated and converted into an IR

Optimizer

Hidden Classes

Type Inference

Inline Caches

Function Synthesis

Inline Expansion

Loop Invariant Code Motion

Constant Folding

Copy Propagation

Common Sub-Expression Elimination

Page 101: Catch and Release: A New Look at Detecting and Mitigating highly obfuscated Exploit Kits

OPTIMIZER-COMPILER At this phase the optimizer tries to optimize the JS input

based on optimization theories after the AST was generated and converted into an IR

Optimizer

Hidden Classes

Type Inference

Inline Caches

Function Synthesis

Inline Expansion

Loop Invariant Code Motion

Constant Folding

Copy Propagation

Common Sub-Expression Elimination

Dead Code Elimination