From 6eab48d761cf779c66154dfc05a3917fb6614adf Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 8 Mar 1999 18:03:41 +0000 Subject: [PATCH] Initial revision git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@350 379699f6-c40d-0410-875b-85095c16579e --- jode/jode-unix.html | 96 +++++++++++++++++++++++++++++++++ jode/jode-useapplet.html | 48 +++++++++++++++++ jode/jode-win.html | 62 ++++++++++++++++++++++ jode/jode.html | 112 +++++++++++++++++++++++++++++++++++++++ jode/test/Unreach.java | 29 ++++++++++ 5 files changed, 347 insertions(+) create mode 100644 jode/jode-unix.html create mode 100644 jode/jode-useapplet.html create mode 100644 jode/jode-win.html create mode 100644 jode/jode.html create mode 100644 jode/test/Unreach.java diff --git a/jode/jode-unix.html b/jode/jode-unix.html new file mode 100644 index 0000000..ad4acf4 --- /dev/null +++ b/jode/jode-unix.html @@ -0,0 +1,96 @@ + + + +Using the decompiler under Unix + + +Home Up
+ +

Step by Step

+ +You need java version 1.1 or higher. In the following description I +assume you have the JDK 1.1, residing in /usr/lib/java. +For other installations you have to adopt the paths. Also I use the +bourne shell syntax. + +
    +
  1. Set the classpath. It should include the jode_cls.zip as well as + the directory where the class files you want to decompile resides. + You can also specify a zip file instead of a directory. It is + also a good idea to include the zip resp. jar file containing the + basic java.* class files. +
    +export CLASSPATH=$HOME/jode_cls.zip:$HOME/download:/usr/lib/java/lib/classes.zip
    +
    +
  2. +
  3. Now you can start the graphical interface as following (Note the + case of the parameter) +
        
    +java jode.JodeWindow
    +
    +
  4. +
  5. The classpath field should already contain the classpath you set + above. The class field contains jode.JodeWindow and + you may push start immediately to decompile this class. +
  6. +
  7. If you want to decompile your own .class file, enter + the name of the file without .class extension and + push the start button. Change the class path if it doesn't point + to the right directory. +
  8. +
  9. After decompiling, you can save the file using the save button. +
  10. +
+ +

Packaged classes

+ +If the class file belongs to a package (like jode.JodeWindow) you +have to give the full qualified class name (the package names +separated by a dot followed by the class name). The class path should +point to the directory containing the package sub directories in this +case.

+ +

Command line utility

+ +There is also a command line utility which is much more powerful, but +also more difficult to use. You can start it (after setting the +classpath) with +
+java jode.Decompiler
+
+and get a list of the supported parameters. To decompile the whole +decompiler you can use these magic lines: +
+mkdir src
+CLASSPATH=jode_cls.zip java jode.Decompiler --dest src \
+  `unzip -v jode_cls.zip|grep .class|cut -c59-|sed s/.class//|sed s?/?.?g`
+
+ +

Obfuscator

+ +So you want to protect your classes from decompiling? Well that is +your choice. You may use my obfuscator. The class files are +decompileable again (except when using -strong option, but this is +reversable by obfuscating again), but at least the information about +the names of identifiers are completely lost.

+ +The obfuscator is quite difficult to use (this is why I hided this +section here) and there is only a short description of the command +line parameters: +
+CLASSPATH=jode_cls.zip java jode.Obfuscator
+
+ +As a hint, to obfuscate the obfuscator use the following command line: +
+CLASSPATH=jode_cls.zip java jode.Obfuscator \
+  -cp jode_cls.zip:/usr/lib/java/lib/classes.zip -d obfuscated.zip \
+  -weak -revtable translate.tbl -swaporder \
+  -preserve jode.Obfuscator.main jode
+
+ +The options -unique and -table can be +helpful to deobfuscate obfuscated code. + + + diff --git a/jode/jode-useapplet.html b/jode/jode-useapplet.html new file mode 100644 index 0000000..6bb049a --- /dev/null +++ b/jode/jode-useapplet.html @@ -0,0 +1,48 @@ + + + +Using the decompiler as applet (locally) + + +Home Up
+ +

Step by Step

+ +If you want to use the applet version you need a recent Internet +Explorer or Netscape which supports java 1.1. + +
    +
  1. Copy jode-applet.html into a local directory. +
  2. +
  3. Copy jode_cls.zip to the same directory. +
  4. +
  5. Copy the .class file or zip file, you + want to decompile, to that directory. +
  6. +
  7. Load the html file into Netscape or Internet Explorer. +
  8. +
  9. Set the classpath simply to `.' (without quotes). + You may also specify a zip or jar file here. Note that applet and + class files must be in the same directory due to security policy.
    + You can also change the default classpath in the html file. +
  10. +
  11. Enter the name of the class without .class + extension. +
  12. +
  13. Press start button in applet.
  14. +
  15. Saving doesn't work in Netscape, but maybe in Internet Explorer.
  16. +
+ +

Packaged classes

+ +If the class file belongs to a package (like jode.JodeWindow) you +have to give the full qualified class name (the package names +separated by a dot followed by the class name). The class path should +point to the directory containing the package sub directories in this +case. + + diff --git a/jode/jode-win.html b/jode/jode-win.html new file mode 100644 index 0000000..c5f9aa6 --- /dev/null +++ b/jode/jode-win.html @@ -0,0 +1,62 @@ + + + +Using the decompiler under Windows + + +Home Up
+ +

Step by Step

+ +You need java version 1.1 or higher. I suggest using the Sun JDK or +JRE 1.1 or 1.2. In the following description I assume Sun JDK 1.2, +for other virtual machines the paths and the name of the java +interpreter (c:\jdk1.2\java) may differ.

+ +
    +
  1. Set the classpath. It should include the jode_cls.zip as well as + the directory where the class files you want to decompile resides. + You can also specify a zip file instead of a directory. It is + also a good Idea to include the zip resp. jar file containing the + basic java.* class files. +
    +set CLASSPATH=c:\temp\jode_cls.zip;c:\temp;c:\jdk1.2\jre\lib\rt.jar
    +
    +
  2. +
  3. Now you can start the graphical interface as following (Note the + case of the parameter) +
        
    +c:\jdk1.2\java jode.JodeWindow
    +
    +
  4. +
  5. The classpath field should already contain the classpath you set + above. The class field contains jode.JodeWindow and + you may push start immediately to decompile this class. +
  6. +
  7. If you want to decompile your own .class file, enter + the name of the file without .class extension and + push the start button. Change the class path if it doesn't point + to the right directory. +
  8. +
  9. After decompiling, you can save the file using the save button. +
  10. +
+ +

Packaged classes

+ +If the class file belongs to a package (like jode.JodeWindow) you +have to give the full qualified class name (the package names +separated by a dot followed by the class name). The class path should +point to the directory containing the package sub directories in this +case.

+ +

Command line utility

+ +There is also a command line utility which is much more powerful, but +also more difficult to use. You can start it (after setting the +classpath) with +
+c:\jdk1.2\java jode.Decompiler
+
+and get a list of the supported parameters. + diff --git a/jode/jode.html b/jode/jode.html new file mode 100644 index 0000000..a006520 --- /dev/null +++ b/jode/jode.html @@ -0,0 +1,112 @@ + + + + JOchens' java-DEcompiler (JODE) + + + + + + + + + +Home +

What is it?

+ +

This is a decompiler for java I have written in my spare time. It +takes class-files as input and produces something similar to the +original java-File. Of course this can't be perfect: There is no way +to produce the comments or the names of local variables (except when +compiled with -g) and there are often more ways to write +the same thing. But it does its job quite well.

+ +

Quick Test

+I have now an applet interface to the decompiler. +Check it out. + +

How to get it

+

You can donwload the files in zip form. +The sources contain only the +java files, the classes +contain only the class files.

+ +I also have a tar.gz file containing only +the RCS directories. This is the form I maintain the +project, but you probably need unix and a few tools to use them. + +

How to use it

+ +

I have some simple step by step pages. There are three +possibilities: +

+ +

Known bugs

+ +

There may be situations, where the code doesn't understand complex +expressions. In this many ugly temporary variables are used, but the +code should still be compileable. This does especially happen when +you compile with `-O' flag and javac has inlined some methods.

+ +

Sometimes this program may exit with an Exception or +produce incorrect code. Most time the code can't be compiled, so that +it can be easily spotted. If you have one of these problems (except +those that occur on some of the jode.test files, I would +be very interested in a bug report (including the class +file, if possible).

+ +

Sometimes it generates some GOTO expression and +labels. This can't be compiled, but shouldn't happen any more with +javac or jikes.

+ +

It doesn't handle inner and anonymous classes, yet. You can +decompile them separately, though (use `+$' switch under +jikes), but there is a bug in javac, so that a final variable is twice +initialized. If you encounter this problem just remove the doubled +line by hand.

+ +

Why did I wrote it?

+ +

Someday I found guavad, a disassembler for java byte +code (it does similar things like javap -c). I used +it on a class file, and found that it was possible to reconstruct the +original java code. First I did it by hand on some small routines, +but I soon realized that it was a rather stupid task, and that I could +write a perl script +that does the same. At the end of the next day I had a working +decompiler.

+ +

Now while it was working, it was not easy to use. You had to +decompile the code first with a disassembler, cut the method, you +wanted to decompile and then run the perl script on it. So I decided +to get some information of the class files and do this all +automatically. I decided to write it in java now, +because it suited best.

+ +

Just for the records: the java code is now nearly 50 times bigger +than the original perl script and is still growing.

+ +

License

+ +

This code is under GNU GPL. That basically means, that you can copy +or modify this code, as long as you put all your modification under +the GPL again. Look +here for the complete license.

+ +
+ +

+http://www.informatik.uni-oldenburg.de/~delwi/jode/jode.html, last +updated on 08-Mar-1999.

+ + + diff --git a/jode/test/Unreach.java b/jode/test/Unreach.java new file mode 100644 index 0000000..3ea149e --- /dev/null +++ b/jode/test/Unreach.java @@ -0,0 +1,29 @@ +package jode.test; + +/* A test class submitted by dave@onekiwi.demon.co.uk */ +class Unreach +{ + static int j = 0; + final double[] d = {0.5, 0.4, 0.3}; // won't decompile + + public static final void m(int i) throws Exception { + switch (i) { + case 1: + j += 2; + for (;;) { + j += 3; + switch (j) { + case 2: + break; + default: + j += 4; + return; + } + } + // An unreachable break is inserted here + default: + j += 5; // decompiles as j = j + 1; -- not quite optimal + } + } +} +