Decompilation of.NET bytecode Stephen Horne Trinity Hall 10 th February 2004 Computer Science Part II Project Progress Report

Slides:



Advertisements
Similar presentations
© 2003 School of Computing, University of Leeds SY32 Secure Computing, Lecture 16 Secure Coding in Java and.NET Part 1: Fundamentals.
Advertisements

Mike Barnett RSDE Microsoft Research Nikolai Tillmann RSDE Microsoft Research TL51.
Opportunities for Gigascale Integration in Three Dimensional Architectures James Joyner, Payman Zarkesh-Ha, Jeffrey Davis, and James Meindl Microelectronics.
pa 1 Porting BETA to ROTOR ROTOR Projects Presentation Day, June by Peter Andersen.
Intermediate Representations CS 671 February 12, 2008.
 Miguel de Icaza VP Developer Platform Novell, Inc. PC54.
Phil Campbell London South Bank University Using Java (2)
1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar.
1 Lecture 10 Intermediate Representations. 2 front end »produces an intermediate representation (IR) for the program. optimizer »transforms the code in.
The University of Adelaide, School of Computer Science
Native x86 Decompilation Using Semantics-Preserving Structural Analysis and Iterative Control-Flow Structuring Edward J. Schwartz *, JongHyup Lee ✝, Maverick.
1 Today’s lecture  Last lecture we started talking about control flow in MIPS (branches)  Finish up control-flow (branches) in MIPS —if/then —loops —case/switch.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
Apr. 12, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 6: Branching and Procedures in MIPS* Jeremy R. Johnson Wed. Apr. 12, 2000.
Decompilation of Binary Programs Christina Cifuentes & K. John Gough School of Computing Science Queensland University of Technology Presented by Conny.
Intermediate Representation I High-Level to Low-Level IR Translation EECS 483 – Lecture 17 University of Michigan Monday, November 6, 2006.
Chapter 14: Building a Runnable Program Chapter 14: Building a runnable program 14.1 Back-End Compiler Structure 14.2 Intermediate Forms 14.3 Code.
Intermediate code generation. Code Generation Create linear representation of program Result can be machine code, assembly code, code for an abstract.
Intermediate Representations Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
CS 536 Spring Intermediate Code. Local Optimizations. Lecture 22.
Intermediate Code CS 471 October 29, CS 471 – Fall Intermediate Code Generation Source code Lexical Analysis Syntactic Analysis Semantic.
Introduction to the C# Programming Language for the VB Programmer.
Data Structure and Algorithm 1 Yingcai Xiao. You Me The Course (
Antonio Cisternino & Diego Colombo VisualStorms Tools Another Brick in the Robot... Università degli Studi di Pisa.
Consider With x = 10 we may proceed as (10-1) = 9 (10-7) = 3 (9*3) = 27 (10-11) = -1 27/(-1) = -27 Writing intermediates on paper.
Intermediate Code. Local Optimizations
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Prof. Fateman CS164 Lecture 211 Local Optimizations Lecture 21.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Defining and Using Procedures Creating Procedures.
Java Vs .Net Presented By, Naveen Kumar Ratkal.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
JVM And CLR Dan Agar April 16, Outline Java and.NET Design Philosophies Overview of Virtual Machines Technical Look at JVM and CLR Comparison of.
Appendix D: Microsoft.NET Framework Overview. Overview.NET Framework Architecture.NET Namespaces.
UNIVERSITI TENAGA NASIONAL “Generates Professionals” CHAPTER 4 : Part 2 INTRODUCTION TO SOFTWARE DEVELOPMENT: PROGRAMMING & LANGUAGES.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 10, 10/30/2003 Prof. Roy Levow.
Cosc 2150: Computer Organization
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Program design and analysis Software components. Representations of programs. Assembly.
1 C# A brief overview by Jack Senechal and Bryan Powell.
1 CS 201 Compiler Construction Introduction. 2 Instructor Information Rajiv Gupta Office: WCH Room Tel: (951) Office.
Compiler Principles Fall Compiler Principles Lecture 0: Local Optimizations Roman Manevich Ben-Gurion University.
1 Hammad Khan. Agenda.NET Framework Introduction to Visual C#
.NET Security and MSIL Tom Roeder CS fa. MSIL Common intermediate language really CIL in ECMA standard MSIL is common name Very close to C# (and.
Code Generation Ⅰ CS308 Compiler Theory1. 2 Background The final phase in our compiler model Requirements imposed on a code generator –Preserving the.
MSIL C#.NET Software Development. MSIL AKA CIL What all.NET languages compile to What all.NET languages compile to Binary Intermediate Language Binary.
9/29: Lecture Topics Conditional branch instructions
CS412/413 Introduction to Compilers Radu Rugina Lecture 18: Control Flow Graphs 29 Feb 02.
1 Control Flow Graphs. 2 Optimizations Code transformations to improve program –Mainly: improve execution time –Also: reduce program size Can be done.
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
CSCI 212 Object-Oriented Programming in Java. Prerequisite: CSCI 111 variable assignment statement while loop for loop post-increment (i++) strong typing.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 5: Procedures Lecture 19: Procedures Procedure’s parameters (c) Pearson Education, 2002.
Intermediate code generation. Code Generation Create linear representation of program Result can be machine code, assembly code, code for an abstract.
A Microsoft.NET Front-End for GCC Bernhard Rabe Martin von Löwis Jan Möller Operating Systems & Middleware Group Hasso-Plattner-Institute, University of.
The Execution System1. 2 Introduction Managed code and managed data qualify code or data that executes in cooperation with the execution engine The execution.
CSC 221 Computer Organization and Assembly Language Lecture 16: Procedures.
CS 116 Object Oriented Programming II Lecture 13 Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
METADATA IN.NET Presented By Sukumar Manduva. INTRODUCTION  What is Metadata ? Metadata is a binary information which contains the complete description.
Computer System Structures
.NET Security and MSIL Tom Roeder CS fa.
C# and the .NET Framework
CS360 Windows Programming
Chapter 1 IDE and Tools for Developing CLR-based Programs
Proof-Transforming Compilation of Programs with Abrupt Termination
Pick up the handout on your way in!!
Introducing the .NET Framework
Java 6 Decompiler Joshua Cranmer.
Program Flow.
Advanced .NET Programming I 9th Lecture
Presentation transcript:

Decompilation of.NET bytecode Stephen Horne Trinity Hall 10 th February 2004 Computer Science Part II Project Progress Report

Slide 2 Decompilation of.NET bytecode The.NET framework C# compiler J# compiler Managed C++ compiler VB.NET compiler Managed C++ VB.NET J# C# CIL and Metadata Common Language Runtime.NET and the Common Language Runtime Microsofts answer to Java CLR is.NET equivalent of the JVM Lots of useful metadata provided in assemblies What about reversing the compilation process? Sometimes we want to recover source from a binary – Language translation – Lost source recovery – Checking for malicious code Obvious legal and ethical ramifications

Slide 3 Decompilation of.NET bytecode Executable Decompiler Source Front end UDM Back end Low-level intermediate code Unstructured control-flow graph Structured control-flow graph High-level intermediate code Structure of a decompiler Reads in bytecode Divides into basic blocks Data-flow analysis Control-flow analysis Code generation

Slide 4 Decompilation of.NET bytecode IL_002b: ldloc.2 IL_002c: ret Example decompilation CIL bytecode Divide code into basic blocks and create CFG Data-flow analysis – Register copy propogation Control-flow analysis – Divide graph into intervals – Loops induced by back-edges within intervals – Nesting of intervals nesting of loops – Conditionals found by common follow nodes – Order of nodes nesting of conditionals Generate code from structured CFG Control-flow graph IL_0000: ldc.i4.0 IL_0001: stloc.0 IL_0002: ldc.i4.0 IL_0003: stloc.1 IL_0004: br.s IL_0023 IL_0006: ldc.i4.3 IL_0007: ldloc.1 IL_0008: mul IL_0009: ldarg.0 IL_000a: bge.s IL_0012 IL_000c: ldloc.0 IL_000d: ldc.i4.1 IL_000e: sub IL_000f: stloc.0 IL_0010: br.s IL_0016 IL_0012: ldloc.0 IL_0013: ldc.i4.1 IL_0014: add IL_0015: stloc.0 IL_001f: ldloc.1 IL_0020: ldc.i4.1 IL_0021: add IL_0022: stloc.1 IL_0027: ldloc.0 IL_0028: stloc.2 IL_0029: br.s IL_002b IL_0023: ldloc.1 IL_0024: ldarg.0 IL_0025: blt.s IL_0006 IL_0016: ldloc.0 IL_0017: call Math::Abs(int32) IL_001c: ldloc.1 IL_001d: blt.s IL_ Process Entry Exit

Slide 5 Decompilation of.NET bytecode Current status public static int ControlExample(int x) { int y = 0; for(int i = 0; i < x; i++) { do { if(3 * i < x) y--; else y++; } while(Math.Abs(y) < i); } return y; } public static Int32 ControlExample(Int32 x) { Int32 local0; Int32 local1; Int32 local2; local0 = 0; local1 = 0; while (local1 < x) { do { if (((3 * local1) < x)) { local0 = (local0 - 1); } else { local0 = (local0 + 1); } } while (Math.Abs(local0) < local1); local1 = (local1 + 1); } local2 = local0; return local2; } Original Decompiled Features implemented: Analysis for basic conditional and looping structures Control flow graph generation C# code generation Almost half the CIL instruction set Decompiles very basic applications Remaining tasks (lots!): Local variable names Basic language features (arrays, switching, breaks etc.) Advanced features (custom indexers, operator overloading, properties) Object oriented features Extensions: Decompilation for other stack-based architectures (e.g. Java) Code generation for other languages (e.g VB.NET) Graphical user interface