Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Obfuscation with focus on added useless opcodes

I am looking for a Java Bytecode obfuscator that "scrambles" the existing opcodes and adds new (useless) code. I am not interested in renamings of any kind, which is something most obfuscators seem to do.

A bit of background: As part of my PhD thesis I am developing a tool that identifies useless parts of a (Java Bytecode) program. In order to present nice results, I'd love to have some input programs with a significant amount of useless code. Besides the examples I am currently focussing on (which have subtle bugs that make code useless, think calling "equals" with a wrong argument) I could also need examples with just "weird" code - produced by a code obfuscator.

I already played around with ProGuard, however it seems it just optimizes (and therefore modifies) the code slightly. The part that renames methods, fields, ... is not relevant to me at all, which is why I switched it off.

like image 945
C-Otto Avatar asked Oct 03 '13 18:10

C-Otto


3 Answers

What you want isn't actually obfuscation.

What you want is a tool like ASM which can add whatever byte code you want including adding/changing methods.

like image 65
dkatzel Avatar answered Oct 19 '22 08:10

dkatzel


Your task is very interesting but it sounds that it is not java byte code obfuscators are designed for.

If you want to add useless code to some project why not just to add to it yet another project (or part of it). Obviously the added code will be "useful": no-one really calls it from the original project. You can add parts of source or even byte code from absolutely different project. Obviously this code will be written in different classes.

If you want to add the code to your existing classes you can probably develop your own tool using for example CGLIB that takes some even existing byte code and appends it to the byte code of your classes. Let's say appends static methods that will not break consistency of your existing class.

like image 20
AlexR Avatar answered Oct 19 '22 07:10

AlexR


If you do obfuscate, stay away from obfuscators that modify the code by changing code flow and/or adding exception blocks and such to make it hard to disassemble it. To make the code unreadable it is usually enough to just change all names of methods, fields and classes.

like image 44
rohan kamat Avatar answered Oct 19 '22 08:10

rohan kamat