anti-debug-bypass
它能做什么
它介绍程序中常见的反调试和反虚拟机检查,以及分析人员在实验室中如何应对。适用于研究受保护或恶意软件的逆向工程人员。
适用场景
- ✓当分析人员发现程序在附加调试器时会关闭或行为不同时。
- ✓当研究人员想找出某个样本使用了哪些反调试检查时。
- ✓当团队研究受保护程序,需要了解它如何对虚拟机做出反应时。
技能链接
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/reverser/anti-debug-bypass/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我一附加调试器,这个程序就停止运行了。怎样才能找出原因?”
每周 5 个新技能,1 分钟读完。
工作原理
该技能列出常见的检查,展示如何在程序中扫描这些检查,并说明在分析过程中如何处理每一种检查。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Anti-Debug Bypass Playbook
Malware and protected commercial software check for debuggers and sandboxes before running real logic. Bypassing these checks is required to dynamically analyze them. Each check has a known counter.
1. Enumerate anti-debug techniques in the binary
Static signature scan
# Windows API calls
strings /tmp/sample | grep -iE 'IsDebuggerPresent|NtQuery|CheckRemoteDebugger|OutputDebugString'
# Linux ptrace check
strings /tmp/sample | grep -iE 'ptrace|/proc/self/status|TracerPid'
# CPUID hypervisor check
strings /tmp/sample | grep -iE 'vmware|VirtualBox|qemu|xen'
# Detect via YARA rules
yara -r /opt/yara-rules/anti_debug.yar /tmp/sample
Decepticon helper:
bin_anti_debug_scan("/tmp/sample")
2. Common checks + bypasses
Windows checks
| Check | What it does | Bypass |
|---|---|---|
IsDebuggerPresent() |
reads PEB.BeingDebugged byte | Set PEB.BeingDebugged = 0 in debugger; ScyllaHide handles |
CheckRemoteDebuggerPresent() |
calls NtQueryInformationProcess(ProcessDebugPort) | Patch return to FALSE; ScyllaHide hooks the syscall |
NtQueryInformationProcess(ProcessDebugPort) |
returns nonzero if debugger attached | Hook + return 0 |
NtQueryInformationProcess(ProcessDebugFlags) |
returns 0 if debugger, 1 if not | Force return 1 |
NtQueryInformationProcess(ProcessDebugObjectHandle) |
nonzero handle if attached | Force NULL |
PEB.NtGlobalFlag |
0x70 if heap debugging | Set to 0 |
PEB.HeapFlags & PEB.ForceFlags |
non-default if debugger | Reset to defaults |
NtSetInformationThread(ThreadHideFromDebugger) |
unhook debugger from thread | Hook NtSetInformationThread |
INT 2D / INT 3 exception handling |
normal flow if no debugger | Set exception handler in debugger |
Hardware breakpoint detection (GetThreadContext check) |
reads DR0-3, fails if BPs set | Use software BPs, or zero DRs before check |
ScyllaHide (x64dbg/x32dbg/IDA plugin) handles essentially all of these automatically.
Linux checks
| Check | What it does | Bypass |
|---|---|---|
ptrace(PTRACE_TRACEME) |
fails if already traced | Run w/o ptrace, or use LD_PRELOAD to hook |
Read /proc/self/status TracerPid: |
nonzero if debugger | LD_PRELOAD hook reading; or modify /proc on a fork |
prctl(PR_SET_DUMPABLE, 0) |
prevents gdb attach |
Patch out the prctl |
getppid() parent process name |
if it's gdb/strace | rename gdb binary, or LD_PRELOAD getppid |
Timing checks via rdtsc |
measures execution time | Use gdb's set $rax = ... to fake; or patch rdtsc out |
LD_PRELOAD bypass example
// bypass.c
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <sys/ptrace.h>
#include <string.h>
long ptrace(int request, int pid, void *addr, void *data) {
return 0; // pretend it always succeeds
}
FILE *fopen(const char *path, const char *mode) {
static FILE *(*orig)(const char *, const char *) = NULL;
if (!orig) orig = dlsym(RTLD_NEXT, "fopen");
if (strstr(path, "/proc/self/status") || strstr(path, "/proc/self/stat")) {
// Return a doctored file
FILE *tmp = tmpfile();
fprintf(tmp, "TracerPid:\t0\n");
rewind(tmp);
return tmp;
}
return orig(path, mode);
}
gcc -shared -fPIC bypass.c -o bypass.so -ldl
LD_PRELOAD=./bypass.so gdb /tmp/sample
3. Anti-VM / sandbox detection
| Check | Bypass |
|---|---|
| CPUID leaf 0x40000000 (hypervisor bit) | Mask CPUID via KVM -cpu host,-hypervisor or VMM config |
VMware backdoor 0x564D5868 magic via IN/OUT |
Patch the magic number check |
| MAC address vendor (00:0C:29 = VMware) | Spoof MAC in VM config |
| Disk size < 50GB | Allocate larger disk for the analysis VM |
| RAM < 2GB | Provision more RAM |
Username sandbox, vagrant, virtual |
Change username in analysis env |
| Recent file count low | Pre-populate Documents folder before run |
| Mouse cursor never moves | Use xdotool to inject mouse jitter |
| Process count, uptime, kernel objects | Boot the VM a while before analysis |
4. Dynamic bypass via debugger
x64dbg / x32dbg (Windows)
- Install ScyllaHide plugin
- In the plugin, enable all checks (PEB patches, NtSetInformation hooks, etc)
- Open the binary, set BP at entry → continue
- ScyllaHide neutralizes most checks transparently
IDA Pro
- Built-in remote debugger + IDAStealth plugin
- For step-tracing through anti-debug: `Debugger options → Suspend on library load
常见问题
它涵盖哪些检查?
它涵盖 Windows 调试器检查、Linux ptrace 检查和虚拟机检测。
分析人员为什么需要这些?
有些程序在检测到分析工具时会隐藏其行为,因此必须先理解这些检查。
这是用来对他人隐藏活动的吗?
不是。它用于在实验室中进行分析工作,以理解程序的行为。
详情
作者的原始描述
Detect and neutralize anti-debug / anti-VM checks — IsDebuggerPresent, ptrace, NtGlobalFlag, timing, hardware-breakpoint detection.
热度
- GitHub 星标
- 6.5k
- 排名
- #14161
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/1
评论
- …