; presentation
Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out
Your Federal Quarterly Tax Payments are due April 15th Get Help Now >>

presentation

VIEWS: 6 PAGES: 10

  • pg 1
									Java 6 Decompiler
Joshua Cranmer

Why decompile?




Source code may be lost but compiled code not Examples
  

Accidentally deleted source code (happened to me!)‫‏‬ Need to patch abandonware (happened to me!)‫‏‬ Security analysis (not happened to me)‫‏‬

Myths of decompilation


Decompilers are illegal
 

Just as legal as BitTorrent If so, then why does IDA Pro exist? Undecidable step is actually pre-disassembly (code v. data)‫‏‬ Based on the notion that it merely undos the steps a compiler does



Decompilation is impossible




Decompilation is impractical


Steps of decompilation


Signature recovery
 

Simple parser Newer features make this more difficult “simple” without optimization or arbitrary scoping Example: fadd -> + Most difficult portion Direct translation impossible in some circumstances
Changes legal syntax to sensible syntax



Stack analysis and variable recovery




Trivial decompilation




Control flow graph recovery
 



Post-decompilation transformation


Signature Recovery


  



Signatures are stored like (Ljava/lang/Object;I)V Generics use a syntax like (TE;)V Proposed Java 7 features are crazier Enums, annotations, etc. use specific bits or binary JVM attributes (relatively simple)‫‏‬ Completed Q1

Stack Analysis




Used to infer about variables and unroll some optimizations Uses Static Single Assignment (a “variable” can only be assigned once)‫‏‬


Variables are not presently unified, making ugliness



Most work done in late Q1 and Q2

Control Flow Graph Reconstruction


  



Hardest part of decompiling Worked on during Q2, Q3, and Q4 Basic algorithm: create blocks and unify Only unifications currently supported are if-else blocks Couldn’t complete due to difficulty to get loops working

Example of CFG Reconstruction


Following is an if-else-block recovery

A
B D C

<block A> if <expression> { <block B> } else { <block C> } <block D>

Post-decompilation Transformation






Not implemented Idea is to take certain recognizable blocks of code and refactor them into common expressions Examples:


 



(before Java 5)‫‏‬ Inner class private accessors Bridge code String concatenation
Object.class

Future work


Code is a horrible internal mess


Probably switch to building off of other open-source projects





  

Better type analysis and unification (especially generics)‫‏‬ Allow especially CFG recovery to be generified for other types of decompilation ??? Profit Send any and all questions to Pidgeot18+jbca@gmail.com


								
To top