需要帮助逆向工程算法

时间:2012-01-03 03:02:53

标签: java algorithm bytearray reverse encryption

我坚持逆向工程一段java代码。我想知道是否有人可以帮助我!

String var1 = "hello";
String var2 = "123456";

long var_l = 0L;
byte[] a1 = new byte[50];
byte[] a2 = new byte[50];

// i believe this checks if its between a-Z?
for (int j = 0; j < var1.length(); j++)
{
    a2[j] = (byte) var1.charAt(j);

    if ((a2[j] < 65) || (a2[j] > 122)
    {
        continue;
    } 

    var_l += 145 + a2[j];
}

下一部分我真的不明白

var_l *= a1[0]; // a1 is a byte array of var2
var_l = 0xFFFF & var_l * (0xFF & var_l);

if (var_l < 100L)
{
    var_l = 2728L;
}

有人可以帮帮我吗?我试图在这里学习加密算法,但我很难遵循逻辑。

以下是完整代码:

param_licensekey&amp;许可证和lictype是全球变种。请阅读下面的评论,说明为什么我会对此进行逆向工程。感谢所有的人。

public boolean check_license()
  {
    long l = 0L;
    byte[] arrayOfByte2 = new byte['ÿ'];
    byte[] arrayOfByte1 = new byte['ÿ'];
    int i;
    if (this.param_licensename.length() >= 2)
    {
      if (this.param_licensekey.length() >= 2)
      {
        for (int j = 0; j < this.param_licensekey.length(); j++)
          arrayOfByte1[j] = (byte)this.param_licensekey.charAt(j);
        for (j = 0; j < this.param_licensename.length(); j++)
        {
          arrayOfByte2[j] = (byte)this.param_licensename.charAt(j);
          if ((this.param_licensename.charAt(j) < 'A') || (this.param_licensename.charAt(j) > 'Z'))
            continue;
          arrayOfByte2[j] = (byte)(32 + arrayOfByte2[j]);
        }
        for (j = 0; j < this.param_licensename.length(); j++)
        {
          if ((arrayOfByte2[j] < 65) || (arrayOfByte2[j] > 122))
            continue;
          l += 145 + arrayOfByte2[j];
        }
        l *= arrayOfByte1[0];
        l = 0xFFFF & l * (0xFF & l);
        if (l < 100L)
          l = 2728L;
        String str = this.param_licensekey.charAt(0) + l;
        if (!this.param_licensekey.startsWith(str))
        {
          this.lictype = -1;
          i = 0;
        }
        else
        {
          this.lictype = (i[0] - 48);
          i = 1;
        }
      }
      else
      {
        i = 0;
      }
    }
    else
      i = 0;
    return i;
  }

1 个答案:

答案 0 :(得分:1)

// var_l = var_l * a1[0]
var_l *= a1[0]; // a1 is a byte array of var2

// The low 16 bits of var_l are multipled by the low 8 bits of var_l (the parenthesis
// are not necessary in this case).
var_l = 0xFFFF & var_l * (0xFF & var_l);

// Self explanatory
if (var_l < 100L) {
 var_l = 2728L;
}
相关问题