Decompile Java Applet

Posted onby

Well, to change the class you'd have to decompile it, which there are tools out there to do if you look for 'java decompiler' on the web. That said, I'd imagine the applet makes round trips back to the hosting server to get other resource files, which you might not have also downloaded (or ahem stolen), so that could explain why it isn't. The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available. See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.

Here is a CAP file possible containing a malware code, without source code, and also without an export file.
It is a CAP file for old platform version, i.e. GP211.

I have a big experience Java reverse-engineering in Classic JVM and Dalvik. But Java Card is lesser popular and closer platform. Most tools are for CLASS/JAR or DEX, not CAP.
I found the several tools (including some VMs who simulates the JCOP) which could disassemble a CAP file, but the CAP is quite big, and the working with assembly code is too complex and slow for me.
And we cannot simply do 'CAP text bytecode -> Notepad++ --> some Java Bytecode editor -> Java bytecode'.
Too many differences between CAP bytecode and Java bytecode. Not just method table, it is also a big amount of different opcodes.
Just decompile the converter.jar of a Java Card Kit (it is a tool which converts CLASS -> CAP) and see that conversion is a quite complex process.
I need some automated converter.
Meanwhile, I developing a set of smart card solutions and the 'CAP decompiler' will be a good piece in the list.
Yes, I'm going to write it.
I plan to build it on top of Javassist from one side, some CAP disassembling library from the second one, and some standard Java decompiler(-s) from the third one.
But I should be sure that there are no analogs.
QUESTION IS HERE:
Is there some tool in the Earth which can convert Java Card *.cap to Java *.class (or decompile *.cap directly) or no?

(Also if you know some pitfalls in this bytecode conversion I will be grateful if you'll describe them to me. Now I saw it as just a copying one opcode list to another one with a giant if...else if...else if...else if... or switch...case...case...case tree (and some misc staff i.e. conversion of access modifiers, fields, etc).
Greenhorn
posted 9 years ago
hi everybody
can .class file decompiled into .java file and then after important modification and then after compilation be used as original?
thanks
Class
Bartender
posted 9 years ago
Firstly am not sure if the decompiled version will be exactly same as that of the original file. Moreover, if you have a valid java file with all imports resolved, you can as well edit that file and compile it again. And for decompiling details- you can search in the Beginner or Java General forums.
This is somewhat not encouraged because you would be making use of some else's work. If the code is open sourced then you can download the source directly and this is fine because the original author wanted it to be shared and reused.

Mohamed Sanaulla My Blog Author of Java 9 Cookbook Java 11 Cookbook

Greenhorn
posted 9 years ago
thanks
may i know what are free decompiler available.
is there decompiler plugine available there?
Ranch Hand

Decompile Java Jar

posted 9 years ago
Ranch Hand
posted 9 years ago
Greenhorn
posted 9 years ago
thanks
is decompile code(.class->.java) 100% reliable as original one
Ranch Hand
posted 9 years ago
AFAIK there's no guaranty for a 100% success. I wouldn't rely on it.
Greenhorn
posted 9 years ago

Mehmet Gunacti wrote:AFAIK there's no guaranty for a 100% success. I wouldn't rely on it.


sir thanks
i have a .class file.
original source file missed.

Decompile Java Appleton

i have to change url in this file
how one can do it?
please tell me sir a successfull way
Ranch Hand

Linux Decompile Java Class

posted 9 years ago
well, create an empty project in your favorite IDE and put the original jar file into the build-path.
decompile the class, put the .java file into your source folder (preserve package structure).
after compilation just update the original jar file using Winrar, drag and drop the new class file and overwrite the original one.
That should do the trick ;)
Bartender
posted 9 years ago

Decompile Java Exe

There is no reliable way to do this. Your decompiled java classes may well... not compile because the decompilation process is not fool proof.
You can however follow the approach mentioned by Mehmet. It will bring you closest to success.
Why are you decompiling anyway ? Did you lose the source ?

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks

Bartender
posted 9 years ago
  • 3
It might be a good idea to carefully read the license. Some licenses explicitly forbid decompiling.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]

Ranch Hand
posted 9 years ago
Why don't you just use Eclipse IDE to open .class file? Eclipse has everything you need for the project...harness the tool to it full power.

OCPJP6-05-11
'Your life is in your hands, to make of it what you choose.'

Ranch Hand
posted 9 years ago
well mr pandy may be completely innocent, but i always thought one of the big advantages of compilers vs interpreters is that your source code is sate.
Sheriff
posted 9 years ago
Safe? No. You can do your best to make it hard to decompile, by using a code obfuscator, but in the end most of the code can be decompiled. After all, the JVM needs to be able to read the byte code, and therefore so can any decompiler.

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask QuestionsHow To Answer Questions

Ranch Hand
posted 9 years ago
the question is, why did the designers of Java allow that ?
they must have discussed this, and accepted the fact that Java code will be decompilable.
Shouldn't they have included an option (parameter maybe ?) that would prevent decompilation ?
Bartender
posted 9 years ago

Mehmet Gunacti wrote:the question is, why did the designers of Java allow that ?
they must have discussed this, and accepted the fact that Java code will be decompilable.
Shouldn't they have included an option (parameter maybe ?) that would prevent decompilation ?


The JLS and the class format are specifications. This means your specification can have a JVM vendor (Sun/IBM/JBOSS) and it allows for freedom. You need not be tied down with a vendor.

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks

Marshal
posted 9 years ago

Mehmet Gunacti wrote:. . . an option (parameter maybe ?) that would prevent decompilation ?

As Rob has already told us, if you can execute the bytecode you can decompile it. So it is not possible to prevent decompilation.
Ranch Hand
posted 9 years ago

Campbell Ritchie wrote:

Mehmet Gunacti wrote:. . . an option (parameter maybe ?) that would prevent decompilation ?

As Rob has already told us, if you can execute the bytecode you can decompile it. So it is not possible to prevent decompilation.
You mean, if you can interpret the code, you can decompile it.

Java Class File Decompiler


Still, there should be a mechanism like, compiling the java source code to binary instead of bytecode. the JVM should then be able to run binary-bytecode...
ok, I was just thinking loud.
AFAIK one is able to decompile .net code (intermediate language ?), too, right ? So I guess MS would have prevented that, if there would be a way to do it.
Bartender
posted 9 years ago

run binary-bytecode...


Assembly you mean ? Here are some links that can clarify the matter for you
http://en.wikipedia.org/wiki/Bytecode
http://en.wikipedia.org/wiki/Assembly_language
http://en.wikipedia.org/wiki/Just-in-time_compilation

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks

Ranch Hand
posted 9 years ago

Deepak Bala wrote:

run binary-bytecode...


Assembly you mean ? Here are some links that can clarify the matter for you

Was just wondering why they didn't come up with a method to prevent decompiling Java classes.
It's not possible, I guess, that's why.
Yes, I meant assembly (or machine code). sorry for the inappropriate term.
Thanks for the links.
Marshal

Java Decompiler Download

posted 9 years ago

Java Decompiler Download For Windows 10

Compiling to machine code would tie your application to a particular platform. You would have to recompile a Windows® application to run on a Mac, for example.
Greenhorn
posted 9 years ago
I haven't had cause to look into it, but there are Java Obfuscators that will attempt to amend your class files to prevent/make decompilation difficult. If that's something that concerns you.