Saturday 22 February 2014

Java .jar and .class De-compilation and recompilation


Java .jar and .class de-compilation and recompilation

if you are familiar with java it is too good but hover you must be have to know that how to write program in java.Java is an advanced language it is mostly used in network based application and for cross platform development the java application execution architecture is as follow




Java code which are saved in .java file are compiled to .class file which basically execute on the JVM for distribution the .class files are packaged in .jar archives which also execute on the JVM so now as our binaries must be .class or .jar files so we have to work on those to reverse it the .class file have the name as that of .java and when the .class file is brought to JVM it frist start to execute main() function if it exists(in libraries there are no main() function) So our starting file in java files must be that one which have main.Now we know that .class is byte code executable on JVM files so we are going here to de-compile it to the .java so we can also use the .jar to be de-compiled the same way de-compilation process is below in simple steps

De-compilation of .Jar or .Class files

Ø First of all go to to the site http://java.decompiler.free.fr and download “Java Decompiler
Ø if it does’t exists search in google “Java Decompiler” or Jd-Gui and download it
Ø It is a single stand alone Gui application just double click and open it
Ø An Application will pop up like below one





Ø This is Java Decompiler window
Ø Go to File menu and click on open
Ø Select your .jar or .class file and click on open
Ø And you will see the code as below in Java Decompiler



Ø Go to file and Click on Save all sources if you have opened a .Jar package
Ø The next step is to give name and it would be saved as named given a zip archive


Ø Save it
Ø Now you have successfully de-compiled the byte code
Ø It is now time to make changes in the code according to your needs
Ø Do it and save the .java file
Ø If your file contains too much class and codes you have to use extra tools to get to your required position
Ø Make the changes you want and save file

Recompilation of .java files

The java files compile easily with the java jdk(Java Development Kit) use it and compile your changed .java files. The process is easy but making the required change take a lot of time so you have to do it be patiently. Firstly you have to understand the code many tools can help you in the process there are a lot of free and paid tools those tool also recover the architecture and also to recover the class diagram this is the easiest type of Reverse Engineering you will find a lot of fun as we go further and further read on you can do it and you will learn a lot
Ø Keep in mind java program always start from main(String[] arg) function

Reverse Engineering Intro

Software reverse engineering is the process of recovering a software code from its binary and making changes in it.the software companies like Microsoft,Adobe etc are trying to protect there software's against the Copying or illegal distribution.They provide the online activation process.The protection of there software are there legal right but still people are trying to remove these constraint and redistribute or copy it. The process is done by reverse engineering.
This is illegal but upon they are good we know a lot of country in the world are said 3rd world countries the people of those countries are poor and have right to use those new things in the world, which exists so they use reverse engineering process and get a way to use it.
The Reverse engineering of software involves the study of software, which should be reversed there are some steps in reversing which are bellow.

I. Study of Software
II. Get information from Software
III. De-compiling the Software if possible
IV. Disassembling the Software
V. Making changes in the de-compiled/disassemble code
VI. Recompiling the changed code
VII. Executing and testing

If you are going to crack a platform based full compiled or instruction based binary the you have to knowledge of assembly language.if your binary is a VM(virtual Machine) based then it is easy you can just De-compile and you will see all the original code of the binary.like if it is Java .class or .jar then you will get the .java files We will discuss all of the type using the following sequence.

1. Java .jar and .class de-compilation and recompilation.
2. C# and VB assemblies(.exe and .dll) de-compilation and recompilation.
3. Android .apk de-compilation and recompilation.
4. Flash .swf files de-compilation and recompilation.
5. .Net based assemblies(.exe and .dll) disassembling and Assembling.
6. C++ generic files disassembling and Assembling.
7. Delphi files disassembling and Assembling.

By following the above sequence at the end you will be at the pretty sure to say your self a Software reverse engineering the first type would be an easy and going through toward the harder way here we will use a lot of open source softwares to do the above job you dont have a need to buy a Paid tool but paid are also available try them by your self