Challenges
Bytecode VM (introduction)
Reverse engineering
Easy
Bytecode VM
Solves: 6
Bytecode VM (introduction)
Author: CyberSamSU
Points
15
Many protected programs run in their own custom bytecode virtual machine (VM) — this is a specific "language" written within the program that does not correspond to any real processor. Below is the opcode table for a very simple stack-based VM:
| Mnemonic | Code | Definition |
|---|---|---|
PUSH | 1 | Operanddagi sonni stekka qo'yadi. |
XOR | 4 | Stek tepasini operand bilan XOR qiladi. |
OUT | 5 | Stek tepasini belgi (chr) sifatida chiqaradi va olib tashlaydi. |
HALT | 0 | Dasturni to'xtatadi. |
The VM works with a stack: PUSH n pushes a number onto the stack, XOR n XORs the top of the stack with n, and OUT outputs the top of the stack as a character and removes it from the stack. The following program (as a list of opcodes) is given — execute it from beginning to end and collect the output characters:
1 106 4 40 5 1 101 4 36 5 1 229 4 188 5 1 80 4 2 5 1 20 4 91 5 1 0 4
81 5 1 21 4 110 5 1 44 4 126 5 1 246 4 197 5 1 9 4 95 5 1 112 4 47 5
1 242 4 132 5 1 229 4 136 5 1 154 4 248 5 1 174 4 193 5 1 228 4 139
5 1 188 4 200 5 1 190 4 195 5 0
Theory: learn the topic
Learning paths:
Reverse engineering 101
To submit a flag, log in.