CRACK Solution

Checksum

CRACK byte sum

In-game screenshot of Checksum
In-game view
FamilyCRACK Graph0.257 DifficultyEasy Ring02 IDe02_checksum

Prerequisites

CENTER HOLD

Unlocks

LINE NOISE

Accepted input SUMS
Techniquebyte sum Rulenonzero SampleSUMS

Walkthrough

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

Reject Samples

  • SUMT
  • TUMS
  • AAAA
  • ZZZZ
  • SUM
  • SUMSS
Verifier Listing
; e02_checksum: no per-character check: the program sums all four input bytes
; and compares the 16-bit total to a magic number. Reverse the math: find four
; bytes that add to the target. The 8-bit ceiling forces explicit carry: the sum
; of four bytes (up to 1020) does not fit one register, so we keep the low byte in
; r3 and count carries (the high byte) in r4 by hand. Technique: accumulation /
; byte sum. r0 = 1 on accept. Accept rule: nonzero.
;
; target = 328 = 0x0148 -> high byte 1, low byte 0x48 (72).
; sample "SUMS": 83+85+77+83 = 328. (One solution; any four bytes summing to 328 pass.)

        len   r1
        cmp   r1, 4
        jnz   bad           ; exactly 4 bytes

        mov   r3, 0         ; r3 = running sum, low byte
        mov   r4, 0         ; r4 = running sum, high byte (carry count)
        mov   r7, 0         ; index

loop:   cmp   r7, 4
        jge   final
        ldb   r0, [r7]      ; r0 = next input byte
        add   r3, r0        ; low += byte  (wraps mod 256)
        cmp   r3, r0        ; if the new low is below the byte we just added,
        jge   nocarry       ; the add wrapped -> a carry into the high byte
        inc   r4
nocarry:
        inc   r7
        jmp   loop

        ; --- compare the 16-bit total to 0x0148 ---------------------------
final:  cmp   r4, 1         ; high byte must be 1
        jnz   bad
        cmp   r3, 0x48      ; low byte must be 72
        jnz   bad

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