This is a binary that takes a command line argument and prints a flag. There
are two flags to be found in this binary.
The first flag appears in plain text in the binarym running “strings” on
on the file will yield the solution. Another option is to look at the
control flow of the main function. Two functions are called with the command
line argument. The first one contains two strings: “–print-flag0” and
“FLAG0-F1RSTBL00D.
The second function that validates command line arguments does not contain
any references to readable strings. We can find a loop with an XOR
operation. Every character of a string that is passed to strcmp is XORed
with the byte 0x42. This yields two strings:
This piece of code takes a string from STDIN and validates it. If the string is
“valid”, then the program jumps directly on the first byte of the data it
received and executes it.
The validation is done with the help of a linked list. Each character is
inserted in a linked list entry. The validation is performed to see if the
string is a palindrome, a sequence that reads the same backward as forward.
A stack is used to keep track of the characters that were read from the
beginning of the string up to the middle character. The stack is then popped
and used to validate the current character is the same as the one that was seen
in the first half of the string.