1

I'm trying to decompile / recompile an obfuscated Java program. From the decompiled source code, it looks like the obfuscator has managed to call a class if:

public class hX extends il implements ciS {
   ...
   private bQk Llm = bQk.DwB();
   private final CAR lTV = new if(this);
   private final TYo RtQ = new ig(this);
   private final TYo G2Z = new ih(this);
   ...
}

Trying to recompile this class of course now results in an error:

[javac] Compiling 1 source file to /home/qdii/cld/dev/bar/build/classes
[javac] /home/qdii/cld/dev/bar/src/hX.java:53: error: <identifier> expected
[javac]     private final CAR lTV = new if(this);

Is there a way to tell the java compiler to accept if as a class name? Otherwise, what are my options? renaming the class and finding all the references to it?

qdii
  • 12,505
  • 10
  • 59
  • 116
  • 8
    It appears that the obfuscator did its job well. You could always try to obtain the source code legally by contacting whoever owns the rights to it. – DontKnowMuchBut Getting Better Sep 13 '20 at 18:45
  • Not your down-voter by the way. I wonder which de-compiler you are using? Not all are equal either. – DontKnowMuchBut Getting Better Sep 13 '20 at 18:49
  • 2
    Note that any company that delivers obfuscated byte code most likely also has license terms that render your activities very doubtful legally. – GhostCat Sep 13 '20 at 19:24
  • 1
    @GhostCat True, but protection of IP is also not the only reason someone might want to obfuscate something. Malware is the obvious example. You can use an obfuscator to optimize the size of the bytecode too. Might be important in some embedded systems. – Michael Sep 13 '20 at 19:39
  • @GhostCat That's an interesting point, thanks for raising it. I'll double check the license at that point to make sure I'm not infringing anything. – qdii Sep 14 '20 at 20:51
  • @DontKnowMuchButGettingBetter Fair, but that would defeat the whole purpose of the exercise, which is to learn more about obfuscation, bytecode and java. – qdii Sep 14 '20 at 20:52

1 Answers1

4

Java source code may have that constraint, but bytecode and classloaders do not care.

It's the compiler that enforces that. If you use an alternative compiler to javac, or otherwise manipulate or generate some bytecode, then you are potentially able to do things that are normally impossible.

That's what an obfuscator is likely to do.

The obfuscator is presumably exploiting this impossibility to make deobfuscation either more difficult or fail completely. Basically, the problem you're having is quite possibly by design.

Is there a way to tell the java compiler to accept if as a class name?

Nope.

Otherwise, what are my options? renaming the class and finding all the references to it?

Yup.

Michael
  • 41,989
  • 11
  • 82
  • 128