收藏订阅
A bit of theory
VMProtect is a completely new software protection tool. Unlike most available protectors, VMProtect modifies the source code of the program. VMProtect transforms parts of code in the file being protected into a program (bytecode hereinafter) executed on the virtual machine (VM hereinafter). You can also think of VM as a virtual processor with a system of commands really different from that used in Intel 8086 processors. For example, VM has no commands responsible for comparing two operands, there are no conditional and unconditional jumps, etc. As you can see now, hackers will have to develop a completely specific tool for analyzing and decompiling bytecode, which will take a lot of time. Unfortunately, we know that there is no unbreakable protection that is why we should achieve the level of protection when expenses on breaking it will be comparable with (or even excede!!!) expenses on purchasing the protected program by legal means. Anyway, you should keep in mind that VMProtect is only a tool helping you to "hide" the main software protection mechanisms.
Preparing a program for protection
To begin with, create a simple project in Delphi consisting of a form (Form1), a text edit field (Edit1) and a button (Button1):
pic 1.
After the user clicks Button1, the program will check if the password is correct and display the corresponding message (correct or incorrect):
The algorithm of determining if the password is correct is very simple - the password is converted into a number. Then, this number is divided by 17 and if the remainder is 13, the password is correct. Otherwise the password is incorrect. Before compiling our project, we will enable generating a MAP file in the options of the project:
pic 2.
We need the MAP file for VMProtect to be able to determine the address of a procedure by its name later. After that we perform "Build Project1" and get a compiled text project and the MAP file.
Using markers
It makes sense to use markers when you need to protect only part (or some parts) of a procedure. You should use assembler insertions to mark sections:
- The start marker of the protected block:
- The end marker of the protected block:
When you later work with VMProtect, markers will have their own unique names like "VMProtectMarker" + sequential marker number.
Watermarks
VMProtect provides you with a unique feature of adding hidden information about the owner of the file to the protected file. A watermark is an array of bytes that must be unique for each of your users. After you embed watermarks into the protected file, you will always be able to determine its owner and take the corresponding measures later (for instance, if the cracked program is distributed illegally).
Working with VMProtect
Load the project using the "File"-"Open" menu item. Add a procedure responsible for checking if the password is correct to the project:
VMProtect can process the protected code in different ways depending on the selected compilation type. Let us take each compilation type in detail:
After you add all necessary procedures to the project, switch to the "Options" tab:
After you specify all necessary options, start compiling the project. After the project is compiled, a new file (for example, TEST.VMP.EXE) will be created next to the protected file (for example, TEST.EXE). The specified procedures will run on the virtual machine in this file.