CRACK Solution

RECOVER THE FLAG

CRACK literal compare

In-game screenshot of RECOVER THE FLAG
In-game view
FamilyCRACK Graph0.036 DifficultyTrivial Ring01 IDt01_flag

Prerequisites

LINE TEST

Unlocks

STAIRCASE

Accepted input FLAG
Techniqueliteral compare Rulenonzero SampleFLAG

Walkthrough

Recover the accepted input below, then submit it to the CRACK verifier.

Verifier Listing
; t01_flag: trivial compare: the input must be exactly "FLAG".
; Technique: literal string compare (the answer is readable straight off the
; constants). r0 = 1 on accept, 0 on reject (accept rule: nonzero).
;
; FLAG = 0x46 0x4c 0x41 0x47.

        len   r1            ; r1 = input length
        cmp   r1, 4
        jnz   bad           ; wrong length -> reject

        mov   r7, 0         ; offset
        ldb   r0, [r7]
        cmp   r0, 0x46      ; 'F'
        jnz   bad
        inc   r7
        ldb   r0, [r7]
        cmp   r0, 0x4c      ; 'L'
        jnz   bad
        inc   r7
        ldb   r0, [r7]
        cmp   r0, 0x41      ; 'A'
        jnz   bad
        inc   r7
        ldb   r0, [r7]
        cmp   r0, 0x47      ; 'G'
        jnz   bad

        mov   r0, 1         ; all four matched -> accept
        ret
bad:    mov   r0, 0
        ret