Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.user.sirius4;
- import android.content.Context;
- import android.content.pm.PackageInfo;
- import android.content.pm.PackageManager$NameNotFoundException;
- import android.content.pm.PackageManager;
- import android.os.Bundle;
- import android.support.v7.app.AppCompatActivity;
- import android.view.View$OnClickListener;
- import android.view.View;
- import android.widget.TextView;
- import java.io.ByteArrayInputStream;
- import java.io.InputStream;
- import java.security.Key;
- import java.security.MessageDigest;
- import java.security.NoSuchAlgorithmException;
- import java.security.spec.AlgorithmParameterSpec;
- import java.util.Arrays;
- import javax.crypto.Cipher;
- import javax.crypto.spec.IvParameterSpec;
- import javax.crypto.spec.SecretKeySpec;
- import javax.security.cert.CertificateEncodingException;
- import javax.security.cert.X509Certificate;
- public class MainActivity extends AppCompatActivity {
- static final byte[] flag;
- static Context mContext;
- static {
- MainActivity.flag = new byte[]{-18, 46, 54, -19, -124, -96, 90, 1, 96, -120, -73, -124, 28, -88, 127, -95, 38, -127, 52, -86, 5, -64, 73, -9, -49, -42, 28, -108, -102, 4, -64, -72};
- }
- public MainActivity() {
- super();
- }
- private static byte[] a() {
- X509Certificate v9_1;
- PackageInfo v4;
- PackageManager v0 = MainActivity.mContext.getPackageManager();
- String v1 = MainActivity.mContext.getPackageName();
- int v2 = 64;
- byte[] v3 = null;
- try {
- v4 = v0.getPackageInfo(v1, v2);
- }
- catch(PackageManager$NameNotFoundException v5) {
- v5.printStackTrace();
- }
- ByteArrayInputStream v7 = new ByteArrayInputStream(v4.signatures[0].toByteArray());
- try {
- v9_1 = X509Certificate.getInstance(((InputStream)v7));
- }
- catch(Exception v9) {
- return v3;
- }
- return MainActivity.b(v9_1);
- }
- private static byte[] b(X509Certificate arg4) {
- byte[] v1;
- byte[] v0 = null;
- try {
- v1 = MessageDigest.getInstance("SHA256").digest(arg4.getEncoded());
- }
- catch(Exception v2) {
- return v0;
- }
- catch(CertificateEncodingException v0_1) {
- v0_1.printStackTrace();
- }
- catch(NoSuchAlgorithmException v0_2) {
- v0_2.printStackTrace();
- }
- return MainActivity.c(v1);
- }
- private static byte[] c(byte[] arg9) {
- int v1 = 100;
- return arg9;
- StackTraceElement[] v0 = v1_1.getStackTrace();
- byte[] v3 = v0[v0.length - 1].getClassName().getBytes();
- int v4;
- for(v4 = 0; v4 < arg9.length; ++v4) {
- int v5 = v3.length;
- int v6;
- for(v6 = 0; v6 < v5; ++v6) {
- arg9[v4] = ((byte)(arg9[v4] ^ v3[v6]));
- }
- }
- return arg9;
- }
- static boolean checkFlag(String arg7) {
- byte[] v0 = MainActivity.a();
- byte[] v1 = new byte[]{-5, -54, 52, -81, -34, 34, -125, 26, -41, 85, -6, -52, -107, -10, -45, 37};
- try {
- IvParameterSpec v2_1 = new IvParameterSpec(v1);
- SecretKeySpec v3 = new SecretKeySpec(v0, "AES");
- Cipher v4 = Cipher.getInstance("AES/CBC/PKCS5PADDING");
- v4.init(1, ((Key)v3), ((AlgorithmParameterSpec)v2_1));
- return Arrays.equals(v4.doFinal(arg7.getBytes("UTF-8")), MainActivity.flag);
- }
- catch(Exception v2) {
- v2.printStackTrace();
- return 0;
- }
- }
- protected void onCreate(Bundle arg3) {
- super.onCreate(arg3);
- this.setContentView(2131296283);
- MainActivity.mContext = this.getApplicationContext();
- MainActivity.a();
- this.findViewById(2131165218).setOnClickListener(new View$OnClickListener() {
- public void onClick(View arg5) {
- String v1 = MainActivity.this.findViewById(2131165239).getText().toString();
- View v2 = MainActivity.this.findViewById(2131165324);
- if(MainActivity.checkFlag(v1)) {
- ((TextView)v2).setText("Correct! Congrats!");
- }
- else {
- ((TextView)v2).setText("Wrong! Try harder!");
- }
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement