Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. class VaultDoor3 {
  4.     public static void main(String args[]) {
  5.         VaultDoor3 vaultDoor = new VaultDoor3();
  6.         Scanner scanner = new Scanner(System.in);
  7.         System.out.print("Enter vault password: ");
  8.         String userInput = scanner.next();
  9.     String input = userInput.substring("picoCTF{".length(),userInput.length()-1);
  10.     if (vaultDoor.checkPassword(input)) {
  11.         System.out.println("Access granted.");
  12.     } else {
  13.         System.out.println("Access denied!");
  14.         }
  15.     }
  16.  
  17.     // Our security monitoring team has noticed some intrusions on some of the
  18.     // less secure doors. Dr. Evil has asked me specifically to build a stronger
  19.     // vault door to protect his Doomsday plans. I just *know* this door will
  20.     // keep all of those nosy agents out of our business. Mwa ha!
  21.     //
  22.     // -Minion #2671
  23.     public boolean checkPassword(String password) {
  24.         if (password.length() != 32) {
  25.             return false;
  26.         }
  27.         char[] buffer = new char[32];
  28.         int i;
  29.         for (i=0; i<8; i++) {
  30.             buffer[i] = password.charAt(i);
  31.         }
  32.         for (; i<16; i++) {
  33.             buffer[i] = password.charAt(23-i);
  34.         }
  35.         for (; i<32; i+=2) {
  36.             buffer[i] = password.charAt(46-i);
  37.         }
  38.         for (i=31; i>=17; i-=2) {
  39.             buffer[i] = password.charAt(i);
  40.         }
  41.         String s = new String(buffer);
  42.         return s.equals("jU5t_a_sna_3lpm1dg347_u_4_mfr54b");
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement