What can you do with this file? I forgot the key to my safe but this file is supposed to help me with retrieving the lost key. Can you help me unlock my safe?
This was another very straight foward reverse engineering challenge. We can use file to see what type file this is. Since it is a complied Java class file, we need to decompile it to see the code.
We can use many open-source tools that decompile Java class code. Since this is a simple challenge, I just used a online Java Decomplier. From the decomplied code, we will get the flag.
importjava.io.BufferedReader;importjava.io.IOException;importjava.io.InputStreamReader;importjava.util.Base64;importjava.util.Base64.Encoder;publicclassSafeOpener {publicstaticvoidmain(String[] args) throwsIOException {BufferedReader keyboard =newBufferedReader(new InputStreamReader(System.in));Encoder encoder =Base64.getEncoder();String encodedkey ="";String key ="";for(int i =0; i <3; ++i) {System.out.print("Enter password for the safe: "); key =keyboard.readLine(); encodedkey =encoder.encodeToString(key.getBytes());System.out.println(encodedkey);boolean isOpen =openSafe(encodedkey);if (isOpen) {break; }System.out.println("You have "+ (2- i) +" attempt(s) left"); } }publicstaticbooleanopenSafe(String password) {String encodedkey ="picoCTF{SAf3_0p3n3rr_y0u_solv3d_it_0e57c117}";if (password.equals(encodedkey)) {System.out.println("Sesame open");returntrue; } else {System.out.println("Password is incorrect");returnfalse; } }}