I could easily make it work with Linux, the same way LWJGL has a native library but can run on many platforms. The only thing i’m trying to do here is see how easy it is for members of this board to crack this protection, to have an idea on how good the protection could turn out to be.
In that other thread I already explained how any bytecode encrypter would be useless, if you alter the JVM.
Besides it was already said that any client-side security is guaranteed to be unsafe.
It might be fun for you to try this, learn from it, but please don’t think you’re doing anything more than raising the bar a little and providing a false sense of security.
Not if you alter the jvm, if someone else does… the jvm has to load the classes as pure byte arrays eventually, unecrypted. If for instance I change the jvm to load classes and wrote them out to disk i’ll have your unecrypted class files.
i’m unable to compile it for 64 bit at this moment, what would you do to bypass the dll? i’m curious
The very functions used to load the unencrypted class bytes into the JVM can be detoured by native code. This allows the JVM to accept virtually a file of any format, as long as the detoured function is able to construct a class at runtime out of it.
I think you’ve missed Riven’s point. The “attacker” can create a modified JVM which bypasses anything you can do. In any situation where the user has access to the software or hardware that decrypts information, the war is lost.
I concede that javassist would not help in breaking your encryption, as you are performing the class definition call in native code too.
However, as others have pointed out there are still avenues of attack that cannot be blocked.
Here’s an excellent article practically written to answer this thread.
Summary: Delve into the native code of the VM & perform the interception there, or hook into the VM through the JVMTI & listen for the class load event.
The idea is to encrypt classes and decrypt them in-memory at runtime. If a user has the classes but no key, they cannot use the classes without breaking the encryption. Sure, if someone has the key, they can dump the unencrypted classes: if you can run it, you can crack it. This idea is still useful for crippleware. It is the best you can do to protect your software if you want crippleware.
Here is the same idea, but for native code:
It encrypts a section of your lib and at runtime decrypts and patches the section in-memory. If you bypass the simple “isRegistered” checks, you’ll jump into encrypted code, execute random garbage, and crash. If you have a valid key, you can dump the memory after decryption and then patch the lib on disk.
Of course, your time is probably better spent improving your software so that more people want it, rather than trying to stop people from stealing it. I understand it can be fun to play around with though, just as is creating useless games.
Any software written in any language can be cracked, I’m just attempting to make it harder to crack it, even make cracking Java as hard as cracking C/C++ applications.
note how on line 2558 there’s a check for JvmtiExport should load class hook, inline patching this to always force false would fix the JVMTI exploit. Alternatively, inline patch the whole function to use your own class loading code.
I still dont get exacly how it work, the DLL modify the JVM memory at runtime to secure the jar that’s it ?
ps: sorry to say that but at very first view, it seems useless to do that except that you will create a lot of bugs/incompatibilty problems, I mean you cant prevent modification of the DLL itself for example
yeah it can be a little difficult to understand. basically, every native application on a computer stores memory. in this memory, there are variables, functions, objects, etc.
by modifying the memory where a function points to, you can force it to jump to a location effectively creating a hook, and by hooking for example JVM_GetManagement(), you can override what the function returns (think of it like an override in Java, except done at runtime by native code). By using these code hooks, you can actually use your own class formats in the JVM, provided you are able to hook the right functions.
protecting against jvmti was a little more difficult, it uses a codescan (kind of like what antiviruses use) to locate any loaded agents in the current module.