Last active
August 19, 2020 05:59
-
-
Save Saket-Upadhyay/b1a609e7c8cda7d2a73517d4914e724d 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.io.UnsupportedEncodingException; | |
import java.lang.reflect.Array; | |
import java.security.InvalidAlgorithmParameterException; | |
import java.security.InvalidKeyException; | |
import java.security.NoSuchAlgorithmException; | |
import java.util.Base64; | |
public class Main { | |
public static void main(String[] args) throws IllegalAccessException, UnsupportedEncodingException { | |
String KINDOFMAGIC[]={"UEBxWw==", "Sk5xVcOICw==", "bnRX", "S0BgWw==", "Nw==", "R0ZxRMOLElk=", "TkJhWw==", "dHZHdcOl", "eWRNYQ==", "bHRSeMOi", "R05tVw==", "d2hScA==", "T0xyVMOADQ==", "f2pQ", "Q0xsVw==", "Nw=="}; | |
String magic= "7E3Q5fm4lBSKXaHTnlCO52VL/iY6f+hQQ35oeFphtZIu3pf0QuOEpFB5nTeg8GTx"; | |
int length = Array.getLength(KINDOFMAGIC); | |
Base64.Decoder decode=Base64.getDecoder(); | |
byte[] NEWBYTEARRAYKOM = new byte[length]; | |
for (int i = 0; i < length; i++) { | |
Object obj = Array.get(KINDOFMAGIC,i); | |
byte[] invoke3 = decode.decode(obj.toString()); | |
String hmm = d(new String(invoke3,"UTF-8"), i ^ 137); | |
NEWBYTEARRAYKOM[i] = ((byte) hmm.charAt(0)); | |
} | |
a.class.getDeclaredFields()[0].set(null, NEWBYTEARRAYKOM); | |
Base64.Decoder decoder=Base64.getDecoder(); | |
byte[] bdecode=decoder.decode(magic); | |
byte[] ANSWER =a.a(bdecode); | |
//PRINT FLAG | |
System.out.println(new String(ANSWER)); | |
// TOOL FOR DECODING INSTRUCTIONS | |
// System.out.println(d(">JÂ0ûDwù¯0Õ´zhÝ!ë\u000ff", -989022505)); | |
} | |
public static int INTGET=1; | |
public static char a(char c, int i) {return (char) (c & ((1 << i) ^ 65535));} | |
public static char b(char c, int i) { return (char) (c | (1 << i));} | |
public static char c(char c, int i) {return (char) ((c & (1 << i)) >> i);} | |
public static String d(CharSequence charSequence, int i) { | |
StringBuilder sb = new StringBuilder(); | |
if (i == 0) {return sb.toString();} | |
for (int i2 = 0; i2 < charSequence.length(); i2++) { | |
char charAt = charSequence.charAt(i2);char c = (char) (i >> (i2 % 4));int i3 = i2 % 3; | |
if (i3 == 0) { | |
for (int i4 = 0; i4 < 8; i4 += 2) {char c2 = (char) (c(charAt, i4) ^ c(c, i4)); | |
if (c2 == 0) {charAt = a(charAt, i4);} else if (c2 == 1) {charAt = b(charAt, i4);}}} else if (i3 == 1) { | |
for (int i5 = 1; i5 < 8; i5 += 2) { | |
char c3 = (char) (c(charAt, i5) ^ c(c, i5));if (c3 == 0) {charAt = a(charAt, i5); | |
} else if (c3 == 1) {charAt = b(charAt, i5);}}} else if (i3 == 2) { | |
for (int i6 = 0; i6 < 8; i6++) {char c4 = (char) (c(charAt, i6) ^ c(c, i6));if (c4 == 0) {charAt = a(charAt, i6);}else if (c4 == 1) {charAt = b(charAt, i6);}}} | |
sb.append((char) (charAt ^ INTGET)); | |
} | |
return sb.toString(); | |
}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment