Pasticciotto is a virtual machine which can be used to obfuscate code. It was developed for the **PoliCTF 17** as a reversing challenge.
I wanted to experiment with VM obfuscation since it was a topic that caught my attention while reversing challenges for various CTFs. So, I decided to write one **from scratch** in order to understand better how instruction set architectures are implemented!
The design and the implementation behind Pasticciotto are not state-of-the-art but hey, it works!
# Why "Pasticciotto"?
In Italian, "Pasticciotto" has two meanings!
The first one is **"little mess"** which perfectly describes how I put up this project. The second one is a typical dessert from Southern Italy, Salento! It's filled with cream! Yum!
VM vm(key, example_assembled_pstc, example_assembled_pstc_len);
vm.run();
return 0;
}
```
That's it!
## Accessing to the VM's sections and registers
The VM **data / code / stack sections** are represented through the `VMAddrSpace` object. It is defined [here](vm/vmas.h). The **registers** are in a `uint16_t` array in the `VM` object defined [here](vm/vm.h).
```c++
void foo() {
// creating the VM with some code
VM vm(key, code, codelen);
// accessing the data section
printf("First data byte: 0x%x", VM.as.data[0]);
// accessing the code section
printf("First code byte: 0x%x", VM.as.code[0]);
// accessing the stack section
printf("First stack byte: 0x%x", VM.as.stack[0]);
// accessing the IP register
printf("The IP is: 0x%x", VM.regs[IP]);
return;
}
```
# What about the challenge?
You can find the client and the server under the `polictf/` directory. I do not want to spoil the challenge for those that haven't completed it yet so you won't find the "specifics" of it. Check out some write-up online!
# Implementation details
Check out the file [IMPLEMENTATION.MD](IMPL) to understand how the VM works and which operations it can do! Watch out for some spoilers if you haven't completed the challenge though!