We first decompile with binary ninja
In the main function, We allocate 3 pointers and 1 variable, change a variable until its non-zero, do a lot more assignments to variables from constants loaded within memory, and perform a hashing function for each of them (there are like 20 of thes variables). Another loop of a pointer, and then we run the 2nd function
The second function is a lot more interesting. It constructs a list, with the first element as a function. Then, it calls that function.
So, the function data is dynamicaly loaded. We debug to see whats going on.
0x5555555550c0
. This is what it looks like: Incorrect\n
onto the memory locations Correct!\n
to the memory space afterwards Correct!\n
Incorrect
) is moved into rbx, then it prints rbx. s
passes the first check, so we know that it is decoding now character by character. Also, changing characters does not modify the r8b
values, so these are constant.dil
, xors it with al
and compares it to be r8b
. So, we should be able to find the character from the expected r8b
values and al
values.def find_a(b_hex, c_hex):
b_int = int(b_hex, 16) # Convert b from hex to integer
c_int = int(c_hex, 16) # Convert c from hex to integer
a_int = c_int ^ b_int # Perform the XOR operation
a_hex = hex(a_int) # Convert a back to hexadecimal
return a_hex
b_decimal = int(input('b_decimal: '))
b_hex = hex(b_decimal & 0xFF) #ensure 8 bit representation.
c_hex = input("c_hex: ")
result_hex = int(find_a(b_hex, c_hex), 16)
print(f"a = {result_hex}, chr(a) = {chr(result_hex)}")
Kept on running the script until i got the flag.
swampCTF{531F_L0AD1NG_T0TALLY_RUL3Z}