CafeBabe project


Description

This program is a graphical shell that supports execution of special code written in form of plugins for this shell (*.cba extension jar-format with additional manifest's entries). Historically all the codes are working with bytecode contents. But nowt his limitation doesnt't exist anymore. It is possible to write any program in form of plugin.

The main condition is - this plugin should follow some predefined rules.All plugins that exist in this framework basically work with bytecode transformation. They can to do the following:

1. Parse content of class files and serialized files and represent them in form of tree.

2. Perform specialized task with a group of class files:

  • bytecodes' content reduction - removing of unnecessary information from class files, such as local variable table, line number table, optional class attributes, unknown attributes;
  • bytecodes migration - moving class files from one namespace to another;
  • bytecodes obfuscation - changing of package/class/fileds/methods names and migration into anonymous namespace;
  • searching for class dependencies - find all the classes that are used with specified main class to reduce a size of deploying archive.

3. Archives (*.jar and *.zip) are transparent for a system. User can easily come into archive as into directory and extract desired content. Some plugins can interprete archive as ordinary directory during execution.

4. Powerful tutorial abilities - user can get useful information about sense of bytecode partitions or about structure of microinstructions, used inside method body.

5. Integration with Java Activation Framework (JAF). Graphical shell can be easily extended for supporting of any another content. Now it support simple text and image content.

6. CafeBabe now represents extendable framework. All tasks are implemented in form of plugins.

7. Ability for modification UTF8-string that resides inside constant pool and method's body. Plugin that operates with bytecode has embedded bytecode editor. With this editor you can do everything: add/remove/modify instructions, cut/copy/paste operations with selected group of instructions etc.

8. Abilities for searching of specified string inside bytecode.

9. User have an ability to quickly analyze content of archives with class files, navigate between archives, packages, classes, fields and methods (Class-Hound Service plugin). Selected class can be easily loaded into classfile plugin and positioning on choosed field/method;

10. System can work in console mode only. There are exists a lot of script files for invokingthe following bytecode task:

  • Stripper Task (Stripper.bat);
  • Migration Task (Migrator.bat);
  • Obfuscation Task (Obfuscator.bat);
  • Dependencies Finder Task (Dietolog.bat).

11. This framework works in wide range of Java platforms: JDK1.1, JDK1.2, JDK1.3 and with Microsoft VM too. You can choose appropriate script file for that. You can also find special script file for running under Unix environment.


Solving tasks: today and future

CafeBabe will be useful for solving the following tasks:

1. Tutorial task

Any new tool should teach user -- otherwise it becomes meaningless tool. CafeBabe's main window represents bytecode structure directly, following the class file format specification.

CafeBabe supports tutorial mode -- in this case user can see tooltips for any branch/leaf/cell of main tree-table. Tooltips discover sense of each byte/short/int inside bytecode.

You can receive another tutorial issue playing with Class-Hound service. Like a wise dog, this service is quickly talking you all about installed archives and including with these archives classes, it will show memberships (list of fields and methods) and hierarchy tree for selected class and by your request will load selected class to main tree-table window.

Class-Hound service has a great educational importance because it proposes live information about really existing classes, fields and methods vs. information, presented in documentation. Also this service produces short information without any extra unwanted info.

2. Optimization task

You can optimize your product from command line (javac -O or javac -g:none) but for that you must recompile whole project. Sometimes it can be undesired solution - f.e. you have no sources. Just run strip task from CafeBabe (for selected file or for group of files) and select what do you want to remove: "SourceFile" attribute, unknown attribute or debugging information inside method body. Some tools add own labels to bytecode when processing it (f.e. SourceGuard from 4thpass) -- try to remove unwished tags.

Other task for optimization is to find all methods that can be declared as final and set up method modifier to final value on bytecode level. We can name such task as finalize task and it will be realized in nearest future.

Also, we can perform other task of optimization - collect only class files, that really needed for application's work. Such task has a name compact task and will be realized in future.

3. Hacker task

CafeBabe gives you an ability to edit constant pool entries - now UTF8 only. It is not limit -- only author's flavour. I can add an ability to edit other types of entries, but I think it is meaningless - all they ultimately refer to UTF8 strings.

4. Obfuscation task

User have an ability to protect application's codes from easy understanding for outer developers. CafeBabe analyzes proposed classes, find dependencies between them and solves obfuscation task. You can select what items you want to obfuscate: packages, classes, fields or methods. In addition you can move all classes from different packages to anonymous package. This approach is greatly decreases size of project.

For convenience user can create files with information about obfuscation task. They hold such items as:

  • main class - class that launches application and its name will be unchanged;
  • classpath for obfuscated application;
  • denied list - list of classes, that doesn't change own names and names of members inside them. It can be useful for native methods;
  • anonymous package mode;
  • obfuscate packages;
  • obfuscate classes;
  • obfuscate fields;
  • obfuscate methods.

By using Configuration panel you can create/load and save these descrptions.

5. Migration Task

If you have Swing program (bytecodes only), written with old namespace conventions (com.sun.java.swing) and now you work with new namespace conventions (javax.swing), migration tool will help you. Just run migration task from CafeBabe (for selected file or for group of files) and you'll receive desired results.

Author think that migration is a sort of obfuscation when you don't change names for classes, fields and methods, only for packages by using information from specified migration table. Exactly this way is realized in Cafebabe.

This task works on bytecode level, thereby you can solve such task without a presence of sources.

6. Creational task - in future

User will have an ability to create new bytecodes "from scratch", add new fields, methods, attributes, constant pool entries and test created class. It can be useful for persons who like VM but hate Java :-).

7. Decompilation task - in future

User will have an ability to decompile entire class or selected method only.


Screenshot

cafe_screen1.jpg (73927 bytes)

cafe_screen2.jpg (88049 bytes)


Requirements

JDK1.1 + Swing1.1 or Java 2 or Microsoft VM + standard classes from JDK1.1


Project Team

Name Role
Alexander G. Shvets Project Leader/Programmer

Download

The CafeBabe program is available for download:
CafeBabe-sources.zip and CafeBabe.zip. Current version is 1.3.5. To run it, unpackage the archive CafeBabe.zip adjust system variables and run corresponding script files for Win-9x/NT or for Unix clones.