Skip to content

Instantly share code, notes, and snippets.

@Saket-Upadhyay
Last active August 18, 2020 11:50
Show Gist options
  • Save Saket-Upadhyay/59b2161e0fd43be02ee766ea06aef2ea to your computer and use it in GitHub Desktop.
Save Saket-Upadhyay/59b2161e0fd43be02ee766ea06aef2ea to your computer and use it in GitHub Desktop.
SCTF ANDROID CHAL SOL 1
package com.x64mayhem;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
public class a {
public static byte[] f821a; //THIS VAR GETS THE KEY
public static byte[] a(byte[] bArr) {
//DECRYPT
Class<a> cls = a.class;
try {
Cipher AESCBC = Cipher.getInstance("AES/CBC/PKCS5Padding");
SecretKeySpec keyspec = new SecretKeySpec((byte[]) cls.getDeclaredFields()[0].get(null), "AES");
IvParameterSpec IVSPEC = new IvParameterSpec((byte[]) cls.getDeclaredFields()[0].get(null));
AESCBC.init(Cipher.DECRYPT_MODE, keyspec, IVSPEC);
return (byte[]) AESCBC.doFinal(bArr);
} catch (NoSuchPaddingException ex) {
ex.printStackTrace();} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();} catch (InvalidAlgorithmParameterException ex) {
ex.printStackTrace();} catch (InvalidKeyException ex) {
ex.printStackTrace();} catch (BadPaddingException ex) {
ex.printStackTrace();} catch (IllegalBlockSizeException ex) {
ex.printStackTrace();} catch (IllegalAccessException e) {e.printStackTrace();}
return null;}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment