Challenges
MCU assembly: register operations
Hardware
Hard
MCU assembly
Solves: 10
MCU assembly: register operations
Author: CyberSamSU
Points
100
Many microcontroller firmwares obfuscate stored text (for example, a license key or a password) using simple register operations — XOR, ADD and ROL (rotate-left). This is not encryption, but an analyst seeing it in a disassembler must reverse it manually.
8-bit ROL(x, n) — shifts the bits of x to the left by n positions, and the shifted-out bits return from the right side (circular shift).
Below is the pseudo-assembly code taken from the firmware:
; R1 = kalit (XOR), R2 = siljish (ADD), R3 = aylantirish soni (ROL)
; R0 — kirish/chiqish registri
LOOP:
LOAD R0, [XABAR + i] ; ochiq matn bayti
XOR R0, R1 ; R0 = R0 XOR R1
ADD R0, R2 ; R0 = (R0 + R2) mod 256
ROL R0, R3 ; R0 ni chapga R3 bitga aylantirish (8-bit doira)
STORE [CHIQISH + i], R0
INC i
JMP LOOP ; agar i < uzunlik
Constants: R1 = 95, R2 = 15, R3 = 2.
Output bytes obtained as a result of the program execution (hex, in order):
6C 94 70 94 3C 7C AC 98 94 88 A8 94
Reverse the operation: first ROR (the reverse of ROL), then subtract for ADD, then XOR again. Flag: BAYROQ{HW_MCU_<SOZ>}
To submit a flag, log in.