wtmoo
Category: Rev
Description
My cow keeps eating all my flags...
Attachments: chall
Write-up
The following code snippet is the pseudocode of main()
in the chall
binary generated by Ghidra:
Based on the provided pseudocode for main()
, we can observe that it reads user input and stores it in the buffer local_58
. Then, it iterates through each character in local_58
and applies certain manipulations based on the character's ASCII value.
Here are the conditions and outcomes for each character:
1. If the character falls within the ASCII range of lowercase letters a
to z
, it subtracts 60
from the character.
2. If the character falls within the ASCII range of uppercase letters A
to Z
, it adds 32
to the character.
3. If the character falls within the ASCII range of digits 0
to 4
, it adds 43
to the character.
4. If the character falls within the ASCII range of digits 5
to 9
, it subtracts 21
from the character.
5. If the character falls within the ASCII range of {
to }
, it remains unchanged.
6. If the character doesn't meet any of the above conditions, the check fails and the program exits.
At the end, the program checks if the resulting buffer local_58
is equal to the string 8.\'8*{;8m33[o[3[3[%\")#*\\}
. Therefore, if we provide the flag as input, it should undergo the manipulation process and result in that string.
We can write a script to reverse this process by iterating through each character in the resulting string and applying the reverse manipulation based on the conditions mentioned. At the end, we will obtain our flag.
The Python script that automates the reversing process can be found here.
Flag: tjctf{wtMoo0O0o0o0a7e8f1}