# REVERSE

## R0ll

{% embed url="<https://github.com/Diefunction/dumbemu>" %}

```bash
python3 -m pip install dumbemu
```

<pre class="language-python"><code class="lang-python"><strong>from dumbemu import DumbEmu
</strong>
BINARY = 'R0ll.exe'

CRYPT_FUNC = 0x1400010E0

FLAG = {
    'prefix': b'FlagY{',
    'suffix': b'}',
    'charset': b'0123456789abcdef'
}

FLAG_LEN = 39

KEY = b'fbec495785a8bcf346b'
KEY_LEN = len(KEY)

if __name__ == "__main__":
    emu = DumbEmu(BINARY)
    
    key = emu.malloc(KEY_LEN)
    flag = emu.malloc(FLAG_LEN)
    
    emu.write(key, KEY)
        
    while len(FLAG['prefix']) &#x3C; FLAG_LEN - 1:
        for c in FLAG['charset']:
            
            _flag = FLAG['prefix'] + bytes([c])
            _flag = _flag.ljust(FLAG_LEN, b'X') + FLAG['suffix']
            
            emu.write(flag, _flag)
            
            args = [flag, key, 0, KEY_LEN]
            result = emu.call(CRYPT_FUNC, None, *args)
            
            if emu.regs.read('r9') > len(FLAG['prefix']):
                FLAG['prefix'] += bytes([c])
                print(f"[+] Current Flag : {FLAG['prefix'].decode()}")
                if emu.regs.read('rax') == 1:
                    break
                break
    print(f"[+] Final Flag: {FLAG['prefix'].decode()}}}")
</code></pre>


---

# 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://blog.diefunction.io/ctf/cybernights-2025/reverse.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.
