DaVinci CTF 2022 writeup

I participated the DaVinci CTF 2022. The 0004 article.

f:id:Berrys:20220314025729p:plain

I solved one non-beginner problem, but I thought a problem which I can solve was for beginner.


Mine Game

f:id:Berrys:20220314025903p:plain

The problem is to send the correct input to the server using the nc command.
Opened file with Ghidra.

f:id:Berrys:20220314030346p:plain

I changed some function name. First, this program receives input in line 11. In line 17, the input function checks input format. The input format is like "num;num;num;...;num".
Between line 18 and line 21, the check1 function determines whether the quotient and remainder of the iva1 variable divided by 14 are between 0 and 13 or not. If it's not, then it displays "cheater". Therefore, we can choose numbers between 0 and 195. In line 22, the check2 function determines whether all 196(=1414) characters beginning with &DAT_00104100 are 0x2d(-) or 0x2a().

f:id:Berrys:20220314031100p:plain

In line 16, the initialization function calculates the remainder of the pseudorandom number divided by 14 and replaces the &DAT_00104100 index with 2a. It also process other things.

f:id:Berrys:20220314031306p:plain

The check2 function determines if the 196 characters from DAT_00104100 are correct.
The solution is to find the input number which does not display "BOOM" in the check1 function. I spent much time to find a solution using the rand function in the initialization function. However, i coudn't, so I looked for a number which does not display "BOOM" in the check1 function one by one.

f:id:Berrys:20220314031615p:plain