1419 words
7 minutes
PicoCTF Reverse Challenge - Vault Door 1 - 6.

Introduction#

This part will explain how to solve the Vault-door challenges, which are written in .java. To solve these, all you really need is basic knowledge of the Java language, and everything will be pretty straightforward.

alt text

#Vault-door-1#

alt text

NOTE

There used to be 2 more challenges before this, vault-door-0 and vault-door-2. But for some reason they got removed - probably because they were considered too easy to count as Reverse Engineering.

Starting with vault-door-1, we’ve got a block that prints the flag (which I’ll skip over) and a check_password function. We can start our analysis from here.

alt text

Looking at this, we probably already have the flag figured out in our head, but it’s a bit of a pain since the characters are scrambled rather than kept in their original order.

You could do this by hand, but for this challenge I’ll write a python script instead.

Using a Python list to speed up the sorting. We’ll lay out each password line like this:

  • flag[0] = ‘a’
  • flag[1] = ‘b’
  • …
  • flag[32] = ‘c’

alt text

Once it’s all written out, it ends up looking like this:

flag = [None] * 32
flag[0]  = 'd' 
flag[29] = '9' 
flag[4]  = 'r' 
flag[2]  = '5' 
flag[23] = 'r' 
flag[3]  = 'c' 
flag[17] = '4' 
flag[1]  = '3' 
flag[7]  = 'b' 
flag[10] = '_' 
flag[5]  = '4' 
flag[9]  = '3' 
flag[11] = 't' 
flag[15] = 'c' 
flag[8]  = 'l' 
flag[12] = 'H' 
flag[20] = 'c' 
flag[14] = '_' 
flag[6]  = 'm' 
flag[24] = '5' 
flag[18] = 'r' 
flag[13] = '3' 
flag[19] = '4' 
flag[21] = 'T' 
flag[16] = 'H' 
flag[27] = '5' 
flag[30] = '2' 
flag[25] = '_' 
flag[22] = '3' 
flag[28] = '0' 
flag[26] = '7' 
flag[31] = 'e';

print("picoCTF{" + ''.join(flag[i] for i in range(32)) + "}")'

So that takes care of the sorting part, and everything gets written out in a single line of code ^_o.

Flag: picoCTF{d35cr4mbl3_tH3_cH4r4cT3r5_75092e}

#Vault-door-3#

alt text

The challenge description is short and to the point: “This vault uses for-loops and byte arrays.” Looking at checkPassword, this is immediately recognizable as a character-permutation challenge (same as vault-door-1), but more complex - the 32-character buffer is split into 4 segments, each shuffled in a different way:

public boolean checkPassword(String password) {
    if (password.length() != 32) {
        return false;
    }
    char[] buffer = new char[32];
    int i;
    for (i=0; i<8; i++) {
        buffer[i] = password.charAt(i);
    }
    for (; i<16; i++) {
        buffer[i] = password.charAt(23-i);
    }
    for (; i<32; i+=2) {
        buffer[i] = password.charAt(46-i);
    }
    for (i=31; i>=17; i-=2) {
        buffer[i] = password.charAt(i);
    }
    String s = new String(buffer);
    return s.equals("jU5t_a_sna_3lpm10g747_u_4_m7re49");
}

Going through each loop to figure out where buffer[i] maps back to in password[?]:

  • i = 0..7: buffer[i] = password[i] - stays in the same position.
  • i = 8..15: buffer[i] = password[23-i] - segment 8-15 reversed.
  • i = 16,18,...,30 (step 2): buffer[i] = password[46-i] - even positions pulled from the mirrored side.
  • i = 31,29,...,17 (step -2): buffer[i] = password[i] - odd positions stay in place.

Since I know buffer has to equal the target string, I just need to reverse each formula to work password back out from the target - no brute-forcing needed, it’s purely algebra.

target = "jU5t_a_sna_3lpm10g747_u_4_m7re49"
password = [None] * 32

for i in range(8):
    password[i] = target[i]
for i in range(8, 16):
    password[23 - i] = target[i]
for i in range(16, 32, 2):
    password[46 - i] = target[i]
for i in range(31, 16, -2):
    password[i] = target[i]

print("academy{" + "".join(password) + "}")

This gives jU5t_a_s1mpl3_an4gr4m_4_u_777e09 - read it aloud and it really is “just a simple anagram”. I also wrote a quick simulation of checkPassword in Python and ran it against this result, just to be sure it actually matches the target and I didn’t flip a +/- sign somewhere in the reverse formulas by mistake.

Flag: academy{jU5t_a_s1mpl3_an4gr4m_4_u_777e09}

alt text

#Vault-door-4#

alt text

The description trolls you a bit: “I made myself dizzy converting all of these numbers into different bases…” - open the file and you immediately see why:

byte[] myBytes = {
    106 , 85  , 53  , 116 , 95  , 52  , 95  , 98  ,
    0x55, 0x6e, 0x43, 0x68, 0x5f, 0x30, 0x66, 0x5f,
    0142, 0131, 0164, 063 , 0163, 0137, 070 , 070 ,
    'a' , '3' , '1' , 'd' , 'a' , 'd' , '6' , 'c' ,
};

4 lines, 4 different numeral bases, all inside the same byte array: line 1 is decimal, line 2 is hex (0x), line 3 is octal (numbers starting with 0 and no x), and line 4 is character literals. Java allows mixing these because they all resolve down to the same byte type at compile time. checkPassword just compares each byte of the password against this array - no permutation involved this time, so all you need is to decode the bases correctly and the password falls right out, no guessing required.

my_bytes = [
    106, 85, 53, 116, 95, 52, 95, 98,
    0x55, 0x6e, 0x43, 0x68, 0x5f, 0x30, 0x66, 0x5f,
    0o142, 0o131, 0o164, 0o63, 0o163, 0o137, 0o70, 0o70,
    ord('a'), ord('3'), ord('1'), ord('d'), ord('a'), ord('d'), ord('6'), ord('c'),
]
password = bytes(my_bytes).decode()
print("academy{" + password + "}")

This gives jU5t_4_bUnCh_0f_bYt3s_88a31dad6c (“just a bunch of bytes”). I double-checked this by re-encoding the password back into bytes and comparing it element by element against the original myBytes - a perfect match.

Flag: academy{jU5t_4_bUnCh_0f_bYt3s_88a31dad6c}

alt text

#Vault-door-5#

alt text

This one’s description trolls you even more blatantly - there’s a comment right in the code that says: “URL encoding is meant for web pages… defintely not vault door! Oh wait, should I have not said that in a source code comment?” That’s basically a spoiler for how to solve it:

public boolean checkPassword(String password) {
    String urlEncoded = urlEncode(password.getBytes());
    String base64Encoded = base64Encode(urlEncoded.getBytes());
    String expected = "JTYzJTMwJTZlJTc2..."; // (truncated)
    return base64Encoded.equals(expected);
}

The processing flow is password → urlEncode → base64Encode → compared against expected. So to get the password back, we just need to go in reverse: expected → base64-decode → urlDecode.

import base64

expected_b64 = (
    "JTYzJTMwJTZlJTc2JTMzJTcyJTc0JTMxJTZlJTY3JTVm"
    "JTY2JTcyJTMwJTZkJTVmJTYyJTYxJTM1JTY1JTVmJTM2"
    "JTM0JTVmJTMzJTYzJTYzJTM4JTYxJTM5JTY0JTM2"
)

url_encoded = base64.b64decode(expected_b64).decode()   # "%63%30%6e%76..."
parts = url_encoded.split("%")[1:]
password = bytes(int(p, 16) for p in parts).decode()

print("academy{" + password + "}")

This gives c0nv3rt1ng_fr0m_ba5e_64_3cc8a9d6 (“converting from base 64”). I also re-encoded this password the forward way (urlEncode, then base64Encode) and compared it against the original expected string - it matched, so this is definitely not a coincidence.

Flag: academy{c0nv3rt1ng_fr0m_ba5e_64_3cc8a9d6}

alt text

#Vault-door-6#

alt text

The description quotes Bruce Schneier’s Applied Cryptography, but the actual result is just a plain XOR - the most fun one in the whole series:

public boolean checkPassword(String password) {
    byte[] passBytes = password.getBytes();
    byte[] myBytes = {
        0x3b, 0x65, 0x21, 0xa , 0x38, 0x0 , 0x36, 0x1d,
        0xa , 0x3d, 0x61, 0x27, 0x11, 0x66, 0x27, 0xa ,
        0x21, 0x1d, 0x61, 0x3b, 0xa , 0x2d, 0x65, 0x27,
        0xa , 0x6d, 0x65, 0x6d, 0x66, 0x63, 0x62, 0x37,
    };
    for (int i=0; i<32; i++) {
        if (((passBytes[i] ^ 0x55) - myBytes[i]) != 0) {
            return false;
        }
    }
    return true;
}

The condition (passBytes[i] ^ 0x55) - myBytes[i] == 0 is equivalent to passBytes[i] ^ 0x55 == myBytes[i]. Since XOR is self-inverse (A ^ B = C implies C ^ B = A), we just need to XOR with 0x55 again to get each byte of the password back:

my_bytes = [
    0x3b, 0x65, 0x21, 0x0a, 0x38, 0x00, 0x36, 0x1d,
    0x0a, 0x3d, 0x61, 0x27, 0x11, 0x66, 0x27, 0x0a,
    0x21, 0x1d, 0x61, 0x3b, 0x0a, 0x2d, 0x65, 0x27,
    0x0a, 0x6d, 0x65, 0x6d, 0x66, 0x63, 0x62, 0x37,
]
password = bytes(b ^ 0x55 for b in my_bytes).decode()
print("academy{" + password + "}")

# verify the forward direction of the check
assert all(((b ^ 0x55) - my_bytes[i]) == 0 for i, b in enumerate(password.encode()))

This gives n0t_mUcH_h4rD3r_tH4n_x0r_808367b (“not much harder than xor” - the challenge basically grading its own difficulty). The script also includes an assert line to verify the original condition - running without error means it’s correct.

Flag: academy{n0t_mUcH_h4rD3r_tH4n_x0r_808367b}

alt text

I submitted all 4 flags directly on CyLab Academy and got “Correct flag!” for every single one - matching what the scripts computed.

Summary#

6/6 doors done. A few takeaways:

  • At its core, this whole series only revolves around 2 techniques: character-position permutation (doors 1, 3) and encode/transform then compare (door 4: multi-base byte array, door 5: url-encode + base64, door 6: XOR). There’s no brute-forcing anywhere across all 6 challenges - every single one can be solved purely through algebra/reversing the function.
  • Always write a script to verify in the forward direction (running the actual original checkPassword with the password you derived) instead of just trusting the reversed result blindly - I made an off-by-index mistake once while working on door 3 (mixed up the position for 46-i), and the simulation script caught the error immediately, saving me from submitting a wrong flag to the system.
PicoCTF Reverse Challenge - Vault Door 1 - 6.
https://stewmalwarehunter.id.vn/posts/vaultdoor-1-6-vault-door-en/
Author
Stew
Published at
2025-07-26
License
CC BY-NC-SA 4.0