HTB University CTF 2023 — WindowsOfOpportunity (easy)
WindowsOfOpportunity (easy)
Here’s the challenge’s details:

From this problem, we get a zip file that contain a binary file. First, we try to run it and check what the file do

It seems this is a typical password or flag checker problem. We can understand how the file work with some basic reverse engineering tools, such as IDA or Ghidra. In this post, i will use IDA

We can see from the result of decompiling the main function that this program will check between user input that being processed with arr array. The code is comparing the sum of consecutive elements in the s array from user input with corresponding elements in the arr array. If at any point these sums don’t match the values in arr, the program prints an error message and exits with a return code of -1.
We can see below the value of the arr array.

So, we just have to perform the same process as the program does. Luckily, we know that the format of the flag is HTB{.*?}, so we can perform the process by start with the ascii value of HTB (which is 72), and then subtract first arr index with it. The result can be used to subtract the second arr index, and so on
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
]
size = len(arr)
a = 72
print(chr(a), end="")
for i in range(size):
result = arr[i] - a
print(chr(result), end="")
a = result
We can validate the result by try to insert it to the windows file again

