Reversing Microsoft Patches to reveal Vulnerable code Harsimran Walia

Slides:



Advertisements
Similar presentations
Debugging ACL Scripts.
Advertisements

Sample chapter from Reverse Engineering Course.
ByteWeight: Learning to Recognize Functions in Binary Code
Smita Thaker 1 Polymorphic & Metamorphic Viruses Presented By : Smita Thaker Dated : Nov 18, 2003.
Native x86 Decompilation Using Semantics-Preserving Structural Analysis and Iterative Control-Flow Structuring Edward J. Schwartz *, JongHyup Lee ✝, Maverick.
RIVERSIDE RESEARCH INSTITUTE Helikaon Linux Debugger: A Stealthy Custom Debugger For Linux Jason Raber, Team Lead - Reverse Engineer.
David Brumley, Pongsin Poosankam, Dawn Song and Jiang Zheng Presented by Nimrod Partush.
Bouncer securing software by blocking bad input Miguel Castro Manuel Costa, Lidong Zhou, Lintao Zhang, and Marcus Peinado Microsoft Research.
CS590 Z Matching Program Versions Xiangyu Zhang. CS590Z Problem Statement  Suppose a program P’ is created by modifying P. Determine the difference between.
Fuzzing Dan Fleck CS 469: Security Engineering Sources:
Outline Learning Assembly by an Example.  Program Formats  Some Simple Instructions  Assemble and Execute Learning Another Example  Data Definition.
Windows XP SP2 Stack Protection Jimmy Hermansson Johan Tibell.
The Superdiversifier: Peephole Individualization for Software Protection Mariusz H. Jakubowski Prasad Naldurg Chit Wei (Nick) Saw Ramarathnam Venkatesan.
September 22, 2014 Pengju (Jimmy) Jin Section E
Memory & Storage Architecture Seoul National University Computer Architecture “ Bomb Lab Hints” 2nd semester, 2014 Modified version : The original.
Security Comparisons of Open Source and Closed Source Programs Katherine Wright.
The (5) Parts Every Computer MUST have. Humans Computers Input Devices (getting information IN) Question: What other INPUT devices can you think of?
0wning Antivirus Alex Wheeler Neel Mehta
Code Injection and Software Cracking’s Effect on Network Security Group 5 Jason Fritts Utsav Kanani Zener Bayudan ECE 4112 Fall 2007.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 18: 0xCAFEBABE (Java Byte Codes)
1 Internet Security Threat Report X Internet Security Threat Report VI Figure 1.Distribution Of Attacks Targeting Web Browsers.
Vulnerability-Specific Execution Filtering (VSEF) for Exploit Prevention on Commodity Software Authors: James Newsome, James Newsome, David Brumley, David.
Disclaimer The Content, Demonstration, Source Code and Programs presented here is "AS IS" without any warranty or conditions.
Application Security Tom Chothia Computer Security, Lecture 14.
Introduction to InfoSec – Recitation 2 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Apache Exploits
What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014.
1 Vulnerability Analysis and Patches Management Using Secure Mobile Agents Presented by: Muhammad Awais Shibli.
CS266 Software Reverse Engineering (SRE) Reversing and Patching Java Bytecode Teodoro (Ted) Cipresso,
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Introduction to Information Security מרצים : Dr. Eran Tromer: Prof. Avishai Wool: מתרגלים : Itamar Gilad
© ETH Zürich Eric Lo ETH Zurich a joint work with Carsten Binnig (U of Heidelberg), Donald Kossmann (ETH Zurich), Tamer Ozsu (U of Waterloo) and Peter.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
TaintScope Presented by: Hector M Lugo-Cordero, MS CAP 6135 April 12, 2011.
Software attacks int ConcatString(char *buf1, char *buf2, size_t len1, size_t len2) { char buf[256]; if((len1 + len2) > 256) return -1; memcpy(buf, buf1,
Introduction to InfoSec – Recitation 2 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
RIVERSIDE RESEARCH INSTITUTE Deobfuscator: An Automated Approach to the Identification and Removal of Code Obfuscation Eric Laspe, Reverse Engineer Jason.
Assembly Code Optimization Techniques for the AMD64 Athlon and Opteron Architectures David Phillips Robert Duckles Cse 520 Spring 2007 Term Project Presentation.
CNIT 127: Exploit Development Ch 3: Shellcode. Topics Protection rings Syscalls Shellcode nasm Assembler ld GNU Linker objdump to see contents of object.
Buffer Overflow Proofing of Code Binaries By Ramya Reguramalingam Graduate Student, Computer Science Advisor: Dr. Gopal Gupta.
CASE/Re-factoring and program slicing
Buffer Overflow Attack Proofing of Code Binary Gopal Gupta, Parag Doshi, R. Reghuramalingam, Doug Harris The University of Texas at Dallas.
CS412/413 Introduction to Compilers and Translators April 14, 1999 Lecture 29: Linking and loading.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Search Worms, ACM Workshop on Recurring Malcode (WORM) 2006 N Provos, J McClain, K Wang Dhruv Sharma
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
02b | Create and Configure Test Plans (2 of 2) Anthony Borton | ALM Consultant, Enhance ALM Steven Borg | Co-founder & Strategist, Northwest Cadence.
Hash Functions Ramki Thurimella. 2 What is a hash function? Also known as message digest or fingerprint Compression: A function that maps arbitrarily.
Introduction Program File Authorization Security Theorem Active Code Authorization Authorization Logic Implementation considerations Conclusion.
Where’s the FEEB?: Effectiveness of Instruction Set Randomization Nora Sovarel, David Evans, Nate Paul University of Virginia Computer Science USENIX Security.
Exploiting Instruction Streams To Prevent Intrusion Milena Milenkovic.
Introduction to Information Security מרצים : Dr. Eran Tromer: Prof. Avishai Wool: מתרגלים : Itamar Gilad
13/July/1999Third USENIX Windows NT Symposium1 Detours: Binary Interception of Win32 Functions Galen Hunt and Doug Brubacher Systems and Networking Group.
Paradyn Project Paradyn / Dyninst Week Madison, Wisconsin May 2-4, 2011 unstrip: Restoring Function Information to Stripped Binaries Using Dyninst Emily.
Correct RelocationMarch 20, 2016 Correct Relocation: Do You Trust a Mutated Binary? Drew Bernat
Unveiling Zeus Automated Classification of Malware Samples Abedelaziz Mohaisen Omar Alrawi Verisign Inc, VA, USA Verisign Labs, VA, USA
Paradyn Project Paradyn / Dyninst Week Madison, Wisconsin April 12-14, 2010 Paradyn Project Safe and Efficient Instrumentation Andrew Bernat.
EsreveR gnireenignE tfosorciM seiraniB Alexander Sotirov CanSecWest / core06.
Instruction Set Architecture
Introduction to Information Security
Static and dynamic analysis of binaries
Computer Architecture and Assembly Language
Cyber Grand Challenge “Cyber Grand Challenge (CGC) is a contest to build high-performance computers capable of playing in a Capture-the-Flag style cyber-security.
Techniques, Tools, and Research Issues
Emily Jacobson and Nathan Rosenblum
Computer Architecture “Bomb Lab Hints”
Nessus Vulnerability Scanning
Matching Program Versions
Computer Architecture and System Programming Laboratory
Return-to-libc Attacks
Presentation transcript:

Reversing Microsoft Patches to reveal Vulnerable code Harsimran Walia

Introduction Need Process

Finding a 0day vulnerability Vulnerability reaches the vendor Vendor finds a fix Releases a patch to fix the vulnerability Introduction Birth of a security patch Microsoft patches Reverse engineer the patch Locate the vulnerability patched Highlight the difficulties Discussion in the presentation

For reversing and obtaining binary difference in my demos I would be using DarunGrim2 How DarunGrim works? The schema of DarunGrim is shown in the figure To generate diffing results – Binaries are disassembled in IDA Pro in the background and darungrim IDA plugin is run which creates the sqlite database – Diffing Engine, the heart of DarunGrim2. The sqlite db from IDA and the binaries from GUI are fed into this engine as inputs Introduction

Algorithm ? Main algorithm of DarunGrim is Basic block fingerprint hash map Each basic block is 1 entity whose fingerprint is generated from the instruction sequence Fingerprint hash generated by IDA Pro Two fingerprint hash tables one each for unpatched and patched binary For finding the binary difference, each unique fingerprint from original binary is searched against the fingerprints of patched binary for a match All fingerprints in the original binary hash tables are either matched or unmatched Introduction

Algorithm ? Contd.. For a function to be called matching, all the basic blocks in the function should be matching For unmatched functions DarunGrim calculates percentage match Match rate based on fingerprint string match – Similar to GNU Diff algorithm which is finding longest common subsequence Introduction

Vulnerability Vs Exploit based signatures Exploit signatures Created by using byte string patterns or regular expressions These are exploit specific They are used widely mainly because of the ease of their creation Cater to only one type of input satisfying that vulnerability condition Fail: different attacks can exploit the same vulnerability, so exploit based signatures will fail For eg. Exploit based signature – ESig = “docx?AAAAAAAAAAA...” – It will fail if some exploit uses a long string of B’s instead of A’s Introduction

Vulnerability Vs Exploit based signatures Vulnerability signatures Based on the properties of the vulnerability and not on the properties of the exploit It is a superset of all the inputs satisfying a particular vulnerability condition For eg. Vulnerability based signature for previous case – VSig = MATCH_STR (Buffer,"docx?(.*)$",limit) – Matches string in buffer with the regex – It is effective against any alphabet unlike exploit signature Introduction Vulnerability Signature Exploit Signature

Vulnerability Vs Exploit based signatures Vulnerability signatures contd.. For a good vulnerability signature – It should strictly not allow any false negatives as even one exploit can pwn the system and create a gateway for the attacker into the network. – It should allow very few false positives, as too many false positives may lead to a DoS attack for the system. – The signature matching time should not create a considerable delay for the software and services. Introduction

The first step of creating an undisclosed exploit is to find the vulnerability to exploit it. To verify if the patch released by Microsoft is working as per it is designed. To create vulnerability based signatures. Need

Finding patchesExtraction of filesBinary DifferencingDifferencing AnalysisDebugging Process

Process Pick a vulnerability and download its patch Pick a vulnerability just before this one that patched the same program or dll – If unavailable, use the same dll from your system Finding patches GDR or QFE/LDR ?? File Versioning Quick-fix Use open source ms-patch-tools to easily get the file versions to compare

Process Finding patches DEMO

Process The traditional way of extracting file from patch –.exe /x – Works only till Windows XP and earlier versions of Windows Above method cannot be used on Win7 and Vista patches delivered as msu Extraction of files Finding patches

Process Use expand command – expand -F:*.msu C:\ – expand -F:*.cab C:\ Extraction of files Finding patches

Process Extraction of files Finding patches DEMO

Finding patches Process DarunGrim v2 used for binary difference – Feed in the two binaries to be compared – Generates a list of functions with the %age match between the two files Extraction of files Binary Differencing Not every function %age < 100 is changed Includes false positives which requires manual analysis

Finding patches Process Extraction of files Binary Differencing DEMO

Finding patches Process Manual inspection of functions with less than 100% match – Remove false positives generated by problems like Instruction reordering Lot of reordering happening over different releases marks even the same blocks as unmatched Split blocks Block in the graph which has only parent and the parent has only one child leads to a split block. causing a problem in the matching process Can be improved by merging the two blocks and treating as a single block. Extraction of filesBinary Differencing Differencing Analysis

Hot patching Instructions like mov eax, eax at the start of functions are a sign of hot patching leading to a mismatch in the block By just ignoring the instruction we can get a match Compiler optimizations Different compilers and even different versions of the same compiler perform different optimizations which also creates problems in getting proper difference – Eventually reach a function which is indeed modified and might be the fix to the vulnerability being patched Finding patches Process Extraction of filesBinary Differencing Differencing Analysis

Finding patches Process Extraction of filesBinary Differencing Differencing Analysis DEMO

Finding patches push [ebp-2Ch] ; unsigned int call ; operator new(uint) mov ebx, eax pop ecx mov [ebp-18h], ebx mov [ebp-3Ch], ebx mov byte ptr [ebp-4], 1 push dword ptr [ebp-2Ch] mov ecx, esi push ebx push [ebp-30h] call sub_118000C func(const *,void *,long) mov edi, eax test edi, edi jge short push [ebp-2Ch] ; unsigned int call ; operator new(uint) pop ecx mov [ebp-14h], eax ; ebp-14h = pBuffer mov [ebp-40h], eax mov byte ptr [ebp-4], 2 push [ebp-2Ch] mov ecx, esi push ebx push edi call sub_118000C func(const *,void *,long) mov esi, eax test esi, esi jge short loc_118158A Process Extraction of filesBinary Differencing Differencing Analysis

Finding patches Process Extraction of filesBinary DifferencingDifferencing Analysis Debugging To validate our finding of analysis by debugging – Getting a crash of the application – Creating a malformed file to get the crash Would be using Immunity Debugger

Finding patches Process Extraction of filesBinary DifferencingDifferencing Analysis Debugging DEMO

Conclusion Presented an overview of how the 1-day exploits and Vulnerability signatures can be created Attempt was made to understand the process involved in reversing and the problems faced during the execution of the process Only talked about Microsoft patches but concept not limited to this. Concepts presented can be perfected by interested audience

Thanks Questions??