Last active
August 18, 2020 11:50
-
-
Save Saket-Upadhyay/59b2161e0fd43be02ee766ea06aef2ea to your computer and use it in GitHub Desktop.
SCTF ANDROID CHAL SOL 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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