SRE  Introduction 1 Software Reverse Engineering (SRE)

Slides:



Advertisements
Similar presentations
1/1/ / faculty of Electrical Engineering eindhoven university of technology Speeding it up Part 3: Out-Of-Order and SuperScalar execution dr.ir. A.C. Verschueren.
Advertisements

Chapter 1  Introduction 1 Chapter 1: Introduction.
DIGITAL RIGHTS MANAGEMENT Hoang Viet Lam Tran Quoc Trieu 1.
Computer Science 654 Lecture 5: Software Reverse Engineering Professor Wayne Patterson Howard University Spring 2009.
Software Part 4  Software 2 Software Reverse Engineering (SRE)
RIVERSIDE RESEARCH INSTITUTE Helikaon Linux Debugger: A Stealthy Custom Debugger For Linux Jason Raber, Team Lead - Reverse Engineer.
Dean Carlson and Beth Anne Byrd CpSc 420.  What is reverse engineering?  Brief History  Usefulness  The process  Bagle Virus example.
WEP 1 WEP WEP 2 WEP  WEP == Wired Equivalent Privacy  The stated goal of WEP is to make wireless LAN as secure as a wired LAN  According to Tanenbaum:
1 Detection of Injected, Dynamically Generated, and Obfuscated Malicious Code (DOME) Subha Ramanathan & Arun Krishnamurthy Nov 15, 2005.
CS266 Software Reverse Engineering (SRE) Applying Anti-Reversing Techniques to Java Bytecode Teodoro (Ted) Cipresso,
Chapter 5 Anti-Anti-Virus. Anti-Anti-Virus  All viruses self-replicate  Anti-anti-virus means it’s “openly hostile” to AV  Anti-anti-virus techniques?
Disclaimer The Content, Demonstration, Source Code and Programs presented here is "AS IS" without any warranty or conditions.
Impeding Malware Analysis Using Conditional Code Obfuscation Paper by: Monirul Sharif, Andrea Lanzi, Jonathon Giffin, and Wenke Lee Conference: Network.
Software-based Code Attestation for Wireless Sensors.
©2011 Check Point Software Technologies Ltd. [PROTECTED] — All rights reserved. Introduction to Reverse Engineering Inbar Raz Malware Research Lab Manager.
RC4 1 RC4 RC4 2 RC4  Invented by Ron Rivest o “RC” is “Ron’s Code” or “Rivest Cipher”  A stream cipher  Generate keystream byte at a step o Efficient.
Building Secure Software Chapter 9 Race Conditions.
Chapter 1  Introduction 1 Chapter 1: Introduction “Begin at the beginning,” the King said, very gravely, “and go on till you come to the end: then stop.”
Reverse Engineering Ian Kayne For School of Computer Science, University of Birmingham 2 nd February 2009.
Memory & Storage Architecture Seoul National University Computer Architecture “ Bomb Lab Hints” 2nd semester, 2014 Modified version : The original.
DIGITAL RIGHT MANAGEMENT Bùi Thành Đ ạ t Nguy ễ n Hoàng Nh ậ t Đông Nguy ễ n Duy C ườ ng
Code Injection and Software Cracking’s Effect on Network Security Group 5 Jason Fritts Utsav Kanani Zener Bayudan ECE 4112 Fall 2007.
Antivirus Software Detects malware (not just viruses) May eliminate malware as well Often sold with firewalls Two approaches: Dictionary-based - Compares.
Vulnerability-Specific Execution Filtering (VSEF) for Exploit Prevention on Commodity Software Authors: James Newsome, James Newsome, David Brumley, David.
Lecture 18 Page 1 CS 111 Online Design Principles for Secure Systems Economy Complete mediation Open design Separation of privileges Least privilege Least.
Trying to like a boss… REVERSE ENGINEERING. WHAT EVEN IS… REVERSE ENGINEERING?? Reverse engineering is the process of disassembling and analyzing a particular.
Malicious Code Brian E. Brzezicki. Malicious Code (from Chapter 13 and 11)
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
APT29 HAMMERTOSS Jayakrishnan M.
Application Security Tom Chothia Computer Security, Lecture 14.
Practical Malware Analysis Ch 8: Debugging Rev
Part 3: Advanced Dynamic Analysis Chapter 8: Debugging.
Software.
Windows PE files Infections and Heuristic Detection Nicolas BRULEZ / Digital River PACSEC '04.
Binary Auditing Geller Bedoya Michael Wozniak. Background  Binary auditing is a technique used to test the security and discover the inner workings of.
CS266 Software Reverse Engineering (SRE) Reversing and Patching Java Bytecode Teodoro (Ted) Cipresso,
EECS 354 Network Security Reverse Engineering. Introduction Preventing Reverse Engineering Reversing High Level Languages Reversing an ELF Executable.
14/10/04 AIPP Lecture 7: The Cut1 Controlling Backtracking: The Cut Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 7 14/10/04.
Auther: Kevian A. Roudy and Barton P. Miller Speaker: Chun-Chih Wu Adviser: Pao, Hsing-Kuo.
Module 6: Debugging a Windows CE Image.  Overview Debug Zones IDE Debug Setup IDE Debug Commands Platform Builder Integrated Kernel Debugger Other Debugging.
CS 211: Computer Architecture Lecture 6 Module 2 Exploiting Instruction Level Parallelism with Software Approaches Instructor: Morris Lancaster.
G53SEC 1 Reference Monitors Enforcement of Access Control.
RIVERSIDE RESEARCH INSTITUTE Deobfuscator: An Automated Approach to the Identification and Removal of Code Obfuscation Eric Laspe, Reverse Engineer Jason.
1 CHAPTER 5 DIFFING. 2 What is Diffing? Practice of comparing two sets of data, before and after a changed has occurred Practice of comparing two sets.
Stealing Passwords Remotely & Malware Analysis PacITPros May 8, 2012.
CPS120: Introduction to Computer Science Compiling a C++ Program From The Command Line.
Introduction to Information Security מרצים : Dr. Eran Tromer: Prof. Avishai Wool: מתרגלים : Itamar Gilad
MD5 & Hash Encryption By Alex Buzak. Overview Purpose of MD5 and Hash Encryptions Examples MD5 Algorithm Explanation of Possible Security Risks Practical.
Software mechanism of Genesis --- a cheating software for Warcraft3 Yang Chen Wen Sun.
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
Lecture 10 Anti-debugger techniques. Anti-debuggers Making reverse-engineering and disassembly painful –Polymorphism –Encryption –Interrupt disabling.
Computer and Information Security Chapter 12 Insecurity in Software 1.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 – Loaders.
Software Reverse Engineering Binary analysis: concepts, methods and tools. Catalin Patulea Mar 5, 2008.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Cryptographic Hash Function. A hash function H accepts a variable-length block of data as input and produces a fixed-size hash value h = H(M). The principal.
Reverse Engineering Contemporary Countermeasures By: Joshua Schwartz.
Polymorphic Virus Analysis Nicolas BRULEZ Senior Virus Researcher Websense Security Labs IMPROVISED TALK MMMKAY?!
CHAPTER 4 Methodology.
Reverse Engineering Dr. Tyler Bletsch and Jiaming Li
Live Phishing Attack Authentication Activity from a Foreign Address.
Cryptographic Hash Function
Malware Incident Response  Dynamic Analysis - 2
Important terms Black-box testing White-box testing Regression testing
Important terms Black-box testing White-box testing Regression testing
Memory Management Tasks
Introduction to Intel x86-64 Assembly, Architecture, Applications, & Alliteration Xeno Kovah – 2014 xkovah at gmail.
Security Flaws 2 Ian Kayne
Module 6: Debugging a Windows CE Image
Computer and Information Security
Presentation transcript:

SRE  Introduction 1 Software Reverse Engineering (SRE)

SRE  Introduction 2 SRE  Software Reverse Engineering o Also known as Reverse Code Engineering (RCE) o Or simply “reversing”  Can be used for good... o Understand malware o Understand legacy code (design recovery)  …or not-so-good o Remove usage restrictions from software o Find and exploit flaws in software o Cheat at games, etc.

SRE  Introduction 3 SRE  For now, we assume… o Reverse engineer is an attacker o Attacker only has exe (no source code)  Attacker might want to o Understand the software o Modify the software  SRE usually focused on Windows o So here we’ll focus on Windows

SRE  Introduction 4 SRE Tools  Disassembler o Converts exe to assembly  as best it can o Cannot always disassemble correctly o In general, it is not possible to re-assemble disassembly into working exe  Debugger o Must step thru code to completely understand it o Labor intensive  lack of automated tools  Hex Editor o To patch (make permanent changes to) exe file  Regmon, Filemon, VMware, etc.

SRE  Introduction 5 SRE Tools  IDA Pro is the top-rated disassembler o Cost is a few hundred dollars o Converts binary to assembly (as best it can)  SoftICE is “alpha and omega” of debuggers o Cost is in the $1000’s o “Kernel mode” debugger o Can debug anything, even the OS  OllyDbg is a high-quality shareware debugger o Includes a good disassembler  Hex editor  to view/modify bits of exe o UltraEdit is good  freeware o HIEW  useful for patching exe  Regmon, Filemon  freeware

SRE  Introduction 6 Why is a Debugger Needed?  Disassembler gives static results o Good overview of program logic o User must “mentally execute” program o Difficult to jump to specific place in the code  Debugger is dynamic o Can set break points o Can treat complex code as “black box” o Not all code disassembles correctly  Disassembler and debugger both required for any serious SRE task

SRE  Introduction 7 SRE Necessary Skills  Working knowledge of target assembly code  Experience with the tools o IDA Pro  sophisticated and complex o SoftICE  large two-volume users manual o OllyDbg  best choice for this class  Knowledge of Windows Portable Executable (PE) file format  Boundless patience and optimism  SRE is a tedious, labor-intensive process!

SRE  Introduction 8 SRE Example  We consider a very simple example  This example only requires disassembler (IDA Pro) and hex editor o Trudy disassembles to understand code o Trudy also wants to patch the code  For most real-world code, also need a debugger (OllyDbg)

SRE  Introduction 9 SRE Example  Program requires serial number  But Trudy doesn’t know the serial number!  Can Trudy get the serial number from exe?

SRE  Introduction 10 SRE Example  IDA Pro disassembly  Looks like serial number is S123N456

SRE  Introduction 11 SRE Example  Try the serial number S123N456  It works!  Can Trudy do better?

SRE  Introduction 12 SRE Example  Again, IDA Pro disassembly  And hex view…

SRE  Introduction 13 SRE Example  test eax,eax does AND of eax with itself o Flag bit set to 0 only if eax is 0 o If test yields 0, then jz is true  Trudy wants jz to always be true!  Can Trudy patch exe so jz always holds?

SRE  Introduction 14 SRE Example AssemblyHex test eax,eax 85 C0 … xor eax,eax 33 C0 …  Can Trudy patch exe so that jz always true? xor  jz always true!!!

SRE  Introduction 15 SRE Example  Edit serial.exe with hex editor serial.exe serialPatch.exe  Save as serialPatch.exe

SRE  Introduction 16 SRE Example  Any “serial number” now works!  Very convenient for Trudy!

SRE  Introduction 17 SRE Example  Back to IDA Pro disassembly… serial.exe serialPatch.exe

SRE  Introduction 18 SRE Attack Mitigation  Impossible to prevent SRE on open system  But can make such attacks more difficult  Anti-disassembly techniques o To confuse static view of code  Anti-debugging techniques o To confuse dynamic view of code  Tamper-resistance o Code checks itself to detect tampering  Code obfuscation o Make code more difficult to understand

SRE  Introduction 19 Anti-disassembly  Anti-disassembly methods include o Encrypted or packed object code o False disassembly o Self-modifying code o Many other techniques  Encryption prevents disassembly o But need decrypted code to decrypt the code! o Same problem as with polymorphic viruses

SRE  Introduction 20 Anti-disassembly Example  Suppose actual code instructions are  What the disassembler sees inst 1 inst 3jmpjunkinst 4 … inst 1 inst 5inst 2inst 3inst 4inst 6 …  This is example of “false disassembly”  Persistent attacker will figure it out!

SRE  Introduction 21 Anti-debugging  Monitor for o Use of debug registers o Inserted breakpoints  Debugger might not handle threads well o Interacting threads may confuse debugger  Many other debugger-unfriendly tricks  Undetectable debugger possible in principle o Hardware-based debugging (HardICE) is possible

SRE  Introduction 22 Anti-debugger Example  Suppose when program gets inst 1, it pre- fetches inst 2, inst 3 and inst 4 o This is done to increase efficiency  Suppose when debugger executes inst 1, it does not pre-fetch instructions  Can we use this difference to confuse the debugger? inst 1 inst 5inst 2inst 3inst 4inst 6 …

SRE  Introduction 23 Anti-debugger Example  Suppose inst 1 overwrites inst 4 in memory  Then program (without debugger) will be OK since it fetched inst 4 at same time as inst 1  Debugger will be confused when it reaches junk where inst 4 is supposed to be  Problem for program if this segment of code executed more than once!  Also, code is very platform-dependent  Again, persistent attacker can figure this out! inst 1 inst 5inst 2inst 3inst 4inst 6 … junk

SRE  Introduction 24 Tamper-resistance  Goal is to make patching more difficult  Code can hash parts of itself  If tampering occurs, hash check fails  Research has shown can get good coverage of code with small performance penalty  But don’t want all checks to look similar o Or else easier for attacker to remove checks  This approach sometimes called “guards”

SRE  Introduction 25 Code Obfuscation  Goal is to make code hard to understand  Opposite of good software engineering! o For example, spaghetti code  Much research into more robust obfuscation o Example: opaque predicate int x,y : if((x  y)  (x  y) > (x  x  2  x  y+y  y)){…} o The if() conditional is always false  Attacker wastes time analyzing dead code

SRE  Introduction 26 Code Obfuscation  Code obfuscation sometimes promoted as a powerful security technique  Diffie and Hellman’s original conjectures for public key crypto based on code obfuscation!  Recently it has been shown that obfuscation probably cannot provide “strong” security o On the (im)possibility of obfuscating programs On the (im)possibility of obfuscating programs o But some question these result (Thomborson)  Obfuscation might still have practical uses! o Even if it can never be as strong as crypto

SRE  Introduction 27 Authentication Example  Software used to determine authentication  Ultimately, authentication is 1-bit decision o Regardless of method used (pwd, biometric, …)  Somewhere in authentication software, a single bit determines success/failure  If attacker can find this bit, he can force authentication to always succeed  Obfuscation makes it more difficult for attacker to find this all-important bit

SRE  Introduction 28 Obfuscation  Obfuscation forces attacker to analyze larger amounts of code  Method could be combined with o Anti-disassembly techniques o Anti-debugging techniques o Code tamper-checking  All of these increase work (and pain) for attacker  But a persistent attacker can ultimately win