加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

Java break / label语句可以在字节码混淆中作为“goto”吗?

发布时间:2020-12-14 05:06:37 所属栏目:Java 来源:网络整理
导读:我试图在反编译一些 Java .class文件之后对其进行反混淆,我遇到了一些代码,其中使用标签的方式不认为它们可以被使用.我不知道这是否是反编译器误解标签的错误,或者如果代码是以这种方式有意混淆的.换句话说,在Java字节码中可以使用这样的标签? 请注意,标签
我试图在反编译一些 Java .class文件之后对其进行反混淆,我遇到了一些代码,其中使用标签的方式不认为它们可以被使用.我不知道这是否是反编译器误解标签的错误,或者如果代码是以这种方式有意混淆的.换句话说,在Java字节码中可以使用这样的标签?

请注意,标签显示在相关的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写的,我会感激的如果有人得到了确保这一点的相关点.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读