impeding malware analysis using conditional code obfuscation paper by: monirul sharif, andrea lanzi,...

26
Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network and Distributed System Security Symposium (NDSS), 2008 Presented by: LIU Limin

Upload: constance-griffith

Post on 18-Dec-2015

216 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Impeding Malware Analysis Using

Conditional Code Obfuscation

Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke LeeConference: Network and Distributed System Security Symposium (NDSS), 2008Presented by: LIU Limin

Page 2: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Outline

Introduction Conditional Code Obfuscation Implications Implementation and Evaluation Discussion

Page 3: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Introduction

Hundreds of new malware samples appear every day.– Trojans, Rootkits, Worms, Viruses,

Backdoors … Automated malware analysis becomes

increasingly important. – Static analysis– Dynamic analysis– State-of-the-art analyzer

Page 4: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Malware Analysis Offense

– Polymorphism, metamorphism and opaque predicates.

– Trigger based behavior. (time-bombs, logic-bombs, bot commands etc.)

?

Defense– Static analysis

– Dynamic analysis

– Input-oblivious analyzers (Dynamic multiple path exploration, Forced execution)

Page 5: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Obfuscation

Obfuscations that are easily to be applicable on existing code can be a threat.

Conditional Code Obfuscation: A simple, automated and transparent obfuscation against powerful input-oblivious analyzer.

Page 6: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Outline

Introduction Conditional Code Obfuscation Implications Implementation And Evaluation Discussion

Page 7: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Conditional Code Snippets

cmd = get_command (sock);if (strcmp (cmd, “startkeylogger”) ==

0){ log_keys();}

n = get_day_of_month ();if ((n > 10) && (n<20)){ attack();}

E.g.1

E.g.2

Page 8: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Obfuscated example snippet

Original code

Obfuscated codecmd = get_command (sock);if (hash (cmd) == H) /* here, H=

hash(“startkeylogger”)*/{ decrypt_function (encr_log_keys, cmd); encr_log_keys(); /*encrypted log_keys*/}

cmd = get_command (sock);if (strcmp (cmd, “startkeylogger”) ==

0){ log_keys();}

One-way

Page 9: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

General Obfuscation Mechanism

Hash properties– Pre-image resistance: infeasible to find c given Hc.– Second pre-image resistance: hard to find another c’ for

which Hash (c’) = Hc .

Candidate conditions– Equality operators: ‘==’, strcmp, strncmp, memcmp…– Unsupported operators: ‘>’, ‘<’…

Conditional code– Code that gets executed when a condition is satisfied.

Page 10: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Automation using Static Analysis

Finding Conditional Code– Identify candidate conditions

Construct a CFG for each function Identify basic blocks having conditional

branches Select candidate conditions those contain

equality operators

– Find corresponding conditional code Intra-procedural: basic blocks which are control

dependent on condition with true outcome Inter-procedural: set of functions which only be

reachable when certain condition is satisfied

Page 11: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Automation using Static Analysis

Handling Common Conditional Code

– Duplicate the code and encrypt it separately for each candidate condition.

Page 12: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Simplifying Compound Constructs

Operators (&& or ||…) combine more than one simple condition

Break the compound conditions into semantically equivalent but simplified conditions

Page 13: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Outline

Introduction Conditional Code Obfuscation Implications Implementation And Evaluation Discussion

Page 14: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Consequences to Existing Analyzers

Path exploration and input discovery– Construct constraints for each path (e.g. X ==

c ). Input Discovery (EXE)

– Discover inputs from constraints by using symbolic execution.

Obfuscated constraints is “Hash (X) == Hc”

Infeasible to reverse the hash function.

Page 15: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Consequences to Existing Analyzers

Forcing execution– Force execution along a specific path without

solving the constraints– Without key, program crashes.

Static analysis– Conceal the behavior in the encrypted block

Page 16: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Attacks

Brute Force and Dictionary Attacks– Constraint: Hash (X) = Hc

Find possible X for satisfying above equation. Domain (X) : set of all possible values that X may

take during execution. t: time taken to a test a single value of X or the

hash computation time. Brute Force attempt: time = |Domain (X)|* t . If X is n bits in length, attack requires 2nt time.

Page 17: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Outline

Introduction Conditional Code Obfuscation Implications Implementation And Evaluation Discussion

Page 18: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Implementation

Platform: Linux Input: C/C++ Source; Output: ELF Binary Four phases:

– Front-end Code Parsing Phase– Analysis/Transformation Phase– Code Generation Phase– Encryption Phase

Two Levels:– Binary level: decrypted code is executable– Intermediate code level: data types information

Page 19: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Analysis phase

Candidate Condition Replacement– Identify candidate conditions and their conditional code– Hash function: SHA-256

Decipher Routine– Encryption algorithm: AES with 256-bit keys

Decryption Key and Markers– Key (X) = Hash (X|N), N is a nonce.– marker: foresee the exact location of the corresponding

code in the resulting binary file.

Page 20: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Encryption phase

Identify code blocks needing encryption. Extracts the encryption key Kc. Replace K c and End_marker() with NOP

instructions. Calculate the size of the block to be encrypted. Place the size as argument to the call to Decipher. Encrypt the block with the key Kc.

Page 21: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Experimental Evaluation

Evaluate system by determining how many manually identified trigger-based malicious behavior were automatically and completed obfuscated.

Three levels of obfuscation strength:– Strong: strings– Medium: integers– Weak: boolean flags

Page 22: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Outline

Introduction Conditional Code Obfuscation Implications Implementation And Evaluation Discussion

Page 23: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Strengths

Malware author can modify the programs to improve the strengths.– Introducing more candidate conditions.

Query for resources and compare with the names.

Replace operators such as <, > or != by ==.

– Increasing the size of the concealed code. Incorporate triggers that encapsulates more

execution behavior.

– Increasing the input domains. Use variables with larger domains (e.g., string)

or use integer with larger size.

Page 24: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Weakness

Limited types of conditions– Equality checks.

Input domain may be very small in some cases.– 32-bit or 64-bit integers.

Page 25: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Possible ways to defeat

Equipped with decryptors that reduce the search space of keys by taking the input domain into account.– the result or an argument receiving data

from a system call, e.g. gettimeofday.

Input-aware analysis.– Collection mechanisms capture interaction

of the binary with its environment.

Page 26: Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network

Conclusion

An obfuscation scheme that can be automatically applied on malware programs.

The obfuscation conceal trigger based-malicious behavior from state-of-the-art malware analyzers.

It is shown that the obfuscation scheme is capable of concealing a large fraction of malicious triggers by experiment.