View Full Version : JAVA REVERSE ENGINEERING: Decompiling and Recompiling Jar Files
engart 9th October 2007, 02:17 TOOLS USED:
1. DJ Java Decompiler- Program which decompiles jar or class files to source code in text format *.java. More info at site:
[Only registered and activated users can see links]
2. JADMaker- Makes .jad file from .jar files
[Only registered and activated users can see links]
3. Java SDK- Platform to develop Java Applications.
[Only registered and activated users can see links]
4. Sony Ericsson SDK 2.5.0 for the Java(TM) ME Platform (127 MB)- To recompile source codes to a jar file include an emulator.
[Only registered and activated users can see links]
You can see the files in a jar file with winrar. There are image files, manifest file class files etc. I f you want change the jar file read carefully.
1. Step:
With JADMaker make a .jad file from .jar file. Drag and drop the jar file over the JADMaker icon.
2. Step:
From Java ME SDK menu open WTK2>KToolbar. You can use different SDK'S or more professional tools like eclipse or Netbeans IDE's.
From KToolbar File menu select Create Project from JAD/JAR File and select the .jad file created at first step.
Now we have created the folders. Where?
Inside C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps Folder.
We can make without creating a project this work, too.
3. Step:
Open with 1. tool java decompiler the .jar file. Archiver shows all the files within jar archive file. Select all with mouse and click Decompile button. Select Folder to save the files. The file structure must be the same as in jar file. Answer the question asked yes. Now inside the folder there are some class files and some jad files. Don't change the folder structure. .jad dosyaları files are source codes of class files. Change the .jad extensions to .java. You can delete class files. Now copy this folder inside the apps folder mentioned at 2nd step.
Now our project is ready. But icons and other files missing. Include them with opening the jar file with winrar. The folder structure must be the same.
4. Step:
We have source codes. So we can make changes. Some codes won't be decompiled. You can see some strange codes, but it is easy to guess the right code. Select Build from KToolbar menu. If we have made mistakes, the compiling will be aborted and errors will be shon under.
If compiling succeeded, when we select Run command, the application will be opened in emulator. Some applications wont run in the emulator or on phone.
5. Step
Now it's time to make jar file. From KTollbar Project menu select Create Package.
Inside the C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps folder of our project jar and jar files are ready inside the bin folder. You van use them now.
If you use a program, buy the program. This tutorial is written to show the weakness of jar files and to help the programmers.
NOT: This document is published in english only at this site for you. It isn't a translation from other sites.
Aliera 11th October 2007, 18:48 I'd like to add a few things I've learned as well.
If your decompilings won't recompile because of deferencing problems due to extreme overloading of the classes, you might try deobfuscating them with an obfuscator like Proguard but instead disable all obtimizations and under obfucation use a custom word file. I use a Arthurian names file for rpg's, somewhat fitting.
If you see a lot of goto and labels it was probably obfuscated with Klassmaster. They can be a pain to figure out but another decompiler Daja can decompile them. Bad thing about it is that it is a pain to install and produces code, while compilable, is extremely hard to follow.
Lastly, there is a utility called JDO for Java DeObfuscator. It's only really useful for jar that only have 2-3 classes for the game, otherwise it's useless.
engart 11th October 2007, 22:19 Could you give please links to the programs you mentioned? (Especially Daja) I couldn't find these programs. After decompiling with DJ Decompiler some strange codes occur sometimes. Especially by loops, break or exceptions.
cburnwal 12th October 2007, 07:43 good software, i wil try that, but can i increase the resolution with the help of jad generator. please, i have sony ericssion w830i.
Aliera 12th October 2007, 17:30 Sorry for not posting these in the 1st place.
Dava Decompiler (Part of the Soot Java Optimization Framework)
[Only registered and activated users can see links]
Whitepaper on decompilers explaining Dava:
[Only registered and activated users can see links]
JDO (Java DeObfuscator):
[Only registered and activated users can see links]
BTW, do you know of any place that posts decompiled sources? Perhaps the Administrator here might allow this. Instead of just the games, the sources that make the games.
Word list for deobfuscating with an obfuscator (like Proguard):
engart 12th October 2007, 22:35 Aliera we know that you know a lot about Decompiling. But please write an understandible tutorial about how to install these tools, how to setup correctly and how to decompile step by step. I can't understand the instructions on those sites, because they are difficult to understand for newbees. Thanks in advance for ypur kindly contributions. I wish our administrators allow to a new section about decompiling tutorials.
James-SK 13th October 2007, 02:22 It's only really useful for jar that only have 2-3 classes for the game, otherwise it's useless.
Why only for 2-3?
BTW, do you know of any place that posts decompiled sources? Perhaps the Administrator here might allow this. Instead of just the games, the sources that make the games.
Maybe it is not good idea, you think game developers would remain inactive? :sniper:
@engart: Reverse engineering isn't for everyone... Step-by-step tutorials for people who don't know anything about programming, Java bytecode, binary files, etc...?
Those talented and interested will find their own ways, they just need to know some hints (just like in the first post) when they begin..
Aliera 13th October 2007, 21:50 Oh JDO... The program gives unique names to all methods completely eliminating overloading which causes the reference and ambiguity errors when compiling. That is great but if the program references something outside it's class it still uses the original name. With just a few classes it's still easy to figure out but with a lot, no way.
As for Dava, I did say it was a pain to setup. I still haven't got it completely working. I wish it wasn't to closely intertwined with the Soot framework.
engart 13th October 2007, 23:50 I found an eclipse plugin for Soot Framework and installed. But couldn't decompile a class file with it. I think there is not a tool, which enables you direct decompile a java application, which is recompilable. You must make some changes to obfuscated class file source codes.
[Only registered and activated users can see links]
wiel 14th October 2007, 04:17 so...can we translate java games now with this stuff?
qwerty111 14th October 2007, 11:19 You would be able to. But there is a better program to do that, which edits the class directly and designed for translating. Seeing as most of your posts are copied from SE-NSE, you should be able to find it.
engart 14th October 2007, 19:04 No. The first post isn't frmSE-NSE. I haven't read anything from SE-NSE.
@James-SK: If anyone who doesn't know anything about Java can write this tutorial, I can2t imagine what the Java knowers make. Btw I have found a book about this subject after this tutorial. The book says the same things as the tutorial:
[Only registered and activated users can see links]
[Only registered and activated users can see links]
Note: Classcracker is a decompiler, too. It decompiles the try catch blocks better then DJ Decompiler and it is in jar format.
[Only registered and activated users can see links]
qwerty111 14th October 2007, 19:14 [quote=engart;1574464]No. The first post isn't frmSE-NSE. I haven't read anything from SE-NSE.
I was talking to wiel. I know you made this tutorial and I am thankful so I repped you and Aliera ([Only registered and activated users can see links]) for your contribution :)
engart 14th October 2007, 20:23 If you could write the link of the class file editor, we would do better things. For about one years ago I had asked at a forum about decompiling but couldn't get an answer. After long searching I could be able to write tis tutorial. Thanks for all contributions.
Here is a deobfuscator but not tested. Maybe helpful.
qwerty111 14th October 2007, 20:38 Here,
Latest Version. Had to sign up to some Chinese site for the update :D:
[Only registered and activated users can see links]
BTW: Any chance you could post Classcracker
wiel 14th October 2007, 22:44 every post here is copied from another site and that app is useless when it comes to translating java games not apps
qwerty111 15th October 2007, 10:17 every post here is copied from another site and that app is useless when it comes to translating java games not apps
True, can't argue with that.
It isn't actually, it depends on where the java game stores the strings. So I would have to say that it isn't useless. I think for those games, a hex editor may work.
qwerty111 18th October 2007, 20:01 Could anybody help me compiling this?
It's been de obfuscated and the codes have been decompiled. Here is my build log.
Project "stmblues" loaded
Project settings saved
Building "stmblues"
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\ah.java:81: ';' expected
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\ah.java:81: not a statement
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\ah.java:104: illegal start of expression
goto _L1
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\ah.java:104: not a statement
goto _L1
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\ah.java:104: ';' expected
goto _L1
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\ah.java:106: ';' expected
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\ah.java:106: not a statement
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\am.java:19: ';' expected
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\am.java:19: not a statement
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\am.java:54: not a statement
exception;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\am.java:84: not a statement
exception;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\at.java:182: illegal start of expression
goto _L1
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\at.java:183: ';' expected
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\i.java:109: ';' expected
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\i.java:109: not a statement
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\i.java:120: ';' expected
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\i.java:120: not a statement
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\i.java:137: ';' expected
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\i.java:137: not a statement
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\info\tinyapps\stm\app\STMBlueS.j ava:7: '.' expected
import ad;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\info\tinyapps\stm\app\STMBlueS.j ava:8: '.' expected
import ah;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\info\tinyapps\stm\app\STMBlueS.j ava:9: '.' expected
import ai;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\info\tinyapps\stm\app\STMBlueS.j ava:10: '.' expected
import am;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\info\tinyapps\stm\app\STMBlueS.j ava:11: '.' expected
import aq;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\info\tinyapps\stm\app\STMBlueS.j ava:12: '.' expected
import d;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\info\tinyapps\stm\app\STMBlueS.j ava:13: '.' expected
import g;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\info\tinyapps\stm\app\STMBlueS.j ava:14: '.' expected
import i;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\info\tinyapps\stm\app\STMBlueS.j ava:21: '.' expected
import r;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\info\tinyapps\stm\app\STMBlueS.j ava:300: ';' expected
JVM INSTR pop ;
^
C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\ apps\stmblues\src\info\tinyapps\stm\app\STMBlueS.j ava:300: not a statement
JVM INSTR pop ;
^
30 errors
com.sun.kvem.ktools.ExecutionException
Build failed
engart 19th October 2007, 01:26 Does anyone know how to setup eclipse with jadclipse plugin? I have read some tutorials found by google, but couldn't open a class file. With a powerful ide and integrated decompiler support would our works be easier.
qwerty111 21st October 2007, 12:34 jode.sourc ([Only registered and activated users can see links])eforge.net another decompiler
Anybody can help with my previous question?
commandoo 21st October 2007, 15:39 is it possible to remove the time limit from java application using this tutorial .......
i have been able to decompile and recompile a .class file but when i re put this modified .class file the application fails to run after in stall
Aliera 24th October 2007, 16:38 Qwert111: This is typical Klassmaster flow-control kind of obfuscation. A simple line by line translation can't be made by your example. You need to try to understand what the program is trying to do and do the equivalent thing with legitimate java code. It's not very hard and I've found myself getting better with this stuff as Klassmaster only changes certain types of code. The changes that typically need to be made are adding a try/catch around a sequence of code or consructing a switch/case and filling in the blanks with the code it does have. I'm not going to get crazy into this thing but I'll look around in my code for some simpler examples and post them. It could give you a better idea as to what's going on and set you on a better course.
Commandoo: Were the recompiled classes preverified? If you simply recompiled them through DJ they weren't. It's recompile option is only usefull for regular java, not Java ME (J2ME). There is a precompile command-line tool, part of the normal WTK, but it can be a pain to use by itself.
popet 27th November 2007, 15:55 Can We Resize The Screen From 240 To 176 X220 I Mean For The Game That Dedicated For Screen 240x320 If We Install To Phone With Screen 176x220 So The Objects, For Instance The Cars Will Not Seen On Screen , So How Abaout That Bro?
PHoeZies 8th December 2007, 21:01 interesting thread.. :)
but maybe better if moved to howto section..
|