Decode jar to java

Decompile APK Get Java + Xml Change Apps

Ever felt to change the look and feel of an app or did you accidentally delete your source code. See how to decompile apk to get the source code and how to customize any android app.

This guide is divided into two parts:-

  1. We will see how to decompile apk and extract the source code.
  2. Step by step how to make, look and feel changes to an Android app.

Disclaimer

This guide is purely for educational purpose. We encourage the users to go through the legality before using this guide on any real world application.

Use Case

  • Recover accidentally deleted source code from the apk file
  • Analysis of security vulnerability and threat detection
  • Modding apps
    • Add a new feature
    • Customize the look and feel
    • Support for non-supported android version

    Limitation

    • Cannot extract the exact same source code as originally written.
    • Some part of the code might not be correctly retrieved.
    • If the app uses a custom framework you will need the custom framework apk file.
    • Most apps do not use custom frameworks.

    Requirement

    • Windows System
    • Java Runtime Environment (JRE) 1.7
      • http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jre-7u80-oth-JPR
      • https://bitbucket.org/iBotPeaches/apktool/downloads
      • https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/windows/apktool.bat
      • https://github.com/pxb1988/dex2jar/releases/
      • https://github.com/java-decompiler/jd-gui/releases/
      • https://github.com/deathmarine/Luyten/releases
      • https://play.google.com/store/apps/details?id=kellinwood.zipsigner2&hl=en

      Concepts & Overview

      • Apk file is a zip file.
      • Zip file consists of XML and other android application resources.
      • Apktools decodes the resource files and converts the android bytecode into assembly level samli files.
      • Dex2jar converts the dex files into java bytecode file archived inside the jar file.
      • JD GUI and Luyten decompiles java byte code to java source code file.

      Software Downloads & Installations

      Create Install Directory
      Download and Install Apktools
      1. Download the latest version of Apktools jar file from the website given above.
      2. Copy apktool_x.y.z.jar into the newly created directory
      3. Rename apktool_x.y.z.jar to apktool.jar
      4. Right click and click on “save link as” on apktool.bat link
      5. Copy apktool.bat file in the same directory
      Download and Install Luyten
      1. Go to Luyten website and download the latest release of luyten-x.y.z.exe
      2. Copy luyten-x.y.z.exe file in the same directory
      Download and Install JD-GUI
      1. Go to JD-GUI website download the latest version of jd-gui-windows-x.y.z.zip
      2. Extract jd-gui-windows-x.y.z.zip file in the same directory
      Download and Install Dex2jar
      1. Go to Dex2jar website download the latest stable release of dex-tools-y.x.zip
      2. Extract dex-tools-y.x.zip file in the same directory
      3. Rename d2j-dex2jar.bat to d2j
      Download and Install JRE 1.7
      1. Download and install JRE 1.7 from the above link.
      2. In command prompt type Java – version this should show 1.7.
      3. Might show a higher version if your system has a newer version should still be fine.
      Install Zip Signer App
      Set the Path Environment Variable
      1. Open System Property
      2. In Windows 7
        1. Click on the start button.
        2. Right-click on Computer and select properties.
        1. Right-click on the start button.
        2. Select system properties.
        Test Installed Software
        1. Open a new command prompt
          1. Click on start
          2. Type in cmd
          3. Then select cmd.exe
          1. Should print out 2.2

          #1: Get Source Code form APK JAVA + XML

          Download APK from Play Store
          Decode APK Using Apktool

          The second step is to use apk tools to decode the apk and extract Dex files and the resource files.

          1. Open command prompt
          2. Type cd “type here the location of the apk file” and press enter
            • If the location is on a different drive then type the drive letter and then press enter.
          3. For apk with custom framework, install it by typing the command apktool if xyz.apk and hit enter (Optional)
            • Replace xyz.apk with the name of your framework apk
          4. To decode your app apk file type in apktool d –m app.apk and hit enter
            • Replace app.apk with the name of your application apk

          The m option stands for match. This is usually done when you require the exact same resource files, but this prevents rebuilding the apk once you have modified it.

          After decoding finishes find the decoded application resources in the same directory in a subfolder named after the application name.

          Convert Dex to Jar using dex2jar
          1. Open command prompt
          2. Type d2j app.apk and hit enter
            • Replace app.apk with the name of your application apk

          Find the converted jar file in the same folder

          Decompile Jar to Java Source Code

          We will be using two applications to convert the jar file into Java code. We will be doing this because the conversion of android Dex code to a Java Jar file is not perfect and certain information is lost. This might lead to improper Java code from the jar file.

          Using two applications provides alternate code for a particular file which was not decoded properly. So if for a particular file the code generated by the first application is not correct. Then we can check the code generated by the second application.

          Decompile Jar to Java Source Code using JD-GUI
          1. Go to the installation directory and open jd-gui.exe.
          2. Select open a file go to the directory the jar file is present.
          3. Select the jar file and click open.
          4. Click on the file and click on Save All Sources.
          5. Select the directory where you want to save.
          Decompile Jar to Java Source Code using Luyten
          1. Go to the installation directory and click on lyuten.exe
          2. Click on file and then click on Open File
          3. Select the directory where the jar file is saved and select the jar file
          4. Click on File and then click on Save All
          5. Select the location for saving the Java code

          #2: Modify Apps Using APK Tool

           Pokemon GO Modded Splash Screen

          Decode Pokemon GO APK Using Apktool

          We will decode the apk file without using the m option. Since we now require to rebuild the application after modifying the required files.

          1. Open command prompt.
          2. Type cd “type here the location of the PokemonGo apk file” and press enter.
            • If the location is on a different drive then type the drive letter and then press enter.
          3. To decode your app apk file type in apktool d PokemonGo.apk and hit enter
            • Make sure to delete any previously decoded application in that folder.
          Modify Pokemon GO Splash Screen
          1. Open the decoded PokemonGo apk folder.
          2. Click on the assets directory.
          3. Go to bin, then go to data.
          4. Search for the splash.png file in this directory.
          5. Open it using any image editor.
          6. Modify it in any manner I will overlap a cute Pikachu image over it.
          7. Save this modified splash screen by overwriting it on the original image.
          Rebuild Pokemon Go Apk Using APkTool
          1. Open command prompt
          2. Type cd “type here the location of the PokemonGo apk file” and press enter.
            • If the location is on a different drive then type the drive letter and then press enter.
          3. Type apktool b PokemonGo
          Transfer Apk Using EZ File Explorer
          1. Open the EZ File Explorer app.
          2. Open the menu by tapping on the three lines icon on the top left corner.
          3. Tap on Network then on Remote Manager.
          4. Turn On FTP Server by tapping it.
          5. Open the phone storage by opening the file explorer and type the address shown in the EZ File Explorer app.
          6. Go to the directory with PokemonGo Apk File.
          7. Open PokemonGo directory and open dist folder.
          8. Copy the apk file in the dist folder.
          9. Paste it the phone storage.
          Sign Apk Using Zip Signer App
          1. Open the zip signer app, tap on Input
          2. Select the apk file that you just copied to your phone
          3. Tap on sign the file
          Install and Test Modified App
          1. Open the phone directory where you saved the apk file using EZ File Explorer
          2. Tap on the pokemongo-signed.apk it will install as an update to the app
          3. Tap install
          4. Open the Pokemon Go app you should see the modified splash screen.

          I hope this guide helped you. If yes, consider supporting us. If you are facing some problem following this guide share it below in the comment section. We will try our best to resolve it. You can help others by sharing this guide with your friends whom you think could benefit from it.

          Have some questions join the discussion.

          Neil Mahaseth

          Hello, friends welcome to HowISolve.com, a community founded by me in June 2015. With the aim to help you solve your everyday tech problems. The motivation for starting this community was instilled from my love for technology and my nature to help others in need.

          By qualification, I am a technocrat with an M.B.A. and B.Tech. from Narsee Monjee, Mumbai. I have experienced both worlds: corporate and startup. I am currently honing my entrepreneurial skills and trying to add value to people’s lives.

          You can also join us by subscribing to our Newsletters & YouTube channel to be a part of this growing community.

          Источник

          .JAR and .Class to Java decompiler

          Until recently, you needed to use a Java decompiler and all of them were either unstable, obsolete, unfinished, or in the best case all of the above. And, if not, then they were commercial. The obsoleteness was typically proved by the fact that they can only decompile JDK 1.3 bytecode.
          The only so-so working solution was to take the .class file and pre-process it, so it becomes JDK 1.3 compatible, and then run Jad over it (one of those older, but better decompilers).

          But recently, a new wave of decompilers has forayed onto the market: Procyon, CFR, JD, Fernflower, Krakatau, Candle.
          Here’s a list of decompilers presented on this site:

          CFR

          This free and open-source decompiler is available here: http://www.benf.org/other/cfr/
          Author: Lee Benfield

          • Java 7: String switches
          • Java 8: lambdas
          • Java 9: modules
          • Java 11: dynamic constants
          • Java 12: Kotlin style «switch expressions»
          • Java 14: ‘instance of’ pattern match and ‘Record types’
          JD

          free for non-commercial use only, http://jd.benow.ca/
          Author: Emmanuel Dupuy

          Updated in 2015. Has its own visual interface and plugins to Eclipse and IntelliJ . Written in C++, so very fast. Supports Java 5.

          Procyon
          • Enum declarations
          • Enum and String switch statements
          • Local classes (both anonymous and named)
          • Annotations
          • Java 8 Lambdas and method references (i.e., the :: operator).
          Fernflower

          Updated in 2015. Very promising analytical Java decompiler, now becomes an integral part of IntelliJ 14. (https://github.com/JetBrains/intellij-community/tree/master/plugins/java-decompiler)
          Supports Java up to version 6 (Annotations, generics, enums)

          JAD

          given here only for historical reason. Free, no source-code available, jad download mirror
          Author: Pavel Kouznetsov

          Probably, this is the most popular Java decompiler, but primarily of this age only. Written in C++, so very fast.
          Outdated, unsupported and does not decompile correctly Java 5 and later.

          Источник

          Java-Espresso

          Through this blog, I share my experiences, Problems that me and my team faced and how we resolved them. Apart from that Technical tips, tricks, Java Basics and also questions that are asked in interviews related to Java.
          Now blog can be accessed from a direct URL www.java-espresso.in

          Monday, February 20, 2012

          JAR to JAVA converter

          I went through many websites,but i did not find any converter for jar file to .java files at one go.
          So, I thought of writing a script for this conversion. This script also keeps the package structure same as in the jar file

          • This is restricted to windows platform
          • Unzip utility should be installed in the system
          • jad decompiler should be installed.
            If you don’t have jad installed, you can find from the following link
            click here to download
          • Unzip the jad.zip downlaoded in step2,set the jad.exe in the systems path variable.
          • Run the command prompt in the administrator mode
          • cd «path to which batch file is placed«
          • jar2java.bat «jar file name/jar file path with jar file name» Note: Give jar file name without extension

          Note:Remove the extention .txt to make it .bat file.

          Example:
          Step 1) >cd D:\jartojava (Copy the above downloaded batch file in this folder)
          Step 2) jartojava> jar2java.bat abc (copy abc.jar in this folder)
          Here a folder named abc is created with all the java files found in abc.jar.

          2 comments:

          You can use this tool:
          http://www.neshkov.com/ac_decompiler.html
          AndroChef successfully decompiles obfuscated Java 6 and Java 7 .class and .jar files. It is simple but powerful tool that allows you to decompile Java and Dalvik bytecode (DEX, APK) into readable Java source. Reply Delete

          I have read your blog its very attractive and impressive. I like it your blog.

          Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 8 online training JavaEE Training in Chennai Java EE Training in Chennai Reply Delete

          Источник

          Читайте также:  Редактор кода html от google
Оцените статью