Krakatoa: Decompilation in Java “Does Bytecode Reveal Source?” Todd A. Proebsting Scott A. Watterson The University of Arizona Presented by Karl von Randow.

Slides:



Advertisements
Similar presentations
18 January 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Advertisements

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.
Virtual Machines Matthew Dwyer 324E Nichols Hall
1 Lecture 10 Intermediate Representations. 2 front end »produces an intermediate representation (IR) for the program. optimizer »transforms the code in.
Topic 10 Java Memory Management. 1-2 Memory Allocation in Java When a program is being executed, separate areas of memory are allocated for each class.
Compilation 2007 Code Generation Michael I. Schwartzbach BRICS, University of Aarhus.
1 1 Lecture 14 Java Virtual Machine Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Lightweight Modeling of Java Virtual Machine Security Constraints using Alloy Mark Reynolds BU CS511 Midterm Report March 26, 2008.
Cmput Lecture 8 Department of Computing Science University of Alberta ©Duane Szafron 2000 Revised 1/26/00 The Java Memory Model.
Lab 9 Java Bytecode & The Jasmin Assembler
Introduction to By Mati Yanko. Primary Goals of Java Portable Secured Object Oriented.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
JETT 2003 Java.compareTo(C++). JAVA Java Platform consists of 4 parts: –Java Language –Java API –Java class format –Java Virtual Machine.
Lightweight Modeling of Java Virtual Machine Security Constraints using Alloy Mark Reynolds BU CS511 Final Report May 7, 2008.
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
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.
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.
5/6/99 Ashish Sabharwal1 JVM Architecture n Local storage area –Randomly accessible –Just like standard RAM –Stores variables (eg. an array) –Have to specify.
Compiler design Computer Science Rensselaer Polytechnic Lecture 1.
1 Memory Model of A Program, Methods Overview l Memory Model of JVM »Method Area »Heap »Stack.
CSc 453 Interpreters & Interpretation Saumya Debray The University of Arizona Tucson.
Code Generation Introduction. Compiler (scalac, gcc) Compiler (scalac, gcc) machine code (e.g. x86, arm, JVM) efficient to execute i=0 while (i < 10)
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 18: 0xCAFEBABE (Java Byte Codes)
Compiler Construction Lecture 17 Mapping Variables to Memory.
CSC 8505 Compiler Construction IR Example: Java Bytecode (looking inside class files)
Application Security Tom Chothia Computer Security, Lecture 14.
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.
Arpit Jain Mtech1. Outline Introduction Dalvik VM Java VM Examples Comparisons Experimental Evaluation.
Java Bytecode What is a.class file anyway? Dan Fleck George Mason University Fall 2007.
ITEC 352 Lecture 20 JVM Intro. Functions + Assembly Review Questions? Project due today Activation record –How is it used?
Lecture 10 : Introduction to Java Virtual Machine
1 Introduction to JVM Based on material produced by Bill Venners.
Roopa.T PESIT, Bangalore. Source and Credits Dalvik VM, Dan Bornstein Google IO 2008 The Dalvik virtual machine Architecture by David Ehringer.
An Efficient Stack Machine Martin Schöberl. JOP Stack Architecture2 Overview JVM stack machine Parameter passing Stack access patterns Common stack caches.
A Java Compiler Overview. October 21, 2003Shane A. Brewer2 Who Am I? Shane A. Brewer Masters Graduate.
1 CPSC 185 Introduction to Computing The course home page
CPSC 388 – Compiler Design and Construction Runtime Environments.
Code Optimization 1 Course Overview PART I: overview material 1Introduction 2Language processors (tombstone diagrams, bootstrapping) 3Architecture of a.
Programming Languages
A Look at Java. Categorize Java Which paradigm? Which paradigm? Scripting? Scripting? Declarative or procedural? Declarative or procedural? Which generation?
More on MIPS programs n SPIM does not support everything supported by a general MIPS assembler. For example, –.end doesn’t work Use j $ra –.macro doesn’t.
Code generation exercises. Function body Transform the following code into java bytecode: def middle(small: Int, big: Int): Int = { val mid = small +
ITEC 352 Lecture 19 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Stacks Function activation / deactivation.
Programming Languages and Paradigms Activation Records in Java.
Building a Java Interpreter CS 142 (b) 01/14. Lab Sessions Monday, Wednesday – 10am – noon – ICS 189 Send an or make an appointment with the TA.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 18: Code Safety and Virtual Machines
Java FilesOops - Mistake Java lingoSyntax
More Examples of Abstract Interpretation Register Allocation.
Code generation exercises. Function body Transform the following code into java bytecode: def middle(small: Int, big: Int): Int = { val mid = small +
Review on Program Challenge CSc3210 Yuan Long.
Recap: Printing Trees into Bytecodes To evaluate e 1 *e 2 interpreter –evaluates e 1 –evaluates e 2 –combines the result using * Compiler for e 1 *e 2.
“Unboxing” means taking an Integer object and assigning its value to a primitive int. This is done using the.intValue( ) method. Example; Integer z = new.
RealTimeSystems Lab Jong-Koo, Lim
CS 536 © CS 536 Spring Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 15.
CS216: Program and Data Representation
MIC-1 SIMULATOR Programming in IJVM
Computer Architecture and Organization Miles Murdocca and Vincent Heuring Chapter 4 – The Instruction Set Architecture.
Assignment 3 Solution Background
Java Byte Codes (0xCAFEBABE) cs205: engineering software
Assignment 3 Solution Background
CSc 453 Interpreters & Interpretation
Lecture 19: 0xCAFEBABE (Java Byte Codes) CS201j: Engineering Software
Byte Code Verification
Compiler Design 21. Intermediate Code Generation
CS 153: Concepts of Compiler Design November 6 Class Meeting
When a function is called...
Building a Java Interpreter
Compiler Design 21. Intermediate Code Generation
CMPE 152: Compiler Design April 16 Class Meeting
CSc 453 Interpreters & Interpretation
Presentation transcript:

Krakatoa: Decompilation in Java “Does Bytecode Reveal Source?” Todd A. Proebsting Scott A. Watterson The University of Arizona Presented by Karl von Randow

Introduction n Decompilation u Transforms low-level language into high-level language. u Inverse of Compilation..class.java Java bytecodeJava source

Outline n Recovering source-level expressions. u a = ( 3 * b ) + method( c + 9 ); n Synthesising high-level control constructs. u while ( a < b ) { … } FOCUS: Recovering source-level expressions

The Java (Dis)advantage n Java bytecodes closely correspond to Java source. n Class files contain type and name information on variables and methods. n Bytecode must be verifiable.

Expression Recovery n The Java VM is Stack based. u Bytecode instructions pop arguments off the stack, and push results. n Local variables are stored in an array. n To recover expressions, simulate running the bytecode, stack and local variable array.

Symbolic Execution n Instead of pushing values, push strings to represent the values (source-level expressions). n For example...

iload n iload_1 takes the value in the 1st local variable and pushes it onto the stack. n Instead we push the name of the variable. u ie. push “a” rather than 7.

imul n Pops two ints off the stack, multiplies them, then pushes the result. n Instead we push a string containing the two popped strings with a “*” in between. String right = pop(); String left = pop(); push( left + “*” + right );

Example of a Method public void bar( int a, int b ) { iload_1 iload_2 imul iconst_2 iadd istore_2 }

Example of a Method public void bar( int a, int b ) { è iload_1 è iload_2 imul iconst_2 iadd istore_2 } “a” “b”

Example of a Method public void bar( int a, int b ) { iload_1 iload_2 è imul iconst_2 iadd istore_2 } “(a*b)” String right = pop(); String left = pop(); push( left + “*” + right ); “a” “b”

Example of a Method public void bar( int a, int b ) { iload_1 iload_2 imul è iconst_2 iadd istore_2 } “(a*b)” “2”

Example of a Method public void bar( int a, int b ) { iload_1 iload_2 imul iconst_2 è iadd istore_2 } “((a*b)+2)”“(a*b)” “2” String right = pop(); String left = pop(); push( left + “+” + right );

Example of a Method public void bar( int a, int b ) { iload_1 iload_2 imul iconst_2 iadd è istore_2 } public void bar( int a, int b ) { b = ((a*b)+2); }

Conclusions n It is possible to automate the decompilation of Java bytecode, and to recover high-level, readable code. n How do we protect Java bytecode against decompilation? n How much harder does this make decompilation?