小弟逆了一个smali里面的反法 想找牛人帮忙看看 是不是逆的不对 因为结果有问题是一个AES的加密算法smali 如下: 这个算法我用了之后发现和app里面加密结果不一样 所以应该是逆错了 但是我又不知道哪里错了。。。。
.locals 10
.annotation build Landroid/annotation/SuppressLint;
value = {
"TrulyRandom"
}
.end annotation
const/4 v0, 0x0
const/4 v1, 0x0
:try_start_0
array-length v3, p3
invoke-static {p0}, Ljavax/crypto/Cipher;->getInstance(Ljava/lang/String;)Ljavax/crypto/Cipher;
move-result-object v4
const/4 v2, 0x1
invoke-virtual {v4, v2, p1, p2}, Ljavax/crypto/Cipher;->init(ILjava/security/Key;Ljava/security/spec/AlgorithmParameterSpec;)V
invoke-virtual {v4}, Ljavax/crypto/Cipher;->getBlockSize()I
move-result v2
array-length v5, p3
rem-int/2addr v5, v2
sub-int v5, v2, v5
array-length v2, p3
add-int/2addr v2, v5
new-array v6, v2, [B
const/4 v2, 0x0
const/4 v7, 0x0
array-length v8, p3
invoke-static {p3, v2, v6, v7, v8}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
move v2, v1
:goto_0
if-ge v2, v5, :cond_0
array-length v7, p3
add-int/2addr v7, v2
const-string v8, "0"
invoke-virtual {v8}, Ljava/lang/String;->getBytes()[B
move-result-object v8
const/4 v9, 0x0
aget-byte v8, v8, v9
aput-byte v8, v6, v7
add-int/lit8 v2, v2, 0x1
goto :goto_0
:cond_0
array-length v2, v6
sub-int/2addr v2, v3
add-int/lit8 v2, v2, 0x10
new-instance v3, Ljava/lang/StringBuilder;
const-string v5, "00000000000000"
invoke-direct {v3, v5}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-static {v2}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;
move-result-object v2
invoke-virtual {v3, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/String;->getBytes()[B
move-result-object v3
array-length v5, v6
if-eqz v3, :cond_4
array-length v1, v3
move v2, v1
:goto_1
add-int v1, v5, v2
if-lez v1, :cond_3
add-int v1, v5, v2
new-array v1, v1, [B
:goto_2
if-lez v5, :cond_1
const/4 v7, 0x0
const/4 v8, 0x0
invoke-static {v6, v7, v1, v8, v5}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
:cond_1
if-lez v2, :cond_2
const/4 v6, 0x0
invoke-static {v3, v6, v1, v5, v2}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
:cond_2
invoke-virtual {v4, v1}, Ljavax/crypto/Cipher;->doFinal([B)[B
:try_end_0
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_0 .. :try_end_0} :catch_0
.catch Ljavax/crypto/NoSuchPaddingException; {:try_start_0 .. :try_end_0} :catch_1
.catch Ljava/security/InvalidKeyException; {:try_start_0 .. :try_end_0} :catch_2
.catch Ljava/security/InvalidAlgorithmParameterException; {:try_start_0 .. :try_end_0} :catch_3
.catch Ljavax/crypto/IllegalBlockSizeException; {:try_start_0 .. :try_end_0} :catch_4
.catch Ljavax/crypto/BadPaddingException; {:try_start_0 .. :try_end_0} :catch_5
move-result-object v0
:goto_3
return-object v0
:catch_0
move-exception v1
const-string v2, "AES"
new-instance v3, Ljava/lang/StringBuilder;
const-string v4, "AES~~~"
invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-static {v2, v1}, Lcom/bilin/huijiao/g/v;->d(Ljava/lang/String;Ljava/lang/String;)V
goto :goto_3
:catch_1
move-exception v1
const-string v2, "AES"
new-instance v3, Ljava/lang/StringBuilder;
const-string v4, "AES~~~"
invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-static {v2, v1}, Lcom/bilin/huijiao/g/v;->d(Ljava/lang/String;Ljava/lang/String;)V
goto :goto_3
:catch_2
move-exception v1
const-string v2, "AES"
new-instance v3, Ljava/lang/StringBuilder;
const-string v4, "AES~~~"
invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-static {v2, v1}, Lcom/bilin/huijiao/g/v;->d(Ljava/lang/String;Ljava/lang/String;)V
goto :goto_3
:catch_3
move-exception v1
const-string v2, "AES"
new-instance v3, Ljava/lang/StringBuilder;
const-string v4, "AES~~~"
invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-static {v2, v1}, Lcom/bilin/huijiao/g/v;->d(Ljava/lang/String;Ljava/lang/String;)V
goto :goto_3
:catch_4
move-exception v1
const-string v2, "AES"
new-instance v3, Ljava/lang/StringBuilder;
const-string v4, "AES~~~"
invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-static {v2, v1}, Lcom/bilin/huijiao/g/v;->d(Ljava/lang/String;Ljava/lang/String;)V
goto :goto_3
:catch_5
move-exception v1
const-string v2, "AES"
new-instance v3, Ljava/lang/StringBuilder;
const-string v4, "AES~~~"
invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-static {v2, v1}, Lcom/bilin/huijiao/g/v;->d(Ljava/lang/String;Ljava/lang/String;)V
goto/16 :goto_3
:cond_3
move-object v1, v0
goto/16 :goto_2
:cond_4
move v2, v1
goto/16 :goto_1
Java 代码:
private byte[] a(String paramString,
SecretKey paramSecretKey,
IvParameterSpec paramIvParameterSpec,
byte[] paramArrayOfByte)
{
try
{
int i2 = 0;
byte[] arrayOfByte3 = null;
int i = paramArrayOfByte.length;
Cipher localCipher = Cipher.getInstance(paramString);
localCipher.init(1, paramSecretKey, paramIvParameterSpec);
int j = localCipher.getBlockSize();
int k = j - (paramArrayOfByte.length % j);
byte[] arrayOfByte1 = new byte[k + paramArrayOfByte.length];
System.arraycopy(paramArrayOfByte, 0, arrayOfByte1, 0, paramArrayOfByte.length);
for (int m = 0; m <k; m++) {
arrayOfByte1[(m + paramArrayOfByte.length)] = "0".getBytes()[0];
}
int n = 16 + (arrayOfByte1.length - i);
StringBuilder stringBuilder = new StringBuilder("00000000000000");
stringBuilder.append(String.valueOf(n));
byte[] arrayOfByte2 = (stringBuilder.toString()).getBytes();
int i1 = arrayOfByte1.length;
byte[] arrayOfByte4;
if (arrayOfByte2 != null){
if (i1 + i2 > 0)
arrayOfByte3 = new byte[i1 + i2];
if (i1 > 0)
System.arraycopy(arrayOfByte1, 0, arrayOfByte3, 0, i1);
if (i2 > 0)
System.arraycopy(arrayOfByte2, 0, arrayOfByte3, i1, i2);
arrayOfByte4 = localCipher.doFinal(arrayOfByte3);
return arrayOfByte4;
}
i2 = arrayOfByte2.length;
return null;
}
catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
{
System.out.println("AES~~~" + localNoSuchAlgorithmException);
return null;
}
catch (NoSuchPaddingException localNoSuchPaddingException)
{
System.out.println("AES~~~" + localNoSuchPaddingException);
return null;
}
catch (InvalidKeyException localInvalidKeyException)
{
System.out.println("AES~~~" + localInvalidKeyException);
return null;
}
catch (InvalidAlgorithmParameterException localInvalidAlgorithmParameterException)
{
System.out.println("AES~~~" + localInvalidAlgorithmParameterException);
return null;
}
catch (IllegalBlockSizeException localIllegalBlockSizeException)
{
System.out.println("AES~~~" + localIllegalBlockSizeException);
return null;
}
catch (BadPaddingException localBadPaddingException)
{
System.out.println("AES~~~" + localBadPaddingException);
return null;
}
}
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!