Using Memory Management to Detect and Extract Illegitimate Code for Malware Analysis Carsten Willems 1, Thorsten Holz 1, Felix Freiling 2 1 Ruhr-University.

Slides:



Advertisements
Similar presentations
ROP is Still Dangerous: Breaking Modern Defenses Nicholas Carlini et. al University of California, Berkeley USENIX Security 2014 Presenter: Yue Li Part.
Advertisements

Defenses. Preventing hijacking attacks 1. Fix bugs: – Audit software Automated tools: Coverity, Prefast/Prefix. – Rewrite software in a type safe languange.
CS457 – Introduction to Information Systems Security Software 4 Elias Athanasopoulos
Ensuring Operating System Kernel Integrity with OSck By Owen S. Hofmann Alan M. Dunn Sangman Kim Indrajit Roy Emmett Witchel Kent State University College.
Lecture 16 Buffer Overflow modified from slides of Lawrie Brown.
By Hiranmayi Pai Neeraj Jain
USING EMET TO DEFEND AGAINST TARGETED ATTACKS PRESENTED BY ROBERT HENSING – SENIOR CONSULTANT – MICROSOFT CORPORATION MICHAEL MATTES – SENIOR CONSULTANT.
KLIMAX: Profiling Memory Write Patterns to Detect Keystroke-Harvesting Malware Stefano Ortolani 1, Cristiano Giuffrida 1, and Bruno Crispo 2 1 Vrije Universiteit.
Differential Slicing: Identifying Causal Execution Differences for Security Applications Noah M. Johnson 1, Juan Caballero 2, Kevin Zhijie Chen 1, Stephen.
CMSC 414 Computer and Network Security Lecture 22 Jonathan Katz.
Breno de MedeirosFlorida State University Fall 2005 Buffer overflow and stack smashing attacks Principles of application software security.
Silberschatz, Galvin and Gagne  Operating System Concepts The Security Problem A system is secure iff its resources are used and accessed as.
19.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 19: Security The Security Problem Authentication Program Threats.
CMSC 414 Computer and Network Security Lecture 24 Jonathan Katz.
CS 153 Design of Operating Systems Spring 2015 Lecture 19: Page Replacement and Memory War.
Nozzle: A Defense Against Heap-spraying Code Injection Attacks Paruj Ratanaworabhan, Cornell University Ben Livshits and Ben Zorn, Microsoft Research (Redmond,
Achieving Trusted Systems by Providing Security and Reliability Ravishankar K. Iyer, Zbigniew Kalbarczyk, Jun Xu, Shuo Chen, Nithin Nakka and Karthik Pattabiraman.
SQL Injection and Buffer overflow
Lecture 16 Buffer Overflow
Guide to Operating System Security Chapter 2 Viruses, Worms, and Malicious Software.
Jarhead Analysis and Detection of Malicious Java Applets Johannes Schlumberger, Christopher Kruegel, Giovanni Vigna University of California Annual Computer.
Defeating public exploit protections (EMET v5.2 and more)
Address Space Layout Permutation
CS 501: Software Engineering Fall 1999 Lecture 16 Verification and Validation.
Behavior-based Spyware Detection By Engin Kirda and Christopher Kruegel Secure Systems Lab Technical University Vienna Greg Banks, Giovanni Vigna, and.
Exploitation: Buffer Overflow, SQL injection, Adobe files Source:
Bob Gilber, Richard Kemmerer, Christopher Kruegel, Giovanni Vigna University of California, Santa Barbara RAID 2011,9 報告者:張逸文 1.
Computer Security and Penetration Testing
3-Protecting Systems Dr. John P. Abraham Professor UTPA.
Detection and Prevention of Buffer Overflow Exploit Cai Jun Anti-Virus Section Manager R&D Department Beijing Rising Tech. Corp. LTD.
Automatic Diagnosis and Response to Memory Corruption Vulnerabilities Authors: Jun Xu, Peng Ning, Chongkyung Kil, Yan Zhai, Chris Bookholt In ACM CCS’05.
Attacking Applications: SQL Injection & Buffer Overflows.
1 © 2004, Cisco Systems, Inc. All rights reserved. CISCO CONFIDENTIAL Using Internet Explorer 7.0 to Access Cisco Unity 5.0(1) Web Interfaces Unity 5.0(1)
Mitigation of Buffer Overflow Attacks
Lecture slides prepared for “Computer Security: Principles and Practice”, 3/e, by William Stallings and Lawrie Brown, Chapter 10 “Buffer Overflow”.
Vigilante: End-to-End Containment of Internet Worms Authors : M. Costa, J. Crowcroft, M. Castro, A. Rowstron, L. Zhou, L. Zhang, and P. Barham In Proceedings.
Defending Browsers against Drive-by Downloads:Mitigating Heap-Spraying Code Injection Attacks Authors:Manuel Egele, Peter Wurzinger, Christopher Kruegel,
Auther: Kevian A. Roudy and Barton P. Miller Speaker: Chun-Chih Wu Adviser: Pao, Hsing-Kuo.
DOWN TO THE BARE METAL: USING PROCESSOR FEATURES FOR BINARY ANALYSIS Carsten Willems 1, Ralf Hund 1, Andreas Fobian 1, Thorsten Holz 1, Amit Vasudevan.
Christopher Kruegel University of California Engin Kirda Institute Eurecom Clemens Kolbitsch Thorsten Holz Secure Systems Lab Vienna University of Technology.
MICHALIS POLYCHRONAKIS(COLUMBIA UNIVERSITY,USA), KOSTAS G. ANAGNOSTAKIS(NIOMETRICS, SINGAPORE), EVANGELOS P. MARKATOS(FORTH-ICS, GREECE) ACSAC,2010 Comprehensive.
 Introduction  Related Work  Challenges for Software-based CPU Emulation Detection Approaches  Our Approach  Evaluation  Limitations 2 A Seminar.
Buffer Overflow Attack Proofing of Code Binary Gopal Gupta, Parag Doshi, R. Reghuramalingam, Doug Harris The University of Texas at Dallas.
M. Alexander Helen J. Wang Yunxin Liu Microsoft Research 1 Presented by Zhaoliang Duan.
Windows XP & Vista Memory Management
Operating Systems Security
Shellcode Development -Femi Oloyede -Pallavi Murudkar.
Wireless and Mobile Security
Introduction Program File Authorization Security Theorem Active Code Authorization Authorization Logic Implementation considerations Conclusion.
Dilip Dwarakanath.  The topic I’m about to present was taken from a paper titled “Apple iOS 4 Security Evaluation” written by Dino A Dai Zovi.  Dino.
Dynamic Taint Analysis for Automatic Detection, Analysis, and Signature Generation of Exploits on Commodity Software Paper by: James Newsome and Dawn Song.
Buffer Overflows Taught by Scott Coté.-. _ _.-. / \.-. ((___)).-. / \ /.ooM \ / \.-. [ x x ].-. / \ /.ooM \ -/ \ /-----\-----/---\--\ /--/---\-----/-----\ / \-
Group 9. Exploiting Software The exploitation of software is one of the main ways that a users computer can be broken into. It involves exploiting the.
Foundations of Network and Computer Security J J ohn Black CSCI 6268/TLEN 5550, Spring 2013.
Security Attacks Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
CNIT 127: Exploit Development Ch 8: Windows Overflows Part 1.
VM: Chapter 7 Buffer Overflows. csci5233 computer security & integrity (VM: Ch. 7) 2 Outline Impact of buffer overflows What is a buffer overflow? Types.
Beyond Stack Smashing: Recent Advances In Exploiting Buffer Overruns Jonathan Pincus and Brandon Baker Microsoft Researchers IEEE Security and.
By: Chuqing He. Android Overview - Purchased by Google in First Android Phone was sold in Oct Linux-based - Holds 75% of the worldwide.
Constraint Framework, page 1 Collaborative learning for security and repair in application communities MIT site visit April 10, 2007 Constraints approach.
HIPS. Host-Based Intrusion Prevention Systems  One of the major benefits to HIPS technology is the ability to identify and stop known and unknown attacks,
Intercept X Early Access Program Sophos Tester
Translation Lookaside Buffer
Secure Programming Dr. X
Mitigation against Buffer Overflow Attacks
Secure Programming Dr. X
CSC 495/583 Topics of Software Security Return-oriented programming
Security.
Understanding and Preventing Buffer Overflow Attacks in Unix
Return-to-libc Attacks
Presentation transcript:

Using Memory Management to Detect and Extract Illegitimate Code for Malware Analysis Carsten Willems 1, Thorsten Holz 1, Felix Freiling 2 1 Ruhr-University Bochum, Germany 2 University of Erlangen, Germany Annual Computer Security Applications Conference (ACSAC) 2012 左昌國 ADLab, NCU-CSIE

Introduction Related Work Model and Definitions Approach Implementation Application to the Analysis of PDF Documents Detection Evaluation Extraction Evaluation Conclusion Outline 2

Exploiting Software The ultimate aim is to perform malicious computation Executing illegitimate code (a.k.a. shellcode) Countermeasures in OSs Data Execution Prevention (DEP) Address Space Layout Randomization (ASLR) Above countermeasures do not help in the analysis of illegitimate code Introduction 3

CWXDetector A tool for the analysis of malware for the Windows OS Dynamic analysis for detecting and extracting illegitimate code Using memory management techniques For analysis CWXDetector is not meant to protect a system But to monitor and analyze the illegitimate code Introduction 4

Limitations Dynamic analysis Could get incomplete results Incapable to detect malicious code embedded in arbitrary data (only those being executed) Malicious computation does not always imply the existence of illegitimate code Return Oriented Programming (ROP) JIT-spraying Introduction 5

Preventive Measures Detection of Illegitimate Code Extraction of Illegitimate Code Related Work 6

Microsoft EMET tool (Enhanced Mitigation Experience Toolkit) emet-v3.aspx emet-v3.aspx CFI Cons: Self-modifying or dynamically created code No assistance to further analysis Related Work – Preventive Measures 7

Static signatures “sled component” searching Heuristics-based approaches Cons: Not generic Have to be extended when new anti-detection come up Related Work – Detection of Illegitimate Code 8

OllyBone OmniUnpack Renovo Cons: OllyBone: debugger-driven malware analysis OmniUnpack: rely on signatures, FP Renovo: requiring emulation environment Related Work – Extraction of Illegitimate Code 9

Attacker Model A remote attacker provides some malicious piece of data to exploit a vulnerability application Resulting in the execution of shellcode Not single staged full-ROP/JIT-sprayed attacks Illegitimate code (ILC) Code that is not legitimate (would not execute if functions properly) Model and Definitions 10

Enforcing an Invariant When a vulnerability is exploited, the control flow is redirected to one of the following locations: ILC on the stack (buffer overflow) ILC in the heap (heap-spraying) ILC in a static data area (exploiting a static data buffer) The approach enforces the following invariant All ILC resides in non-executable memory  all execution attempts of ILC will result in page fault exception Approach 11

Trusted Files and Functions All existing files are trusted before analysis. All created or modified files are untrusted during later operation. Trusted memory modification functions Trusted callers Approach 12

Memory Protection Modifications Only trusted callers can allocate executable memory. Only trusted callers can modify existing memory to being executable. Only trusted files can be mapped into executable memory.  all attempts that violate these rules are intercepted (hooked) and the resulting memory regions becomes non-executable. Exception: If the target memory belongs to a mapped trusted file (writable), the executable right has to be removed. Enforcing W ^ X Approach 13

Custom Page Fault Handler When page fault triggered Check if it is related to the system If so, Dumping memory Modifying the memory to executable and continuing Multi Version Dumping Different versions of each executed page may be created Compare each dumped record Approach 14

CWXDetector For x86 version of Windows XP Memory Function Hooks NtAllocateVirtualMemory NtProtectVirtualMemory NtMapViewOfSection Checking the Caller Trace the user-mode call stack Custom Page Fault Handler Hook MmAccessFault Check if the fault was cause by execute operation Check if the fault address resides in user-space Additional NtCreateFile NtCreateProcess Implementation 15

32bit Windows XP SP2 Adobe Acrobat Reader versions 6.0.0, 7.0.0, 7.0.7, 8.1.1, 8.1.2, 8.1.6, 9.0.0, 9.2.0, and Foxit Reader version installed the customized page fault handler and the system hooks 2. started the particular viewer application 3. disabled DEP for the viewer application 4. opened the PDF document 5. enforced the invariant: new allocated memory and modified memory Application to the Analysis of PDF Documents 16

6. if the execution of ILC was detected, dumped the memory page to a file, created a log entry, and modified the related PTE to being executable. Check the dumped file for patterns  marked as “PATTERN” 7. if a new process was created by the PDF viewer  marked as “PROCESS” and prevent the process from spawning 8. if a dialog window was shown  marked as “DIALOG” and simulated a user input to close the window 9. “CRASH” 10. time out “NOTHING” Application to the Analysis of PDF Documents 17

The log file contains information about: All attempts to allocate executable memory invoked by untrusted callers All attempts to modify existing memory to being executable invoked by untrusted callers All attempts to execute memory that contains ILC All created files All created processes All shown user dialog windows Application to the Analysis of PDF Documents 18

Every PDF file ended up with a tuple (d, c) d: whether illegal code was detected c: {PATTERN, CRASH, PROCESS, DIALOG, NOTHING} (d, c) > (d’, c’) iff either d had detected ILC and d’ not, or (if d = d’) c > c’ PATTERN > CRASH > PROCESS > DIALOG > NOTHING Application to the Analysis of PDF Documents 19

Determining Trusted Callers Identifying all the functions from all trusted files that are used to produce executable memory Loader-related function in ntdll.dll Tested benign PDF documents and manually inspected the function calls Application to the Analysis of PDF Documents 20

Benign PDF Sampleset Retrieved URL of the TOP 5000 sites from alexa Queried Google for the first 10 PDF documents on each site Using tool pdfid, selected all documents which contained JavaScript, OpenActions or some other extended PDF features Uniformly picked random samples from other files to 7,218 samples The benign set on the system No ILC execution detected  FP 0% Detection Evaluation 21

Malicious PDF Sampleset 7,278 known malicious PDF documents form a well-known AV vendor all their valid PDF samples from Jan Detection Evaluation 22

Detection Evaluation 23

15 “CRASH”: All performed invalid memory accesses (before executing ILC) 33 “PROCESS”: Using regular build-in features to create IE or OE with special crafted parameters 295 “DIALOG”: Invalid embedded JavaScript code Social engineering 154 “NOTHING”: Required specific environment Detection Evaluation 24

Detection Evaluation 25

Detection Evaluation 26

Adobe Acrobat Reader ,869 samples Quality: Valid x86 instructions (code ratio) Contained strings Partitions Extraction Evaluation 27

Analyzed all 4,869 PDF samples and got 2 versions of partitions Initial partition Final partition Code ratio determined by IDA Pro Valid strings Extraction Evaluation 28

Extraction Evaluation 29

Initail partitions 7,807 strings 1,866 URLs Final partitions 8,676 strings 2,280 URLs Extraction Evaluation 30

A generic and automatic method to detect and extract illegitimate code Effective in supporting malware analysis Also good detection rates Conclusions 31