Skip to content

Instantly share code, notes, and snippets.

@mzennis
Created December 16, 2024 08:48
Show Gist options
  • Save mzennis/3c6aa9d4a5a9194b8792b932b2f6808d to your computer and use it in GitHub Desktop.
Save mzennis/3c6aa9d4a5a9194b8792b932b2f6808d to your computer and use it in GitHub Desktop.
import android.util.Base64;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
/**
* Created by mzennis on 16/12/2024
*/
@RunWith(AndroidJUnit4.class)
public class UncrackableApp1Test {
@Test
public void unfoldTheSecretT()
throws NoSuchPaddingException, IllegalBlockSizeException,
NoSuchAlgorithmException, BadPaddingException, InvalidKeyException
{
byte[] firstArg = b("8d127684cbc37c17616d806cf50473cc"); // secret key
byte[] secondArg = Base64.decode("5UJiFctbmgbDoLXmpL12mkno8HT4Lv8dlat8FxR2GOc=", 0);
System.out.println(
new String(
a(firstArg, secondArg) // put all together
)
);
}
public static byte[] a(byte[] bArr, byte[] bArr2)
throws NoSuchPaddingException, NoSuchAlgorithmException,
InvalidKeyException, IllegalBlockSizeException, BadPaddingException
{
SecretKeySpec secretKeySpec = new SecretKeySpec(bArr, "AES/ECB/PKCS7Padding");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(2, secretKeySpec);
return cipher.doFinal(bArr2);
}
public static byte[] b(String str) {
int length = str.length();
byte[] bArr = new byte[length / 2];
for (int i = 0; i < length; i += 2) {
bArr[i / 2] = (byte) ((Character.digit(str.charAt(i), 16) << 4) + Character.digit(str.charAt(i + 1), 16));
}
return bArr;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment