tags:

views:

204

answers:

7

Possible Duplicate:
Jar executable that cannot be decompiled

How can I make "undecompilable" source in java? I have a microedition app that has code that I need to hide Is it possible?

Thanks in advance

+1  A: 

Try Proguard.

mklhmnn
+1  A: 

You can't. See this question:
http://stackoverflow.com/questions/919690/jar-executable-that-cannot-be-decompiled

Interesting-looking book on the subject:
http://apress.com/book/view/9781590592656

gkrogers
+1 to counteract the senseless -1.
Andrew Dunn
@Andrew That's how voting works. Senseless to you, senseful to someone else. :)
bzlm
+2  A: 

You cannot make code undecompilable, you can only obfuscate it:

http://en.wikipedia.org/wiki/Obfuscated_code

Baltasarq
A: 

You can try obfuscation, but nobody will want to steal your sauce code anyway, so I guess it's more for peace of mind. When it comes down to it, everything is decompilable to a degree, otherwise operating systems wouldn't be able to run any programs!

Andrew Dunn
Huh? I don't get the part about operating systems...
Mchl
If an operating system can convert the data in an executable to processor instructions, then that can be converted into assembly, which can theoretically at least, be converted to any programming language known to man, even LOLCODE.
Andrew Dunn
@Mchl: Even binary machine code has to mean something, and can therefore be translated into a higher-level representation with some difficulty
IanGilham
That's seems a bit like circular logic to me, but I guess technically it is true.
Mchl
This is irrelevant, but is the "sauce" in "sauce" code intentional :P I initially read the line as "secret sauce"
blwy10
Yeah, I replace sauce with source all the time, it's so much more tasty :D
Andrew Dunn
+1  A: 

In short. You can obfuscate your code to make it difficult for someone to read it and reuse it. If that is what you want, it could also make it difficult for someone to see what it does. But not impossible.

avok00
A: 

If you want your users to actually, you know, use the program, they need to be able to run the program. In order to be able to run the program, the CPU must be able to understand the program. CPUs are much stupider than humans, so this means that humans can understand the program, too.

If you obfuscate your program in such a way that it cannot be understood by humans, this also means that it cannot be executed.

If you don't want people to get access to your code, there is only one way: don't give it to them. Put it on a server and let your users connect to it via the network.

But all of that is completely unnecessary, since your code is automatically protected by copyright law anyway, which is much more powerful than any obfuscation.

Jörg W Mittag
The code is inside cellphones, I don't hide it
iberck
@Jörg Well, what you write is only true in theory, and even so, only on a very generalized level. Certainly there are ways to "obfuscate your program in such a way that it cannot be understood by humans" but keep it working. Perhaps not in this specific technical context though.
bzlm
A: 

Why do you say that it is impossible? You can make code undecompilable, the cuestion is how?

I have a fragment of code in java microedition that is undecompilable by jd:


public static void main(String args[]) {
    int s = getSize("",false);
    System.out.println(s);
}

public static int getSize(String recordStore, boolean available) {
        RecordStore rs = null;
        int size = -1;
        try {
            rs = RecordStore.openRecordStore(recordStore, true);
            size = available ? rs.getSizeAvailable() : rs.getSize();
        } catch (Exception ex) {
        } finally {
            if (rs != null) {
                try {
                    rs.closeRecordStore();
                } catch (RecordStoreNotOpenException ex) {
                } catch (RecordStoreException ex) {
                }
            }
        }
        return size;
    }

Another example? Try to decompile opera mini source code, inside it there is a fragment of code that you can't decompile (here is hidden the proxy server of opera mini)

Do you know what are the rules to make code undecompilable in order to avoid reverse engineering on java code?

Thanks for read me

iberck