Java Code Obfuscation Neerja Bhatnagar. Reverse Engineering Figuring out source code corresponding to a given byte code Source code intellectual property,

Slides:



Advertisements
Similar presentations
1 The Project of this year Mariano Ceccato FBK - Fondazione Bruno Kessler
Advertisements

METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
CSE 1302 Lecture 8 Inheritance Richard Gesick Figures from Deitel, “Visual C#”, Pearson.
Inheritance Inheritance Reserved word protected Reserved word super
SE-1020 Dr. Mark L. Hornick 1 Inheritance and Polymorphism: Abstract Classes The “not quite” classes.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
ITEC200 – Week03 Inheritance and Class Hierarchies.
Name: Hao Yuan Supervisor: Len Hamey ITEC810 ProjectTransformations for Obfuscating Object-Oriented Programs1.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
CS 106 Introduction to Computer Science I 11 / 15 / 2006 Instructor: Michael Eckmann.
Obfuscation techniques in Java Therese Berge Jonas Ringedal.
CS 2511 Fall  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance  Polymorphism.
Chapter 10 Classes Continued
Computer Science 240 Principles of Software Design.
(c) University of Washington03-1 CSC 143 Java Inheritance Reading: Ch. 10.
Breaking Abstractions and Unstructuring Data Structures Christian Collberg Clark Thomborson Douglas Low “Mobile programs are distributed in forms that.
Inheritance using Java
COP 3003 Object-Oriented Programming - Polymorphism Dr. Janusz Zalewski, Fall 2013 Prepared by Dr Dahai Guo.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Java Programming Robert Chatley William Lee
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
Computer Science 240 © Ken Rodham 2006 Principles of Software Design.
Computer Science and Engineering College of Engineering The Ohio State University Interfaces The credit for these slides goes to Professor Paul Sivilotti.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Low-Level Detailed Design SAD (Soft Arch Design) Mid-level Detailed Design Low-Level Detailed Design Design Finalization Design Document.
Inheritance (Part 4) Abstract Classes 1.  sometimes you will find that you want the API for a base class to have a method that the base class cannot.
1 Computer Science 340 Software Design & Testing Inheritance.
(c) University of Washington01-1 CSC 143 Java Programming as Modeling Reading: Ch. 1-6.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 7 Structured Data and Classes.
Reformatted slides from the textbook, C++ How to Program, 6/e Pearson Education, Inc. All rights reserved Chapter 3. [Lecture 02] Introduction to.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
Classes and Objects in Java
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Programming in Java CSCI-2220 Object Oriented Programming.
1 Class responsibilities & relationships. 2 Responsibilities Responsibilities describe a class’s purpose in terms of its functionality Responsibilities.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
CSCI 1100/1202 April 1-3, Program Development The creation of software involves four basic activities: –establishing the requirements –creating.
Chapter 8 Inheritance. 2  Review of class relationships  Uses – One class uses the services of another class, either by making objects of that class.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
Formal Refinement of Obfuscated Codes Hamidreza Ebtehaj 1.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
Chapter 2 – The Little Crab Program:. Little Crab Scenario Inheritance: The Arrows Denote Hierarchy Crab is an Animal Animal is an Actor Therefore, It.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
Important Annoucement 1  I messed up something in the last class  if a subclass overrides a method that throws an exception then it must either 1. throw.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
3-July-2002cse142-D2-Methods © 2002 University of Washington1 Methods CSE 142, Summer 2002 Computer Programming 1
 The word static is used to declare either a ________ variable or method.  Why do we use statics?  What is Polymorphism? class In general, we use a.
Lecture 6: Composition and Inheritance CS202 Fall 2013.
Object-Oriented Programming Concepts
More Sophisticated Behavior
Module Road Map Refactoring Why Refactoring? Examples
Interfaces.
Un</br>able’s MySecretSecrets
Compiler Design 18. Object Oriented Semantic Analysis (Symbol Tables, Type Checking) Kanat Bolazar March 30, 2010.
Lecture 22 Inheritance Richard Gesick.
Advanced Java Programming
Fundaments of Game Design
Topics OOP Review Inheritance Review Abstract Classes
Presentation transcript:

Java Code Obfuscation Neerja Bhatnagar

Reverse Engineering Figuring out source code corresponding to a given byte code Source code intellectual property, needs protection Money, intelligence, hard work, time put to work to develop code

Problem of Reverse Engineering Java code especially prone to reverse engineering, because Java byte code well documented and well structured (freely available in JVM specs) Most of the information contained in source code also present in byte code. Software engineers have little control over distribution of Java applications and their source code because most Java applications distributed over the Internet (easy downloads)

Code Obfuscation Technique to discourage and deter reverse engineering Scrambles byte code to make it unintelligible, difficult to understand Alters structure and appearance of code Attempts to make in uneconomical for an attacker to reverse engineer code Does not affect function of original program Does not alter source code, alters byte code

Code Obfuscation Techniques Low-Level Layout Obfuscations Control Obfuscations Data Obfuscations High-Level or Design Obfuscations Class Coalescing Obfuscation Class Splitting Obfuscation Type Hiding

Design Obfuscations Low-level obfuscation techniques not sufficient because they do not hide design information Design information can facilitate an attacker from gaining general understanding of code and what it does Design obfuscations aim at hiding valuable high-level design information

Class Coalescing Obfuscation Combines two or more classes into a single class If the classes to be coalesced have attributes with same name, these are renamed to distinguish among them have non-constructor methods with same signature, except for one non-constructor methods, all others are renamed and altered

Class Coalescing Obfuscation Example

public class Animal { String name; int age; public Animal() { name = “Goofy”; age = 1; } public int calcAge() { return 2004 – 1985; } public void comments() { System.out.println(“Fluffy”); } public class A { String name; String model; int age; int age2; public Animal() { name = “Goofy”; age = 1; } public Car() { name = “VW”; age = 2; } public int calcAge() { return 2004 – 1985; } public int calcAge(int make) { return 2004 – make; } public void comments() { System.out.println(“Fluffy”); } public void commentsFromCar() { System.out.println(“Smooth”); } public class Car { String model; int age; public Car() { name = “VW”; age = 2; } public int calcAge(int make) { return 2004 – make; } public void comments() { System.out.println(“Smooth”); }

Class Coalescing Obfuscation Shortcomings Becomes very complicated when classes extend other classes or implement interfaces because superclasses and interfaces need to be coalesced too variable names and method signatures cannot be altered in any way Cannot be performed when classes extend classes from Java standard library Java standard library classes need to be coalesced too Makes code non-portable Classes with native methods cannot be coalesced because analyzing native code very difficult

Class Splitting Obfuscation Splits a class into multiple classes Several ways to split a class Valid split function preserves dependencies among class’s methods and fields Valid split functions include Split class A into classes A1 and A2, where A2 extends A1 Split methods defined in class A between classes A1 and A2

Class Splitting Obfuscation Example

public class Dog { String name; int age; String sound; public Dog() { name = “Bruno”; age = 5; sound = “woof”; } public void bark() { System.out.println(“Woof! Woof!”); } public void sleep() { System.out.println(“zzz…zzz”); } public class Animal { String name; int age; public Animal() { name = “Bruno”; age = 5; } public void sleep() { System.out.println(“zzz…zzz”); } public class Doggie extends Animal { String sound; public Doggie() { super(); sound = “woof”; } public void bark() { System.out.println(“Woof! Woof!”); }

Class Splitting Obfuscation Shortcomings Splitting a class very difficult unless initial design faulty May have reverse effect Splitting a class may improve overall code design, and get rid of spaghetti code! Might actually help the attacker, rather than deter him

Type Hiding Uses the concept of Java interface Transforms a concrete class into several interfaces Each interface contains a random subset of the concrete class’s methods and fields Obscures by declaring a concrete class that implements those interfaces

Type Hiding Example

public class Dog { String name; int age; String sound; public Dog() { name = “Bruno”; age = 5; sound = “woof”; } public void bark() { System.out.println(“Woof! Woof!”); } public void sleep() { System.out.println(“zzz…zzz”); } interface LivingCreature { public void bark(); } interface Animal { public void sleep(); } public class Doggie { String name; int age; String sound; public Dog() { name = “Bruno”; age = 5; sound = “woof”; } public void bark() { System.out.println(“Woof! Woof!”); } public void sleep() { System.out.println(“zzz…zzz”); }

Type Hiding Shortcomings Type hiding done the way described in previous slide especially vulnerable to reverse engineering More effective when combined with low-level obfuscation techniques Can be made stronger when randomly selected classes go through type hiding, instead of all classes

Obfuscation Products RetroGuard by Retrologic SystemsRetrologic Systems Klassmaster by ZelixZelix JObfuscator by DuckwareDuckware Semantic Designs

Conclusion None of the obfuscation techniques sufficient by themselves A combination of these techniques might provide strong resistance to reverse engineering Some claim code obfuscation slows down an application Impact on performance depends on a particular technique Impact usually minimal or none at all Decision to obfuscate or not is a trade-off between protecting code or taking a slight performance hit