Home / Showcases / Flag checker

Native · Solve

Find the flag in a compiled checker.

A small Linux program asks for a flag. Its instructions say exactly what it wants: every character, and one sum over all of them.

  1. 01

    Find the check

    From the strings to the function that decides.

  2. 02

    Extract the rules

    A length, a XOR per byte, a weighted sum.

  3. 03

    Solve and run

    Compute the flag, type it into the program.

We wrote this checker for the showcase and compiled it with gcc 14.2 (-O1, x86-64). The listings below are the program's real disassembly. Download it (binary, source, checksum) and try it with your own agent.

Ask your agent

Your coding agent

›Use REP on ./checker. Find the checking function, turn every check into an equation, solve it, and prove the answer by running the program.

Find the checking code

main prints Flag: , reads a line, and prints Correct! or Wrong. depending on check. Inside check: the length must be 0x14 (20), then check_char(input, i) runs for i = 0…19, then check_sum(input) decides.

check_char · real disassembly
11a0: movsxd rsi,esi
11a3: movzx  eax,BYTE PTR [rdi+rsi*1]
11a7: lea    rdx,[rip+0xe92]        # 2040 <MASK>
11ae: xor    al,BYTE PTR [rdx+rsi*1]
11b1: lea    rdx,[rip+0xe68]        # 2020 <WANT>
11b8: cmp    al,BYTE PTR [rdx+rsi*1]
11bb: sete   al
11be: movzx  eax,al
11c1: ret

One check reveals one character

(input[i] ^ MASK[i]) == WANT[i]. XOR undoes itself, so input[i] = WANT[i] ^ MASK[i]. The two tables, read from the program's data section:

iWANTMASKXORchar
03c5a66f
10d616cl
2096861a
3086f67g
40d767b{
……………
19a2df7d}

The masks step by 7 (0x5a, 0x61, 0x68 …): a pattern, not random bytes, which is a hint the agent can use to check it read the table right.

The last check

check_sum · real disassembly
11e0: movzx  edx,BYTE PTR [rdi+rax*1-0x1]
11e5: imul   edx,eax
11e8: add    ecx,edx
11ea: add    rax,0x1
11ee: cmp    rax,0x15
11f2: jne    11e0
11f4: cmp    ecx,0x58ad

Each character times its position (1 to 20), added up, must be 0x58ad = 22701. The XOR answer already fixes every character, so this sum is a check on the solution, not a second puzzle.

Try the rules

    The real program agrees:

    Terminal
    $ ./checker
    Flag: flag{read_the_bytes}
    Correct!