SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
The dedexer disassembler
      Gabor Paller
 gaborpaller@gmail.com
       2009.10.22
Background
●   As we all know, Android is a Linux-Java
    platform.
    ●   The underlying operating system is a version of
        Linux
    ●   The application model exposed to the developer is
        Java-based
●   Android is not Java
    ●   Google does not use the Java logo in relation with
        Android
    ●   Android application model has no relationship with
        any Java standard (JSR)
Dalvik
●   At the core of Android, there is the proprietary
    Dalvik virtual machine executing Android
    programs.
●   Some interesting Dalvik properties
    ●   It lives in symbiosis with the Linux process/access
        right system to provide application separation
    ●   It has its own bytecode format which is in distant
        relationship with the Java bytecode format
Life of a Java application in Android
●   Java is just a front-end
    ●   Developer codes in Java
    ●   The source code is compiled by the Java compiler
        into .class files
    ●   Then the dx (dexer) tool which is part of the Android
        SDK processes the .class files into Dalvik's
        proprietary format
    ●   The result of a proprietary file format called DEX
        that contains Dalvik bytecode.
    ●   The format has no relationship with the Java
        bytecode
Why should you care?
●   Well, you shouldn't
    ●   You have to dig very deep to find discrepancies
        between the execution environment projected by
        Dalvik and JVM (classloading).
    ●   If you develop your own language (like Simple), you
        may compile directly to Dalvik bytecode. Even in
        this case there is an option of compiling to Java
        bytecode first and leave the Dalvik bytecode to dx.
●   Big exception: reverse engineering
Inside the APK
Disassembly options
●   For binary XML files, use a binary-to-textual
    XML converter like AXMLPrinter2
●   For the DEX file, use dedexer
    ●   Alternative products:
        –   Dexdump – comes with the Android SDK, less convenient
            to use than dedexer because e.g. it does not support
            labels, produces one large file, etc.
        –   Baksmali – a competing open-source DEX disassembler.
            Comes with a Dalvik bytecode assembler (smali)
●   In any case, you have to live with Dalvik
    bytecode disassembly – there's no way back to
    Java presently!
Using dedexer
●   Download ddx.jar from
    http://dedexer.sourceforge.net
●   Unpack the DEX file from the APK file.
●   Issue:
    java -jar ddx.jar -d target_dir source_dex_file
●   The decompiled files will be produced in
    target_dir with .ddx extension. We will learn,
    how to read those files.
Before
●   class PatternSet {
         Pattern[] patterns; /* whole
    pattern set */
         Pattern[] trainingpatterns; /*
    patterns to be used during training */
         Pattern[] crossvalpatterns; /*
    patterns to be used during cross
    validation */
    ...
After
●   .class PatternSet
    .super java/lang/Object
    .source PatternSet.java

    .field crossvaldeviations [D
    .field crossvalpatterns [Lpattern;
    .field patterns [LPattern;
Before
●   public PatternSet (String sourceFile,
    int noofinputs, int nooftargets, double
    ratiotraining, double ratiocrossval,
    double ratiotest, Randomizer randomizer)
    {
    ...
After
●   .method public
    <init>(Ljava/lang/String;IIDDDLRandomize
    r;)V
    .limit registers 23
    ; this: v12 (LpatternSet;)
    ; parameter[0] : v13
    (Ljava/lang/String;)
    ; parameter[1] : v14 (I)
    ; parameter[2] : v15 (I)
    ; parameter[3] : v16 (D)
    ; parameter[4] : v18 (D)
    ; parameter[5] : v20 (D)
    ; parameter[6] : v22 (LRandomizer;)
Before
LineReader linereader = new
LineReader(sourceFile);
int counter = 0;
double temp_double;
while (linereader.NextLineSplitted()){
...
After
●   new-instance    v1,LineReader
    ; v1 : LlineReader;
    invoke-direct   {v1,v13},LineReader/<init>
    ; <init>(Ljava/lang/String;)V
    ; v1 : LLineReader; , v13 : Ljava/lang/String;
    .line 27
    const/4 v2,0
    ; v2 : single-length
    l24aa:
    .line 29
    invoke-virtual
    {v1},LineReader/NextLineSplitted          ;
    NextLineSplitted()Z
    ; v1 : LlineReader;
    move-result     v3 ; v3 : single-length
    if-eqz v3,l24da ; v3 : single-length
Comments
●   Instruction set is available on the
    http://dedexer.sourceforge.net page.
●   This was generated with the brand new
    dedexer feature (-r switch) that tracks register
    usage. It is essentially a data flow analyser.
Conclusion
●   Reverse-engineering of DEX files is more
    tiresome than it could be.
●   Presently, knowledge of Dalvik bytecode is
    required.
●   Dedexer does less than it could when
    disassembling optimized DEX (ODEX) files.
●   This is the main direction of development
    currently.
●   I do not intend to do DEX-to-Java.

Contenu connexe

Tendances

NDK Primer (AnDevCon Boston 2014)
NDK Primer (AnDevCon Boston 2014)NDK Primer (AnDevCon Boston 2014)
NDK Primer (AnDevCon Boston 2014)Ron Munitz
 
L Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsL Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsJan Aerts
 
Java Course 2: Basics
Java Course 2: BasicsJava Course 2: Basics
Java Course 2: BasicsAnton Keks
 
Qt Framework Events Signals Threads
Qt Framework Events Signals ThreadsQt Framework Events Signals Threads
Qt Framework Events Signals ThreadsNeera Mital
 
Virtual Machines Lecture
Virtual Machines LectureVirtual Machines Lecture
Virtual Machines Lecturelienhard
 
Java Course 3: OOP
Java Course 3: OOPJava Course 3: OOP
Java Course 3: OOPAnton Keks
 
Java OOP Concepts 1st Slide
Java OOP Concepts 1st SlideJava OOP Concepts 1st Slide
Java OOP Concepts 1st Slidesunny khan
 
Hacking for fun and for profit
Hacking for fun and for profitHacking for fun and for profit
Hacking for fun and for profitdavtbaum
 
Java Programming Guide Quick Reference
Java Programming Guide Quick ReferenceJava Programming Guide Quick Reference
Java Programming Guide Quick ReferenceFrescatiStory
 
EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4Max Kleiner
 
Objective-c for Java Developers
Objective-c for Java DevelopersObjective-c for Java Developers
Objective-c for Java DevelopersMuhammad Abdullah
 

Tendances (17)

NDK Primer (AnDevCon Boston 2014)
NDK Primer (AnDevCon Boston 2014)NDK Primer (AnDevCon Boston 2014)
NDK Primer (AnDevCon Boston 2014)
 
Lecture1
Lecture1Lecture1
Lecture1
 
Introduction to VHDL
Introduction to VHDLIntroduction to VHDL
Introduction to VHDL
 
L Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsL Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformatics
 
Vhdl introduction
Vhdl introductionVhdl introduction
Vhdl introduction
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Java Course 2: Basics
Java Course 2: BasicsJava Course 2: Basics
Java Course 2: Basics
 
Qt Framework Events Signals Threads
Qt Framework Events Signals ThreadsQt Framework Events Signals Threads
Qt Framework Events Signals Threads
 
Virtual Machines Lecture
Virtual Machines LectureVirtual Machines Lecture
Virtual Machines Lecture
 
Java Course 3: OOP
Java Course 3: OOPJava Course 3: OOP
Java Course 3: OOP
 
Java OOP Concepts 1st Slide
Java OOP Concepts 1st SlideJava OOP Concepts 1st Slide
Java OOP Concepts 1st Slide
 
Hacking for fun and for profit
Hacking for fun and for profitHacking for fun and for profit
Hacking for fun and for profit
 
Java Programming Guide Quick Reference
Java Programming Guide Quick ReferenceJava Programming Guide Quick Reference
Java Programming Guide Quick Reference
 
Spdas2 vlsibput
Spdas2 vlsibputSpdas2 vlsibput
Spdas2 vlsibput
 
EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4
 
Objective-c for Java Developers
Objective-c for Java DevelopersObjective-c for Java Developers
Objective-c for Java Developers
 
Unit 2 Java
Unit 2 JavaUnit 2 Java
Unit 2 Java
 

En vedette

Introduction to computers
Introduction to computersIntroduction to computers
Introduction to computersVisualBee.com
 
Android reverse engineering: understanding third-party applications. OWASP EU...
Android reverse engineering: understanding third-party applications. OWASP EU...Android reverse engineering: understanding third-party applications. OWASP EU...
Android reverse engineering: understanding third-party applications. OWASP EU...Internet Security Auditors
 
Merkel wiper auas
Merkel wiper auasMerkel wiper auas
Merkel wiper auaswalleseals
 
Marriott management philosophy
Marriott management philosophyMarriott management philosophy
Marriott management philosophyFawad Akhtar
 
Emc cla rii on fibre channel storage fundamentals
Emc cla rii on fibre channel storage fundamentalsEmc cla rii on fibre channel storage fundamentals
Emc cla rii on fibre channel storage fundamentalsweiguang sun
 
Report abc company draft
Report abc company   draftReport abc company   draft
Report abc company draftAiiM Education
 
Does Your Stuff Scale?
Does Your Stuff Scale?Does Your Stuff Scale?
Does Your Stuff Scale?stevenh0lmes
 
Mh beethoven
Mh beethovenMh beethoven
Mh beethovenS Marley
 
Helping Journalists Get It Right
Helping Journalists Get It RightHelping Journalists Get It Right
Helping Journalists Get It RightRenita Coleman
 
02មហាគ្រោះជាតិខ្មែរ great danger-khmer-nation-official-khmerlanguage​​ by tie...
02មហាគ្រោះជាតិខ្មែរ great danger-khmer-nation-official-khmerlanguage​​ by tie...02មហាគ្រោះជាតិខ្មែរ great danger-khmer-nation-official-khmerlanguage​​ by tie...
02មហាគ្រោះជាតិខ្មែរ great danger-khmer-nation-official-khmerlanguage​​ by tie...Veha Thmey
 
China high speed railway lines network-201407
China high speed railway lines network-201407China high speed railway lines network-201407
China high speed railway lines network-201407tjrgx
 
Obo mne
Obo mneObo mne
Obo mnewindof
 
Propertics of element
Propertics  of elementPropertics  of element
Propertics of elementsatapisat
 

En vedette (18)

Introduction to computers
Introduction to computersIntroduction to computers
Introduction to computers
 
Android reverse engineering: understanding third-party applications. OWASP EU...
Android reverse engineering: understanding third-party applications. OWASP EU...Android reverse engineering: understanding third-party applications. OWASP EU...
Android reverse engineering: understanding third-party applications. OWASP EU...
 
1351 anglyskoe slovo_dlya_detey_i_vzroslykh
1351 anglyskoe slovo_dlya_detey_i_vzroslykh1351 anglyskoe slovo_dlya_detey_i_vzroslykh
1351 anglyskoe slovo_dlya_detey_i_vzroslykh
 
Merkel wiper auas
Merkel wiper auasMerkel wiper auas
Merkel wiper auas
 
HAKQ Profile
HAKQ ProfileHAKQ Profile
HAKQ Profile
 
Marriott management philosophy
Marriott management philosophyMarriott management philosophy
Marriott management philosophy
 
Emc cla rii on fibre channel storage fundamentals
Emc cla rii on fibre channel storage fundamentalsEmc cla rii on fibre channel storage fundamentals
Emc cla rii on fibre channel storage fundamentals
 
Solinea Lazuli Tower Project Brief
Solinea Lazuli Tower Project BriefSolinea Lazuli Tower Project Brief
Solinea Lazuli Tower Project Brief
 
Being Miss Geeky - WIT
Being Miss Geeky - WITBeing Miss Geeky - WIT
Being Miss Geeky - WIT
 
Effectivnoe upravlenie personalom
Effectivnoe upravlenie personalomEffectivnoe upravlenie personalom
Effectivnoe upravlenie personalom
 
Report abc company draft
Report abc company   draftReport abc company   draft
Report abc company draft
 
Does Your Stuff Scale?
Does Your Stuff Scale?Does Your Stuff Scale?
Does Your Stuff Scale?
 
Mh beethoven
Mh beethovenMh beethoven
Mh beethoven
 
Helping Journalists Get It Right
Helping Journalists Get It RightHelping Journalists Get It Right
Helping Journalists Get It Right
 
02មហាគ្រោះជាតិខ្មែរ great danger-khmer-nation-official-khmerlanguage​​ by tie...
02មហាគ្រោះជាតិខ្មែរ great danger-khmer-nation-official-khmerlanguage​​ by tie...02មហាគ្រោះជាតិខ្មែរ great danger-khmer-nation-official-khmerlanguage​​ by tie...
02មហាគ្រោះជាតិខ្មែរ great danger-khmer-nation-official-khmerlanguage​​ by tie...
 
China high speed railway lines network-201407
China high speed railway lines network-201407China high speed railway lines network-201407
China high speed railway lines network-201407
 
Obo mne
Obo mneObo mne
Obo mne
 
Propertics of element
Propertics  of elementPropertics  of element
Propertics of element
 

Similaire à The dedexer disassembler

Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tipsSamuel Chow
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'acorehard_by
 
Android ndk - Introduction
Android ndk  - IntroductionAndroid ndk  - Introduction
Android ndk - IntroductionRakesh Jha
 
OWF12/PAUG Conf Days Dart a new html5 technology, nicolas geoffray, softwar...
OWF12/PAUG Conf Days Dart   a new html5 technology, nicolas geoffray, softwar...OWF12/PAUG Conf Days Dart   a new html5 technology, nicolas geoffray, softwar...
OWF12/PAUG Conf Days Dart a new html5 technology, nicolas geoffray, softwar...Paris Open Source Summit
 
Best Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with DockerBest Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with DockerEric Smalling
 
NDK Programming in Android
NDK Programming in AndroidNDK Programming in Android
NDK Programming in AndroidArvind Devaraj
 
Ii 1300-java essentials for android
Ii 1300-java essentials for androidIi 1300-java essentials for android
Ii 1300-java essentials for androidAdrian Mikeliunas
 
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabRon Munitz
 
DSD-INT 2014 - Delft3D Open Source Workshop - Qinghua Ye & Adri Mourits, Delt...
DSD-INT 2014 - Delft3D Open Source Workshop - Qinghua Ye & Adri Mourits, Delt...DSD-INT 2014 - Delft3D Open Source Workshop - Qinghua Ye & Adri Mourits, Delt...
DSD-INT 2014 - Delft3D Open Source Workshop - Qinghua Ye & Adri Mourits, Delt...Deltares
 
CodeMotion tel aviv 2015 - android reverse engineering lab
CodeMotion tel aviv 2015 - android reverse engineering labCodeMotion tel aviv 2015 - android reverse engineering lab
CodeMotion tel aviv 2015 - android reverse engineering labRon Munitz
 
Curso de Desenvolvimento Mobile - Android - Stack
Curso de Desenvolvimento Mobile - Android - StackCurso de Desenvolvimento Mobile - Android - Stack
Curso de Desenvolvimento Mobile - Android - StackJackson F. de A. Mafra
 
為什麼Method數超過65535會build fail?
為什麼Method數超過65535會build fail?為什麼Method數超過65535會build fail?
為什麼Method數超過65535會build fail?Chih-Chung Lee
 
Docker for developers
Docker for developersDocker for developers
Docker for developersDrupalDay
 
Docker for developers
Docker for developersDocker for developers
Docker for developerssparkfabrik
 
Docker up and Running For Web Developers
Docker up and Running For Web DevelopersDocker up and Running For Web Developers
Docker up and Running For Web DevelopersBADR
 

Similaire à The dedexer disassembler (20)

Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
 
Android ndk
Android ndkAndroid ndk
Android ndk
 
Android NDK
Android NDKAndroid NDK
Android NDK
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
 
Getting Native with NDK
Getting Native with NDKGetting Native with NDK
Getting Native with NDK
 
Android ndk - Introduction
Android ndk  - IntroductionAndroid ndk  - Introduction
Android ndk - Introduction
 
OWF12/PAUG Conf Days Dart a new html5 technology, nicolas geoffray, softwar...
OWF12/PAUG Conf Days Dart   a new html5 technology, nicolas geoffray, softwar...OWF12/PAUG Conf Days Dart   a new html5 technology, nicolas geoffray, softwar...
OWF12/PAUG Conf Days Dart a new html5 technology, nicolas geoffray, softwar...
 
Best Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with DockerBest Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with Docker
 
NDK Programming in Android
NDK Programming in AndroidNDK Programming in Android
NDK Programming in Android
 
Ii 1300-java essentials for android
Ii 1300-java essentials for androidIi 1300-java essentials for android
Ii 1300-java essentials for android
 
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
DSD-INT 2014 - Delft3D Open Source Workshop - Qinghua Ye & Adri Mourits, Delt...
DSD-INT 2014 - Delft3D Open Source Workshop - Qinghua Ye & Adri Mourits, Delt...DSD-INT 2014 - Delft3D Open Source Workshop - Qinghua Ye & Adri Mourits, Delt...
DSD-INT 2014 - Delft3D Open Source Workshop - Qinghua Ye & Adri Mourits, Delt...
 
CodeMotion tel aviv 2015 - android reverse engineering lab
CodeMotion tel aviv 2015 - android reverse engineering labCodeMotion tel aviv 2015 - android reverse engineering lab
CodeMotion tel aviv 2015 - android reverse engineering lab
 
Dart Jump Start
Dart Jump StartDart Jump Start
Dart Jump Start
 
Curso de Desenvolvimento Mobile - Android - Stack
Curso de Desenvolvimento Mobile - Android - StackCurso de Desenvolvimento Mobile - Android - Stack
Curso de Desenvolvimento Mobile - Android - Stack
 
為什麼Method數超過65535會build fail?
為什麼Method數超過65535會build fail?為什麼Method數超過65535會build fail?
為什麼Method數超過65535會build fail?
 
Docker for developers
Docker for developersDocker for developers
Docker for developers
 
Docker for developers
Docker for developersDocker for developers
Docker for developers
 
Docker up and Running For Web Developers
Docker up and Running For Web DevelopersDocker up and Running For Web Developers
Docker up and Running For Web Developers
 

Plus de Gabor Paller

Towards a floating plastic waste early warning system
Towards a floating plastic waste early warning systemTowards a floating plastic waste early warning system
Towards a floating plastic waste early warning systemGabor Paller
 
Dataflow-based heterogeneous code generator for IoT applications
Dataflow-based heterogeneous code generator for IoT applicationsDataflow-based heterogeneous code generator for IoT applications
Dataflow-based heterogeneous code generator for IoT applicationsGabor Paller
 
Sigfox szenzorfejlesztéssel kapcsolatos tapasztalatok
Sigfox szenzorfejlesztéssel kapcsolatos tapasztalatokSigfox szenzorfejlesztéssel kapcsolatos tapasztalatok
Sigfox szenzorfejlesztéssel kapcsolatos tapasztalatokGabor Paller
 
Energy-efficient operation of GSM-connected infrared rodent sensors
Energy-efficient operation of GSM-connected infrared rodent sensorsEnergy-efficient operation of GSM-connected infrared rodent sensors
Energy-efficient operation of GSM-connected infrared rodent sensorsGabor Paller
 
AgroDat poster at Sensornets 2015 conference
AgroDat poster at Sensornets 2015 conferenceAgroDat poster at Sensornets 2015 conference
AgroDat poster at Sensornets 2015 conferenceGabor Paller
 
Connect your Android to the real world with Bluetooth Low Energy
Connect your Android to the real world with Bluetooth Low EnergyConnect your Android to the real world with Bluetooth Low Energy
Connect your Android to the real world with Bluetooth Low EnergyGabor Paller
 
Sensor fusion between car and smartphone
Sensor fusion between car and smartphoneSensor fusion between car and smartphone
Sensor fusion between car and smartphoneGabor Paller
 
Advantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processingAdvantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processingGabor Paller
 
Better motion control using accelerometer/gyroscope sensor fusion
Better motion control using accelerometer/gyroscope sensor fusionBetter motion control using accelerometer/gyroscope sensor fusion
Better motion control using accelerometer/gyroscope sensor fusionGabor Paller
 
Motion recognition with Android devices
Motion recognition with Android devicesMotion recognition with Android devices
Motion recognition with Android devicesGabor Paller
 
LiveFolders as feeds
LiveFolders as feedsLiveFolders as feeds
LiveFolders as feedsGabor Paller
 

Plus de Gabor Paller (11)

Towards a floating plastic waste early warning system
Towards a floating plastic waste early warning systemTowards a floating plastic waste early warning system
Towards a floating plastic waste early warning system
 
Dataflow-based heterogeneous code generator for IoT applications
Dataflow-based heterogeneous code generator for IoT applicationsDataflow-based heterogeneous code generator for IoT applications
Dataflow-based heterogeneous code generator for IoT applications
 
Sigfox szenzorfejlesztéssel kapcsolatos tapasztalatok
Sigfox szenzorfejlesztéssel kapcsolatos tapasztalatokSigfox szenzorfejlesztéssel kapcsolatos tapasztalatok
Sigfox szenzorfejlesztéssel kapcsolatos tapasztalatok
 
Energy-efficient operation of GSM-connected infrared rodent sensors
Energy-efficient operation of GSM-connected infrared rodent sensorsEnergy-efficient operation of GSM-connected infrared rodent sensors
Energy-efficient operation of GSM-connected infrared rodent sensors
 
AgroDat poster at Sensornets 2015 conference
AgroDat poster at Sensornets 2015 conferenceAgroDat poster at Sensornets 2015 conference
AgroDat poster at Sensornets 2015 conference
 
Connect your Android to the real world with Bluetooth Low Energy
Connect your Android to the real world with Bluetooth Low EnergyConnect your Android to the real world with Bluetooth Low Energy
Connect your Android to the real world with Bluetooth Low Energy
 
Sensor fusion between car and smartphone
Sensor fusion between car and smartphoneSensor fusion between car and smartphone
Sensor fusion between car and smartphone
 
Advantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processingAdvantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processing
 
Better motion control using accelerometer/gyroscope sensor fusion
Better motion control using accelerometer/gyroscope sensor fusionBetter motion control using accelerometer/gyroscope sensor fusion
Better motion control using accelerometer/gyroscope sensor fusion
 
Motion recognition with Android devices
Motion recognition with Android devicesMotion recognition with Android devices
Motion recognition with Android devices
 
LiveFolders as feeds
LiveFolders as feedsLiveFolders as feeds
LiveFolders as feeds
 

The dedexer disassembler

  • 1. The dedexer disassembler Gabor Paller gaborpaller@gmail.com 2009.10.22
  • 2. Background ● As we all know, Android is a Linux-Java platform. ● The underlying operating system is a version of Linux ● The application model exposed to the developer is Java-based ● Android is not Java ● Google does not use the Java logo in relation with Android ● Android application model has no relationship with any Java standard (JSR)
  • 3. Dalvik ● At the core of Android, there is the proprietary Dalvik virtual machine executing Android programs. ● Some interesting Dalvik properties ● It lives in symbiosis with the Linux process/access right system to provide application separation ● It has its own bytecode format which is in distant relationship with the Java bytecode format
  • 4. Life of a Java application in Android ● Java is just a front-end ● Developer codes in Java ● The source code is compiled by the Java compiler into .class files ● Then the dx (dexer) tool which is part of the Android SDK processes the .class files into Dalvik's proprietary format ● The result of a proprietary file format called DEX that contains Dalvik bytecode. ● The format has no relationship with the Java bytecode
  • 5. Why should you care? ● Well, you shouldn't ● You have to dig very deep to find discrepancies between the execution environment projected by Dalvik and JVM (classloading). ● If you develop your own language (like Simple), you may compile directly to Dalvik bytecode. Even in this case there is an option of compiling to Java bytecode first and leave the Dalvik bytecode to dx. ● Big exception: reverse engineering
  • 7. Disassembly options ● For binary XML files, use a binary-to-textual XML converter like AXMLPrinter2 ● For the DEX file, use dedexer ● Alternative products: – Dexdump – comes with the Android SDK, less convenient to use than dedexer because e.g. it does not support labels, produces one large file, etc. – Baksmali – a competing open-source DEX disassembler. Comes with a Dalvik bytecode assembler (smali) ● In any case, you have to live with Dalvik bytecode disassembly – there's no way back to Java presently!
  • 8. Using dedexer ● Download ddx.jar from http://dedexer.sourceforge.net ● Unpack the DEX file from the APK file. ● Issue: java -jar ddx.jar -d target_dir source_dex_file ● The decompiled files will be produced in target_dir with .ddx extension. We will learn, how to read those files.
  • 9. Before ● class PatternSet { Pattern[] patterns; /* whole pattern set */ Pattern[] trainingpatterns; /* patterns to be used during training */ Pattern[] crossvalpatterns; /* patterns to be used during cross validation */ ...
  • 10. After ● .class PatternSet .super java/lang/Object .source PatternSet.java .field crossvaldeviations [D .field crossvalpatterns [Lpattern; .field patterns [LPattern;
  • 11. Before ● public PatternSet (String sourceFile, int noofinputs, int nooftargets, double ratiotraining, double ratiocrossval, double ratiotest, Randomizer randomizer) { ...
  • 12. After ● .method public <init>(Ljava/lang/String;IIDDDLRandomize r;)V .limit registers 23 ; this: v12 (LpatternSet;) ; parameter[0] : v13 (Ljava/lang/String;) ; parameter[1] : v14 (I) ; parameter[2] : v15 (I) ; parameter[3] : v16 (D) ; parameter[4] : v18 (D) ; parameter[5] : v20 (D) ; parameter[6] : v22 (LRandomizer;)
  • 13. Before LineReader linereader = new LineReader(sourceFile); int counter = 0; double temp_double; while (linereader.NextLineSplitted()){ ...
  • 14. After ● new-instance v1,LineReader ; v1 : LlineReader; invoke-direct {v1,v13},LineReader/<init> ; <init>(Ljava/lang/String;)V ; v1 : LLineReader; , v13 : Ljava/lang/String; .line 27 const/4 v2,0 ; v2 : single-length l24aa: .line 29 invoke-virtual {v1},LineReader/NextLineSplitted ; NextLineSplitted()Z ; v1 : LlineReader; move-result v3 ; v3 : single-length if-eqz v3,l24da ; v3 : single-length
  • 15. Comments ● Instruction set is available on the http://dedexer.sourceforge.net page. ● This was generated with the brand new dedexer feature (-r switch) that tracks register usage. It is essentially a data flow analyser.
  • 16. Conclusion ● Reverse-engineering of DEX files is more tiresome than it could be. ● Presently, knowledge of Dalvik bytecode is required. ● Dedexer does less than it could when disassembling optimized DEX (ODEX) files. ● This is the main direction of development currently. ● I do not intend to do DEX-to-Java.