Ivan has posted 22 posts at DZone. View Full User Profile

A Gun is a Great equalizer: OpenJDK Hack vs. Class Encryption

06.25.2012
| 7605 views |
  • submit to reddit

The purpose of this article is to warn developers about futility of using class-file encryption obfuscators for application protection and uselessness of spending money on it.

All the protection methods are described in the fundamental work of Dmitry Leskov - Protect Your Java Code — Through Obfuscators And Beyond.

When we are using class file encryption method we assume that the byte-code is encrypted and when the application starts decrypted byte-code through custom ClassLoader or JVMTI-interface loads into JVM.

How to circumvent this kind of protection you can find in article of Dmitry Leskov, but today there are some products that have native component which interacts with JVM and monitors debug-mode and/or unauthorized agents. But despite all the assurances of the developers, these products does not protect your byte-code at all.

To show you vulnerability of all obfuscators which encrypts classes we will take some steps.

First of all, we should start encrypted application with option "-XX:+TraceClassLoading" and be sure that all encrypted class files are visible on this level of tracing.

Downloading the OpenJDK sources and patching it to dump encrypted classes to file.

For an experiment we are using Debian Linux 6.0.5 (Stable) and source bundle of OpenJDK7. If you are using different platform, please see OpenJDK Build README for instructions of how to build OpenJDK.

To minimize count of modifications if  "-XX:+TraceClassLoading" option is set JDK will dump all loaded classes in $WORKDIR/classes.dump file. Structure of dump file:

{
int lengthClassName,
byte[] className,
int lengthByteCode,
byte[] bytecode
}, 
{ next record … },
…

Let's prepare environment for build:

# apt-get install openjdk-6-jdk
# apt-get build-dep openjdk-6

Next, we have to download OpenJDK sources and our patch, which will add the following code into ClassFileParser::parseClassFile function, in hotspot/src/share/vm/classfile/classFileParser.cpp:

      // dumping class bytecode
      // dump file format:
      // length of the class name - 4 bytes
      // class name
      // length of the class bytecode - 4 bytes
      // byte code
      // ... next class ...
	  ClassFileStream* cfs = stream();
	  FILE * pFile;
	  int length = cfs->length();
	  int nameLength = strlen(this_klass->external_name());
	  pFile = fopen("classes.dump","ab");
	  // size of the class name
	  fputc((int)((nameLength >> 24) & 0XFF), pFile );
	  fputc((int)((nameLength >> 16) & 0XFF), pFile );
	  fputc((int)((nameLength >> 8) & 0XFF), pFile );
	  fputc((int)(nameLength & 0XFF), pFile );
      // class name
	  fwrite (this_klass->external_name() , 1, nameLength, pFile );
	  // size of the class bytecode
	  fputc((int)((length >> 24) & 0XFF), pFile );
	  fputc((int)((length >> 16) & 0XFF), pFile );
	  fputc((int)((length >> 8) & 0XFF), pFile );
	  fputc((int)(length & 0XFF), pFile );
      // class bytecode
	  fwrite (cfs->buffer() , 1 , length, pFile );
	  fclose(pFile);		

Let's try to build unmodified JDK to be sure that it builds correctly:

# export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk ALLOW_DOWNLOADS=true
# make sanity && make 

Apply patch and start build:

# cd $OPENJDK_SRC
# patch -p1 < $PATH_TO_PATCH_FILE
# make

Next, change dir to bin of builded JVM: $OPENJDK_SRC/build/linux-i586/j2re-image/bin/

To test work of patched JRE start java with -XX:+TraceClassLoading:

# ./java -XX:+TraceClassLoading

If all correct you will see classes.dump with all classes which JRE loads in start phase.

And now the most interesting moment. Download some encrypted application, for example trial version of obfuscator with class encryption. I will not mention for obvious reasons, specific names, it is enough to search on Google for the key «byte-code encryption». 

Let's say we have SomeClassGuard.jar. Inside SomeClassGuard.jar in the hierarchy com/ ****/ someclassguard/engine there are class-encrypted files, you can see it for yourself using any decompiler or look at the file header in the HEX-viewer.

Start the SomeClassGuard.jar:

# ./java -XX:+TraceClassLoading -jar SomeClassGuard.jar 

Ok, we have classes.dump now, but we need to parse this file. Let's write java program for that particular case:

package openjdkmod;

import java.io.DataInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
* Classes dump format extractor class.
* Author Ivan Kinash kinash@licel.ru
*/
public class ClassesDumpExractor {

   /**
    * Extract contents classes.dump to specified dir
    */
   public static void main(String[] args) throws
FileNotFoundException, IOException {
       if (args.length != 2) {
           System.err.println("Usage openjdkmod.ClassesDumpExtractor
 ");
           System.exit(-1);
       }
       File classesDumpFile = new File(args[0]);
       if (!classesDumpFile.exists()) {
           System.err.println("Source file: " + args[0] + " not found!");
           System.exit(-1);
       }
       File outDir = new File(args[1]);
       if (!outDir.exists()) {
           outDir.mkdirs();
       }
       DataInputStream din = new DataInputStream(new
FileInputStream(classesDumpFile));
       while (true) {
           try {
               int classNameLength = din.readInt();
               byte[] classNameBytes = new byte[classNameLength];
               din.readFully(classNameBytes);
               String className = new String(classNameBytes);
               System.out.println("className:" + className);
               int classLength = din.readInt();
               byte[] classBytes = new byte[classLength];
               din.readFully(classBytes);
               File parentDir = className.indexOf(".")>0?new
File(outDir, className.substring(0,className.lastIndexOf(".")).replace(".",
File.separator)):outDir;
               if(!parentDir.exists()) parentDir.mkdirs();
               File outFile = new File(parentDir,
(className.indexOf(".")>0?className.substring(className.lastIndexOf(".")+1):className)+".class");
               FileOutputStream outFos = new FileOutputStream(outFile);
               outFos.write(classBytes);
               outFos.close();
           } catch (EOFException e) {
               din.close();
               return;
           }
       }


   }
}

Let's execute compiled class like this:

# java openjdkmod.ClassesDumpExractor classes.dump dump_directory

On the output we'll get the directory with decrypted class files.

Conclusion

Class encryption is senseless, danger and expensive exercise.

If you want to protect your code there are few ways to do that:

  • Use Java Byte-code to Native-code Compilers
  • Combine classical obfuscator with string encryption obfuscators

For the super security use external devices which supports secure storage and internal byte-code execution.

You can use the method described above for debugging various applications, when you want to investigate which byte-code loads into JVM in runtime.

Note 1:  You can reach the same result without any modification of JDK, using sun.misc.Unsafe class if you aware about class storage methods inside JVM.

Note 2: The author is not responsible for the misuse of information from the article.

Note 3: Original source for the picture is: http://it.wikipedia.org/wiki/File:Netbeans-Duke.png

Published at DZone with permission of its author, Ivan Kinash.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Vladimir Kondratyev replied on Tue, 2012/06/26 - 6:19am

Inav, you miss very important point about class ecryption. Encryption can be used not only to protect class files from decompiling. The second main goals is to prevent modifications. For example, if you have no private RAS-key you will not be able to modify class class file, write crack, keygen, etc.

Ivan Kinash replied on Tue, 2012/06/26 - 12:55pm in response to: Vladimir Kondratyev

Vladimir, I can't agree with you. The method described above allows you not only to get byte-code of the classes, but also to modify this byte-code.

As far as I understood you meant - class encryption is good for protection of a licensing system. But here I can't agree with you, again. Software implementation of asymmetric cryptography don't give us security in our case. If there are an open key in a validation process malicious user can easily change it. 

And if we execute Java application with

-XX:+CompileTheWorld -XX:+CompileTheWorldPreloadClasses

 

option, we can get all the class files, remove using of custom ClassLoader and change byte-code as we want to, e.g. disable license validation, etc.


Yury Bendersky replied on Thu, 2012/11/29 - 3:29am

Ivan, I think, you are wrong. 

First. Your example described above can't  prove your claim "class encryption is senseless, danger and expensive exercise", because one example (or two, or billion) can't prove any claim  (statement).

Second. But one counterexample can refute the claim. Try to crack the counterexample at:

http://www.bisguard.com/examples/counterexample.jar

It's not so easy as you think. 

Ivan Kinash replied on Fri, 2013/05/17 - 4:35pm in response to: Yury Bendersky

Hi Yury,

Sorry for getting back to you late, there was no notification from DZone about your comment, unfortunately.

If you control the environment, there is no way to protect applications really securely, I think that proposition is proper for this case. You only can do it worse or better (easy or hard to crack).

As for your example. It is enough to set your own cryptoProvider with the higher priority level than Java has and then you can get decrypted classes more easily than this article describes.

I am not publishing universal method for obvious reasons.

Also, there is no problem to set java.vendor, etc system properties if you have source code of OpenJDK. 

Thank you.

Yury Bendersky replied on Sat, 2013/05/18 - 12:51pm in response to: Ivan Kinash

This is all very interesting, Ivan. But still what about:  A) your claims; B) my counterexample

Ivan Kinash replied on Sun, 2013/05/19 - 5:14am in response to: Yury Bendersky

A) Maybe I wrote my previous comment unclear. Ok, see B.

B) Here is the decrypted & decompiled code:

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;

public class CounterExample
{
  public static void main(String[] args)
    throws IOException
  {
    while (true)
    {
      System.out.println("Enter any number (x for exit)");

      ByteArrayOutputStream bis = new ByteArrayOutputStream();
      while (true)
      {
        int i = System.in.read();
        if (i == 13) break;
        bis.write(i);
      }

      String input = new String(bis.toByteArray()).trim();

      if (input.equalsIgnoreCase("x")) System.exit(0);

      try
      {
        double arg = Double.parseDouble(input);
        double f = 6.1425926D * Math.sin(Math.cos(arg) * arg) + 5.71828182846D * Math.cos(Math.sin(arg) * arg);
        int i = (int)(100.0D * f);
        System.out.println("F(" + input + ") = " + i);
      }
      catch (NumberFormatException e)
      {
        System.out.println("F(" + input + ") = NaN");
      }

      bis.reset();
    }
  }
}

Yury Bendersky replied on Thu, 2013/05/23 - 9:20am in response to: Ivan Kinash

My congratulation to you and the full respect, Ivan.

Though you broke “back door” but not encryption itself, you won the first round.

I didn't use in the counterexample the full protection by reasons similar to yours as well as because of some license and commercial restrictions. For instance, one of the standard java crypto algorithms was used. Using non-standard ones or even my owns, having no provider at all, makes setting high priority to cryptoProvider impossible.

To help you clarify your conclusion: 

a) I published 

http://www.bisguard.com/examples/counterexample2.zip 

for use in this forum only (see eula.txt inside of zip file); 

b) I'll try to formulate my claims as follows

  1. breaking the byte code encryption can be more difficult than breaking the native code; I estimate its complexity as the complexity of breaking RC crypto algorithm with 40 bit key

  2. the byte code encryption as a code protection technique is not a method but a process like a war, and the defender always has an advantage over the attacker (triple at least, according to Carl von Clausewitz)

Try to break my “hand made doors” now. Thank you

Ivan Kinash replied on Thu, 2013/05/23 - 4:31pm in response to: Yury Bendersky

Yury, thank you,

I've decompiled and decrypted counterexample2.zip. Are you sure you want me to publish the source code here? Or we could switch our discussion to email?

Yury Bendersky replied on Fri, 2013/05/24 - 6:59am in response to: Ivan Kinash

You can publish.

P.S. What decompiler did you use? 

Ivan Kinash replied on Fri, 2013/05/24 - 7:05am in response to: Yury Bendersky

// Source File Name:   CounterExample.java

import java.io.*;
import java.lang.reflect.Method;
import java.security.MessageDigest;
import java.util.*;

public class CounterExample
{
    class Function
    {

        byte delta()
        {
            x = x + 1 & 0xff;
            y = y + z[x] & 0xff;
            byte temp = z[x];
            z[x] = z[y];
            z[y] = temp;
            return z[z[x] + z[y] & 0xff];
        }

        double calculate(byte bytes[])
        {
            for(int i = 0; i < bytes.length; i++)
                bytes[i] = (byte)(bytes[i] ^ delta());

            return bytesToDouble(bytes);
        }

        double bytesToDouble(byte bytes[])
        {
            if(bytes == null || bytes.length == 0)
                return 0.0D;
            double d = (double)bytes[0] / 137D;
            for(int i = 1; i < bytes.length; i++)
                if(d > 128D || d < -127D)
                    d /= bytes[i];
                else
                    d *= bytes[i];

            return d;
        }

        int x;
        int y;
        byte z[];
        final CounterExample this$0;

        Function()
        {
            this$0 = CounterExample.this;
            super();
            z = new byte[256];
            byte key[] = getDigest();
            int key_length = key.length;
            int i;
            for(i = 0; i < 256; i++)
                z[i] = (byte)i;

            i = 0;
            int j = 0;
            for(; i < 256; i++)
            {
                j = j + key[i % key_length] + z[i] & 0xff;
                byte temp = z[i];
                z[i] = z[j];
                z[j] = temp;
            }

            key = null;
            x = 0;
            y = 0;
        }
    }


    public CounterExample()
    {
    }

    void theEighthMethod(StringBuffer buffer)
    {
        doIntrospection(buffer);
    }

    void theThirdMethod(StringBuffer buffer)
    {
        doIntrospection(buffer);
    }

    void doIntrospection(StringBuffer buffer)
    {
        StackTraceElement elements[] = (new Throwable()).getStackTrace();
        Class klass = CounterExample;
        Method methods[] = klass.getDeclaredMethods();
        String methodNames[] = new String[methods.length];
        for(int i = 0; i < methods.length; i++)
            methodNames[i] = methods[i].getName();

        Arrays.sort(methodNames);
        String as[];
        int k = (as = methodNames).length;
        for(int j = 0; j < k; j++)
        {
            String methodName = as[j];
            for(int i = 0; i < methodName.length(); i++)
                buffer.append((byte)methodName.charAt(i));

        }

        List lineNumbers = new ArrayList();
        StackTraceElement astacktraceelement[];
        int i1 = (astacktraceelement = elements).length;
        for(int l = 0; l < i1; l++)
        {
            StackTraceElement element = astacktraceelement[l];
            if(!element.getClassName().startsWith(CounterExample.getName()))
                continue;
            lineNumbers.add(Integer.valueOf(element.getLineNumber()));
            if(element.getMethodName().equals("getDigest"))
                break;
        }

        Integer ints[] = new Integer[lineNumbers.size()];
        lineNumbers.toArray(ints);
        while(!isSorted(ints)) 
        {
            Integer sortedArray[] = new Integer[ints.length];
            System.arraycopy(ints, 0, sortedArray, 0, ints.length);
            Arrays.sort(sortedArray);
            Integer ainteger[];
            if((ainteger = sortedArray).length != 0)
            {
                Integer i = ainteger[0];
                buffer.append(i);
                return;
            }
        }
        Integer ainteger1[];
        int k1 = (ainteger1 = ints).length;
        for(int j1 = 0; j1 < k1; j1++)
        {
            Integer i = ainteger1[j1];
            buffer.append(i);
        }

    }

    void theSecondMethod(StringBuffer buffer)
    {
        doIntrospection(buffer);
    }

    boolean isSorted(Integer ints[])
    {
        for(int j = 1; j < ints.length; j++)
            if(ints[j - 1].compareTo(ints[j]) > 0)
                return false;

        return true;
    }

    void theFirstMethod(StringBuffer buffer)
    {
        doIntrospection(buffer);
    }

    byte[] getDigest()
    {
        StringBuffer buffer = new StringBuffer();
        theSecondMethod(buffer);
        theFifthMethod(buffer);
        theSixthMethod(buffer);
        theThirdMethod(buffer);
        theSeventhMethod(buffer);
        theFirstMethod(buffer);
        theFourthMethod(buffer);
        theEighthMethod(buffer);
        String str = buffer.toString();
        buffer = null;
        byte array[] = new byte[str.length() / 3];
        for(int i = 0; i < array.length; i++)
            array[i] = Integer.valueOf(str.substring(3 * i, 3 * i + 3)).byteValue();

        str = null;
        hash(array);
        byte bytes[] = new byte[32];
        try
        {
            MessageDigest md = MessageDigest.getInstance("SHA-256");
            bytes = md.digest(array);
            array = null;
        }
        catch(Throwable throwable) { }
        return bytes;
    }

    void theFifthMethod(StringBuffer buffer)
    {
        doIntrospection(buffer);
    }

    void hash(byte bytes[])
    {
        int length = bytes.length;
        byte bis[] = {
            -124, 9, 46, -111, -36, -88, 3, -29, -83, -105, 
            -13, -47, 8, 27, 27, -20, -18, 91, -115, 0, 
            -25, 83, 114, -13, -12, 15, 31, 56, 61, -32, 
            40, -23, -128, 89, -116, -84, -8, 55, -96, -105, 
            -59, 88, 39, -91, -85, -28, -118, 80, -89, 15, 
            -47, -81, 61, -85, -25, 97, -13, 116, -41, 109, 
            88, -126, 29, 90, 31, -38, -98, -75, 61, 111, 
            -56, -108, 32, 18, -80, -69, 24, -108, 117, -70, 
            -8, 100, -106, 80, 93, -69, 36, -33, 65, 66, 
            101, 26, -99, 54, -98, 96, -2, 122, -104, 40, 
            -77, -74, -56, 15, 21, 60, 10, 35, 17, -96, 
            -43, 59, -13, -22, 80, -48, 46, -39, 121, -109, 
            -97, 105, -5, 13, 52, -4, -82, -10, -124, 23, 
            -79, -111, 72, 19, 66, -63, 126, 30, -99, -1, 
            -119, 52, -37, -98, -77, -85, 22, -117, -73, 24, 
            62, -101, 29, 9, -61, -48, 12, -14, 110, -14, 
            -122, 6, 10, 89, -23, -60, 120, 24, -56, -39, 
            54, 118, 47, -53, -122, -7, 56, -110, -27, 17, 
            2, -85, 53, -31, 77, -95, 35, 39, 77, -61, 
            -121, -46, -6, 113, -108, -19, -125, -14, 8, 38, 
            -30, -68, -87, -112, -1, -78, 103, -6, -103, -37, 
            -69, -66, 116, -30, -120, -7, 113, -11, -49, -63, 
            80
        };
        int dim = bis.length;
        int i = 0;
        do
        {
            if(bytes[i] < bis[mod(i, dim)])
                bytes[i] ^= bis[mod((i * i + 5 * i) - 1, dim)];
            else
                bytes[i] ^= bis[mod((i * i - 5 * i) + 1, dim)];
            if(++i > length / 2 - 1)
                break;
            bytes[i] ^= bis[mod(37 * i - 7, dim)];
            bytes[i] ^= bis[mod(5 * i + 7, dim)];
            int n = 0;
            if(n < 3 && ++i <= length / 2 - 1)
            {
                if(bytes[i] > bis[mod((2 * i * i + 7 * i) - 11, dim)])
                {
                    bytes[i] ^= bis[mod(3 * i - 1, dim)];
                    continue;
                }
                if(bytes[i] > bis[mod(i * i + 31, dim)])
                {
                    bytes[i] ^= bis[mod((i * i + i) - 1, dim)];
                    continue;
                }
                if(bytes[i] <= bis[mod(i * i + 1, dim)]);
            } else
            {
                bytes[i] ^= bis[mod((i * i - i) + 1, dim)];
            }
            if(++i <= length / 2 - 1)
                if(bytes[i] > bis[mod((3 * i * i + 2 * i) - 29, dim)])
                {
                    bytes[i] ^= bis[mod(i - 37, dim)];
                } else
                {
                    bytes[i] ^= bis[mod(i + 37, dim)];
                    continue;
                }
            if(bytes[i] > bis[mod((i * i * i - 7 * i) + 11, dim)])
            {
                bytes[i] ^= bis[mod(i + 17, dim)];
                break;
            }
            if(bytes[i] > bis[mod(13 * i * i, dim)])
                bytes[i] ^= bis[mod(i - 17, dim)];
        } while(true);
        do
        {
            if(bytes[i] < bis[mod(i, dim)])
                bytes[i] ^= bis[mod((i * i + 5 * i) - 1, dim)];
            else
                bytes[i] ^= bis[mod((i * i - 5 * i) + 1, dim)];
            if(++i > length - 1)
                break;
            bytes[i] ^= bis[mod((i * i - i) + 1, dim)];
            bytes[i] ^= bis[mod(5 * i + 7, dim)];
            int n = 0;
            if(n < 3)
            {
                if(++i > length - 1)
                    break;
                if(bytes[i] < bis[mod((2 * i * i + 7 * i) - 11, dim)])
                {
                    bytes[i] ^= bis[mod(3 * i - 1, dim)];
                    continue;
                }
                if(bytes[i] < bis[mod(i * i + 31, dim)])
                    bytes[i] ^= bis[mod((i * i + i) - 1, dim)];
                else
                if(bytes[i] < bis[mod(i * i + 1, dim)])
                    continue;
            } else
            {
                bytes[i] ^= bis[mod(37 * i - 7, dim)];
            }
            if(++i <= length - 1)
                if(bytes[i] < bis[mod((3 * i * i + 2 * i) - 29, dim)])
                {
                    bytes[i] ^= bis[mod(i - 37, dim)];
                } else
                {
                    bytes[i] ^= bis[mod(i + 37, dim)];
                    continue;
                }
            if(bytes[i] < bis[mod((i * i * i - 7 * i) + 11, dim)])
            {
                bytes[i] ^= bis[mod(i + 17, dim)];
                break;
            }
            if(bytes[i] < bis[mod(13 * i * i, dim)])
                bytes[i] ^= bis[mod(i - 17, dim)];
        } while(true);
        i = length - 1;
        do
        {
            if(bytes[i] < bis[mod(i, dim)])
                bytes[i] ^= bis[mod((i * i - 5 * i) + 1, dim)];
            else
                bytes[i] ^= bis[mod((i * i + 5 * i) - 1, dim)];
            if(--i < 0)
                break;
            bytes[i] ^= bis[mod(5 * i + 7, dim)];
            bytes[i] ^= bis[mod((i * i - i) + 1, dim)];
            int n = 0;
            if(n < 3)
            {
                if(--i < 0)
                    break;
                if(bytes[i] < bis[mod((2 * i * i + 7 * i) - 11, dim)])
                {
                    bytes[i] ^= bis[mod((i * i + i) - 1, dim)];
                } else
                {
                    if(bytes[i] < bis[mod(i * i + 31, dim)])
                    {
                        bytes[i] ^= bis[mod(3 * i - 1, dim)];
                        continue;
                    }
                    if(bytes[i] <= bis[mod(i * i + 1, dim)])
                        continue;
                }
            } else
            {
                bytes[i] ^= bis[mod(i - 37, dim)];
            }
            if(--i >= 0)
                if(bytes[i] < bis[mod((3 * i * i + 2 * i) - 29, dim)])
                {
                    bytes[i] ^= bis[mod(37 * i - 7, dim)];
                } else
                {
                    bytes[i] ^= bis[mod(i + 17, dim)];
                    continue;
                }
            if(bytes[i] < bis[mod((i * i * i - 7 * i) + 11, dim)])
            {
                bytes[i] ^= bis[mod(i + 37, dim)];
                break;
            }
            if(bytes[i] > bis[mod(13 * i * i, dim)])
                bytes[i] ^= bis[mod(i - 17, dim)];
        } while(true);
    }

    int mod(int n, int dim)
    {
        int i = n % dim;
        if(i < 0)
            return i + dim;
        else
            return i;
    }

    void theSixthMethod(StringBuffer buffer)
    {
        doIntrospection(buffer);
    }

    void theSeventhMethod(StringBuffer buffer)
    {
        doIntrospection(buffer);
    }

    public static void main(String args[])
    {
_L2:
        ByteArrayOutputStream bis;
        bis = new ByteArrayOutputStream();
        System.out.println("Enter any number (x for exit)");
        do
        {
            int i = System.in.read();
            if(i == 13)
                break;
            try
            {
                bis.write(i);
            }
            catch(IOException e)
            {
                System.out.println("F() = NaN");
            }
        } while(true);
        String input = (new String(bis.toByteArray())).trim();
        if(input.equalsIgnoreCase("x"))
            System.exit(0);
        try
        {
            Double.parseDouble(input);
            double d = ((new CounterExample()). new Function()).calculate(bis.toByteArray());
            System.out.println((new StringBuilder("F(")).append(input).append(") = ").append(d).toString());
        }
        catch(NumberFormatException e)
        {
            System.out.println((new StringBuilder("F(")).append(input).append(") = NaN").toString());
        }
        bis.reset();
        if(true) goto _L2; else goto _L1
_L1:
    }

    void theFourthMethod(StringBuffer buffer)
    {
        doIntrospection(buffer);
    }
}

I am using JAD.

Yury Bendersky replied on Fri, 2013/05/24 - 8:54am in response to: Ivan Kinash

But this code can't be compiled.

Samy Mukadi replied on Mon, 2013/08/26 - 4:38am in response to: Ivan Kinash

You get it to work by intercepting bytecode from jvm. But if the application only starts the jvm from a native code, decrypting natively, and where you can not set the value of -XX-traceClassLoading? Is all the source code for JVM public? 

Rakjia Domacha replied on Sun, 2013/09/01 - 8:50pm in response to: Yury Bendersky

Even if the decompiled source code cannot be compiled, if what you've wanted was to prevent people from seeing your logic/ implementation, this seems to fails to do so. 

Doesn't it ? 

The Java compiler may not like the decompiled result, but a human programmer can literally read the original source.


Yury Bendersky replied on Sun, 2013/09/08 - 5:17am in response to: Rakjia Domacha

Rakjia,

1. Try to read code from Ivan and compare results of protected source and read by human. 

2. How can human understand code of 1,000,000 lines?

3. Look at any cryptoalgorithm; even it has 500 lines it's impossible to explain how it works.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.