How can I achieve java byte code encryption (against reverse engineering) [duplicate] - java

This question already has answers here:
Closed 13 years ago.
Possible Duplicate:
How to lock compiled Java Classes to prevent decompilation
...ideally combined with licensing?
Our product is ported from PHP to Java. With PHP, there was a great code encryption / license tool named IONCube Encoder. It encrypts the PHP source code an allows the execution only if a appropriate license is present.
Is there any equivalent for a Java application (that does not rely on a hardware dongle)?

Take a look at JET Excelsior. That's what we've been using and it's worked pretty well for us.

IONCube Encoder works by obfuscating your code, not encrypting it. If you want to get the same effect, there are a number of obfuscation tools for Java, such as
KlassMaster
DashO

You might also want to have a look at the proguard obfuscator

Related

Is it possible to view a Java class files bytecode [duplicate]

This question already has answers here:
Is it possible to view bytecode of Class file? [duplicate]
(5 answers)
Closed 7 years ago.
I am working on a bytecode manipulation/generation in Java and I was just wondering if there is an easy way I could check the bytecode. I do not want to decompile the file, I would like to actually look at the compiled bytecode. I do not need to edit it. Any links or programs for doing this would be acceptable answers.
Since you wanted to be guided to some program that can easily show you the byte code then my suggestion is to use IntelliJ IDEA since it has built-in support for viewing byte code.
Here's an example how to do it (it can also be mapped to some keys of your choice):
It is very easy, and it can surely be done in eclipse or NetBeans as well.
Not sure what exactly you need, but apart from javap, which is a command-line tool for displaying the bytecode, you can take a look at javassist, asm and cglib - they allow you to parse the bytecode with java code.
I've been working on a decompiler that has a color-coded bytecode output mode (which I find far more readable than javap). It can also output Java code or an intermediate 'bytecode AST'.
The javap command-line tool, which is bundled with Oracle's JDK, gives a detailed textual dump of .class files along with the constant pool and all functions' bytecode content. Just run it with -v to get a full dump.

Java Code Security [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Do you obfuscate your commercial Java code?
Is there any way other then obfuscation to protect jars from being opened by someone else? The thing is that I don't want anyone to access the code, which is why I don't prefer Java. From the decompilers I used, programs made in C# and Java have EVERYTHING like the names of the variables intact which would make it easy to get access to programs that are not free. Worse, give out the source code.
Most of these points are covered by comments above, but I'll expand on them a bit here:
If your code is running on the user's machine, the user can decompile your code. It doesn't matter what language it is. Java, C, whitespace, brainfuck, it doesn't matter. If the code runs on a computer, a human can read it. Even if you make your own homebrew language and compiler, the compiled code is still going to be a sequence of standard machine instructions, which decompilers will handily turn into readable code in C or whatever language you like.
No exceptions. Forget about it.
But there are ways to get what you want: protecting some secret business logic. An easy way to do this would be to place the business logic on your own machine and expose it with a web service. The user can still see the client requests and service responses but otherwise your logic is a black box.
You could also make your own machines, lock them down, and distribute them to users. Be aware that although this is possible, it's technically quite difficult to do correctly (think of all the hacked gaming consoles and smartphones), and will significantly increase the cost of your service.
As far as I know, jar files (generated with NetBeans) may contain only .class files, which are Java bitecode, not source code. I don't know if there's a way to reverse-engineer a .class file, but it has very little ASCII usable text.

Is it possible to automatically convert java code to PHP?

Is there are tools for converting java code to php? I have source code of java library and I need it to convert to php.
It is possible to automatically convert it. This is called a source to source compiler. Normally when you compile software, the parser will build an abstract syntax tree and convert this into the target machine language code. But it is just as possible to have a compiler convert this into another high level (compilable) language.
Java is a strongly typed language, and PHP is not, so source to source compilers are rare and the code conversion process is incomplete. However this said, there is a reasonably good one with a free demo at: http://javatophp.com
Automatically - No. Now. Maybe in future. Don't spend time, write new code bro.
I don't think there is a solution like this currently.
You might try using a php-java bridge that would allow you to call the java code from within PHP:
http://php-java-bridge.sourceforge.net/pjb/
Zend Server also provides a bridge
Team of 5 folks at Facebook have spent 18 month to write sofrware that converts PHP to C++ (meet: HipHop). There is no such software for transforming from Java to PHP yet.
The answer is: yes... it is possible if you have year and a half and team of pro programmers :)
Otherwise, you rewrite it manually (I think, this is your choise).
There are lots of aspects of Java that cannot be expressed in PHP. Type safety for one. This sounds like a fool's errand to me. If you were looking to go in the opposite direction the question might have some interest.

Java Library for generating C++ Source Code

I'm working on a Java project and am looking for a library that creates C++ source code, much like Java Code Model (discussed here: A Java API to generate Java source files).
I answered a similar question, but for Java code. The generation technology is language neutral, but your success will depend on how much of your design you can encode in the templates (as in the Java example). I think the other approach in which you try to code your entire app in the model and then have all your code generated for you will never be more than a fantasy, however.

Self modifying code in Java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Have you ever created or encountered a self modifying code in Java?
If yes, then please post the link or simply post the code.
Ignoring the world of grief you could be causing yourself via self-modifying code(!), it seems to me there are 3 options:
use the inbuilt compiler support of Java 6 and write/recompile/reload classes
use the Apache BCEL bytecode manipulation library to write your class directly
make use of Java 6's inbuilt scripting support (or use Apache BSF) to write methods in your JVM scripting language of choice, and execute these
Of the three above, my initial choice (in the absence of requirements) would be to take a look at option 3. I suspect it's the least painful way to start. I've used all of the above - unfortunately I can't post links to client code.
You can write (Java) code that generates new classes (byte code) at runtime using a library like bcel. That's not quite the same as self-modifying code. I suspect self-modifying code is not something the JVM supports.
For an example of generating new code at runtime, have a look at the source code of clojure.
That should be difficult to realize. But you can create at runtime new classes and load them with a custom classloader. If you want to modify the code again, you have to reload the class.
From BCEL:
The Byte Code Engineering Library is intended to give users
a convenient possibility to analyze, create, and manipulate
(binary) Java class files (those ending with .class).
Classes are represented by objects which contain all the
symbolic information of the given class: methods, fields and
byte code instructions, in particular.
I see these options for this purpose:
Generate the java source code and compile it with the external javac or the internal compiler tools (can't remember the name). And as you are responsible for the naming, just include a version count in the class name to avoid class loading anomalies.
Use the built in JavaScript engine support
Some scenarios can be solved using java Proxys
Edit: I once created a Java 1.4 program which took business rules from an existing legacy database, generated java files (basically implementations of a Predicate interface) with a bunch of println() from them and used the command line javac to compile them.
As an undergrad I got to work on the JikesRVM. It is a JVM implemented (mostly) in Java. At runtime it will JIT compile itself! It's a really cool piece of technology.
You could always just use a dynamic language...

Categories

Resources