back to blog

HTB University CTF 2023 — WindowsOfOpportunity (easy)

Overview

A Windows binary that validates input against a hardcoded array. Decompiling with IDA reveals the program sums consecutive elements from user input and compares them to an arr array.

Solution

Knowing the flag starts with HTB{ (H = ASCII 72), we can recover each character by subtracting the previous value from each array element:

arr = [
    156, 150, 189, 175, 147, 195, 148,  96, 162, 209,
    194, 207, 156, 163, 166, 104, 148, 193, 215, 172,
    150, 147, 147, 214, 168, 159, 210, 148, 167, 214,
    143, 160, 163, 161, 163,  86, 158
]

a = 72  # ord('H')
print(chr(a), end="")
for i in range(len(arr)):
    result = arr[i] - a
    print(chr(result), end="")
    a = result

Run it, submit the output to the binary, and it confirms the flag.