CRACK Solution

Const Gate

CRACK direct compare

In-game screenshot of Const Gate
In-game view
FamilyCRACK Graph0.068 DifficultyTutorial Ring01 IDz1_const_gate

Prerequisites

MASK WRONGDUTY

Unlocks

PATCH BAY

Accepted input OK
Techniquedirect compare Rulenonzero SampleOK

Walkthrough

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

Reject Samples

  • O
  • OKK
  • OX
  • ok
  • KO
Verifier Listing
; z1_const_gate: Const Gate. A length-2 gate, then two DIRECT character
; compares against immediate constants. No cipher, no math: read the two cmp
; immediates and turn the hex back into ASCII. r0 = 1 on accept (nonzero rule).
;
; input[0] must be 0x4F ('O'), input[1] must be 0x4B ('K'); length exactly 2.
; Answer: OK

        len   r1
        cmp   r1, 2
        jnz   bad           ; length must be exactly 2

        mov   r7, 0
        ldb   r0, [r7]
        cmp   r0, 0x4f      ; 'O'
        jnz   bad
        inc   r7
        ldb   r0, [r7]
        cmp   r0, 0x4b      ; 'K'
        jnz   bad

        mov   r0, 1
        ret
bad:    mov   r0, 0
        ret