Mini-VM: serial-checking bytecode
Legacy software from the SamSU laboratory verifies its license serial in its own small virtual machine (SamVM). The program source is lost; only the bytecode file serial_check.svm remains. If the serial is valid, the VM itself prints the service key (flag); if invalid, it only outputs NO. Do not trust ready-made strings inside the file: some were left behind solely as decoys.
File format (little-endian): 'SVM1' | u16 code_len | u16 data_len | code | data. VM memory is 0x400 bytes: data is loaded starting at address 0x000, the entered serial is placed starting at 0x200 (14 ASCII characters XXXX-XXXX-XXXX, where X is an uppercase Latin letter or digit, followed by a 0 byte), and the region from 0x300 onward is free working memory. The program starts at address 0. Stack elements are 32-bit unsigned integers (all arithmetic is modulo 232). A two-operand instruction takes b (top of stack) and a, and returns a OP b. Shift and rotation amounts are b & 31.
| Code | Name | Operand | Meaning |
|---|---|---|---|
00 | NOP | - | hech narsa |
01 | PUSH | u32 | sonni stekka qo'yish |
02 | POP | - | stek uchini tashlash |
03 | DUP | - | stek uchini takrorlash |
04 | SWAP | - | ikki yuqori elementni almashtirish |
05..0A | ADD SUB MUL XOR AND OR | - | a OP b |
0B 0C 0D | SHL SHR ROL | - | a ni b (mod 32) ga chapga/o'ngga siljitish / chapga aylantirish |
10 / 12 | LDB / LDW | - | manzilni olib, bayt / 32 bit (LE) o'qish |
11 / 13 | STB / STW | - | manzilni (uch), qiymatni (undan keyingi) olib yozish |
14 | EQ | - | a == b ? 1 : 0 |
20 / 21 / 22 | JMP / JZ / JNZ | u16 | o'tish (JZ/JNZ stek uchini olib shartni tekshiradi) |
30 | OUT | - | stek uchini bayt sifatida chop etish |
31 | HALT | - | to'xtatish |
Task: find the valid serial, run the VM (in an emulator you write yourself) with that serial, and submit the printed flag. Flag format: BAYROQ{MINI_VM_BYTECODE_xxxxxxxxxxxxxxxx} (the last 16 characters are lowercase hex). Writing the disassembler and emulator with stdlib is sufficient; z3 is optional.