EzicMan

especially for reverse

Nov 23rd, 2018
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.user.sirius4;
  2.  
  3. import android.content.Context;
  4. import android.content.pm.PackageInfo;
  5. import android.content.pm.PackageManager$NameNotFoundException;
  6. import android.content.pm.PackageManager;
  7. import android.os.Bundle;
  8. import android.support.v7.app.AppCompatActivity;
  9. import android.view.View$OnClickListener;
  10. import android.view.View;
  11. import android.widget.TextView;
  12. import java.io.ByteArrayInputStream;
  13. import java.io.InputStream;
  14. import java.security.Key;
  15. import java.security.MessageDigest;
  16. import java.security.NoSuchAlgorithmException;
  17. import java.security.spec.AlgorithmParameterSpec;
  18. import java.util.Arrays;
  19. import javax.crypto.Cipher;
  20. import javax.crypto.spec.IvParameterSpec;
  21. import javax.crypto.spec.SecretKeySpec;
  22. import javax.security.cert.CertificateEncodingException;
  23. import javax.security.cert.X509Certificate;
  24.  
  25. public class MainActivity extends AppCompatActivity {
  26. static final byte[] flag;
  27. static Context mContext;
  28.  
  29. static {
  30. 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};
  31. }
  32.  
  33. public MainActivity() {
  34. super();
  35. }
  36.  
  37. private static byte[] a() {
  38. X509Certificate v9_1;
  39. PackageInfo v4;
  40. PackageManager v0 = MainActivity.mContext.getPackageManager();
  41. String v1 = MainActivity.mContext.getPackageName();
  42. int v2 = 64;
  43. byte[] v3 = null;
  44. try {
  45. v4 = v0.getPackageInfo(v1, v2);
  46. }
  47. catch(PackageManager$NameNotFoundException v5) {
  48. v5.printStackTrace();
  49. }
  50.  
  51. ByteArrayInputStream v7 = new ByteArrayInputStream(v4.signatures[0].toByteArray());
  52. try {
  53. v9_1 = X509Certificate.getInstance(((InputStream)v7));
  54. }
  55. catch(Exception v9) {
  56. return v3;
  57. }
  58.  
  59. return MainActivity.b(v9_1);
  60. }
  61.  
  62. private static byte[] b(X509Certificate arg4) {
  63. byte[] v1;
  64. byte[] v0 = null;
  65. try {
  66. v1 = MessageDigest.getInstance("SHA256").digest(arg4.getEncoded());
  67. }
  68. catch(Exception v2) {
  69. return v0;
  70. }
  71. catch(CertificateEncodingException v0_1) {
  72. v0_1.printStackTrace();
  73. }
  74. catch(NoSuchAlgorithmException v0_2) {
  75. v0_2.printStackTrace();
  76. }
  77.  
  78. return MainActivity.c(v1);
  79. }
  80.  
  81. private static byte[] c(byte[] arg9) {
  82. int v1 = 100;
  83. return arg9;
  84. StackTraceElement[] v0 = v1_1.getStackTrace();
  85. byte[] v3 = v0[v0.length - 1].getClassName().getBytes();
  86. int v4;
  87. for(v4 = 0; v4 < arg9.length; ++v4) {
  88. int v5 = v3.length;
  89. int v6;
  90. for(v6 = 0; v6 < v5; ++v6) {
  91. arg9[v4] = ((byte)(arg9[v4] ^ v3[v6]));
  92. }
  93. }
  94.  
  95. return arg9;
  96. }
  97.  
  98. static boolean checkFlag(String arg7) {
  99. byte[] v0 = MainActivity.a();
  100. byte[] v1 = new byte[]{-5, -54, 52, -81, -34, 34, -125, 26, -41, 85, -6, -52, -107, -10, -45, 37};
  101. try {
  102. IvParameterSpec v2_1 = new IvParameterSpec(v1);
  103. SecretKeySpec v3 = new SecretKeySpec(v0, "AES");
  104. Cipher v4 = Cipher.getInstance("AES/CBC/PKCS5PADDING");
  105. v4.init(1, ((Key)v3), ((AlgorithmParameterSpec)v2_1));
  106. return Arrays.equals(v4.doFinal(arg7.getBytes("UTF-8")), MainActivity.flag);
  107. }
  108. catch(Exception v2) {
  109. v2.printStackTrace();
  110. return 0;
  111. }
  112. }
  113.  
  114. protected void onCreate(Bundle arg3) {
  115. super.onCreate(arg3);
  116. this.setContentView(2131296283);
  117. MainActivity.mContext = this.getApplicationContext();
  118. MainActivity.a();
  119. this.findViewById(2131165218).setOnClickListener(new View$OnClickListener() {
  120. public void onClick(View arg5) {
  121. String v1 = MainActivity.this.findViewById(2131165239).getText().toString();
  122. View v2 = MainActivity.this.findViewById(2131165324);
  123. if(MainActivity.checkFlag(v1)) {
  124. ((TextView)v2).setText("Correct! Congrats!");
  125. }
  126. else {
  127. ((TextView)v2).setText("Wrong! Try harder!");
  128. }
  129. }
  130. });
  131. }
  132. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×