我试图在反编译后对一些 Java .class 文件进行去混淆处理,但我遇到了部分代码,它以我认为无法使用的方式使用标签。我不知道这是反编译器误解标签的错误,还是代码被故意这样混淆了。也就是说,在Java字节码中可以这样使用标签吗?
请注意,标 checkout 现在相关的 break 语句之后,而不是之前。它几乎似乎是将它们用作 goto,而不是用于跳出循环的标签。也根本没有循环,所以我对它们应该如何在这里使用有点困惑。
这是怎么回事?我在评论中标记了 3 个标签 (###)
if (i != 96)
{
if ((i ^ 0xFFFFFFFF) != -98)
{
if (i == 98)
break label417; // ### Here are the three breaks... The relevant labels appear later in the code
if (i != 99)
break label540;
if (!bool)
break label461;
}
}
else
{
if (localwb == this.localWB5)
{
if (this.localWB4 != null) {
this.localWB4.a((byte)-92, this);
if (!bool);
}
else
{
this.localWB6.a((byte)-9, this);
}
return true;
}
if (localwb == this.localWB4)
{
this.localWB6.a((byte)-59, this);
return true;
}
if (this.localWB3 != localwb)
break label540;
this.localWB2.a((byte)-38, this);
return true;
}
if (this.localWB6 == localwb)
{
if (this.localWB4 != null) {
this.localWB4.a((byte)-122, this);
if (!bool);
}
else {
this.localWB5.a((byte)-63, this);
}
return true;
}
if (this.localWB4 == localwb)
{
this.localWB5.a((byte)-22, this);
return true;
}
if ((this.localWB2 == localwb) && (this.localWB3.M))
{
this.localWB3.a((byte)-84, this);
return true;
label417: // ### The first label. Note how this next if-statement has inaccessible code... if the above if-statement is true, it would have already returned true; However, the label appears after the return statement, almost as if the label is being used as a goto.
if (localwb == this.localWB2)
{
this.localWB6.a((byte)-86, this);
return true;
}
if (this.localWB3 == localwb)
{
this.localWB5.a((byte)-31, this);
return true;
label461: // ### The second label
if ((this.localWB6 == localwb) || (this.localWB4 == localwb))
{
this.localWB2.a((byte)-60, this);
return true;
}
if (localwb == this.localWB5)
{
if (this.localWB3.M)
{
this.localWB3.a((byte)-44, this);
if (!bool);
}
else {
this.localWB2.a((byte)-9, this);
}
return true;
}
}
}
label540: // ### The final label.
最佳答案
goto
bytecode instruction (是的,它实际上称为“goto”)用于实现 break
和其他构造。
goto
本身的规范仅将目标限制在与goto
指令相同的方法内。
4.10. Verification of class
Files 中定义了许多其他约束,特别是在 Checking Code ,它描述了如何验证方法的实际字节码。
我怀疑您不能使用goto
产生局部变量和操作数堆栈的不一致解释,例如要求目标指令与源指令兼容指令,但我实际的规范是用 Prolog 编写的,如果有人能得到确保这一点的相关要点,我将不胜感激。
关于java - Java break/label 语句可以在字节码混淆中充当 "goto"吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14496134/