调用一个类名为 “if”。

huangapple go评论55阅读模式
英文:

Calling a class “if”

问题

我正在尝试对一个经过混淆的Java程序进行反编译/重新编译。从反编译的源代码中看,混淆器似乎成功调用了一个名为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);
   ...
}

当然,尝试重新编译这个类会导致错误:

[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);

有没有办法告诉Java编译器接受if作为类名?否则,我的选择是什么?将类重命名并找到所有引用它的地方呢?

英文:

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: &lt;identifier&gt; 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?

答案1

得分: 4

以下是翻译好的部分:

Java源代码可能有这种限制,但字节码和类加载器不关心。

强制执行这一点的是编译器。如果您使用另一种替代的javac编译器,或者以其他方式操纵或生成一些字节码,那么您有可能做一些通常情况下不可能的事情。

这正是混淆器可能会做的事情。

可以推测混淆器正在利用这种不可能性,以使反混淆变得更加困难或完全失败。基本上,您遇到的问题很可能是有意设计的。

> 有没有办法告诉Java编译器接受if作为类名?

没有。

> 那么,我的选择是什么?将类名更改并找到所有引用它的地方?

是的。

英文:

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.

huangapple
  • 本文由 发表于 2020年9月14日 02:44:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/63874339.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定