2022picoCTF题目地址
https://play.picoctf.org/practice?category=3&originalEvent=70&page=1
我们下载java程序后打开 一目了然,非常简单,答案已经出来了
源代码分析
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(); #使用了base64加密方式
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); #给我们输入的字符以base64方式加密
isOpen = openSafe(encodedkey);
if (!isOpen) {
System.out.println("You have " + (2 - i) + " attempt(s) left");
i++;
continue;
}
break;
}
}
public static boolean openSafe(String password) { #告诉我们这是flag
String encodedkey = "cGwzYXMzX2wzdF9tM18xbnQwX3RoM19zYWYz"; #加密字符,base64解密即可
if (password.equals(encodedkey)) {
System.out.println("Sesame open");
return true;
}
else {
System.out.println("Password is incorrect\n");
return false;
}
}
}
flag
|