# rev/awa-jelly

### Writeup by Aryan

We are given a link to [AWA5.0](https://github.com/TempTempai/AWA5.0), a weird language consisting solely of awa's. Our job is to reverse engineer a certain output to figure out the input string. We are provided with the code.

<figure><img src="/files/AdxjKOqTtyxnRzYMjjIr" alt=""><figcaption></figcaption></figure>

Going to the [AWA5.0 website](https://temptempai.github.io/AWA5.0/), we can put in a string of all lowercase alphabets.

<figure><img src="/files/IqOjvUMGSJcqHcakszHe" alt=""><figcaption></figcaption></figure>

At this point, rather than trying to read documentation or reverse the code, I intuitively guessed the solution. Certain characters are not allowed as inputs, so they are removed from the string, and everything else is simply shuffled in a specific order.

Comparing the sorted input to the sorted output allows us to quickly deduce the unallowed characters, from which we can add uppercase alphabets to our input string until it reaches length 32 (which is the length of the output the challenge provides us with).

Once we are able to craft a successful input consisting of 32 unique allowed characters, we can get the corresponding output on the website. Then, we can write a basic script to figure out the index mapping, and finally reverse the process on the provided output.

```python
# messy code sorry
def find_input_from_output(output_string, input_string, decode_string):
    output_to_input = [-1] * 32
    
    for i in range(len(input_string)):
        for j in range(len(output_string)):
            if output_string[j] == input_string[i] and output_to_input[j] == -1:
                output_to_input[j] = i
                break
    
    input_from_output = ""
    for i in range(len(decode_string)):
        input_from_output += decode_string[output_to_input.index(i)]
    
    return ''.join(input_from_output)

output_example = "jelmnopCrsFtcufwEBy0a1234hADbdgi"
input_example = "ABCDEFabcdefghijlmnoprstuwy01234"
new_output = "1o1i_awlaw_aowsay3wa0awa!iJlooHi"

result = find_input_from_output(output_example, input_example, new_output)
print("vsctf{"+result+"}")
```

Flag: `vsctf{J3lly_0oooosHii11i_awawawawaawa!}`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://centinels.gitbook.io/home/writeups/vsctf/rev-awa-jelly.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
