按版本分档处理反调试检查,无需内核驱动的逆向辅助工具。
工具逆向反调试x64dbg
After going through the VMProtect anti-debug checks version by version, I put the handling into an x64dbg plugin.
This is KozDbg v1.0. It covers the researched versions from VMProtect 3.3.1 to 3.10.1, with a separate profile for each tested version.
No kernel driver is required. The plugin runs inside x64dbg and handles the supported user-mode checks and kernel-debugger queries from user mode. Native x64 targets only.
Source code on GitHub
The demo
Three small programs here: BasicProbe, RiddleGame and KeyCheck.
The video starts with protecting them using the different VMProtect versions. Then I open the protected files in x64dbg, select the matching KozDbg profile and run them.
Supported versions
Code:
VMProtect
|
Profile
|
Handling
----------+---------+-----------------------------------------------
3.3
.
1
|
331
|
API interception
3.4
.
0
|
340
|
API interception
3.5
.
0
|
350
|
API interception
3.6
|
360
|
Clustered
direct syscalls
3.8
.
0
|
380
|
Scattered
direct syscalls
3.9
.
4
|
394
|
Scattered
direct syscalls
and
extended checks
3.10
.
1
|
3101
|
Scattered
direct syscalls
and
extended checks
These are the actual tested versions. The 3.3.x–3.10.x range does not mean every intermediate build was tested.
KozDbg does not detect the VMProtect version automatically. Select the profile for the version you are working with.
Installation
Download the release package and extract the three files into the plugins directory next to x64dbg.exe:
Code:
plugins
/
KozDbg
.
dp64
KozDbg
.
dp64
.
ini
KozDbg
.
dp64
.
ini
.
profiles
.
ini
Start x64dbg. KozDbg should appear under Plugins.
The package starts with the 3.3.1 profile and auto-enable turned on. Change the profile before loading a target protected with another version.
Selecting a profile
You can select the version directly from Plugins > KozDbg. There is no need to open the settings window every time.
Load the program after selecting the profile. At the system breakpoint, check that KozDbg reports the profile as armed, then press F9. If x64dbg stops at the protected entry point or a TLS entry point, press F9 again.
If setup fails, read the error before continuing. Selecting a profile after the program has already performed its checks cannot undo those checks.
The settings
The settings window exposes the individual options. Hover over the question mark beside a checkbox for a short explanation.
The available controls depend on the selected version:
PEB and debugger API checks.
Remote debugger, debug object and kernel debugger queries.
Thread hiding, driver names and supported invalid-handle checks.
Trap-flag exception delivery and saved debug registers.
Instrumentation callback and remote-breakin protection in later profiles.
The TitanHide device check in 3.9.4 and 3.10.1.
Decoder acceleration for recognized packed layouts.
The kernel-debugger option handles the query result seen by the protected program. It does not install a kernel component.
The TitanHide option also does not require TitanHide. It handles the device-open check used by those later VMProtect versions.
Addresses and packed programs
The plugin resolves API addresses and syscall numbers in the running process. It does not select targets by filename, hash or a fixed protected-code address.
One issue appeared when testing the packed 3.3.1 RiddleGame. Breakpoints at the start of native API stubs changed bytes the protected startup depended on. Moving the interception point past the validated syscall-identification prefix allowed the program to reach its GUI. The older profiles now use that placement too.
Packing can also make the direct-syscall path slow. A memory guard on a page shared with a busy decoder loop causes a lot of debugger events.
Decoder acceleration handles recognized layouts using available hardware-breakpoint slots. If it cannot allocate one safely, the memory-guard path remains in use. Startup can be slower in that case.
Different protection settings can produce different layouts, so passing these examples is not a guarantee for every protected executable.
Custom profiles
Click Profiles INI in Settings. The file is KozDbg.dp64.ini.profiles.ini, next to the plugin.
Copy an existing section, give it a unique ID and change its name and options. For example, start from the 331 preset if you want another configuration of the API engine.
Restart x64dbg after editing profile definitions. Your new profile appears in the menu and settings dropdown.
The INI configures the existing handling. It does not contain the entire implementation. Adding a new check requires changing the C++ source and rebuilding the plugin.
The full format is documented in PROFILES.md in the source package.
Commands
The same controls are available from the command bar:
Code:
kz_settings
kz_profile
331
kz_profile
MyProfile
kz_status
kz_apply applies the current profile while the target is paused. kz_profile off disables the plugin.
Repeated informational messages are counted instead of printed continuously. kz_status shows the state and counters. Errors still appear; x64dbg's own exception messages are separate.
Updating
Close x64dbg completely before replacing KozDbg.dp64.
Keep your existing INI files when updating. Replacing them with the defaults would discard your saved settings and custom profiles.
What this tool does
KozDbg handles the anti-debug checks covered by its profiles. Once startup passes, you continue with normal debugging.
It does not unpack the executable, remove virtualization or bypass the program's password check.
The source is available under the MIT license.
Anti-debug analyses
The implementation follows these analyses:
VMProtect 3.3.x–3.5.x anti-debug analysis
VMProtect 3.6 anti-debug analysis
VMProtect 3.8.0 anti-debug analysis
VMProtect 3.9.4 anti-debug analysis
VMProtect 3.10.1 anti-debug analysis
Links
Original article on my blog
Demo
i read the rules and it said that external links should not be a problem if approved by moderators. Please delete external links (likely 'ivankozlovsky.com') if they are prohibited.