Challenges
Bytecode VM with a loop
Reverse engineering
Hard
Complex VM
Solves: 8
Bytecode VM with a loop
Author: CyberSamSU
Points
80
This time the VM has a loop and a conditional jump. Opcode table (the same VM as in challenge 2, but more instructions are used):
| Mnemonic | Code | Description |
|---|---|---|
PUSH | 1 | Operanddagi sonni stekka qo'yadi. |
STEP | 13 | MA'LUMOTLAR jadvalidan navbatdagi baytni oladi, uni KALIT jadvalidagi navbatdagi bayt bilan XOR qiladi, natijani stekka qo'yadi va ichki ko'rsatkichni 1 ga oshiradi. |
OUT | 5 | Stek tepasini belgi (chr) sifatida chiqaradi va olib tashlaydi. |
DEC | 11 | Stek tepasidan 1 ayiradi (mod 256). |
DUP | 6 | Stek tepasidagi qiymatni ikkilantiradi (nusxa qo'shadi). |
JZ | 9 | Stekdan qiymat oladi; agar u 0 bo'lsa, operand manziliga o'tadi, aks holda davom etadi. |
JMP | 8 | Operand ko'rsatgan manzilga (indeksga) o'tadi. |
HALT | 0 | Dasturni to'xtatadi. |
Additionally, the VM has two external tables: DATA (data) and KEY (key, length 3, repeats periodically). Every time the STEP instruction is called, it XORs the next data[i] with key[i % 3] and pushes it to the stack.
MA'LUMOTLAR: [8, 147, 93, 24, 157, 85, 49, 128, 55, 28, 141, 114, 39, 190, 107, 37, 162, 96, 37, 188, 97, 55]
KALIT: [74, 210, 4]
Program (address-indexed):
| Address | Opcode | Operand |
|---|---|---|
0 | PUSH | 22 |
2 | STEP | |
3 | OUT | |
4 | DEC | |
5 | DUP | |
6 | JZ | 10 |
8 | JMP | 2 |
10 | HALT | |
If it is difficult to trace manually — write a small Python interpreter yourself based on the VM description above (this is the most reliable way).
Theory: learn the topic
To submit a flag, log in.