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.
- start:80 00len r0
- 61 00 0ccmp r0, 0x0c
- 72 75jnz fail
- 10 03 00mov r3, 0x00
- 10 06 00mov r6, 0x00
- check:10 01 f0mov r1, 0xf0
- 30 01 03add r1, r3
- 20 00 01ldb r0, r1
- 10 01 b0mov r1, 0xb0
- 30 01 03add r1, r3
- 20 02 01ldb r2, r1
- 40 00 02xor r0, r2
- 30 00 06add r0, r6
- 50 00 03rol r0, 0x03
- 10 01 a0mov r1, 0xa0
- 30 01 03add r1, r3
- 20 02 01ldb r2, r1
- 60 00 02cmp r0, r2
- 72 75jnz fail
- 31 03 01add r3, 0x01
- 31 06 07add r6, 0x07
- 61 03 0ccmp r3, 0x0c
- 72 0djnz check
- 10 03 00mov r3, 0x00
- 10 05 00mov r5, 0x00
- reveal:10 01 c0mov r1, 0xc0
- 30 01 03add r1, r3
- 20 00 01ldb r0, r1
- 10 01 f0mov r1, 0xf0
- 30 01 05add r1, r5
- 20 02 01ldb r2, r1
- 40 00 02xor r0, r2
- 90 00out r0
- 31 03 01add r3, 0x01
- 31 05 01add r5, 0x01
- 61 05 0ccmp r5, 0x0c
- 72 6cjnz next
- 10 05 00mov r5, 0x00
- next:61 03 21cmp r3, 0x21
- 72 47jnz reveal
- 10 00 01mov r0, 0x01
- 00hlt
- fail:10 00 00mov r0, 0x00
- 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.
| Opcode | Instruction | Effect |
|---|---|---|
| 00 | hlt | stop |
| 10 | mov rA, imm | rA = imm |
| 11 | mov rA, rB | rA = rB |
| 20 | ldb rA, rB | rA = mem[rB] |
| 30 / 31 | add rA, rB / imm | rA = rA + x, wraps at 256 |
| 40 / 41 | xor rA, rB / imm | rA = rA ^ x |
| 50 | rol rA, imm | rotate rA left by imm bits |
| 60 / 61 | cmp rA, rB / imm | z = (rA == x) |
| 70 | jmp addr | pc = addr |
| 71 / 72 | jz / jnz addr | jump if z is set / clear |
| 80 | len rA | rA = length of your key |
| 90 | out rA | print rA as a character |