picoCTF Vault Door 1 Writeup: Reassemble a Password from Scrambled charAt Checks

Rev Eng 2026-10-19 · Updated 2026-11-21 · picoGym · By CTFdojo · ⏱ ... · 👁 ... views
𝕏 Share
TL;DR

Like Vault Door Training, main() strips picoCTF{ and }. This time checkPassword() requires length 32 and then checks each position with password.charAt(i) == 'x', listed in a deliberately scrambled order. Collect the pairs, sort by index, join.

PlatformpicoGym (picoCTF 2019)
Verified againstrmn0x01's Vault Door series writeup
CategoryReverse Engineering
DifficultyBeginner
Tools python3 text editor

Challenge description

The second Vault Door hides the same kind of hard-coded password, but splits it into 32 single-character checks and shuffles them.

Provided: VaultDoor1.java

Stuck? Try a hint before reading the solution

Hint 1

Every character is checked individually — just not in order.

Hint 2

Collect the charAt(i) == 'c' pairs and sort them by index.

Step 1 — Read the check

checkPassword() is one long boolean expression:

public boolean checkPassword(String password) {
    return password.length() == 32 &&
           password.charAt(0)  == '?' &&
           password.charAt(29) == '?' &&
           password.charAt(4)  == '?' &&
           password.charAt(2)  == '?' &&
           ...
           password.charAt(31) == '?';
}

Every one of the 32 positions has exactly one check, but the indices jump around so the password can't be read top to bottom.

Step 2 — Sort the checks by index

Rather than reordering 32 lines by hand, extract the (index, character) pairs with a regular expression and sort them:

import re, sys

src = open(sys.argv[1]).read()
pairs = re.findall(r"charAt\((\d+)\)\s*==\s*'(.)'", src)
chars = dict((int(i), c) for i, c in pairs)
print("".join(chars[i] for i in range(len(chars))))
$ python3 rebuild.py VaultDoor1.java
[32-character password]

If the script raises a KeyError, a check didn't match the pattern — open the file and look for an unusual spacing or escaped character.

Step 3 — Wrap and verify

Put the result inside picoCTF{...} and confirm with the program itself:

$ javac VaultDoor1.java && java VaultDoor1
Enter vault password: picoCTF{[32-character password]}
Access granted.
🚩 picoCTF{flag intentionally hidden}

The flag is deliberately hidden — follow the method, you've earned it. 💪

Key takeaways

Shuffling the checks slows down a human reader, not a script:

Resources

CTFdojo
CTFdojo
Community of ethical hackers writing beginner-friendly CTF writeups and guides.

Got a question or a different approach?

Discuss this writeup with the community on the CTFdojo Discord.

Join the Discord →