Contents

picoCTF - Reverse Engineering - Safe Opener


Reverse Engineering - Safe Opener - writeup

description

Can you open this safe?

I forgot the key to my safe but this program is supposed to help me with retrieving the lost key.

Can you help me unlock my safe?

Put the password you recover into the picoCTF flag format like: picoCTF{password}

writeup

The “safe” is a .java file.

Since .java is used for java source code this should be fairly easy to reverse engineer.

In the main method of the class ‘SafeOpener’, directly at the top I see this:

1
2
Base64.Encoder encoder = Base64.getEncoder();
String encodedkey = "";

So the key is simply encoded in base64.

Inside the method ‘boolean openSafe(String password)’ I found this:

1
String encodedkey = "cGwzYXMzX2wzdF9tM18xbnQwX3RoM19zYWYz";

So that is the encoded key.

All I have to do here is to decode the aforementioned key using base64 decoding.

1
2
3
echo -n "cGwzYXMzX2wzdF9tM18xbnQwX3RoM19zYWYz" | base64 -d

pl3as3_l3t_m3_1nt0_th3_saf3

That should be the correct password.

Let’s compile and run that java code…

1
javac SafeOpener.java
1
java SafeOpener
1
2
3
Enter password for the safe: pl3as3_l3t_m3_1nt0_th3_saf3
cGwzYXMzX2wzdF9tM18xbnQwX3RoM19zYWYz
Sesame open

And here we have our flag.

1
picoCTF{pl3as3_l3t_m3_1nt0_th3_saf3}