Alien Portal
Hard, 7 Solves
Last updated
Hard, 7 Solves
Last updated
This challenge was initially supposed to be a stack overflow, in order to overwrite the result of a strcmp, followed by a key-gen bypass via static bruteforce - you can see it as an upgraded .
Since the CTF is over, here's the source code.
The player is given a binary "vuln.exe"
Checksec
output shows us:
Important note, stack protections have been disabled; this means that the compiled binary doesn't have any stack canaries- stack-based overflow!
The first part of the challenge is bypassing the strcmp that happens between local_5e
and local_58 .
Feel free to reassign the variable names to whatever you want, for this writeup we will just be assigning:
local_5e
= input (entry-point)
local_58
= flag (inaccessible)
The entry point is the vulnerable "gets"
function that is called to read local_5e
or the "input".
Here comes the elegance, the intended solution was an overflow at the gets function to overwrite iVar2 and set it to 0x1, however a more efficient solution was discovered by exploiting the strcmp
function.
strcmp()
takes in 2 string inputs, 'cs'
and 'ct'
, and loops through each character in the string to compare them.
In this case, the input to the program is limited to only 6 characters before it overflows to the 'flag'
or local_58
variable, by changing the flag variable to hold our own input, we can include a NULL byte to trick strcmp()
into returning a 0- effectively bypassing the strcmp.
The current payload with strcmp() bypass.
payload = b'A'*5 + b'\x00' + b'A'*5 + b'\x00';
With accordance to the payload, strcmp()
will compare 5 bytes of b'A' with another 5 bytes of b'A' and then a terminating NULL byte will be hit, and the rest of each string will not be compared.
After you get past the inital strcmp() check, you will be returned to another function: two_fa().
The function receives an input for a key, which is then passed into the encrypt_key() function, the result of this function is checked against 0x70c
where, the flag would be printed.
Seems simple enough, it just loops over the values of the key and sums the ASCII value of the letter.
Here's the exploit- it's a mashup of my own exploit.py and the funny script that @duckupus made.
Flag found :) LNC2023{SecreT_Al13n_por7a1?}
The following parts of the writeup take heavy inspiration from my friend @duckupus. His writeup can be found on his github .
The binary has been compiled in 32-bit ELF format
, for Intel architecture with dynamic linking. Those using 64-bit architecture may have to install multiarch-support to run it, refer to .
- The main() function, start of the callstack.
- Another function on the callstack two_fa()
However, to know when to stop comparing, strcmp()
looks for a in both strings.