> For the complete documentation index, see [llms.txt](https://kabinet.gitbook.io/ctf-writeup/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kabinet.gitbook.io/ctf-writeup/2023/dart-ctf/flag-3.md).

# Flag 3

In the `debug application`, there are some python code

{% code overflow="wrap" %}

```python
Imp = b'Use the same carefully'
MyValue =  b'a*)h\x1f/!U9&\x1f\x1cz\x19\x038\r%/?\x15)\x10\x1d\t\x15A\\\nt&S8:L2%7\tW\x1dZ54\x14\t#U8\r?b70PX'a

def enc(MyValue):
    bytevalue = bytearray()
    for i in range(len(MyValue)):
        bytevalue.append(MyValue[i] ^ Imp[i % len(Imp)])
    return bytes(bytevalue)

value = enc(MyValue.encode())
print(value)
Flag 2 : Telemetry check-in confirmed.
```

{% endcode %}

The code defines a function called `enc()` that performs performs an XOR operation between each byte in `MyValue` and the corresponding byte in the `Imp` byte string.

The result of this operation is then appended to a new byte array called `bytevalue`. Finally, the **`enc()`** function returns the contents of `bytevalue` as a byte string.

Modifying the code to print out the decoded text, which is a key for azure function.

{% code overflow="wrap" %}

```python
Imp = b'Use the same carefully'
MyValue =  b'a*)h\x1f/!U9&\x1f\x1cz\x19\x038\r%/?\x15)\x10\x1d\t\x15A\\\nt&S8:L2%7\tW\x1dZ54\x14\t#U8\r?b70PX'

def enc(MyValue):
    bytevalue = bytearray()
    for i in range(len(MyValue)):
        bytevalue.append(MyValue[i] ^ Imp[i % len(Imp)])
    return bytes(bytevalue)

value = enc(MyValue)

print(value.decode())
```

{% endcode %}

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

I then manually visited all 3 function with the function key to see if it works, and the `Blanket App` allow me to retrieve the flag.

{% code overflow="wrap" %}

```
http://rosarray.azurewebsites.net/api/Blanket?code=4YLHkGDuJGryZzbJhCZSyPEnl554oTU2U_lQDEl1h6YMAzFuLeZBDQ==
```

{% endcode %}

Flag 3 : Anomaly detected in spacecraft trajectory.
