SHARE
TWEET

Untitled

a guest Aug 18th, 2019 119 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package hpandro.java.infosec.activity;
  2.  
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.view.View;
  7. import android.widget.Button;
  8. import android.widget.EditText;
  9. import android.widget.Toast;
  10. import java.security.MessageDigest;
  11. import java.security.NoSuchAlgorithmException;
  12.  
  13. public class TaskActivity extends AppCompatActivity {
  14.   private Button btnLogin;
  15.  
  16.   private EditText edtPassword;
  17.  
  18.   private EditText edtUserName;
  19.  
  20.   private static String SHA1(byte[] paramArrayOfByte) throws NoSuchAlgorithmException { return base16encode(MessageDigest.getInstance("SHA-1").digest(paramArrayOfByte)); }
  21.  
  22.   private static byte[] add(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2) {
  23.     byte[] arrayOfByte = new byte[paramArrayOfByte1.length + paramArrayOfByte2.length];
  24.     System.arraycopy(paramArrayOfByte1, 0, arrayOfByte, 0, paramArrayOfByte1.length);
  25.     System.arraycopy(paramArrayOfByte2, 0, arrayOfByte, paramArrayOfByte1.length, paramArrayOfByte2.length);
  26.     return arrayOfByte;
  27.   }
  28.  
  29.   private static String base16encode(byte[] paramArrayOfByte) throws NoSuchAlgorithmException {
  30.     String str = "";
  31.     int i = paramArrayOfByte.length;
  32.     for (byte b = 0; b < i; b++) {
  33.       str = String.format("%s%02x", new Object[] { str, Byte.valueOf(paramArrayOfByte[b]) });
  34.     }
  35.     return str;
  36.   }
  37.  
  38.   private static byte[] getData() throws Exception {
  39.     byte[] arrayOfByte1 = parseHexString("aa153b5d1fcb55556034df7a27765f4297f195d2", 20);
  40.     byte[] arrayOfByte2 = parseHexString("53edd6990376d7b77512d2b5556613ca2567f04c", 20);
  41.     byte[] arrayOfByte3 = parseHexString("c4495a00bf20b05edea55999211d773d805bd319", 20);
  42.     return xor(h(add(xor(xor(h(add(arrayOfByte1, h(add(arrayOfByte2, h(arrayOfByte3))))), arrayOfByte3), arrayOfByte2), arrayOfByte1)), arrayOfByte3);
  43.   }
  44.  
  45.   private static byte[] h(byte[] paramArrayOfByte) throws Exception { return parseHexString(SHA1(paramArrayOfByte), 20); }
  46.  
  47.   private static byte[] parseHexString(String paramString, int paramInt) {
  48.     byte[] arrayOfByte = new byte[paramInt];
  49.     for (byte b = 0; b < paramInt; b++)
  50.       arrayOfByte[b] = (byte)Integer.parseInt(paramString.substring(b * 2, b * 2 + 2), 16);
  51.     return arrayOfByte;
  52.   }
  53.  
  54.   private static String pass() throws Exception { return base16encode(getData()).substring(12, 24); }
  55.  
  56.   private static String user() throws Exception { return base16encode(getData()).substring(0, 12); }
  57.  
  58.   private static byte[] xor(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2) {
  59.     int i = paramArrayOfByte1.length;
  60.     if (i != paramArrayOfByte2.length)
  61.       return null;
  62.     byte[] arrayOfByte = new byte[i];
  63.     byte b = 0;
  64.     while (true) {
  65.       byte[] arrayOfByte1 = arrayOfByte;
  66.       if (b < i) {
  67.         arrayOfByte[b] = (byte)(paramArrayOfByte1[b] ^ paramArrayOfByte2[b]);
  68.         b++;
  69.         continue;
  70.       }
  71.       return arrayOfByte1;
  72.     }
  73.   }
  74.  
  75.   protected void onCreate(Bundle paramBundle) {
  76.     super.onCreate(paramBundle);
  77.     setContentView(2131361822);
  78.     this.edtUserName = (EditText)findViewById(2131230786);
  79.     this.edtPassword = (EditText)findViewById(2131230785);
  80.     this.btnLogin = (Button)findViewById(2131230757);
  81.     this.btnLogin.setOnClickListener(new View.OnClickListener() {
  82.           public void onClick(View param1View) {
  83.             try {
  84.               if (TaskActivity.this.edtUserName.getText().toString().equals(TaskActivity.user()) && TaskActivity.this.edtPassword.getText().toString().equals(TaskActivity.pass())) {
  85.                 Intent intent = new Intent(TaskActivity.this, SuccessActivity.class);
  86.                 Toast.makeText(TaskActivity.this, "You gotchhha!!", 1).show();
  87.                 TaskActivity.this.startActivity(intent);
  88.                 TaskActivity.this.finish();
  89.                 return;
  90.               }
  91.               Toast.makeText(TaskActivity.this, "Please enter valid data!", 1).show();
  92.               return;
  93.             } catch (Exception param1View) {
  94.               param1View.printStackTrace();
  95.               return;
  96.             }
  97.           }
  98.         });
  99.   }
  100. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top