Skip to content

Instantly share code, notes, and snippets.

@sharpicx
Created July 6, 2024 12:47
Show Gist options
  • Save sharpicx/03ba81f487002a9831d752f9855be7f7 to your computer and use it in GitHub Desktop.
Save sharpicx/03ba81f487002a9831d752f9855be7f7 to your computer and use it in GitHub Desktop.
challenge android
Java.perform(() => {
let RootDetector = Java.use("***.*****.**********.RootDetector");
RootDetector["isRooted"].implementation = function () {
return false; // only for boolean function calling
};
let EmulatorDetector = Java.use("***.*****.*********.EmulatorDetector");
EmulatorDetector["isEmulator"].implementation = function () {
return false; // only for boolean function calling
};
let AntiFrida = Java.use("***.*****.*********.AntiFrida");
AntiFrida["isFridaRunning"].implementation = function () {
return false; // only for boolean function calling
};
});
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;
class HelloWorld {
public static void main(String[] args) {
try {
byte[] key = "*************".getBytes(StandardCharsets.UTF_8);
MessageDigest sha = MessageDigest.getInstance("SHA-256");
byte[] keyBytes = Arrays.copyOf(sha.digest(key), 16);
System.out.println(keyBytes);
SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
byte[] encryptedData = cipher.doFinal("true".getBytes(StandardCharsets.UTF_8));
String base64EncryptedData = Base64.getEncoder().encodeToString(encryptedData);
System.out.println(base64EncryptedData);
System.out.println(checksum(base64EncryptedData));
} catch (Exception e) {
e.printStackTrace();
}
}
private static String checksum(String input) throws NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(input.getBytes(StandardCharsets.UTF_8));
StringBuilder sb = new StringBuilder();
for (byte b : hash) {
sb.append(String.format("%02x", Byte.valueOf(b)));
}
return sb.toString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment