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.
| Platform | picoGym (picoCTF 2019) |
| Verified against | rmn0x01's Vault Door series writeup |
| Category | Reverse Engineering |
| Difficulty | Beginner |
| Tools | python3 text editor |
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
Every character is checked individually — just not in order.
Collect the charAt(i) == 'c' pairs and sort them by index.
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.
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.
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.
The flag is deliberately hidden — follow the method, you've earned it. 💪
Shuffling the checks slows down a human reader, not a script:
charAt(i) == 'c' checks reveal the password one character at a timeDiscuss this writeup with the community on the CTFdojo Discord.
Join the Discord →