[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EBKW69D5PYB00EAF5NDMBC":3,"skill-same:01M7EBKW69D5PYB00EAF5NDMBC":52},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M7EBKW69D5PYB00EAF5NDMBC","anti-reversing-techniques",null,"Understand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fanti-reversing-techniques-agents-main\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: anti-reversing-techniques\ndescription: Understand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.\n---\n\n> **AUTHORIZED USE ONLY**: This skill contains dual-use security techniques. Before proceeding with any bypass or analysis:\n>\n> 1. **Verify authorization**: Confirm you have explicit written permission from the software owner, or are operating within a legitimate security context (CTF, authorized pentest, malware analysis, security research)\n> 2. **Document scope**: Ensure your activities fall within the defined scope of your authorization\n> 3. **Legal compliance**: Understand that unauthorized bypassing of software protection may violate laws (CFAA, DMCA anti-circumvention, etc.)\n>\n> **Legitimate use cases**: Malware analysis, authorized penetration testing, CTF competitions, academic security research, analyzing software you own\u002Fhave rights to\n\n# Anti-Reversing Techniques\n\nUnderstanding protection mechanisms encountered during authorized software analysis, security research, and malware analysis. This knowledge helps analysts bypass protections to complete legitimate analysis tasks.\n\nFor advanced techniques, see [references\u002Fadvanced-techniques.md](references\u002Fadvanced-techniques.md)\n\n---\n\n## Input \u002F Output\n\n**What you provide:**\n\n- **Binary path or sample**: the executable, DLL, or firmware image under analysis\n- **Platform**: Windows x86\u002Fx64, Linux, macOS, ARM — affects which checks apply\n- **Goal**: bypass for dynamic analysis, identify protection type, build detection code, implement for CTF\n\n**What this skill produces:**\n\n- **Protection identification**: named technique (e.g., RDTSC timing check, PEB BeingDebugged) with location in binary\n- **Bypass strategy**: specific patch addresses, hook points, or tool commands to neutralize each check\n- **Analysis report**: structured findings listing each protection layer, severity, and recommended bypass\n- **Code artifacts**: Python\u002FIDAPython scripts, GDB command sequences, or C stubs for bypassing or implementing checks\n\n---\n\n## Anti-Debugging Techniques\n\n### Windows Anti-Debugging\n\n#### API-Based Detection\n\n```c\n\u002F\u002F IsDebuggerPresent\nif (IsDebuggerPresent()) {\n    exit(1);\n}\n\n\u002F\u002F CheckRemoteDebuggerPresent\nBOOL debugged = FALSE;\nCheckRemoteDebuggerPresent(GetCurrentProcess(), &debugged);\nif (debugged) exit(1);\n\n\u002F\u002F NtQueryInformationProcess\ntypedef NTSTATUS (NTAPI *pNtQueryInformationProcess)(\n    HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);\n\nDWORD debugPort = 0;\nNtQueryInformationProcess(\n    GetCurrentProcess(),\n    ProcessDebugPort,        \u002F\u002F 7\n    &debugPort,\n    sizeof(debugPort),\n    NULL\n);\nif (debugPort != 0) exit(1);\n\n\u002F\u002F Debug flags\nDWORD debugFlags = 0;\nNtQueryInformationProcess(\n    GetCurrentProcess(),\n    ProcessDebugFlags,       \u002F\u002F 0x1F\n    &debugFlags,\n    sizeof(debugFlags),\n    NULL\n);\nif (debugFlags == 0) exit(1);  \u002F\u002F 0 means being debugged\n```\n\n**Bypass:** Use ScyllaHide plugin in x64dbg (patches all common checks automatically). Manually: force `IsDebuggerPresent` return to 0, patch `PEB.BeingDebugged` to 0, hook `NtQueryInformationProcess`. In IDA: `ida_bytes.patch_byte(check_addr, 0x90)`.\n\n#### PEB-Based Detection\n\n```c\n\u002F\u002F Direct PEB access\n#ifdef _WIN64\n    PPEB peb = (PPEB)__readgsqword(0x60);\n#else\n    PPEB peb = (PPEB)__readfsdword(0x30);\n#endif\n\n\u002F\u002F BeingDebugged flag\nif (peb->BeingDebugged) exit(1);\n\n\u002F\u002F NtGlobalFlag\n\u002F\u002F Debugged: 0x70 (FLG_HEAP_ENABLE_TAIL_CHECK |\n\u002F\u002F                 FLG_HEAP_ENABLE_FREE_CHECK |\n\u002F\u002F                 FLG_HEAP_VALIDATE_PARAMETERS)\nif (peb->NtGlobalFlag & 0x70) exit(1);\n\n\u002F\u002F Heap flags\nPDWORD heapFlags = (PDWORD)((PBYTE)peb->ProcessHeap + 0x70);\nif (*heapFlags & 0x50000062) exit(1);\n```\n\n**Bypass:** In x64dbg, follow `gs:[60]` (x64) or `fs:[30]` (x86) in dump. Set `BeingDebugged` (offset +2) to 0; clear `NtGlobalFlag` (offset +0xBC on x64).\n\n#### Timing-Based Detection\n\n```c\n\u002F\u002F RDTSC timing\nuint64_t start = __rdtsc();\n\u002F\u002F ... some code ...\nuint64_t end = __rdtsc();\nif ((end - start) > THRESHOLD) exit(1);\n\n\u002F\u002F QueryPerformanceCounter\nLARGE_INTEGER start, end, freq;\nQueryPerformanceFrequency(&freq);\nQueryPerformanceCounter(&start);\n\u002F\u002F ... code ...\nQueryPerformanceCounter(&end);\ndouble elapsed = (double)(end.QuadPart - start.QuadPart) \u002F freq.QuadPart;\nif (elapsed > 0.1) exit(1);  \u002F\u002F Too slow = debugger\n\n\u002F\u002F GetTickCount\nDWORD start = GetTickCount();\n\u002F\u002F ... code ...\nif (GetTickCount() - start > 1000) exit(1);\n```\n\n**Python script — timing-based anti-debug detection scanner:**\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"Scan a binary for common timing-based anti-debug patterns.\"\"\"\nimport re\nimport sys\n\nPATTERNS = {\n    \"RDTSC\":              rb\"\\x0f\\x31\",                    # RDTSC opcode\n    \"RDTSCP\":             rb\"\\x0f\\x01\\xf9\",                # RDTSCP opcode\n    \"GetTickCount\":       rb\"GetTickCount\\x00\",\n    \"QueryPerfCounter\":   rb\"QueryPerformanceCounter\\x00\",\n    \"NtQuerySysInfo\":     rb\"NtQuerySystemInformation\\x00\",\n}\n\ndef scan(path: str) -> None:\n    data = open(path, \"rb\").read()\n    print(f\"Scanning: {path} ({len(data)} bytes)\\n\")\n    for name, pattern in PATTERNS.items():\n        hits = [m.start() for m in re.finditer(re.escape(pattern), data)]\n        if hits:\n            offsets = \", \".join(hex(h) for h in hits[:5])\n            print(f\"  [{name}] found at: {offsets}\")\n    print(\"\\nDone. Cross-reference offsets in IDA\u002FGhidra to find check logic.\")\n\nif __name__ == \"__main__\":\n    scan(sys.argv[1])\n```\n\n**Bypass:** Use hardware breakpoints (no INT3 overhead), NOP the comparison + conditional jump, freeze RDTSC via hypervisor, or hook timing APIs to return consistent values.\n\n#### Exception-Based Detection\n\n```c\n\u002F\u002F SEH: if debugger is attached it consumes the INT3 exception\n\u002F\u002F and execution falls through to exit(1) instead of the __except handler\n__try { __asm { int 3 } }\n__except(EXCEPTION_EXECUTE_HANDLER) { return; }  \u002F\u002F Clean: exception handled here\nexit(1);  \u002F\u002F Dirty: debugger swallowed the exception\n\n\u002F\u002F VEH: register handler that self-handles INT3 (increments RIP past INT3)\n\u002F\u002F Debugger intercepts first, handler never runs → detected\nLONG CALLBACK VectoredHandler(PEXCEPTION_POINTERS ep) {\n    if (ep->ExceptionRecord->ExceptionCode == EXCEPTION_BREAKPOINT) {\n        ep->ContextRecord->Rip++;\n        return EXCEPTION_CONTINUE_EXECUTION;\n    }\n    return EXCEPTION_CONTINUE_SEARCH;\n}\n```\n\n**Bypass**: In x64dbg, set \"Pass exception to program\" for EXCEPTION_BREAKPOINT (Options → Exceptions → add 0x80000003).\n\n### Linux Anti-Debugging\n\n```c\n\u002F\u002F ptrace self-trace\nif (ptrace(PTRACE_TRACEME, 0, NULL, NULL) == -1) {\n    \u002F\u002F Already being traced\n    exit(1);\n}\n\n\u002F\u002F \u002Fproc\u002Fself\u002Fstatus\nFILE *f = fopen(\"\u002Fproc\u002Fself\u002Fstatus\", \"r\");\nchar line[256];\nwhile (fgets(line, sizeof(line), f)) {\n    if (strncmp(line, \"TracerPid:\", 10) == 0) {\n        int tracer_pid = atoi(line + 10);\n        if (tracer_pid != 0) exit(1);\n    }\n}\n\n\u002F\u002F Parent process check\nif (getppid() != 1 && strcmp(get_process_name(getppid()), \"bash\") != 0) {\n    \u002F\u002F Unusual parent (might be debugger)\n}\n```\n\n**Bypass (LD_PRELOAD hook):**\n\n```bash\n# hook.c: long ptrace(int request, ...) { return 0; }\n# gcc -shared -fPIC -o hook.so hook.c\nLD_PRELOAD=.\u002Fhook.so .\u002Ftarget\n```\n\n**GDB bypass command sequence:**\n\n```gdb\n# 1. Make ptrace(PTRACE_TRACEME) always return 0 (success)\ncatch syscall ptrace\ncommands\n  silent\n  set $rax = 0\n  continue\nend\n\n# 2. Bypass check after ptrace call: find \"cmp rax, 0xffffffff; je \u003Cexit>\"\n#    Clear ZF so the conditional jump is not taken:\n#    set $eflags = $eflags & ~0x40\n\n# 3. Bypass \u002Fproc\u002Fself\u002Fstatus TracerPid check at the open() level\ncatch syscall openat\ncommands\n  silent\n  # If arg contains \"status\", patch the fd result to \u002Fdev\u002Fnull equivalent\n  continue\nend\n\n# 4. Bypass parent process name check\nset follow-fork-mode child\nset detach-on-fork off\n```\n\n---\n\n## Anti-VM Detection\n\n### Hardware Fingerprinting\n\n```c\n\u002F\u002F CPUID-based detection\nint cpuid_info[4];\n__cpuid(cpuid_info, 1);\n\u002F\u002F Check hypervisor bit (bit 31 of ECX)\nif (cpuid_info[2] & (1 \u003C\u003C 31)) {\n    \u002F\u002F Running in hypervisor\n}\n\n\u002F\u002F CPUID brand string\n__cpuid(cpuid_info, 0x40000000);\nchar vendor[13] = {0};\nmemcpy(vendor, &cpuid_info[1], 12);\n\u002F\u002F \"VMwareVMware\", \"Microsoft Hv\", \"KVMKVMKVM\", \"VBoxVBoxVBox\"\n\n\u002F\u002F MAC address prefix\n\u002F\u002F VMware: 00:0C:29, 00:50:56\n\u002F\u002F VirtualBox: 08:00:27\n\u002F\u002F Hyper-V: 00:15:5D\n```\n\n### Registry\u002FFile Detection\n\n```c\n\u002F\u002F Windows registry keys\n\u002F\u002F HKLM\\SOFTWARE\\VMware, Inc.\\VMware Tools\n\u002F\u002F HKLM\\SOFTWARE\\Oracle\\VirtualBox Guest Additions\n\u002F\u002F HKLM\\HARDWARE\\ACPI\\DSDT\\VBOX__\n\n\u002F\u002F Files\n\u002F\u002F C:\\Windows\\System32\\drivers\\vmmouse.sys\n\u002F\u002F C:\\Windows\\System32\\drivers\\vmhgfs.sys\n\u002F\u002F C:\\Windows\\System32\\drivers\\VBoxMouse.sys\n\n\u002F\u002F Processes\n\u002F\u002F vmtoolsd.exe, vmwaretray.exe\n\u002F\u002F VBoxService.exe, VBoxTray.exe\n```\n\n### Timing-Based VM Detection\n\n```c\n\u002F\u002F VM exits cause timing anomalies\nuint64_t start = __rdtsc();\n__cpuid(cpuid_info, 0);  \u002F\u002F Causes VM exit\nuint64_t end = __rdtsc();\nif ((end - start) > 500) {\n    \u002F\u002F Likely in VM (CPUID takes longer)\n}\n```\n\n**Bypass:** Use bare-metal environment, harden VM (remove guest tools, randomize MAC, delete artifact files), patch detection branches in the binary, or use FLARE-VM\u002FREMnux with hardened settings.\n\nFor advanced VM detection (RDTSC delta calibration, VMware backdoor port, hypervisor leaf enumeration, guest driver artifact checks), see [references\u002Fadvanced-techniques.md](references\u002Fadvanced-techniques.md).\n\n---\n\n## Code Obfuscation\n\n### Control Flow Obfuscation\n\n#### Control Flow Flattening\n\n```c\n\u002F\u002F Original\nif (cond) {\n    func_a();\n} else {\n    func_b();\n}\nfunc_c();\n\n\u002F\u002F Flattened\nint state = 0;\nwhile (1) {\n    switch (state) {\n        case 0:\n            state = cond ? 1 : 2;\n            break;\n        case 1:\n            func_a();\n            state = 3;\n            break;\n        case 2:\n            func_b();\n            state = 3;\n            break;\n        case 3:\n            func_c();\n            return;\n    }\n}\n```\n\n**Analysis Approach:**\n\n- Identify state variable\n- Map state transitions\n- Reconstruct original flow\n- Tools: D-810 (IDA), SATURN\n\n#### Opaque Predicates\n\n```c\nint x = rand();\nif ((x * x) >= 0) { real_code(); }   \u002F\u002F Always true  → junk_code() is dead\nif ((x*(x+1)) % 2 == 1) { junk(); }  \u002F\u002F Always false → consecutive product is even\n```\n\n**Analysis Approach:** Identify invariant expressions via symbolic execution (angr, Triton), or pattern-match known opaque forms and prune them.\n\n### Data Obfuscation\n\n#### String Encryption\n\n```c\n\u002F\u002F XOR encryption\nchar decrypt_string(char *enc, int len, char key) {\n    char *dec = malloc(len + 1);\n    for (int i = 0; i \u003C len; i++) {\n        dec[i] = enc[i] ^ key;\n    }\n    dec[len] = 0;\n    return dec;\n}\n\n\u002F\u002F Stack strings\nchar url[20];\nurl[0] = 'h'; url[1] = 't'; url[2] = 't'; url[3] = 'p';\nurl[4] = ':'; url[5] = '\u002F'; url[6] = '\u002F';\n\u002F\u002F ...\n```\n\n**Analysis Approach:**\n\n```python\n# FLOSS for automatic string deobfuscation\nfloss malware.exe\n\n# IDAPython string decryption\ndef decrypt_xor(ea, length, key):\n    result = \"\"\n    for i in range(length):\n        byte = ida_bytes.get_byte(ea + i)\n        result += chr(byte ^ key)\n    return result\n```\n\n#### API Obfuscation\n\n```c\n\u002F\u002F Dynamic API resolution\ntypedef HANDLE (WINAPI *pCreateFileW)(LPCWSTR, DWORD, DWORD,\n    LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);\n\nHMODULE kernel32 = LoadLibraryA(\"kernel32.dll\");\npCreateFileW myCreateFile = (pCreateFileW)GetProcAddress(\n    kernel32, \"CreateFileW\");\n\n\u002F\u002F API hashing\nDWORD hash_api(char *name) {\n    DWORD hash = 0;\n    while (*name) {\n        hash = ((hash >> 13) | (hash \u003C\u003C 19)) + *name++;\n    }\n    return hash;\n}\n\u002F\u002F Resolve by hash comparison instead of string\n```\n\n**Analysis Approach:** Identify the hash algorithm, build a database of known API name hashes, use HashDB plugin for IDA, or run under a debugger to let the binary resolve calls at runtime.\n\n### Instruction-Level Obfuscation\n\n```asm\n; Dead code insertion — semantically inert but pollutes disassembly\npush ebx \u002F mov eax, 1 \u002F pop ebx \u002F xor ecx, ecx \u002F add ecx, ecx\n\n; Instruction substitution — same semantics, different encoding\nxor eax, eax  →  sub eax, eax  |  mov eax, 0  |  and eax, 0\nmov eax, 1    →  xor eax, eax; inc eax  |  push 1; pop eax\n```\n\nFor advanced anti-disassembly tricks (overlapping instructions, junk byte insertion, self-modifying code, ROP as obfuscation), see [references\u002Fadvanced-techniques.md](references\u002Fadvanced-techniques.md).\n\n---\n\n## Bypass Strategies Summary\n\n### General Principles\n\n1. **Understand the protection**: Identify what technique is used\n2. **Find the check**: Locate protection code in binary\n3. **Patch or hook**: Modify check to always pass\n4. **Use appropriate tools**: ScyllaHide, x64dbg plugins\n5. **Document findings**: Keep notes on bypassed protections\n\n### Tool Recommendations\n\n```\nAnti-debug bypass:    ScyllaHide, TitanHide\nUnpacking:           x64dbg + Scylla, OllyDumpEx\nDeobfuscation:       D-810, SATURN, miasm\nVM analysis:         VMAttack, NoVmp, manual tracing\nString decryption:   FLOSS, custom scripts\nSymbolic execution:  angr, Triton\n```\n\n### Ethical Considerations\n\nThis knowledge should only be used for:\n\n- Authorized security research\n- Malware analysis (defensive)\n- CTF competitions\n- Understanding protections for legitimate purposes\n- Educational purposes\n\nNever use to bypass protections for: software piracy, unauthorized access, or malicious purposes.\n\n---\n\n## Troubleshooting\n\n**Detection technique works on x86 but not ARM**\n\nRDTSC and CPUID are x86-only. On ARM, use `MRS x0, PMCCNTR_EL0` (requires kernel PMU access) or `clock_gettime(CLOCK_MONOTONIC)`. PEB\u002FTEB do not exist on ARM — replace with `\u002Fproc\u002Fself\u002Fstatus` (Linux) or `task_info` (macOS). Rebuild detection logic with platform-specific APIs.\n\n**False positive on legitimate debugger or analysis tool**\n\nTiming checks fire when Process Monitor or AV hooks inflate syscall latency. Calibrate the threshold at startup: measure the guarded path 3 times and use `mean + 3*stddev`. For ptrace checks, verify the TracerPid comm name via `\u002Fproc\u002F\u003Cpid>\u002Fcomm` before exiting — it may be an unrelated monitoring tool, not a debugger.\n\n**Bypass patch causes crash instead of continuing execution**\n\nBefore NOPing a conditional jump, trace the \"detected\" branch fully. If it initializes or frees heap state needed later, patching the jump skips that setup and corrupts state. Instead, patch the comparison operand to the expected \"clean\" value, or use x64dbg's \"Set condition to always false\" on the breakpoint rather than modifying bytes.\n\n---\n\n## Related Skills\n\n- `binary-analysis-patterns` — static and dynamic analysis workflows for ELF\u002FPE\u002FMach-O\n- `memory-forensics` — process memory acquisition, artifact extraction, and live analysis\n- `protocol-reverse-engineering` — decoding custom binary protocols and encrypted network traffic\n","> **AUTHORIZED USE ONLY**: This skill contains dual-use security techniques. Before proceeding with any bypass or analysis:\n>\n> 1. **Verify authorization**: Confirm you have explicit written permission from the software owner, or are operating within a legitimate security context (CTF, authorized pentest, malware analysis, security research)\n> 2. **Document scope**: Ensure your activities fall within the defined scope of your authorization\n> 3. **Legal compliance**: Understand that unauthorized bypassing of software protection may violate laws (CFAA, DMCA anti-circumvention, etc.)\n>\n> **Legitimate use cases**: Malware analysis, authorized penetration testing, CTF competitions, academic security research, analyzing software you own\u002Fhave rights to\n\n# Anti-Reversing Techniques\n\nUnderstanding protection mechanisms encountered during authorized software analysis, security research, and malware analysis. This knowledge helps analysts bypass protections to complete legitimate analysis tasks.\n\nFor advanced techniques, see [references\u002Fadvanced-techniques.md](references\u002Fadvanced-techniques.md)\n\n---\n\n## Input \u002F Output\n\n**What you provide:**\n\n- **Binary path or sample**: the executable, DLL, or firmware image under analysis\n- **Platform**: Windows x86\u002Fx64, Linux, macOS, ARM — affects which checks apply\n- **Goal**: bypass for dynamic analysis, identify protection type, build detection code, implement for CTF\n\n**What this skill produces:**\n\n- **Protection identification**: named technique (e.g., RDTSC timing check, PEB BeingDebugged) with location in binary\n- **Bypass strategy**: specific patch addresses, hook points, or tool commands to neutralize each check\n- **Analysis report**: structured findings listing each protection layer, severity, and recommended bypass\n- **Code artifacts**: Python\u002FIDAPython scripts, GDB command sequences, or C stubs for bypassing or implementing checks\n\n---\n\n## Anti-Debugging Techniques\n\n### Windows Anti-Debugging\n\n#### API-Based Detection\n\n```c\n\u002F\u002F IsDebuggerPresent\nif (IsDebuggerPresent()) {\n    exit(1);\n}\n\n\u002F\u002F CheckRemoteDebuggerPresent\nBOOL debugged = FALSE;\nCheckRemoteDebuggerPresent(GetCurrentProcess(), &debugged);\nif (debugged) exit(1);\n\n\u002F\u002F NtQueryInformationProcess\ntypedef NTSTATUS (NTAPI *pNtQueryInformationProcess)(\n    HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);\n\nDWORD debugPort = 0;\nNtQueryInformationProcess(\n    GetCurrentProcess(),\n    ProcessDebugPort,        \u002F\u002F 7\n    &debugPort,\n    sizeof(debugPort),\n    NULL\n);\nif (debugPort != 0) exit(1);\n\n\u002F\u002F Debug flags\nDWORD debugFlags = 0;\nNtQueryInformationProcess(\n    GetCurrentProcess(),\n    ProcessDebugFlags,       \u002F\u002F 0x1F\n    &debugFlags,\n    sizeof(debugFlags),\n    NULL\n);\nif (debugFlags == 0) exit(1);  \u002F\u002F 0 means being debugged\n```\n\n**Bypass:** Use ScyllaHide plugin in x64dbg (patches all common checks automatically). Manually: force `IsDebuggerPresent` return to 0, patch `PEB.BeingDebugged` to 0, hook `NtQueryInformationProcess`. In IDA: `ida_bytes.patch_byte(check_addr, 0x90)`.\n\n#### PEB-Based Detection\n\n```c\n\u002F\u002F Direct PEB access\n#ifdef _WIN64\n    PPEB peb = (PPEB)__readgsqword(0x60);\n#else\n    PPEB peb = (PPEB)__readfsdword(0x30);\n#endif\n\n\u002F\u002F BeingDebugged flag\nif (peb->BeingDebugged) exit(1);\n\n\u002F\u002F NtGlobalFlag\n\u002F\u002F Debugged: 0x70 (FLG_HEAP_ENABLE_TAIL_CHECK |\n\u002F\u002F                 FLG_HEAP_ENABLE_FREE_CHECK |\n\u002F\u002F                 FLG_HEAP_VALIDATE_PARAMETERS)\nif (peb->NtGlobalFlag & 0x70) exit(1);\n\n\u002F\u002F Heap flags\nPDWORD heapFlags = (PDWORD)((PBYTE)peb->ProcessHeap + 0x70);\nif (*heapFlags & 0x50000062) exit(1);\n```\n\n**Bypass:** In x64dbg, follow `gs:[60]` (x64) or `fs:[30]` (x86) in dump. Set `BeingDebugged` (offset +2) to 0; clear `NtGlobalFlag` (offset +0xBC on x64).\n\n#### Timing-Based Detection\n\n```c\n\u002F\u002F RDTSC timing\nuint64_t start = __rdtsc();\n\u002F\u002F ... some code ...\nuint64_t end = __rdtsc();\nif ((end - start) > THRESHOLD) exit(1);\n\n\u002F\u002F QueryPerformanceCounter\nLARGE_INTEGER start, end, freq;\nQueryPerformanceFrequency(&freq);\nQueryPerformanceCounter(&start);\n\u002F\u002F ... code ...\nQueryPerformanceCounter(&end);\ndouble elapsed = (double)(end.QuadPart - start.QuadPart) \u002F freq.QuadPart;\nif (elapsed > 0.1) exit(1);  \u002F\u002F Too slow = debugger\n\n\u002F\u002F GetTickCount\nDWORD start = GetTickCount();\n\u002F\u002F ... code ...\nif (GetTickCount() - start > 1000) exit(1);\n```\n\n**Python script — timing-based anti-debug detection scanner:**\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"Scan a binary for common timing-based anti-debug patterns.\"\"\"\nimport re\nimport sys\n\nPATTERNS = {\n    \"RDTSC\":              rb\"\\x0f\\x31\",                    # RDTSC opcode\n    \"RDTSCP\":             rb\"\\x0f\\x01\\xf9\",                # RDTSCP opcode\n    \"GetTickCount\":       rb\"GetTickCount\\x00\",\n    \"QueryPerfCounter\":   rb\"QueryPerformanceCounter\\x00\",\n    \"NtQuerySysInfo\":     rb\"NtQuerySystemInformation\\x00\",\n}\n\ndef scan(path: str) -> None:\n    data = open(path, \"rb\").read()\n    print(f\"Scanning: {path} ({len(data)} bytes)\\n\")\n    for name, pattern in PATTERNS.items():\n        hits = [m.start() for m in re.finditer(re.escape(pattern), data)]\n        if hits:\n            offsets = \", \".join(hex(h) for h in hits[:5])\n            print(f\"  [{name}] found at: {offsets}\")\n    print(\"\\nDone. Cross-reference offsets in IDA\u002FGhidra to find check logic.\")\n\nif __name__ == \"__main__\":\n    scan(sys.argv[1])\n```\n\n**Bypass:** Use hardware breakpoints (no INT3 overhead), NOP the comparison + conditional jump, freeze RDTSC via hypervisor, or hook timing APIs to return consistent values.\n\n#### Exception-Based Detection\n\n```c\n\u002F\u002F SEH: if debugger is attached it consumes the INT3 exception\n\u002F\u002F and execution falls through to exit(1) instead of the __except handler\n__try { __asm { int 3 } }\n__except(EXCEPTION_EXECUTE_HANDLER) { return; }  \u002F\u002F Clean: exception handled here\nexit(1);  \u002F\u002F Dirty: debugger swallowed the exception\n\n\u002F\u002F VEH: register handler that self-handles INT3 (increments RIP past INT3)\n\u002F\u002F Debugger intercepts first, handler never runs → detected\nLONG CALLBACK VectoredHandler(PEXCEPTION_POINTERS ep) {\n    if (ep->ExceptionRecord->ExceptionCode == EXCEPTION_BREAKPOINT) {\n        ep->ContextRecord->Rip++;\n        return EXCEPTION_CONTINUE_EXECUTION;\n    }\n    return EXCEPTION_CONTINUE_SEARCH;\n}\n```\n\n**Bypass**: In x64dbg, set \"Pass exception to program\" for EXCEPTION_BREAKPOINT (Options → Exceptions → add 0x80000003).\n\n### Linux Anti-Debugging\n\n```c\n\u002F\u002F ptrace self-trace\nif (ptrace(PTRACE_TRACEME, 0, NULL, NULL) == -1) {\n    \u002F\u002F Already being traced\n    exit(1);\n}\n\n\u002F\u002F \u002Fproc\u002Fself\u002Fstatus\nFILE *f = fopen(\"\u002Fproc\u002Fself\u002Fstatus\", \"r\");\nchar line[256];\nwhile (fgets(line, sizeof(line), f)) {\n    if (strncmp(line, \"TracerPid:\", 10) == 0) {\n        int tracer_pid = atoi(line + 10);\n        if (tracer_pid != 0) exit(1);\n    }\n}\n\n\u002F\u002F Parent process check\nif (getppid() != 1 && strcmp(get_process_name(getppid()), \"bash\") != 0) {\n    \u002F\u002F Unusual parent (might be debugger)\n}\n```\n\n**Bypass (LD_PRELOAD hook):**\n\n```bash\n# hook.c: long ptrace(int request, ...) { return 0; }\n# gcc -shared -fPIC -o hook.so hook.c\nLD_PRELOAD=.\u002Fhook.so .\u002Ftarget\n```\n\n**GDB bypass command sequence:**\n\n```gdb\n# 1. Make ptrace(PTRACE_TRACEME) always return 0 (success)\ncatch syscall ptrace\ncommands\n  silent\n  set $rax = 0\n  continue\nend\n\n# 2. Bypass check after ptrace call: find \"cmp rax, 0xffffffff; je \u003Cexit>\"\n#    Clear ZF so the conditional jump is not taken:\n#    set $eflags = $eflags & ~0x40\n\n# 3. Bypass \u002Fproc\u002Fself\u002Fstatus TracerPid check at the open() level\ncatch syscall openat\ncommands\n  silent\n  # If arg contains \"status\", patch the fd result to \u002Fdev\u002Fnull equivalent\n  continue\nend\n\n# 4. Bypass parent process name check\nset follow-fork-mode child\nset detach-on-fork off\n```\n\n---\n\n## Anti-VM Detection\n\n### Hardware Fingerprinting\n\n```c\n\u002F\u002F CPUID-based detection\nint cpuid_info[4];\n__cpuid(cpuid_info, 1);\n\u002F\u002F Check hypervisor bit (bit 31 of ECX)\nif (cpuid_info[2] & (1 \u003C\u003C 31)) {\n    \u002F\u002F Running in hypervisor\n}\n\n\u002F\u002F CPUID brand string\n__cpuid(cpuid_info, 0x40000000);\nchar vendor[13] = {0};\nmemcpy(vendor, &cpuid_info[1], 12);\n\u002F\u002F \"VMwareVMware\", \"Microsoft Hv\", \"KVMKVMKVM\", \"VBoxVBoxVBox\"\n\n\u002F\u002F MAC address prefix\n\u002F\u002F VMware: 00:0C:29, 00:50:56\n\u002F\u002F VirtualBox: 08:00:27\n\u002F\u002F Hyper-V: 00:15:5D\n```\n\n### Registry\u002FFile Detection\n\n```c\n\u002F\u002F Windows registry keys\n\u002F\u002F HKLM\\SOFTWARE\\VMware, Inc.\\VMware Tools\n\u002F\u002F HKLM\\SOFTWARE\\Oracle\\VirtualBox Guest Additions\n\u002F\u002F HKLM\\HARDWARE\\ACPI\\DSDT\\VBOX__\n\n\u002F\u002F Files\n\u002F\u002F C:\\Windows\\System32\\drivers\\vmmouse.sys\n\u002F\u002F C:\\Windows\\System32\\drivers\\vmhgfs.sys\n\u002F\u002F C:\\Windows\\System32\\drivers\\VBoxMouse.sys\n\n\u002F\u002F Processes\n\u002F\u002F vmtoolsd.exe, vmwaretray.exe\n\u002F\u002F VBoxService.exe, VBoxTray.exe\n```\n\n### Timing-Based VM Detection\n\n```c\n\u002F\u002F VM exits cause timing anomalies\nuint64_t start = __rdtsc();\n__cpuid(cpuid_info, 0);  \u002F\u002F Causes VM exit\nuint64_t end = __rdtsc();\nif ((end - start) > 500) {\n    \u002F\u002F Likely in VM (CPUID takes longer)\n}\n```\n\n**Bypass:** Use bare-metal environment, harden VM (remove guest tools, randomize MAC, delete artifact files), patch detection branches in the binary, or use FLARE-VM\u002FREMnux with hardened settings.\n\nFor advanced VM detection (RDTSC delta calibration, VMware backdoor port, hypervisor leaf enumeration, guest driver artifact checks), see [references\u002Fadvanced-techniques.md](references\u002Fadvanced-techniques.md).\n\n---\n\n## Code Obfuscation\n\n### Control Flow Obfuscation\n\n#### Control Flow Flattening\n\n```c\n\u002F\u002F Original\nif (cond) {\n    func_a();\n} else {\n    func_b();\n}\nfunc_c();\n\n\u002F\u002F Flattened\nint state = 0;\nwhile (1) {\n    switch (state) {\n        case 0:\n            state = cond ? 1 : 2;\n            break;\n        case 1:\n            func_a();\n            state = 3;\n            break;\n        case 2:\n            func_b();\n            state = 3;\n            break;\n        case 3:\n            func_c();\n            return;\n    }\n}\n```\n\n**Analysis Approach:**\n\n- Identify state variable\n- Map state transitions\n- Reconstruct original flow\n- Tools: D-810 (IDA), SATURN\n\n#### Opaque Predicates\n\n```c\nint x = rand();\nif ((x * x) >= 0) { real_code(); }   \u002F\u002F Always true  → junk_code() is dead\nif ((x*(x+1)) % 2 == 1) { junk(); }  \u002F\u002F Always false → consecutive product is even\n```\n\n**Analysis Approach:** Identify invariant expressions via symbolic execution (angr, Triton), or pattern-match known opaque forms and prune them.\n\n### Data Obfuscation\n\n#### String Encryption\n\n```c\n\u002F\u002F XOR encryption\nchar decrypt_string(char *enc, int len, char key) {\n    char *dec = malloc(len + 1);\n    for (int i = 0; i \u003C len; i++) {\n        dec[i] = enc[i] ^ key;\n    }\n    dec[len] = 0;\n    return dec;\n}\n\n\u002F\u002F Stack strings\nchar url[20];\nurl[0] = 'h'; url[1] = 't'; url[2] = 't'; url[3] = 'p';\nurl[4] = ':'; url[5] = '\u002F'; url[6] = '\u002F';\n\u002F\u002F ...\n```\n\n**Analysis Approach:**\n\n```python\n# FLOSS for automatic string deobfuscation\nfloss malware.exe\n\n# IDAPython string decryption\ndef decrypt_xor(ea, length, key):\n    result = \"\"\n    for i in range(length):\n        byte = ida_bytes.get_byte(ea + i)\n        result += chr(byte ^ key)\n    return result\n```\n\n#### API Obfuscation\n\n```c\n\u002F\u002F Dynamic API resolution\ntypedef HANDLE (WINAPI *pCreateFileW)(LPCWSTR, DWORD, DWORD,\n    LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);\n\nHMODULE kernel32 = LoadLibraryA(\"kernel32.dll\");\npCreateFileW myCreateFile = (pCreateFileW)GetProcAddress(\n    kernel32, \"CreateFileW\");\n\n\u002F\u002F API hashing\nDWORD hash_api(char *name) {\n    DWORD hash = 0;\n    while (*name) {\n        hash = ((hash >> 13) | (hash \u003C\u003C 19)) + *name++;\n    }\n    return hash;\n}\n\u002F\u002F Resolve by hash comparison instead of string\n```\n\n**Analysis Approach:** Identify the hash algorithm, build a database of known API name hashes, use HashDB plugin for IDA, or run under a debugger to let the binary resolve calls at runtime.\n\n### Instruction-Level Obfuscation\n\n```asm\n; Dead code insertion — semantically inert but pollutes disassembly\npush ebx \u002F mov eax, 1 \u002F pop ebx \u002F xor ecx, ecx \u002F add ecx, ecx\n\n; Instruction substitution — same semantics, different encoding\nxor eax, eax  →  sub eax, eax  |  mov eax, 0  |  and eax, 0\nmov eax, 1    →  xor eax, eax; inc eax  |  push 1; pop eax\n```\n\nFor advanced anti-disassembly tricks (overlapping instructions, junk byte insertion, self-modifying code, ROP as obfuscation), see [references\u002Fadvanced-techniques.md](references\u002Fadvanced-techniques.md).\n\n---\n\n## Bypass Strategies Summary\n\n### General Principles\n\n1. **Understand the protection**: Identify what technique is used\n2. **Find the check**: Locate protection code in binary\n3. **Patch or hook**: Modify check to always pass\n4. **Use appropriate tools**: ScyllaHide, x64dbg plugins\n5. **Document findings**: Keep notes on bypassed protections\n\n### Tool Recommendations\n\n```\nAnti-debug bypass:    ScyllaHide, TitanHide\nUnpacking:           x64dbg + Scylla, OllyDumpEx\nDeobfuscation:       D-810, SATURN, miasm\nVM analysis:         VMAttack, NoVmp, manual tracing\nString decryption:   FLOSS, custom scripts\nSymbolic execution:  angr, Triton\n```\n\n### Ethical Considerations\n\nThis knowledge should only be used for:\n\n- Authorized security research\n- Malware analysis (defensive)\n- CTF competitions\n- Understanding protections for legitimate purposes\n- Educational purposes\n\nNever use to bypass protections for: software piracy, unauthorized access, or malicious purposes.\n\n---\n\n## Troubleshooting\n\n**Detection technique works on x86 but not ARM**\n\nRDTSC and CPUID are x86-only. On ARM, use `MRS x0, PMCCNTR_EL0` (requires kernel PMU access) or `clock_gettime(CLOCK_MONOTONIC)`. PEB\u002FTEB do not exist on ARM — replace with `\u002Fproc\u002Fself\u002Fstatus` (Linux) or `task_info` (macOS). Rebuild detection logic with platform-specific APIs.\n\n**False positive on legitimate debugger or analysis tool**\n\nTiming checks fire when Process Monitor or AV hooks inflate syscall latency. Calibrate the threshold at startup: measure the guarded path 3 times and use `mean + 3*stddev`. For ptrace checks, verify the TracerPid comm name via `\u002Fproc\u002F\u003Cpid>\u002Fcomm` before exiting — it may be an unrelated monitoring tool, not a debugger.\n\n**Bypass patch causes crash instead of continuing execution**\n\nBefore NOPing a conditional jump, trace the \"detected\" branch fully. If it initializes or frees heap state needed later, patching the jump skips that setup and corrupts state. Instead, patch the comparison operand to the expected \"clean\" value, or use x64dbg's \"Set condition to always false\" on the breakpoint rather than modifying bytes.\n\n---\n\n## Related Skills\n\n- `binary-analysis-patterns` — static and dynamic analysis workflows for ELF\u002FPE\u002FMach-O\n- `memory-forensics` — process memory acquisition, artifact extraction, and live analysis\n- `protocol-reverse-engineering` — decoding custom binary protocols and encrypted network traffic\n",{"name":5,"description":7},"main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","03-逆向工程\u002Fanti-reversing-techniques-agents-main",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill anti-reversing-techniques",{"tool":38,"command":39},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill anti-reversing-techniques",{"tool":41,"command":42},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill anti-reversing-techniques","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fanti-reversing-techniques-agents-main\u002FSKILL.md",true,[46],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"references\u002Fadvanced-techniques.md","REFERENCE","参考文档",10615,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fanti-reversing-techniques-agents-main\u002Freferences\u002Fadvanced-techniques.md",[53,61,66,73,80,87],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":60},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":62,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":60},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":60},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":60},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":60},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":60},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]