首页
社区
课程
招聘
[求助]这段smali 代码如何 转成 java代码 求助大神
发表于: 2015-4-3 13:32 13110

[求助]这段smali 代码如何 转成 java代码 求助大神

2015-4-3 13:32
13110
文件一:
.class public Lcom/abc/shop/plugin/a/c;
.super Ljava/lang/Object;


# direct methods
.method public static a(ILjava/lang/String;)[B
    .registers 13

    const/16 v5, 0x20

    const/4 v1, 0x0

    invoke-virtual {p1}, Ljava/lang/String;->getBytes()[B

    move-result-object v8

    array-length v0, v8

    rem-int/lit8 v0, v0, 0x4

    if-nez v0, :cond_21

    array-length v0, v8

    div-int/lit8 v0, v0, 0x4

    :goto_f
    new-array v9, v0, [I

    move v0, v1

    move v2, v1

    :goto_13
    array-length v3, v8

    if-lt v0, v3, :cond_27

    array-length v0, v9

    mul-int/lit8 v0, v0, 0x4

    new-array v5, v0, [B

    move v0, v1

    move v2, v1

    :goto_1d
    array-length v3, v9

    if-lt v0, v3, :cond_72

    return-object v5

    :cond_21
    array-length v0, v8

    div-int/lit8 v0, v0, 0x4

    add-int/lit8 v0, v0, 0x1

    goto :goto_f

    :cond_27
    array-length v3, v8

    if-lt v0, v3, :cond_5b

    move v3, v1

    :goto_2b
    add-int/lit8 v4, v0, 0x1

    array-length v6, v8

    if-lt v4, v6, :cond_5e

    move v4, v5

    :goto_31
    add-int/lit8 v6, v0, 0x2

    array-length v7, v8

    if-lt v6, v7, :cond_63

    move v6, v5

    :goto_37
    add-int/lit8 v7, v0, 0x3

    array-length v10, v8

    if-lt v7, v10, :cond_68

    move v7, v5

    :goto_3d
    const/4 v10, 0x4

    new-array v10, v10, [B

    aput-byte v3, v10, v1

    const/4 v3, 0x1

    aput-byte v4, v10, v3

    const/4 v3, 0x2

    aput-byte v6, v10, v3

    const/4 v3, 0x3

    aput-byte v7, v10, v3

    invoke-static {v10}, Lcom/abc/shop/plugin/a/a;->a([B)I

    move-result v3

    rem-int/lit8 v4, v2, 0x2

    if-nez v4, :cond_6d

    xor-int/2addr v3, p0

    aput v3, v9, v2

    :goto_56
    add-int/lit8 v2, v2, 0x1

    add-int/lit8 v0, v0, 0x4

    goto :goto_13

    :cond_5b
    aget-byte v3, v8, v0

    goto :goto_2b

    :cond_5e
    add-int/lit8 v4, v0, 0x1

    aget-byte v4, v8, v4

    goto :goto_31

    :cond_63
    add-int/lit8 v6, v0, 0x2

    aget-byte v6, v8, v6

    goto :goto_37

    :cond_68
    add-int/lit8 v7, v0, 0x3

    aget-byte v7, v8, v7

    goto :goto_3d

    :cond_6d
    xor-int/lit8 v3, v3, -0x1

    aput v3, v9, v2

    goto :goto_56

    :cond_72
    aget v3, v9, v0

    invoke-static {v3}, Lcom/abc/shop/plugin/a/a;->a(I)[B

    move-result-object v6

    move v3, v1

    :goto_79
    array-length v4, v6

    if-lt v3, v4, :cond_7f

    add-int/lit8 v0, v0, 0x1

    goto :goto_1d

    :cond_7f
    aget-byte v4, v6, v3

    aput-byte v4, v5, v2

    add-int/lit8 v4, v2, 0x1

    add-int/lit8 v2, v3, 0x1

    move v3, v2

    move v2, v4

    goto :goto_79
.end method


---------------------------------------------------------------------下面是引用到的另外一个文件---------------------
文件二:

.class public Lcom/abc/shop/plugin/a/a;
.super Ljava/lang/Object;


# direct methods
.method public static a([B)I
    .registers 3

    const/4 v0, 0x0

    aget-byte v0, p0, v0

    and-int/lit16 v0, v0, 0xff

    shl-int/lit8 v0, v0, 0x18

    const/4 v1, 0x1

    aget-byte v1, p0, v1

    and-int/lit16 v1, v1, 0xff

    shl-int/lit8 v1, v1, 0x10

    or-int/2addr v0, v1

    const/4 v1, 0x2

    aget-byte v1, p0, v1

    and-int/lit16 v1, v1, 0xff

    shl-int/lit8 v1, v1, 0x8

    or-int/2addr v0, v1

    const/4 v1, 0x3

    aget-byte v1, p0, v1

    and-int/lit16 v1, v1, 0xff

    or-int/2addr v0, v1

    return v0
.end method

.method public static a(I)[B
    .registers 2

    const/4 v0, 0x0

    invoke-static {p0, v0}, Lcom/abc/shop/plugin/a/a;->a(II)[B

    move-result-object v0

    return-object v0
.end method

.method public static a(II)[B
    .registers 8

    const/4 v5, 0x3

    const/4 v4, 0x2

    const/4 v3, 0x1

    const/4 v2, 0x0

    const/4 v0, 0x4

    new-array v0, v0, [B

    packed-switch p1, :pswitch_data_42

    :goto_a
    return-object v0

    :pswitch_b
    shr-int/lit8 v1, p0, 0x18

    and-int/lit16 v1, v1, 0xff

    int-to-byte v1, v1

    aput-byte v1, v0, v2

    shr-int/lit8 v1, p0, 0x10

    and-int/lit16 v1, v1, 0xff

    int-to-byte v1, v1

    aput-byte v1, v0, v3

    shr-int/lit8 v1, p0, 0x8

    and-int/lit16 v1, v1, 0xff

    int-to-byte v1, v1

    aput-byte v1, v0, v4

    and-int/lit16 v1, p0, 0xff

    int-to-byte v1, v1

    aput-byte v1, v0, v5

    goto :goto_a

    :pswitch_26
    shr-int/lit8 v1, p0, 0x18

    and-int/lit16 v1, v1, 0xff

    int-to-byte v1, v1

    aput-byte v1, v0, v5

    shr-int/lit8 v1, p0, 0x10

    and-int/lit16 v1, v1, 0xff

    int-to-byte v1, v1

    aput-byte v1, v0, v4

    shr-int/lit8 v1, p0, 0x8

    and-int/lit16 v1, v1, 0xff

    int-to-byte v1, v1

    aput-byte v1, v0, v3

    and-int/lit16 v1, p0, 0xff

    int-to-byte v1, v1

    aput-byte v1, v0, v2

    goto :goto_a

    nop

    :pswitch_data_42
    .packed-switch -0x1
        :pswitch_26
        :pswitch_b
    .end packed-switch
.end method


用smali2java  文件二转换后的代码很清晰:
package com.abc.shop.plugin.a;

public class a
{
  public static int a(byte[] paramArrayOfByte)
  {
    return (0xFF & paramArrayOfByte[0]) << 24 | (0xFF & paramArrayOfByte[1]) << 16 | (0xFF & paramArrayOfByte[2]) << 8 | 0xFF & paramArrayOfByte[3];
  }

  public static byte[] a(int paramInt)
  {
    return a(paramInt, 0);
  }

  public static byte[] a(int paramInt1, int paramInt2)
  {
    byte[] arrayOfByte = new byte[4];
    switch (paramInt2)
    {
    default:
      return arrayOfByte;
    case 0:
      arrayOfByte[0] = ((byte)(0xFF & paramInt1 >> 24));
      arrayOfByte[1] = ((byte)(0xFF & paramInt1 >> 16));
      arrayOfByte[2] = ((byte)(0xFF & paramInt1 >> 8));
      arrayOfByte[3] = ((byte)(paramInt1 & 0xFF));
      return arrayOfByte;
    case -1:
    }
    arrayOfByte[3] = ((byte)(0xFF & paramInt1 >> 24));
    arrayOfByte[2] = ((byte)(0xFF & paramInt1 >> 16));
    arrayOfByte[1] = ((byte)(0xFF & paramInt1 >> 8));
    arrayOfByte[0] = ((byte)(paramInt1 & 0xFF));
    return arrayOfByte;
  }
}


求助一下 文件一 怎么转成JAVA   用smali2java 转换的逻辑都错误了。
文件一:
package com.abc.shop.plugin.a;

public class c
{
  public static byte[] a(int paramInt, String paramString)
  {
    byte[] arrayOfByte1 = paramString.getBytes();
    if (arrayOfByte1.length % 4 == 0);
    int[] arrayOfInt;
    int j;
    int k;
    byte[] arrayOfByte2;
    int i4;
    int i5;
    for (int i = arrayOfByte1.length / 4; ; i = 1 + arrayOfByte1.length / 4)
    {
      arrayOfInt = new int[i];
      j = 0;
      k = 0;
      if (j < arrayOfByte1.length)
        break;
      arrayOfByte2 = new byte[4 * arrayOfInt.length];
      i4 = 0;
      i5 = 0;
      if (i4 < arrayOfInt.length)
        break label227;
      return arrayOfByte2;
    }
    int m;
    label81: int n;
    label94: int i1;
    label107: int i2;
    label120: int i3;
    if (j >= arrayOfByte1.length)
    {
      m = 0;
      if (j + 1 < arrayOfByte1.length)
        break label182;
      n = 32;
      if (j + 2 < arrayOfByte1.length)
        break label193;
      i1 = 32;
      if (j + 3 < arrayOfByte1.length)
        break label204;
      i2 = 32;
      i3 = a.a(new byte[] { m, n, i1, i2 });
      if (k % 2 != 0)
        break label215;
      arrayOfInt[k] = (i3 ^ paramInt);
    }
    while (true)
    {
      k++;
      j += 4;
      break;
      m = arrayOfByte1[j];
      break label81;
      label182: n = arrayOfByte1[(j + 1)];
      break label94;
      label193: i1 = arrayOfByte1[(j + 2)];
      break label107;
      label204: i2 = arrayOfByte1[(j + 3)];
      break label120;
      label215: arrayOfInt[k] = (i3 ^ 0xFFFFFFFF);
    }
    label227: byte[] arrayOfByte3 = a.a(arrayOfInt[i4]);
    int i6 = 0;
    while (true)
    {
      if (i6 >= arrayOfByte3.length)
      {
        i4++;
        break;
      }
      arrayOfByte2[i5] = arrayOfByte3[i6];
      int i7 = i5 + 1;
      i6++;
      i5 = i7;
    }
  }
}

好乱啊,怎么改成JAVA呀?

[培训]科锐逆向工程师培训第53期2025年7月8日开班!

收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 74
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
逻辑错是正常的,自己慢慢读smali把他修复
2015-4-10 22:31
0
雪    币: 201
活跃值: (25)
能力值: (RANK:10 )
在线值:
发帖
回帖
粉丝
3
我有一款工具可以正确地反编译成JAVA代码的
2015-6-27 19:17
0
游客
登录 | 注册 方可回帖
返回