rev: add a few more challenges
This commit is contained in:
42
rev/safe_opener/SafeOpener.java
Normal file
42
rev/safe_opener/SafeOpener.java
Normal file
@@ -0,0 +1,42 @@
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
public class SafeOpener {
|
||||
public static void main(String args[]) throws IOException {
|
||||
BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
|
||||
Base64.Encoder encoder = Base64.getEncoder();
|
||||
String encodedkey = "";
|
||||
String key = "";
|
||||
int i = 0;
|
||||
boolean isOpen;
|
||||
|
||||
|
||||
while (i < 3) {
|
||||
System.out.print("Enter password for the safe: ");
|
||||
key = keyboard.readLine();
|
||||
|
||||
encodedkey = encoder.encodeToString(key.getBytes());
|
||||
System.out.println(encodedkey);
|
||||
|
||||
isOpen = openSafe(encodedkey);
|
||||
if (!isOpen) {
|
||||
System.out.println("You have " + (2 - i) + " attempt(s) left");
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean openSafe(String password) {
|
||||
String encodedkey = "cGwzYXMzX2wzdF9tM18xbnQwX3RoM19zYWYz";
|
||||
|
||||
if (password.equals(encodedkey)) {
|
||||
System.out.println("Sesame open");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
System.out.println("Password is incorrect\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
0
rev/safe_opener/a.out
Normal file
0
rev/safe_opener/a.out
Normal file
3
rev/safe_opener/flag.txt
Normal file
3
rev/safe_opener/flag.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
# NOTE: password in source code is base64 encoded
|
||||
|
||||
picoCTF{pl3as3_l3t_m3_1nt0_th3_saf3}
|
Reference in New Issue
Block a user