> For the complete documentation index, see [llms.txt](https://rayyanwong.gitbook.io/rayyan/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rayyanwong.gitbook.io/rayyan/picoctf_writeups/reverse-engineering/vault-door-5.md).

# Vault door 5

![](/files/JCuJyhp0hKYKZPq5hHTv)

### Analysis:&#x20;

There are 2 functions, base64encode and urlencode. urlencode is in UTF-8 format.

String expected is compared with the converted password we entered to see if its corrrect.

### Solution:

We want to first reverse the base64 encoding and utf-8 and we can do it using pybase64 module.

Next we notice that in urlencode there is `.format("%%%2x",input...)` To break this down ( my interpretation ). The first % is to start, and last to end. Leaving the middle one which is added into the string. 2x means changing it into hexadecimal form. As a result, the string after i decode will be %(hex value)...

To address this, we can `.replace('%',' 0x')` in python and we can then convert hex to int.

This is the code:

```python
from pybase64 import b64decode

string = "JTYzJTMwJTZlJTc2JTMzJTcyJTc0JTMxJTZlJTY3JTVm"+ "JTY2JTcyJTMwJTZkJTVmJTYyJTYxJTM1JTY1JTVmJTM2"+ "JTM0JTVmJTM4JTM0JTY2JTY0JTM1JTMwJTM5JTM1"
decoded = b64decode(string).decode('utf-8')
replaced = decoded.replace("%"," 0x") #we need to reverse the binary conversion ".format(%%%2x)"
# %%% means add perfectange sign first % is to start, last to exit
#2x refers to changing to hexadecimal, thus we need to convert it back to original numbers
print(replaced)
characters = replaced.split(" ")
output = "picoCTF{"
for ch in characters:
    if ch != '':
        output += chr(int(ch,16))

print(output+"}")

```

Flag : picoCTF{c0nv3rt1ng\_fr0m\_ba5e\_64\_84fd5095}
