Skip to content

Crackme

A key check running on a tiny 8-bit machine I made for this page. Eight registers, 256 bytes of memory, sixteen instructions. Find the key that makes it print something other than “Wrong key.”

The debugger is right there and the bytes are all yours. Patching the jump won't get you far. If you want the long version of how I approach these, there's a write-up of a harder one.

Debugger

Runs the key in the box above. Click an address to set a breakpoint.

  1. start:80 00len r0
  2. 61 00 0ccmp r0, 0x0c
  3. 72 75jnz fail
  4. 10 03 00mov r3, 0x00
  5. 10 06 00mov r6, 0x00
  6. check:10 01 f0mov r1, 0xf0
  7. 30 01 03add r1, r3
  8. 20 00 01ldb r0, r1
  9. 10 01 b0mov r1, 0xb0
  10. 30 01 03add r1, r3
  11. 20 02 01ldb r2, r1
  12. 40 00 02xor r0, r2
  13. 30 00 06add r0, r6
  14. 50 00 03rol r0, 0x03
  15. 10 01 a0mov r1, 0xa0
  16. 30 01 03add r1, r3
  17. 20 02 01ldb r2, r1
  18. 60 00 02cmp r0, r2
  19. 72 75jnz fail
  20. 31 03 01add r3, 0x01
  21. 31 06 07add r6, 0x07
  22. 61 03 0ccmp r3, 0x0c
  23. 72 0djnz check
  24. 10 03 00mov r3, 0x00
  25. 10 05 00mov r5, 0x00
  26. reveal:10 01 c0mov r1, 0xc0
  27. 30 01 03add r1, r3
  28. 20 00 01ldb r0, r1
  29. 10 01 f0mov r1, 0xf0
  30. 30 01 05add r1, r5
  31. 20 02 01ldb r2, r1
  32. 40 00 02xor r0, r2
  33. 90 00out r0
  34. 31 03 01add r3, 0x01
  35. 31 05 01add r5, 0x01
  36. 61 05 0ccmp r5, 0x0c
  37. 72 6cjnz next
  38. 10 05 00mov r5, 0x00
  39. next:61 03 21cmp r3, 0x21
  40. 72 47jnz reveal
  41. 10 00 01mov r0, 0x01
  42. 00hlt
  43. fail:10 00 00mov r0, 0x00
  44. 00hlt

Registers

r0
00
r1
00
r2
00
r3
00
r4
00
r5
00
r6
00
r7
00
pc
00
z
0

0 steps

Output

nothing yet

Memory

00800061000c72751003001006001001f0..a..ru.........
103001032000011001b0300103200201400.. .....0.. ..@
2000023000065000031001a03001032002..0..P.....0.. .
3001600002727531030131060761030c72.`..ru1..1..a..r
400d1003001005001001c0300103200001..........0.. ..
501001f030010520020140000290003103...0.. ..@....1.
600131050161050c726c10050061032172.1..a..rl...a.!r
7047100001001000000000000000000000G...............
8000000000000000000000000000000000................
9000000000000000000000000000000000................
a0ec11ba32fe48631cd013d78300000000...2.Hc.........
b0d3541d6e87a81102bb7c851600000000.T.n.....|......
c00920207f2d3a7d700d3a5d596e22317f. .-:}p.:]Yn"1.
d02c21247035305f526e26207f30213c3b,!$p50_Rn& .0!<;
e077000000000068756e74657232000000w.....hunter2...
f000000000000000000000000000000000................

pc next read your key

Instruction set

One opcode byte, then one byte per operand. Registers are bytes, so everything wraps at 256. Your key is copied to 0xf0 before the program starts.

OpcodeInstructionEffect
00hltstop
10mov rA, immrA = imm
11mov rA, rBrA = rB
20ldb rA, rBrA = mem[rB]
30 / 31add rA, rB / immrA = rA + x, wraps at 256
40 / 41xor rA, rB / immrA = rA ^ x
50rol rA, immrotate rA left by imm bits
60 / 61cmp rA, rB / immz = (rA == x)
70jmp addrpc = addr
71 / 72jz / jnz addrjump if z is set / clear
80len rArA = length of your key
90out rAprint rA as a character