Diefunction
Ctrlk
  • About
  • Vulnerabilities
    • GHSL-2021-023 / CVE-2021-32819
    • NodeJS - Abusing Lazy Loading Technique
  • CTF
    • Technology Control Company
    • Athackcon
    • Cyber Night 3
    • BlackHatMEA Quals 2022
    • BlackHatMEA Quals 2023
    • BlackhatMEA Finals 2024
    • BITSCTF - Reverse Mishap
    • Cybernights 2025
      • REVERSE
      • PWN
    • BYUCTF 2025
    • CyberYard 2025
Powered by GitBook
On this page
  1. CTF
  2. Cybernights 2025

REVERSE

R0ll

LogoGitHub - Diefunction/dumbemu: A lightweight, dependency-minimal PE file emulator built on top of Unicorn Engine. DumbEmu allows for function-level emulation of Windows executables without requiring any Windows dependencies or API implementation.GitHub
python3 -m pip install dumbemu

PreviousCybernights 2025NextPWN

Last updated 2 months ago

Was this helpful?

Was this helpful?

from dumbemu import DumbEmu

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']) < 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()}}}")