<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>云散皆星河的博客</title>
  <subtitle>一个随便发发的博客</subtitle>
  <link href="https://blog.xn--9kq396ceqaq4si9m.cn"/>
  <link href="https://blog.xn--9kq396ceqaq4si9m.cn/feed/atom" rel="self"/>
  <updated>2026-10-15T16:28:40+08:00</updated>
  <id>https://blog.xn--9kq396ceqaq4si9m.cn</id>
  <entry>
    <title>我写了半个用户态杀软--R3 ShieldCore!!!</title>
    <link href="https://blog.xn--9kq396ceqaq4si9m.cn/post/%E6%88%91%E5%86%99%E4%BA%86%E5%8D%8A%E4%B8%AA%E7%94%A8%E6%88%B7%E6%80%81%E6%9D%80%E8%BD%AF-r3-shieldcore"/>
    <id>https://blog.xn--9kq396ceqaq4si9m.cn/post/%E6%88%91%E5%86%99%E4%BA%86%E5%8D%8A%E4%B8%AA%E7%94%A8%E6%88%B7%E6%80%81%E6%9D%80%E8%BD%AF-r3-shieldcore</id>
    <published>2026-10-06T23:00:00+08:00</published>
    <updated>2026-10-15T16:28:40+08:00</updated>
    <summary type="html">本文介绍基于 C++20 开发的用户态行为拦截引擎 R3 ShieldCore，它无内核驱动，依靠 DLL 注入与 Inline Hook 监控系统行为。项目通过多种注入方式消除时间盲区，挂钩上百个 API 实现文件、进程、网络等行为管控，借助共享内存完成跨进程通信，并设计稳妥的卸载逻辑。该原型可拦截常规用户态恶意行为，但易被直接 Syscall、手工映射等手段绕过，存在明显防护局限。</summary>
    <content type="html">&lt;h1 id=&quot;我写了半个用户态杀软-r3-shieldcore&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#我写了半个用户态杀软-r3-shieldcore&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;我写了半个用户态杀软--R3 ShieldCore!!!&lt;/h1&gt;
&lt;p&gt;它叫 R3 ShieldCore,Windows 上的用户态行为拦截引擎,代码在 &lt;a href=&quot;https://github.com/yunsjxh/R3ShieldCore&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;https://github.com/yunsjxh/R3ShieldCore&lt;/a&gt; 做的事一句话:把一份 DLL 注入进机器上几乎每一个进程,在进程里把用户态 API 换掉,在行为落地之前拦下来。&lt;/p&gt;
&lt;p&gt;叫它&quot;半个杀软&quot;是因为它只占了用户态这一半——注入、hook、拦 API 调用,都在用户态;另一半在内核和硬件,它够不着。&lt;/p&gt;
&lt;p&gt;约 110 处 inline hook,分给 17 个 guard,处理 18 类对象,纯 C++20。&lt;/p&gt;
&lt;h2 id=&quot;注入把同一份-dll-放进每个进程&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#注入把同一份-dll-放进每个进程&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;注入:把同一份 DLL 放进每个进程&lt;/h2&gt;
&lt;p&gt;枚举进程用的是 &lt;code class=&quot;inline-code&quot;&gt;NtGetNextProcess&lt;/code&gt;,一路 next 到 &lt;code class=&quot;inline-code&quot;&gt;STATUS_NO_MORE_ENTRIES&lt;/code&gt;,带 &lt;code class=&quot;inline-code&quot;&gt;SYNCHRONIZE | DllInject::ProcessAccess&lt;/code&gt; 权限。注不注进去,先过 &lt;code class=&quot;inline-code&quot;&gt;ShouldSkipProcessInjection&lt;/code&gt;。&lt;/p&gt;
&lt;p&gt;关键是&lt;strong&gt;判断这个进程有没有开始跑&lt;/strong&gt;。没跑起来的进程,主线程的指令指针还停在 &lt;code class=&quot;inline-code&quot;&gt;RtlUserThreadStart&lt;/code&gt;,这时候适合用 APC 投递;跑起来了的,只能起远程线程。判断方式是拿 &lt;code class=&quot;inline-code&quot;&gt;NtGetNextThread&lt;/code&gt; 数线程:&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;cpp&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;cpp&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;NtGetNextThread(hProcess, nullptr, access, 0, 0, &amp;amp;thread1);
NTSTATUS status = NtGetNextThread(hProcess, thread1.get(), access, 0, 0, &amp;amp;thread2);
if (status == STATUS_NO_MORE_ENTRIES) {
    // 就一个线程。挂起它，看指令指针
    SuspendThread(thread1.get());
    GetThreadContext(thread1.get(), &amp;amp;c);
    if (c.Rip == pRtlUserThreadStart) {   // 还没跑起来
        // 走 APC 路
    }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;为什么要看这个,而不是无脑起远程线程?因为会踩到一个真实故障:控制台程序如果被我们在它还没通知 &lt;code class=&quot;inline-code&quot;&gt;csrss.exe&lt;/code&gt; 之前就触发了控制台初始化(&lt;code class=&quot;inline-code&quot;&gt;KERNELBASE!ConsoleCommitState&lt;/code&gt; 早于 &lt;code class=&quot;inline-code&quot;&gt;CsrClientCallServer&lt;/code&gt;),&lt;code class=&quot;inline-code&quot;&gt;csrss&lt;/code&gt; 会返回 access denied,&lt;strong&gt;父进程的 CreateProcess 直接失败&lt;/strong&gt;。所以没跑起来的必须走 APC,让它自己线程去执行,别抢跑。&lt;/p&gt;
&lt;p&gt;APC 那条路会建一个互斥体(&lt;code class=&quot;inline-code&quot;&gt;ProcessInitAPCMutex&lt;/code&gt;)去重,防止轮询路和同步路把同一个进程注两遍。32 位进程里还得跨架构去取 64 位 &lt;code class=&quot;inline-code&quot;&gt;ntdll&lt;/code&gt; 的 &lt;code class=&quot;inline-code&quot;&gt;RtlUserThreadStart&lt;/code&gt;,靠 &lt;code class=&quot;inline-code&quot;&gt;wow64ext&lt;/code&gt;。&lt;/p&gt;
&lt;p&gt;送进去的不是 DLL 路径加一句 &lt;code class=&quot;inline-code&quot;&gt;LoadLibrary&lt;/code&gt;。是&lt;strong&gt;一段位置无关的反射 shellcode&lt;/strong&gt;:靠 PEB 遍历自己把 &lt;code class=&quot;inline-code&quot;&gt;LoadLibraryW&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;GetProcAddress&lt;/code&gt; 摸出来,再把 DLL 装起来,全程不依赖目标进程给任何东西。&lt;/p&gt;
&lt;h2 id=&quot;新进程不能有盲区&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#新进程不能有盲区&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;新进程不能有盲区&lt;/h2&gt;
&lt;p&gt;轮询路有个天生的问题:进程已经跑起来了才轮到我们,中间那段就是盲区。所以还有一条同步路——在&lt;strong&gt;父进程&lt;/strong&gt;里 hook &lt;code class=&quot;inline-code&quot;&gt;CreateProcessInternalW&lt;/code&gt;(先找 &lt;code class=&quot;inline-code&quot;&gt;kernelbase.dll&lt;/code&gt;,退而求其次 &lt;code class=&quot;inline-code&quot;&gt;kernel32.dll&lt;/code&gt;),强制给创建标志或上 &lt;code class=&quot;inline-code&quot;&gt;CREATE_SUSPENDED&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;cpp&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;cpp&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;DWORD dwNewCreationFlags = dwCreationFlags | CREATE_SUSPENDED;
bRet = pThis-&amp;gt;originalCreateProcessInternalW(..., dwNewCreationFlags, ...);&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;子进程建出来、主线程还挂着,这时候注入,成功才 &lt;code class=&quot;inline-code&quot;&gt;ResumeThread&lt;/code&gt;;失败就 &lt;code class=&quot;inline-code&quot;&gt;TerminateProcess&lt;/code&gt; 加关句柄、把 &lt;code class=&quot;inline-code&quot;&gt;PROCESS_INFORMATION&lt;/code&gt; 清空、返回 FALSE。让一个一条钩子都没装的进程跑起来,是比杀掉它更坏的结局。&lt;/p&gt;
&lt;p&gt;这里踩过一个坑。原函数在自己内部&lt;strong&gt;也要往刚建出来的子进程里写东西&lt;/strong&gt;——&lt;code class=&quot;inline-code&quot;&gt;RTL_USER_PROCESS_PARAMETERS&lt;/code&gt;,也就是环境块、命令行、当前目录,走的是 &lt;code class=&quot;inline-code&quot;&gt;NtWriteVirtualMemory&lt;/code&gt;。而如果本进程被全量注入了,那次写会被我们自己的钩子判成&quot;跨进程写内存 = 高危&quot;,BLOCK 模式下当场拒掉,于是原函数回滚、返回 FALSE、&lt;code class=&quot;inline-code&quot;&gt;GetLastError()&lt;/code&gt; 是 5,&lt;strong&gt;根本走不到注入那一步&lt;/strong&gt;。实测调用栈:&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;#0 KERNELBASE!NtWriteVirtualMemory   &amp;lt;- 被自己拦下的那一次
#5 KERNEL32!CreateProcessA
#4 KERNELBASE!CreateProcessInternalW &amp;lt;- 原函数&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;解法是开一个&quot;CreateProcess 窗口&quot;:窗口内,由本线程建出来的子进程,对跨进程写内存、改页保护、建远程线程这几样一律透传;窗口一关立即失效。这个窗口对象是 POD,手工 Enter/Leave 配对——不能用 RAII,因为函数体里有 &lt;code class=&quot;inline-code&quot;&gt;__try/__finally&lt;/code&gt;,带析构函数的对象一进来 MSVC 就报 C2712。&lt;/p&gt;
&lt;p&gt;还有个&quot;瘦会话&quot;的设计。&lt;code class=&quot;inline-code&quot;&gt;explorer.exe&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;svchost.exe&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;runtimebroker.exe&lt;/code&gt; 这三个进程&lt;strong&gt;一个 guard 都不装&lt;/strong&gt;,只装 &lt;code class=&quot;inline-code&quot;&gt;CreateProcessInternalW&lt;/code&gt;。目的是让它们拉起的子进程能走上面那条同步路,盲区趋近于零——&quot;双击运行一个启动即写 MBR 的样本&quot;,只有这条路能赢。代价是这三个进程自己不受监控,这是故意的:&lt;code class=&quot;inline-code&quot;&gt;explorer.exe&lt;/code&gt; 的文件 I/O 频率极高(开目录、缩略图、拖放),全量 hook 在 BLOCK 模式下必炸,而且 DLL 里任何一个 bug 都会让整个桌面挂掉。&lt;/p&gt;
&lt;h2 id=&quot;进了进程把-api-换掉&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#进了进程把-api-换掉&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;进了进程,把 API 换掉&lt;/h2&gt;
&lt;p&gt;DLL 落地后的流程是 &lt;code class=&quot;inline-code&quot;&gt;MH_Initialize&lt;/code&gt; → 设定线程冻结方式 → 各 guard 依次 &lt;code class=&quot;inline-code&quot;&gt;MH_CreateHook&lt;/code&gt; + &lt;code class=&quot;inline-code&quot;&gt;MH_QueueEnableHook&lt;/code&gt; 排队 → 最后一次 &lt;code class=&quot;inline-code&quot;&gt;MH_ApplyQueued&lt;/code&gt; 全部生效。用&quot;排队再一次性生效&quot;而不是逐个立刻挂上,是为了避免钩子挂到一半的中间态。&lt;/p&gt;
&lt;p&gt;线程冻结方式分两种:APC 路进来时本进程还没别的线程在跑,用 &lt;code class=&quot;inline-code&quot;&gt;MH_FREEZE_METHOD_NONE_UNSAFE&lt;/code&gt;;其余情况用 &lt;code class=&quot;inline-code&quot;&gt;MH_FREEZE_METHOD_FAST_UNDOCUMENTED&lt;/code&gt;,靠 MinHook 的未文档化手法把别的线程冻住再改代码。&lt;/p&gt;
&lt;p&gt;挂点大致分布是:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;ntdll&lt;/code&gt;:&lt;code class=&quot;inline-code&quot;&gt;NtCreateKey&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;NtSetValueKey&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;NtCreateFile&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;NtWriteFile&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;NtOpenProcess&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;NtCreateThreadEx&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;NtWriteVirtualMemory&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;NtProtectVirtualMemory&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;NtAllocateVirtualMemory&lt;/code&gt; 等&lt;/li&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;user32&lt;/code&gt;:&lt;code class=&quot;inline-code&quot;&gt;SetWindowsHookEx&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;SendInput&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;BlockInput&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;ClipCursor&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;ws2_32&lt;/code&gt;:&lt;code class=&quot;inline-code&quot;&gt;connect&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;WSAConnect&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;sendto&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;bind&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;advapi32&lt;/code&gt;:服务相关那一批&lt;/li&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;combase&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;ole32&lt;/code&gt;:&lt;code class=&quot;inline-code&quot;&gt;CoCreateInstance&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;CoGetClassObject&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;WMI、计划任务、摄像头设备这三类是纯 COM 接口,&lt;strong&gt;没有可挂的导出函数&lt;/strong&gt;,只能去改 vtable 指针,和 MinHook 是两套手艺。&lt;/p&gt;
&lt;p&gt;17 个 guard 的安装顺序不能乱:&lt;code class=&quot;inline-code&quot;&gt;RegistryGuard&lt;/code&gt; 必须先装,因为其余 16 个都是先问它的 &lt;code class=&quot;inline-code&quot;&gt;IsBypassed()&lt;/code&gt; 结论来决定自己挂不挂;而且共享通道也是它开的。通道开不起来的时候,这个进程&lt;strong&gt;直接跳过全部 hook&lt;/strong&gt;,而不是装一半——装了一半的防护比没装更难查。&lt;/p&gt;
&lt;p&gt;拿 &lt;code class=&quot;inline-code&quot;&gt;NtCreateKey&lt;/code&gt; 举例(&lt;code class=&quot;inline-code&quot;&gt;registry_guard.cpp&lt;/code&gt;):&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;cpp&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;cpp&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;NTSTATUS NTAPI NtCreateKey_Hook(PHANDLE KeyHandle, ACCESS_MASK DesiredAccess,
    const RG_OBJECT_ATTRIBUTES* ObjectAttributes, ULONG TitleIndex,
    RG_UNICODE_STRING* Class, ULONG CreateOptions, PULONG Disposition)
{
    InterlockedIncrement(&amp;amp;g_activeHooks);

    R3ShieldCore::Event event;
    Action action = Action::Pass;
    NTSTATUS status = STATUS_UNSUCCESSFUL;

    __try {
        action = Evaluate(R3ShieldCore::Op::CreateKey, nullptr,
            ObjectAttributes ? ObjectAttributes-&amp;gt;ObjectName : nullptr, nullptr,
            DesiredAccess, event, true);
    }
    __except (EXCEPTION_EXECUTE_HANDLER) {
        action = ExceptionAction(event);
    }

    if (action == Action::Block) {
        event.Status = static_cast&amp;lt;ULONG&amp;gt;(STATUS_ACCESS_DENIED);
        Publish(event);
        status = STATUS_ACCESS_DENIED;
    }
    else {
        status = pOriginalNtCreateKey(KeyHandle, DesiredAccess, ObjectAttributes,
            TitleIndex, Class, CreateOptions, Disposition);
        if (action == Action::Record) {
            event.Status = static_cast&amp;lt;ULONG&amp;gt;(status);
            if (status &amp;gt;= 0 &amp;amp;&amp;amp; KeyHandle) {
                __try { RefineKeyPath(*KeyHandle, event); }
                __except (EXCEPTION_EXECUTE_HANDLER) {}
            }
            Publish(event);
        }
    }

    InterlockedDecrement(&amp;amp;g_activeHooks);
    return status;
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;骨架就四件事:&lt;code class=&quot;inline-code&quot;&gt;Evaluate&lt;/code&gt; 判、&lt;code class=&quot;inline-code&quot;&gt;Block&lt;/code&gt; 就直接返 &lt;code class=&quot;inline-code&quot;&gt;STATUS_ACCESS_DENIED&lt;/code&gt; 不往下走、&lt;code class=&quot;inline-code&quot;&gt;Record&lt;/code&gt; 就先调原函数再补路径再上报、首尾一对计数。&lt;/p&gt;
&lt;p&gt;这段代码我试过抽象。想用模板把这一百来个函数收敛成一个,省掉那 130 处手工记账,结果 MSVC 在 &lt;code class=&quot;inline-code&quot;&gt;__try&lt;/code&gt; 上直接甩 C2712——异常处理和带析构函数的 C++ 对象不能共处一个函数。所以每个 hook 都是手写、长得一模一样。注释里写了原因,免得下次再有&quot;优化一下&quot;的冲动。&lt;/p&gt;
&lt;p&gt;顺带说一个判据上的规矩:多层过滤的顺序是&lt;strong&gt;先判断是不是文件对象 → 再判高危 → 最后才走豁免&lt;/strong&gt;。高危路径往往正好落在豁免范围里,先走豁免就会被当噪音放过去。这个顺序在 &lt;code class=&quot;inline-code&quot;&gt;registry_guard.cpp&lt;/code&gt; 和 &lt;code class=&quot;inline-code&quot;&gt;file_guard.cpp&lt;/code&gt; 里反复标着。&lt;/p&gt;
&lt;h2 id=&quot;事件从别的进程传回来&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#事件从别的进程传回来&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;事件从别的进程传回来&lt;/h2&gt;
&lt;p&gt;引擎和注入的 DLL 之间有两块共享内存,职责分得很开:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Policy&lt;/strong&gt;:引擎写,DLL 用 &lt;code class=&quot;inline-code&quot;&gt;FILE_MAP_READ&lt;/code&gt; &lt;strong&gt;只读&lt;/strong&gt;打开。里面是模式、开关位、各种名单、统计。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Events&lt;/strong&gt;:环形缓冲,各进程写、引擎单消费者读。&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Policy 只读不是随手写的——早先有个字段是&quot;高危命中计数&quot;,让 hook 侧去递增,结果被注入的进程一写就 &lt;code class=&quot;inline-code&quot;&gt;0xC0000005&lt;/code&gt;,异常被 &lt;code class=&quot;inline-code&quot;&gt;__except&lt;/code&gt; 吞掉变成&quot;静默放行&quot;,症状是&quot;高危既不拦也不记&quot;。所以凡是 hook 侧要递增的计数,一律放在 Events 那边的 &lt;code class=&quot;inline-code&quot;&gt;ChannelHeader&lt;/code&gt; 里,那个映射才是可写的。&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;ChannelHeader&lt;/code&gt; 卡在 32 字节(&lt;code class=&quot;inline-code&quot;&gt;static_assert&lt;/code&gt; 钉死),后面直接跟着 &lt;code class=&quot;inline-code&quot;&gt;Event[Capacity]&lt;/code&gt;。发布一条事件的协议是:&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;cpp&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;cpp&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;LONG index = InterlockedIncrement(&amp;amp;channel-&amp;gt;WriteIndex) - 1;
// 消费者没追上就丢弃 —— 绝不阻塞调用方
bool dropped = (index - channel-&amp;gt;ReadIndex) &amp;gt;= channel-&amp;gt;Capacity;
Event* slot = ChannelEventAt(channel, index);
if (dropped) { memset(slot, 0, sizeof(Event)); InterlockedIncrement(&amp;amp;channel-&amp;gt;DroppedCount); }
else         { memcpy(slot, &amp;amp;event, sizeof(Event)); }
slot-&amp;gt;Sequence = 0;
MemoryBarrier();
InterlockedExchange(&amp;amp;slot-&amp;gt;Sequence, index + 1);   // 消费者只认 Sequence == index+1&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;生产者&lt;strong&gt;任何时候都不阻塞&lt;/strong&gt;——hook 跑在别人的业务线程上,卡一下就是卡别人整个程序,所以缓冲满了就丢,记 &lt;code class=&quot;inline-code&quot;&gt;DroppedCount&lt;/code&gt;。丢弃的那格也得占位,不占的话消费者会永远卡在那个序号上、此后一条都读不出来。&lt;/p&gt;
&lt;p&gt;消费者这边的套圈处理更绕一点。如果 &lt;code class=&quot;inline-code&quot;&gt;writeIndex - readIndex &amp;gt; Capacity&lt;/code&gt;,说明生产者已经把那一圈覆盖了、&lt;code class=&quot;inline-code&quot;&gt;Sequence&lt;/code&gt; 再也不可能等于 &lt;code class=&quot;inline-code&quot;&gt;readIndex + 1&lt;/code&gt;,这时必须主动把 &lt;code class=&quot;inline-code&quot;&gt;readIndex&lt;/code&gt; 推到 &lt;code class=&quot;inline-code&quot;&gt;writeIndex - Capacity&lt;/code&gt;,跳过这段已丢的事件。不推的话消费者就永久死锁在那儿。&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;Event&lt;/code&gt; 结构里字段挺多,挑几个有意思的:&lt;code class=&quot;inline-code&quot;&gt;ObjectType&lt;/code&gt; 决定 &lt;code class=&quot;inline-code&quot;&gt;Op&lt;/code&gt; 该按哪套枚举解释(注册表、文件、进程各有各的 &lt;code class=&quot;inline-code&quot;&gt;Op&lt;/code&gt; 空间,共用同一个结构、同一条通道、同一套 UI);&lt;code class=&quot;inline-code&quot;&gt;TargetProcessId&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;CreatorProcessId&lt;/code&gt; 专门用来区分进程创建里的&quot;谁建的&quot;和&quot;建了谁&quot;;网络那些事件单独有 &lt;code class=&quot;inline-code&quot;&gt;TargetPort&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;NetProtocol&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;LocalAddress&lt;/code&gt;,不把 IP 和端口拼成一个字符串,因为 UI 要分列,而且 IPv6 的 &lt;code class=&quot;inline-code&quot;&gt;::&lt;/code&gt; 跟端口分隔符会打架。&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;Event::Flags&lt;/code&gt; 是 32 位,到 &lt;code class=&quot;inline-code&quot;&gt;0x80000000&lt;/code&gt; 就用满了。所以从某个版本起新语义一律走尾部追加的 &lt;code class=&quot;inline-code&quot;&gt;Flags2&lt;/code&gt;,不再往 &lt;code class=&quot;inline-code&quot;&gt;Flags&lt;/code&gt; 里挤。&lt;/p&gt;
&lt;p&gt;跨进程 ABI 版本号现在到 20。&lt;strong&gt;尾部追加字段虽然不动前面的偏移,但会改 &lt;code class=&quot;inline-code&quot;&gt;sizeof(Policy)&lt;/code&gt;&lt;/strong&gt;,而 &lt;code class=&quot;inline-code&quot;&gt;sizeof&lt;/code&gt; 变了就必须升版本,原因是两个方向都会坏事:新 DLL 配旧引擎,旧引擎建的 section 更小,新 DLL 按新尺寸 &lt;code class=&quot;inline-code&quot;&gt;MapViewOfFile&lt;/code&gt; 会直接失败;旧 DLL 配新引擎,旧 DLL 只映射自己那一段能成功,但它会按旧布局去读新加的 &lt;code class=&quot;inline-code&quot;&gt;NeverInjectPaths&lt;/code&gt; 那块字节。两个方向最后都落成同一句话——&lt;strong&gt;版本对不上就当作&quot;共享通道不可用&quot;,本进程跳过全部 hook&lt;/strong&gt;,而不是含糊地按错误布局读内存。Policy 和 Channel 各带一个 magic(&lt;code class=&quot;inline-code&quot;&gt;&amp;#039;RGP1&amp;#039;&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;&amp;#039;RGE1&amp;#039;&lt;/code&gt;),加上版本号和引擎 pid 一起校验。&lt;/p&gt;
&lt;h2 id=&quot;弹窗怎么跨进程&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#弹窗怎么跨进程&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;弹窗怎么跨进程&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;ask&lt;/code&gt; 模式要弹窗,可麻烦在于:我的 DLL 跑在&lt;strong&gt;别人的进程&lt;/strong&gt;里,窗得画在&lt;strong&gt;引擎进程&lt;/strong&gt;里。这条通道没用命名管道,也没用窗口消息——那两样都带着能被目标进程观察、甚至干扰的语义。用的是命名共享内存加命名事件。&lt;/p&gt;
&lt;p&gt;共享内存里排 8 个槽。每个槽有个 &lt;code class=&quot;inline-code&quot;&gt;State&lt;/code&gt;(Free / Claimed / Pending / Answered)和一个 &lt;code class=&quot;inline-code&quot;&gt;Generation&lt;/code&gt;(世代号)。生产者是任意进程里那个被卡住的 hook 线程,流程是这样:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;逐个槽 CAS 抢,把 &lt;code class=&quot;inline-code&quot;&gt;State&lt;/code&gt; 从 Free 抢成 Claimed&lt;/li&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;InterlockedIncrement(Generation)&lt;/code&gt;——&lt;strong&gt;必须在发布之前&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;填请求字段&lt;/li&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;MemoryBarrier()&lt;/code&gt;,再把 &lt;code class=&quot;inline-code&quot;&gt;State&lt;/code&gt; 置成 Pending&lt;/li&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;SetEvent&lt;/code&gt; 通知引擎&lt;/li&gt;&lt;li&gt;等本槽的应答事件,带超时。醒来先确认 &lt;code class=&quot;inline-code&quot;&gt;State == Answered&lt;/code&gt; &lt;strong&gt;且&lt;/strong&gt; &lt;code class=&quot;inline-code&quot;&gt;AnsweredGeneration == 自己的世代号&lt;/code&gt;,不满足说明这是上一次请求的迟到答复,继续等&lt;/li&gt;&lt;li&gt;超时就自己把槽释放掉,返回兜底结论(默认 deny)&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;引擎那边是 UI 线程做的:扫 Pending 的槽、快照、弹窗、写结论和 &lt;code class=&quot;inline-code&quot;&gt;AnsweredGeneration&lt;/code&gt;,然后 &lt;code class=&quot;inline-code&quot;&gt;InterlockedCompareExchange(State, Answered, Pending)&lt;/code&gt;——&lt;strong&gt;只在槽还是 Pending 的时候才置成 Answered&lt;/strong&gt;。如果 DLL 那边已经超时把槽释放了,CAS 就失败,这个答复直接被丢掉,不会串到别人的新请求上。&lt;/p&gt;
&lt;p&gt;第 2 步和第 7 步合起来就是整个协议的命门。没有世代号的话,&quot;上一个请求超时释放了槽、下一个请求占了同一个槽、上一个的答复这时候才到&quot;——这条时序会把 A 的结论喂给 B,而 B 可能正好是个写注册表的操作。所以每个请求带着自己的世代号走,答复必须对号。&lt;/p&gt;
&lt;p&gt;几个边角:等的时候按 250 毫秒切片轮询,不是死等一整个超时,这样卸载通知一来就能立刻收手;同一个进程已经有请求在等用户时,新的直接返回兜底结论,既防刷屏也防&quot;用户还没点完、同一个进程被问十遍&quot;;&lt;code class=&quot;inline-code&quot;&gt;log&lt;/code&gt; 模式在 &lt;code class=&quot;inline-code&quot;&gt;Ask&lt;/code&gt; 入口直接短路返回 Allow,压根不碰通道——观测模式不能因为通道不在就变成拒绝。&lt;/p&gt;
&lt;h2 id=&quot;卸载顺序一步都不能换&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#卸载顺序一步都不能换&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;卸载顺序,一步都不能换&lt;/h2&gt;
&lt;p&gt;卸载这五步是这个项目里我最不敢动的地方:&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;cpp&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;cpp&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;R3ShieldCorePrompt::NotifyShutdown();      // 1. 让还在等答复的 Ask 立刻收手
MH_DisableHook(MH_ALL_HOOKS);              // 2. 新调用走回原函数
Sleep(100);                                // 3. 给&amp;quot;跨过前几字节、还没进计数&amp;quot;的线程一点时间
RegistryGuard::WaitForHooksToDrain(10000); //    ...17 个 guard 各等一次
m_newProcessInjector.reset();              // 4. 等 CreateProcessInternalW 的在飞调用归零
MH_Uninitialize();                         // 5. 确认没人在 DLL 里了，才释放 trampoline&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;第 5 步之前的每一件事,都是为了确保没有线程还待在这个 DLL 的代码里。早期版本直接 &lt;code class=&quot;inline-code&quot;&gt;MH_Uninitialize&lt;/code&gt;,结果把宿主打崩:那一步会释放 trampoline,而此刻可能有线程正卡在 hook 里(ask 模式下甚至停在等用户点按钮,最长几十秒),它返回的时候就是野指针。WER 报的是 &lt;code class=&quot;inline-code&quot;&gt;r3shieldcore-lib.dll_unloaded&lt;/code&gt;,异常码 &lt;code class=&quot;inline-code&quot;&gt;c0000005&lt;/code&gt;。实测打崩过 &lt;code class=&quot;inline-code&quot;&gt;MyApp.exe&lt;/code&gt; 和 &lt;code class=&quot;inline-code&quot;&gt;OfficeClickToRun.exe&lt;/code&gt;。&lt;/p&gt;
&lt;p&gt;第 3 步能奏效,靠的是每个 hook 首尾那对 &lt;code class=&quot;inline-code&quot;&gt;InterlockedIncrement/Decrement(&amp;amp;g_activeHooks)&lt;/code&gt;。这也是我说&quot;130 处手工记账&quot;是笔债的原因——这 130 处里任何一处漏了递减,&lt;code class=&quot;inline-code&quot;&gt;WaitForHooksToDrain&lt;/code&gt; 就永远等不到归零,卸载卡死在那儿。&lt;/p&gt;
&lt;h2 id=&quot;几个真踩过的坑&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#几个真踩过的坑&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;几个真踩过的坑&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;掩码用错位。&lt;/strong&gt; 注册表那边判断&quot;是不是写意图&quot;,我一开始拿 &lt;code class=&quot;inline-code&quot;&gt;KEY_WRITE&lt;/code&gt; 当掩码。问题是它的 &lt;code class=&quot;inline-code&quot;&gt;READ_CONTROL(0x00020000)&lt;/code&gt; 位和 &lt;code class=&quot;inline-code&quot;&gt;KEY_READ&lt;/code&gt; 完全重叠,结果把一大票纯读打开全判成了写意图。实测十二秒里刷出 240 条噪音。这种错它不报错,只是安静地做错事。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;一个连字符。&lt;/strong&gt; 轮询路和同步路本来该共用同一个拼名函数去造那个去重互斥体的名字。同步路那份写成了 &lt;code class=&quot;inline-code&quot;&gt;L&amp;quot;\\ProcessInitAPCMutex-pid=%u&amp;quot;&lt;/code&gt;——拼出来是个对象路径,而私有命名空间根本没被真的创建过,于是 &lt;code class=&quot;inline-code&quot;&gt;CreateMutex&lt;/code&gt; 每次都返回 &lt;code class=&quot;inline-code&quot;&gt;ERROR_PATH_NOT_FOUND&lt;/code&gt;,每次都抛异常。&lt;strong&gt;同步注入路从来没成功过一次&lt;/strong&gt;,子进程被原样放行,全靠 10 毫秒轮询兜底,而日志里看起来一切正常。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;注入两次就死。&lt;/strong&gt; 会话信号量是按 pid 命名的。同一个进程被注入两次时,第二次的 &lt;code class=&quot;inline-code&quot;&gt;create&lt;/code&gt; 拿到的是同一个信号量对象(计数已被第一次拿走),&lt;code class=&quot;inline-code&quot;&gt;acquire()&lt;/code&gt; 就永久阻塞。如果第二次走的是 APC 路,这段代码跑在&lt;strong&gt;主线程&lt;/strong&gt;上,于是主线程卡死、&lt;code class=&quot;inline-code&quot;&gt;main&lt;/code&gt; 永远进不去:现象是窗口一片空白、进程常驻。改成先 &lt;code class=&quot;inline-code&quot;&gt;OpenSemaphoreW&lt;/code&gt; 探测,存在就直接放弃这次注入——&lt;strong&gt;fail-fast&lt;/strong&gt;,后来的让位给先到的。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;只堵最后一步等于没堵。&lt;/strong&gt; 代码注入链是四步:&lt;code class=&quot;inline-code&quot;&gt;NtAllocateVirtualMemory&lt;/code&gt; 申请可执行内存 → &lt;code class=&quot;inline-code&quot;&gt;NtWriteVirtualMemory&lt;/code&gt; 写 shellcode → &lt;code class=&quot;inline-code&quot;&gt;NtProtectVirtualMemory&lt;/code&gt; 改成可执行 → &lt;code class=&quot;inline-code&quot;&gt;NtCreateThreadEx&lt;/code&gt; 起线程。早先我只挂了最后一步,前面三步完全裸奔。补上之后,判据的唯一关键是&lt;strong&gt;目标进程 ≠ 当前进程&lt;/strong&gt;:这几个 API 在每个进程里都被合法高频调用(.NET/Java 的 JIT、浏览器的 JIT、任何带 GC 的运行时都在自己进程里 allocate + write + protect),对本进程必须一律放行,否则整个系统当场瘫掉。&lt;/p&gt;
&lt;h2 id=&quot;它拦不到什么&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#它拦不到什么&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;它拦不到什么&lt;/h2&gt;
&lt;p&gt;上面这一整套都建立在&quot;它走用户态 API&quot;的前提上。反过来,程序自己带 syscall 号直接进内核、手工映射一份 DLL、或者复制一个令牌——这三条我一条都拦不住。不是没修,是用户态这个位置本身够不着。&lt;/p&gt;
&lt;p&gt;仓库里带了个 &lt;code class=&quot;inline-code&quot;&gt;dskill.exe&lt;/code&gt;,就是用直 syscall 绕过我全部 hook 的。我把它打进发布包,一来让&quot;能被绕过&quot;这句话有实证,二来它也是自我保护生效后留给自己的逃生门。&lt;/p&gt;
&lt;p&gt;顺着这个边界往下推:写 MBR 的恶搞程序拦不到(那不走任何用户态 API,得靠 minifilter 在内核拦 &lt;code class=&quot;inline-code&quot;&gt;IRP_MJ_WRITE&lt;/code&gt;);提前进内核覆写硬盘、改 BIOS 的那种更够不着。但注册表自启、计划任务、加载 DLL、拉起子进程、出站连接这些要经过我挂着的 API 的动作,能在半路截住——银狐、熊猫烧香这类样本落在用户态的那部分手脚,就属于这一类。&lt;/p&gt;
&lt;h2 id=&quot;说到底&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#说到底&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;说到底&lt;/h2&gt;
&lt;p&gt;它是那半个杀软:用户态这一半,注入、hook、拦 API,做得还算认真;内核和硬件那半边够不着。110 处钩子装在每一个进程里,从里面往外看。你要是想搞清楚自己机器上谁在动手,它够用——墙它变不出来。&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>用 Python 复现极域 V6.0 教师端通信协议</title>
    <link href="https://blog.xn--9kq396ceqaq4si9m.cn/post/%E7%94%A8-python-%E5%A4%8D%E7%8E%B0%E6%9E%81%E5%9F%9F-v60-%E6%95%99%E5%B8%88%E7%AB%AF%E9%80%9A%E4%BF%A1%E5%8D%8F%E8%AE%AE"/>
    <id>https://blog.xn--9kq396ceqaq4si9m.cn/post/%E7%94%A8-python-%E5%A4%8D%E7%8E%B0%E6%9E%81%E5%9F%9F-v60-%E6%95%99%E5%B8%88%E7%AB%AF%E9%80%9A%E4%BF%A1%E5%8D%8F%E8%AE%AE</id>
    <published>2026-10-05T19:27:00+08:00</published>
    <updated>2026-10-15T16:33:22+08:00</updated>
    <summary type="html">作者基于 IDA 静态逆向与网络抓包，使用 Python 实现极域 V6.0 教师端模拟器，用于协议安全研究。软件依靠两组 UDP 多播通道完成设备发现、登录握手、保活、消息下发、学生信息上报、屏幕缩略图传输。项目使用`socket`、`struct`构造二进制数据包，还原完整状态机，解决多个协议难点：黑屏锁屏需要组合两套不同报文；处理 UDP 图像分片重组，修复图像翻转、色彩反相问题；通用 MESS 消息必须先解析类别再做子类型解析，避免解析错乱。工程上增加多线程、分级日志、自动解锁等调试与安全防护机制。文章总结逆向经验：静态分析与抓包要互相印证，优先还原状态机而非孤立数据包，解析需要分层处理；该项目为研究原型，仅可在授权环境测试，开源发布。</summary>
    <content type="html">&lt;h1 id=&quot;用-python-复现极域-v60-教师端通信协议&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#用-python-复现极域-v60-教师端通信协议&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;用 Python 复现极域 V6.0 教师端通信协议&lt;/h1&gt;
&lt;blockquote&gt;&lt;p&gt;本文介绍一个基于 Python 的第三方极域课堂管理系统 V6.0 教师端模拟器。项目通过静态逆向分析与网络抓包，还原教师端和学生端之间的 UDP 通信过程，并将发现、登录、保活、消息、学生信息上报与屏幕缩略图等能力组合成一个可观察、可验证的协议实验平台。&lt;/p&gt;
&lt;p&gt;本项目仅用于协议学习、安全研究与教学演示。请只在自己拥有或已获得明确授权的网络和设备上测试。&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;项目源码：&lt;a href=&quot;https://github.com/yunsjxh/Third-party-JiYu-Teacher-Endpoint&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;yunsjxh/Third-party-JiYu-Teacher-Endpoint&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;为什么要重新实现一个教师端&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#为什么要重新实现一个教师端&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;为什么要重新实现一个教师端&lt;/h2&gt;
&lt;p&gt;课堂管理软件看起来是一个普通的桌面应用，但它背后其实包含了一套完整的局域网通信协议：教师端需要先在网络中宣告自己的存在，学生端发现教师后发起登录，双方继续交换保活包、状态包和控制包；当教师请求屏幕预览时，学生端还要把一张图像拆成多个 UDP 数据片段再发送回来。&lt;/p&gt;
&lt;p&gt;如果只观察软件界面，我们看到的是“学生上线”“发送消息”“查看缩略图”等按钮；从协议研究的角度看，真正值得追踪的是另一组问题：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;学生端如何判断网络中存在一个合法的教师端？&lt;/li&gt;&lt;li&gt;登录握手由哪些数据包组成，顺序是否重要？&lt;/li&gt;&lt;li&gt;同一个界面功能是否可能由多条协议路径共同完成？&lt;/li&gt;&lt;li&gt;UDP 不保证到达和顺序，缩略图应当如何重组？&lt;/li&gt;&lt;li&gt;二进制协议中的长度、字节序、编码和填充字段如何确定？&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;这个项目的目标不是简单模仿一个界面，而是把这些藏在可执行文件和网络流量里的规则，整理成一份能够运行的 Python 实现。&lt;/p&gt;
&lt;h2 id=&quot;从黑盒到协议地图&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#从黑盒到协议地图&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;从黑盒到协议地图&lt;/h2&gt;
&lt;p&gt;协议还原主要依靠两类证据。&lt;/p&gt;
&lt;p&gt;第一类是 IDA Pro 静态分析。它适合定位协议魔数、字段偏移、分支条件和关键常量。例如，一个 32 位整数在内存中以小端序出现时，&lt;code class=&quot;inline-code&quot;&gt;0x434E4F4F&lt;/code&gt; 对应 ASCII 字符串 &lt;code class=&quot;inline-code&quot;&gt;OONC&lt;/code&gt;；沿着接收函数继续追踪，就能看到程序如何按照不同 Magic 进入不同处理分支。&lt;/p&gt;
&lt;p&gt;第二类是真实环境中的网络抓包。静态分析可以告诉我们“代码可能怎样解释这个字段”，抓包则能验证“正常教师端实际上发送了什么”。将多组样本逐字节比较后，才可能区分固定值、序列号、GUID、IP 地址、长度字段和可选负载。&lt;/p&gt;
&lt;p&gt;最终得到的通信结构可以概括为两条 UDP 通道：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;通道&lt;/th&gt;&lt;th&gt;地址&lt;/th&gt;&lt;th&gt;主要职责&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;主通道&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;224.50.50.42:4705&lt;/code&gt;&lt;/td&gt;&lt;td&gt;教师发现、保活、控制命令、屏幕缩略图&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;会话通道&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;225.2.2.1:5512&lt;/code&gt;&lt;/td&gt;&lt;td&gt;登录宣告、MESS 消息、状态与信息上报&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;教师端会周期性发送 &lt;code class=&quot;inline-code&quot;&gt;OONC&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;CANC&lt;/code&gt; 和 &lt;code class=&quot;inline-code&quot;&gt;ANNO&lt;/code&gt;，学生端通过 &lt;code class=&quot;inline-code&quot;&gt;LOGI&lt;/code&gt; 进入登录流程，并用 &lt;code class=&quot;inline-code&quot;&gt;KACA&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;TRMC&lt;/code&gt; 等报文维持会话。教师端随后回送 &lt;code class=&quot;inline-code&quot;&gt;WACA&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;LPNT&lt;/code&gt; 和 &lt;code class=&quot;inline-code&quot;&gt;DMOC&lt;/code&gt;，让学生端确认教师身份并进入稳定连接状态。&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;教师端模拟器                         极域学生端
     |                                  |
     |---- OONC / CANC / ANNO ---------&amp;gt;|  发现教师
     |&amp;lt;------------- LOGI --------------|  请求登录
     |---- MESS / LPNT / DMOC ----------&amp;gt;|  完成握手
     |&amp;lt;------------- KACA ---------------|  保活/发现
     |---------------- WACA ------------&amp;gt;|  保活响应
     |---- TNRS / 信息请求 / 消息 -------&amp;gt;|  业务请求
     |&amp;lt;---- LANT / TNAL / MESS ----------|  数据回流&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;这张图也是整个程序的骨架。实现不再是一堆彼此孤立的十六进制常量，而是广播线程、会话接收线程、主通道接收线程和命令行交互之间的一组协作关系。&lt;/p&gt;
&lt;h2 id=&quot;python-如何表达二进制协议&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#python-如何表达二进制协议&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;Python 如何表达二进制协议&lt;/h2&gt;
&lt;p&gt;项目没有引入复杂的协议框架，而是直接使用标准库中的 &lt;code class=&quot;inline-code&quot;&gt;socket&lt;/code&gt; 和 &lt;code class=&quot;inline-code&quot;&gt;struct&lt;/code&gt;。原因很直接：协议字段大多是固定长度的小端整数、GUID、IPv4 地址和 UTF-16LE 字符串，&lt;code class=&quot;inline-code&quot;&gt;struct.pack&lt;/code&gt; 足以准确表达它们。&lt;/p&gt;
&lt;p&gt;以教师在线宣告包为例，其实现由 Magic、版本、包体长度、教师 GUID、本机 IP 和递增序列号组成：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;python&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;python&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;pkt = (
    struct.pack(&amp;#039;&amp;lt;II&amp;#039;, 0x434E4F4F, 0x10000)
    + struct.pack(&amp;#039;&amp;lt;I&amp;#039;, 16)
    + teacher_guid.bytes_le
    + socket.inet_aton(local_ip)
    + struct.pack(&amp;#039;&amp;lt;III&amp;#039;, 1, 1, sequence)
)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;这里最容易出错的并不是 Python 语法，而是协议细节：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;&amp;lt;I&lt;/code&gt; 表示小端无符号 32 位整数；&lt;/li&gt;&lt;li&gt;Windows GUID 的内存布局需要使用 &lt;code class=&quot;inline-code&quot;&gt;bytes_le&lt;/code&gt;；&lt;/li&gt;&lt;li&gt;中文文本必须按 UTF-16LE 编码，并正确计算字符数和结尾空字符；&lt;/li&gt;&lt;li&gt;包头中的长度不一定等于最终 UDP 数据报长度，而可能只描述某一层负载；&lt;/li&gt;&lt;li&gt;某些接收路径会额外读取负载尾部，因此构造包时需要保留兼容填充。&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;二进制协议复现的核心不是“让程序发出数据”，而是让每个字节都能对应到可解释、可验证的字段。&lt;/p&gt;
&lt;h2 id=&quot;难点一黑屏和键鼠锁定其实是两条路径&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#难点一黑屏和键鼠锁定其实是两条路径&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;难点一：黑屏和键鼠锁定其实是两条路径&lt;/h2&gt;
&lt;p&gt;项目中最有代表性的发现，是黑屏功能并不由一个命令独立完成。&lt;/p&gt;
&lt;p&gt;逆向分析显示，学生端存在两条相关处理路径：&lt;code class=&quot;inline-code&quot;&gt;MESS type=0x20&lt;/code&gt; 负责创建黑屏窗口并设置内部状态位，&lt;code class=&quot;inline-code&quot;&gt;COMD case 6&lt;/code&gt; 负责实际锁定键盘和鼠标。只发送其中一条路径，表面上可能暂时有效，却会在解锁时暴露问题。&lt;/p&gt;
&lt;p&gt;例如，仅通过 COMD 显示黑屏时，学生端内部的 bit &lt;code class=&quot;inline-code&quot;&gt;0x20&lt;/code&gt; 没有被正确设置。后续解锁命令进入另一段分支，无法执行预期的解锁函数。真实教师端的做法是组合两条路径，模拟器也因此采用同样的流程：&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;通过会话通道组播 MESS 黑屏包，建立黑屏状态；&lt;/li&gt;&lt;li&gt;需要锁定输入时，再向目标学生单播 COMD 命令；&lt;/li&gt;&lt;li&gt;定时黑屏到期后，由教师端主动发送解锁消息；&lt;/li&gt;&lt;li&gt;手动解锁时取消已有定时器，避免重复动作。&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;这说明逆向工程中一个很重要的原则：不能只根据界面效果判断协议是否还原正确。真正可靠的实现，还要匹配状态变化、后续行为和异常路径。&lt;/p&gt;
&lt;h2 id=&quot;难点二udp-分片不是简单拼接&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#难点二udp-分片不是简单拼接&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;难点二：UDP 分片不是简单拼接&lt;/h2&gt;
&lt;p&gt;屏幕预览是另一个典型问题。学生端会通过 &lt;code class=&quot;inline-code&quot;&gt;LANT&lt;/code&gt;/&lt;code class=&quot;inline-code&quot;&gt;TNAL&lt;/code&gt; 报文分片发送 JPEG 数据，教师端需要维护每个学生独立的接收状态，包括总长度、当前缓冲区和已接收字节数。&lt;/p&gt;
&lt;p&gt;项目使用学生 IP 作为重组键：新图像开始时创建状态，后续分片写入对应位置；只有在确认数据完整后才尝试交给 Pillow 解码。这样可以避免多个学生同时回传缩略图时互相覆盖。&lt;/p&gt;
&lt;p&gt;成功解码并不代表图像已经正确。抓包样本还暴露了两个图像层问题：画面是 bottom-up 的，色度通道也存在反相。项目的修复流程是：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;python&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;python&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;img = Image.open(io.BytesIO(buffer))
img = img.transpose(Image.FLIP_TOP_BOTTOM)
y, cb, cr = img.convert(&amp;#039;YCbCr&amp;#039;).split()
cb = ImageOps.invert(cb)
cr = ImageOps.invert(cr)
img = Image.merge(&amp;#039;YCbCr&amp;#039;, (y, cb, cr)).convert(&amp;#039;RGB&amp;#039;)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;这段处理体现了协议分析经常遇到的情况：传输层的数据结构正确，只能说明“收到了一张图”；要得到视觉上正确的结果，还需要理解发送端图像缓冲区的存储方式和颜色空间。&lt;/p&gt;
&lt;h2 id=&quot;难点三同一个-mess必须先判断语义类别&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#难点三同一个-mess必须先判断语义类别&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;难点三：同一个 MESS，必须先判断语义类别&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;MESS&lt;/code&gt; 是双向的通用消息容器。聊天、黑屏、周期状态、系统信息、进程列表和窗口列表都会经过它。如果只读取某个固定偏移并直接把数字解释成 subtype，就可能把进程 PID 当成 Wi-Fi 数量，把窗口句柄当成另一类状态值。&lt;/p&gt;
&lt;p&gt;模拟器的处理方式是先读取 category，再进入对应解析器：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;0x800000&lt;/code&gt; 表示信息上报；&lt;/li&gt;&lt;li&gt;type 5 是系统信息；&lt;/li&gt;&lt;li&gt;type 6 是窗口列表；&lt;/li&gt;&lt;li&gt;type 7 是进程列表；&lt;/li&gt;&lt;li&gt;周期状态则走另一套 subtype 解释规则。&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;系统信息包含计算机名、用户、MAC、操作系统、CPU 和内存等定长字段。窗口和进程列表采用分片形式，每个条目由一个 32 位 ID 和一个以空字符结尾的 UTF-16LE 名称组成。收到首片时清空旧数据，再将后续分片追加到对应学生的状态中。&lt;/p&gt;
&lt;p&gt;这套设计让项目从“能发控制包”进一步变成了“能维护学生状态的教师端”。命令行中的 &lt;code class=&quot;inline-code&quot;&gt;list&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ps&lt;/code&gt; 和 &lt;code class=&quot;inline-code&quot;&gt;wins&lt;/code&gt; 读取的正是这份动态建档数据。&lt;/p&gt;
&lt;h2 id=&quot;让研究脚本具备可调试性&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#让研究脚本具备可调试性&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;让研究脚本具备可调试性&lt;/h2&gt;
&lt;p&gt;协议实验往往会产生大量重复数据。若每次在线宣告和心跳都输出完整十六进制转储，真正有价值的异常包很快会被淹没。&lt;/p&gt;
&lt;p&gt;项目为此增加了几项工程化处理：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;使用四个后台线程分别处理主通道广播、会话广播和两个接收循环；&lt;/li&gt;&lt;li&gt;过滤本机发出的多播，避免模拟器处理自己的数据；&lt;/li&gt;&lt;li&gt;将日常广播与高频心跳降到 DEBUG 级别；&lt;/li&gt;&lt;li&gt;使用轮转日志限制单个日志文件大小，并保留有限备份；&lt;/li&gt;&lt;li&gt;主窗口只负责 &lt;code class=&quot;inline-code&quot;&gt;teacher&amp;gt;&lt;/code&gt; 命令交互，独立 PowerShell 窗口实时显示日志；&lt;/li&gt;&lt;li&gt;对未知包保留 hexdump，便于继续补充协议知识；&lt;/li&gt;&lt;li&gt;对黑屏操作设置自动解锁，降低实验中因参数错误造成的影响。&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;这些设计并不会改变协议本身，却显著改善了研究体验。协议实现最怕“偶尔能用但无法解释”，而良好的日志、状态隔离和错误输出，能够把一次偶发现象变成可重复验证的结论。&lt;/p&gt;
&lt;h2 id=&quot;运行与观察&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#运行与观察&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;运行与观察&lt;/h2&gt;
&lt;p&gt;项目运行环境很轻量，只依赖 Python 3.8+ 和 Pillow：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;bash&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install Pillow
python &amp;quot;teacher_sim .py&amp;quot;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;程序启动后会自动选择本机网络地址，加入两个多播组，并启动四个后台线程。学生端完成登录后，可以通过 &lt;code class=&quot;inline-code&quot;&gt;list&lt;/code&gt; 查看已建档设备，通过 &lt;code class=&quot;inline-code&quot;&gt;preview &amp;lt;ip&amp;gt;&lt;/code&gt; 请求屏幕缩略图，或使用 &lt;code class=&quot;inline-code&quot;&gt;msg &amp;lt;ip&amp;gt; &amp;lt;text&amp;gt;&lt;/code&gt; 验证双向消息链路。&lt;/p&gt;
&lt;p&gt;仓库还包含一个纯静态项目主页，由 &lt;code class=&quot;inline-code&quot;&gt;index.html&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;styles.css&lt;/code&gt; 和 &lt;code class=&quot;inline-code&quot;&gt;script.js&lt;/code&gt; 组成。页面用 Canvas 动画呈现数据包在教师端与学生端之间流动的效果，并把功能、协议通道、运行方式和安全边界整理成更直观的展示页面。它不参与教师端协议通信，因此核心模拟器仍然可以作为单文件 Python 程序独立运行。&lt;/p&gt;
&lt;h2 id=&quot;项目带来的几个启发&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#项目带来的几个启发&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;项目带来的几个启发&lt;/h2&gt;
&lt;p&gt;回顾整个实现过程，有几条经验尤其值得保留。&lt;/p&gt;
&lt;p&gt;第一，抓包和静态分析必须互相校验。只看流量，很难知道字段为何这样排列；只看反编译代码，也可能误判实际执行路径。二者结合，才能逐步建立可靠的协议模型。&lt;/p&gt;
&lt;p&gt;第二，要优先还原状态机，而不是孤立的数据包。一个报文能被接收，不代表功能已经完成；登录顺序、状态位、定时器和响应包往往同样重要。&lt;/p&gt;
&lt;p&gt;第三，解析器要先分层再解释。Magic、外层头、category、type 和具体负载各自属于不同层次，跳过上层语义直接解释下层字段，很容易得到“数值合理但含义错误”的结果。&lt;/p&gt;
&lt;p&gt;第四，研究工具也需要安全护栏。自动解锁、目标登录校验、清晰日志和明确的授权范围，不只是使用体验问题，也是负责任地开展协议研究所必需的部分。&lt;/p&gt;
&lt;h2 id=&quot;结语&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#结语&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;结语&lt;/h2&gt;
&lt;p&gt;这个项目把一个封闭桌面软件背后的通信过程，转化成了可阅读的代码、可观察的日志和可重复的实验。从教师在线宣告、学生登录，到消息解析和图像分片重组，每一项功能都建立在对具体字节和状态变化的理解上。&lt;/p&gt;
&lt;p&gt;它目前仍是面向极域 V6.0 的研究性实现，并不追求替代成熟的课堂管理产品。它更有价值的身份，是一份活的协议笔记：当新的字段、新的包类型或更准确的握手顺序被发现时，代码、文档和实验结果可以继续相互印证。&lt;/p&gt;
&lt;p&gt;项目采用 MIT License。无论阅读源码、复现实验还是继续扩展协议，都请始终把合法授权和最小影响放在第一位。&lt;/p&gt;
&lt;p&gt;完整源码和后续更新可在 GitHub 仓库 &lt;a href=&quot;https://github.com/yunsjxh/Third-party-JiYu-Teacher-Endpoint&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;yunsjxh/Third-party-JiYu-Teacher-Endpoint&lt;/a&gt; 查看。&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>疏影：面向 Weeback 的专项破解与工程实现</title>
    <link href="https://blog.xn--9kq396ceqaq4si9m.cn/post/%E7%96%8F%E5%BD%B1%E9%9D%A2%E5%90%91-weeback-%E7%9A%84%E4%B8%93%E9%A1%B9%E7%A0%B4%E8%A7%A3%E4%B8%8E%E5%B7%A5%E7%A8%8B%E5%AE%9E%E7%8E%B0"/>
    <id>https://blog.xn--9kq396ceqaq4si9m.cn/post/%E7%96%8F%E5%BD%B1%E9%9D%A2%E5%90%91-weeback-%E7%9A%84%E4%B8%93%E9%A1%B9%E7%A0%B4%E8%A7%A3%E4%B8%8E%E5%B7%A5%E7%A8%8B%E5%AE%9E%E7%8E%B0</id>
    <published>2026-10-05T19:23:00+08:00</published>
    <updated>2026-10-15T16:36:20+08:00</updated>
    <summary type="html">疏影是针对 Weeback 的专项破解工具，主体工作在用户态，附带可选自研内核驱动。通过 IDA 逆向还原其数据库密码异或变换算法，可自动定位软件目录、管理进程与 DLL、清理驱动残留、解密管理员凭据。驱动默认不加载，通过版本 profile 避免硬编码内核偏移。工具仅限授权环境使用，该软件密码仅简单可逆混淆，安全设计薄弱。</summary>
    <content type="html">&lt;h1 id=&quot;疏影面向-weeback-的专项破解与工程实现&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#疏影面向-weeback-的专项破解与工程实现&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;疏影：面向 Weeback 的专项破解与工程实现&lt;/h1&gt;
&lt;p&gt;先把项目定位说清楚：疏影（Sparse Shadow）不是一款通用的 Windows 系统维护软件，而是围绕 Weeback 定制开发的专项破解工具。项目代码中出现的 MPPG / eClass Client 名称、进程、安装目录和数据库，都是这条破解链路的一部分。&lt;/p&gt;
&lt;p&gt;它要解决的不是单一功能，而是一整套围绕对象程序展开的工作：定位安装信息和运行进程、管理 DLL 模块、读取数据库并还原管理员凭据字段、处理关联驱动，以及在用户态信息不足时借助自研内核驱动观察和管理进程状态。后来加入的 &lt;code class=&quot;inline-code&quot;&gt;YsjxhProcess&lt;/code&gt;，把这些能力进一步延伸到了内核层。&lt;/p&gt;
&lt;p&gt;其中，凭据字段的还原逻辑不是通过猜测或枚举尝试得出的，而是使用 IDA 静态分析 Weeback 的 Setup.exe 后，沿数据库写入流程定位到 &lt;code class=&quot;inline-code&quot;&gt;sub_4CB0D0&lt;/code&gt;（地址 &lt;code class=&quot;inline-code&quot;&gt;0x4CB0D0&lt;/code&gt;），再根据反汇编结果整理出的算法。这篇文章记录这条分析链路，以及疏影如何把分析结果落成一个完整工具。&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;疏影包含系统级和内核级操作能力，仅应用于本人拥有、管理或得到明确授权的设备。涉及驱动、进程保护和未公开内核结构的功能，应当在具有快照和内核调试条件的隔离虚拟机中测试。&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;下载:&lt;a href=&quot;https://wwaux.lanzoul.com/i09ox3y8kzcd&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;&lt;a href=&quot;https://wwaux.lanzoul.com/i09ox3y8kzcd&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;https://wwaux.lanzoul.com/i09ox3y8kzcd&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;一个统一的破解与调试界面&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#一个统一的破解与调试界面&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;一个统一的破解与调试界面&lt;/h2&gt;
&lt;p&gt;疏影主程序使用 C++20、Win32 和 GDI+ 编写。界面没有采用传统工具软件中密集堆叠的系统控件，而是围绕 Material Design 3 的层级重新组织了信息：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;侧栏负责功能导航；&lt;/li&gt;&lt;li&gt;状态卡片呈现安装、进程和驱动概况；&lt;/li&gt;&lt;li&gt;危险操作与普通查询使用不同的颜色和确认流程；&lt;/li&gt;&lt;li&gt;操作结果统一进入活动日志；&lt;/li&gt;&lt;li&gt;“扩展驱动工具”窗口使用与主界面一致的浅色 MD3 风格。&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;目前主界面覆盖 Weeback 安装信息扫描、相关进程管理、DLL 模块操作、数据库字段还原、关联驱动处理、内核进程和活动日志等页面。功能虽然较多，但所有入口都服务于同一个明确目标，而不是试图做成包罗万象的系统工具。&lt;/p&gt;
&lt;h2 id=&quot;主程序真正做了什么&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#主程序真正做了什么&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;主程序真正做了什么&lt;/h2&gt;
&lt;p&gt;疏影的大部分功能都在用户态完成，不需要安装 &lt;code class=&quot;inline-code&quot;&gt;YsjxhProcess&lt;/code&gt;。普通启动时，程序会把安装记录、目标目录、运行进程、数据库和关联组件串成一条连续的破解流程；内核驱动只是处理少数特殊状态时才使用的可选扩展。&lt;/p&gt;
&lt;h3 id=&quot;自动检测与破解概览&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#自动检测与破解概览&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;自动检测与破解概览&lt;/h3&gt;
&lt;p&gt;启动后的概览页不是静态菜单。程序会读取 32 位和 64 位卸载注册表视图，寻找与 Weeback、MPPG 和 eClass Client 相关的安装条目，并从 &lt;code class=&quot;inline-code&quot;&gt;DisplayName&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;InstallLocation&lt;/code&gt; 和卸载命令中整理产品名称、版本与安装目录。找到有效目录后，后续的进程扫描和 DLL 页面会自动使用同一个目标范围。&lt;/p&gt;
&lt;p&gt;同一次检测还会尝试定位 &lt;code class=&quot;inline-code&quot;&gt;mppgsvrc.db&lt;/code&gt;、读取管理员记录，并扫描关联的服务、SYS 文件、键盘过滤项和网络过滤组件。概览卡片最终汇总安装条目数、运行进程数、数据库状态与关联组件数量，用户不必逐页点击才能判断当前机器的大致状态。&lt;/p&gt;
&lt;p&gt;如果注册表信息缺失、路径已经失效，或者使用的是非标准安装位置，也可以手动选择目录。手动目录会替代自动结果，避免工具因为安装程序没有正确写入卸载信息而失去后续功能。&lt;/p&gt;
&lt;h3 id=&quot;安装目录与进程联动&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#安装目录与进程联动&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;安装目录与进程联动&lt;/h3&gt;
&lt;p&gt;“安装与进程”页面并不是按一份写死的进程名列表工作。疏影会递归收集目标安装目录中的 &lt;code class=&quot;inline-code&quot;&gt;.exe&lt;/code&gt; 文件名，再用 Tool Help 进程快照匹配当前正在运行的实例。列表中显示可取得的 PID、进程名称和完整映像路径，因此新版本增加或更换可执行文件后，通常不需要同步修改程序内的固定名称表。&lt;/p&gt;
&lt;p&gt;用户可以重新扫描，也可以结束当前识别出的相关进程。结束操作会执行两轮，中间短暂等待，再重新生成快照：第一轮处理当前实例，第二轮用于发现退出较慢或短时间内重新出现的同名进程。每个成功和失败结果都会计数并写入活动日志，拒绝访问的进程不会被伪装成处理成功。&lt;/p&gt;
&lt;p&gt;这套“目录先限定范围、进程再动态匹配”的方式也服务于 DLL 页面。它比单纯按名称操作多了一层路径约束，可以减少同名程序被误判为 Weeback 组件的可能。&lt;/p&gt;
&lt;h3 id=&quot;dll-模块管理&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#dll-模块管理&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;DLL 模块管理&lt;/h3&gt;
&lt;p&gt;DLL 页面允许在已识别的目标进程之间切换，选择本地 &lt;code class=&quot;inline-code&quot;&gt;.dll&lt;/code&gt; 文件后执行加载或卸载。真正操作前，程序会再次打开目标进程、确认它仍在运行、重新读取当前映像路径，并验证路径仍位于选定的 Weeback 安装目录内。这样可以防止列表刷新前后 PID 被复用，或同名进程来自其它目录时误操作。&lt;/p&gt;
&lt;p&gt;加载成功后，界面会记录模块文件名、目标进程名和 PID；重复加载会明确提示模块已经存在。卸载时按所选 DLL 的模块名在目标进程中定位，不要求用户手工输入基址。目标消失、路径变化、权限不足或模块不存在时，界面保留系统错误码与可读错误信息，便于继续排查。&lt;/p&gt;
&lt;p&gt;DLL 操作属于会改变目标进程状态的功能，因此它只接受明确选择的安装目录内进程和本地 DLL，并在执行前显示确认。它不是面向任意 PID 的通用注入器。&lt;/p&gt;
&lt;h3 id=&quot;数据库定位与字段还原&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#数据库定位与字段还原&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;数据库定位与字段还原&lt;/h3&gt;
&lt;p&gt;数据库页面既支持手动选择 &lt;code class=&quot;inline-code&quot;&gt;mppgsvrc.db&lt;/code&gt;，也会按盘符检查 Weeback / eClass Client 的常见目录。如果已经识别出安装路径，程序还会在该目录下继续查找数据库。选定文件后，路径与处理状态会保留在页面中，不需要每次操作重新输入。&lt;/p&gt;
&lt;p&gt;读取凭据时，疏影通过 SQLite 查询 &lt;code class=&quot;inline-code&quot;&gt;users&lt;/code&gt; 表中大小写不敏感匹配的 &lt;code class=&quot;inline-code&quot;&gt;Admin&lt;/code&gt; 记录，并用 &lt;code class=&quot;inline-code&quot;&gt;CAST(password AS BLOB)&lt;/code&gt; 保留字段的原始字节。随后才执行 IDA 分析得到的 &lt;code class=&quot;inline-code&quot;&gt;0xB3&lt;/code&gt; 变换、截断空字节并转换为界面字符串。独立脚本 &lt;code class=&quot;inline-code&quot;&gt;decrypt_mppg_password.py&lt;/code&gt; 提供相同的文件定位和命令行核对入口，方便在 GUI 之外验证数据库内容。&lt;/p&gt;
&lt;p&gt;这里没有字典、口令枚举或联网查询。功能的核心是复现目标程序自身的数据变换；具体逆向过程放在下一节单独说明。&lt;/p&gt;
&lt;h3 id=&quot;关联组件检查与清理&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#关联组件检查与清理&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;关联组件检查与清理&lt;/h3&gt;
&lt;p&gt;“驱动清理”页面虽然处理的是驱动遗留物，但整个编排发生在用户态。检查阶段会分别列出固定服务、&lt;code class=&quot;inline-code&quot;&gt;System32\drivers&lt;/code&gt; 中的关联 SYS 文件、键盘类注册表里的 &lt;code class=&quot;inline-code&quot;&gt;kafe&lt;/code&gt; UpperFilters 项、&lt;code class=&quot;inline-code&quot;&gt;MS_NdisNetFilter&lt;/code&gt; 网络组件，以及 Driver Store 中匹配的 OEM INF 包。页面区分正在运行、文件存在、等待重启删除和已暂存等状态。&lt;/p&gt;
&lt;p&gt;执行完整清理时，疏影会先停止并删除对应服务，备份键盘类 &lt;code class=&quot;inline-code&quot;&gt;UpperFilters&lt;/code&gt; 后只移除目标项，再处理 SYS 文件、网络过滤组件和 Driver Store 包。正在占用的文件可以登记为重启后删除；只读属性会先被清除。完成后会重新扫描、生成详细日志和 UpperFilters 备份，并让用户决定是否安排延迟重启。&lt;/p&gt;
&lt;p&gt;这不是简单地遍历目录删除文件。服务、注册表过滤器、网络组件和驱动包各自使用对应的 Windows API，失败项单独统计，避免某一步失败后仍给出“全部完成”的结论。&lt;/p&gt;
&lt;h3 id=&quot;活动日志、确认与窗口能力&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#活动日志、确认与窗口能力&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;活动日志、确认与窗口能力&lt;/h3&gt;
&lt;p&gt;安装检测、目录选择、进程结束、DLL 操作、数据库处理、组件清理和驱动状态查询都会进入当前会话的活动日志。界面同时使用短暂提示展示即时结果，而较长的路径、错误码和统计信息留在日志页，避免提示框承载过多文本。&lt;/p&gt;
&lt;p&gt;会改变系统状态的操作会先进入统一确认流程，危险操作使用独立的视觉样式。主窗口还支持普通置顶和同用户 UIAccess 增强置顶，并保存置顶偏好；这主要用于破解时同时观察其它程序窗口，不改变当前用户本身的权限。&lt;/p&gt;
&lt;p&gt;从实际使用顺序看，疏影首先是一套用户态破解工作台：自动发现环境，限定目标范围，完成进程、模块、数据库和残留组件处理，并记录每一步结果。只有这些能力不足时，才需要进入后面的内核进程页面。&lt;/p&gt;
&lt;h2 id=&quot;用-ida-还原-sub4cb0d0&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#用-ida-还原-sub4cb0d0&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;用 IDA 还原 sub_4CB0D0&lt;/h2&gt;
&lt;p&gt;Weeback 使用的服务端数据库 &lt;code class=&quot;inline-code&quot;&gt;mppgsvrc.db&lt;/code&gt; 是一个 SQLite 数据库。管理员记录位于 &lt;code class=&quot;inline-code&quot;&gt;users&lt;/code&gt; 表中，凭据内容保存在 &lt;code class=&quot;inline-code&quot;&gt;password&lt;/code&gt; 字段。直接查看字段只能看到处理后的字节，但它并不是不可逆摘要，而是 Setup.exe 写入前做过一次可逆变换。&lt;/p&gt;
&lt;p&gt;在 IDA 中跟进数据库写入相关调用后，可以定位到地址 &lt;code class=&quot;inline-code&quot;&gt;0x4CB0D0&lt;/code&gt; 的函数 &lt;code class=&quot;inline-code&quot;&gt;sub_4CB0D0&lt;/code&gt;。交叉引用说明它位于凭据字段进入数据库之前的数据处理路径上。去掉反编译器生成的类型和临时变量后，其核心逻辑可以整理为：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;c&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;c&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-c&quot;&gt;while (*input) {
    if (*input == 0xB3)
        *output = *input;
    else
        *output = *input ^ 0xB3;

    ++output;
    ++input;
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;从 IDA 伪代码中可以直接提取四个判断点：循环条件读取当前输入字节，说明 &lt;code class=&quot;inline-code&quot;&gt;0x00&lt;/code&gt; 是结束标记；条件分支单独比较 &lt;code class=&quot;inline-code&quot;&gt;0xB3&lt;/code&gt;；普通分支只执行一次固定常量 XOR；循环尾部同时递增输入和输出指针。函数没有动态密钥或状态表，因此整个字段处理过程可以被完整复现。&lt;/p&gt;
&lt;p&gt;也就是说，函数逐字节读取以 &lt;code class=&quot;inline-code&quot;&gt;\0&lt;/code&gt; 结尾的输入：字节等于 &lt;code class=&quot;inline-code&quot;&gt;0xB3&lt;/code&gt; 时原样复制，其余字节与 &lt;code class=&quot;inline-code&quot;&gt;0xB3&lt;/code&gt; 异或。异或满足自反性：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;(x XOR 0xB3) XOR 0xB3 = x&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;因此，正向处理和还原可以使用同一套变换。不过这里有一个容易被一句“再异或一次”掩盖的边界条件：&lt;code class=&quot;inline-code&quot;&gt;0xB3&lt;/code&gt; 在原函数中不会参与异或，所以还原时也必须保持不变。对于只包含常见 ASCII 字符的输入，无条件异或通常能得到相同结果；若要严格复刻原函数，则应保留这个特殊分支。&lt;/p&gt;
&lt;p&gt;严格复刻 &lt;code class=&quot;inline-code&quot;&gt;sub_4CB0D0&lt;/code&gt; 时，等价的解码循环应写成：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;cpp&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;cpp&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;for (auto&amp;amp; byte : cipher) {
    if (byte != 0xB3) {
        byte ^= 0xB3;
    }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;为什么这个变换能够原样还原？输入循环不会处理作为字符串结束符的 &lt;code class=&quot;inline-code&quot;&gt;0x00&lt;/code&gt;。对于有效输入字节，只有 &lt;code class=&quot;inline-code&quot;&gt;0x00 ^ 0xB3&lt;/code&gt; 才会产生 &lt;code class=&quot;inline-code&quot;&gt;0xB3&lt;/code&gt;，而 &lt;code class=&quot;inline-code&quot;&gt;0x00&lt;/code&gt; 不属于被处理的字段内容。因此，结果中的 &lt;code class=&quot;inline-code&quot;&gt;0xB3&lt;/code&gt; 可以按原函数语义解释为输入字节 &lt;code class=&quot;inline-code&quot;&gt;0xB3&lt;/code&gt;，不会与另一个有效输入字节冲突。&lt;/p&gt;
&lt;p&gt;在疏影中，数据还原页面先以 BLOB 方式读取字段，避免 SQLite 文本转换提前截断或改变字节：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;sql&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;sql&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-sql&quot;&gt;SELECT name, CAST(password AS BLOB)
FROM users
WHERE name = &amp;#039;Admin&amp;#039; COLLATE NOCASE;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;随后对返回的字节序列执行还原，在第一个空字节处截断，再按 UTF-8 转为界面使用的宽字符串。项目还提供独立的辅助脚本 &lt;code class=&quot;inline-code&quot;&gt;decrypt_mppg_password.py&lt;/code&gt;，既可接收数据库路径，也可扫描常见安装目录寻找 &lt;code class=&quot;inline-code&quot;&gt;mppgsvrc.db&lt;/code&gt;。如果原始内容可能包含字节 &lt;code class=&quot;inline-code&quot;&gt;0xB3&lt;/code&gt;，GUI 与脚本中的处理循环也应保留上述特殊分支；对于普通 ASCII 内容，逐字节无条件 XOR 的结果与这条分支一致。&lt;/p&gt;
&lt;p&gt;这段 IDA 分析也说明了可逆字段处理与安全存储的区别。固定常量的逐字节异或没有密钥管理、随机盐、初始化向量或单向性；一旦算法被确认，数据库中的内容即可按原流程还原。疏影所做的是把这个静态分析结论自动化。工具展示结果时仍应限制在本人拥有或得到明确授权的设备上，也不应把还原后的内容写入持久日志。这是对产品对客户不负责任的态度造成的。&lt;/p&gt;
&lt;h2 id=&quot;可选的内核扩展ysjxhprocess&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#可选的内核扩展ysjxhprocess&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;可选的内核扩展：YsjxhProcess&lt;/h2&gt;
&lt;p&gt;安装扫描、普通进程管理、DLL 模块操作、数据库字段还原和关联组件清理都不依赖 &lt;code class=&quot;inline-code&quot;&gt;YsjxhProcess&lt;/code&gt;。只有需要观察或修改普通 Win32 接口无法覆盖的内核进程状态时，疏影才使用这个独立驱动组件。&lt;/p&gt;
&lt;p&gt;项目结构大致如下：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;疏影.exe
  ├─ Win32 / GDI+ 主界面
  ├─ YsjxhProcessClient 用户态客户端
  └─ 内嵌 YsjxhProcessDriver.sys

YsjxhProcessDriver.sys
  ├─ 设备与 IOCTL 分发
  ├─ 进程状态枚举
  ├─ 进程状态管理与恢复
  ├─ 自身保护回调
  └─ profile 配置与运行时校验

YsjxhProcessCtl.exe
  └─ 命令行诊断和测试入口&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;主程序与驱动通过共享 IOCTL 协议通信。Release 构建会把同一次生成的 SYS 嵌入疏影，运行时再释放到 &lt;code class=&quot;inline-code&quot;&gt;%ProgramData%\YsjxhProcess&lt;/code&gt;。这样可以避免用户误拿旧驱动，也能确保界面、协议和驱动版本保持一致。&lt;/p&gt;
&lt;h2 id=&quot;默认不加载驱动&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#默认不加载驱动&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;默认不加载驱动&lt;/h2&gt;
&lt;p&gt;内核驱动的错误可能直接影响整个操作系统，因此疏影没有把“启动程序”和“加载驱动”绑定在一起。&lt;/p&gt;
&lt;p&gt;普通启动时，疏影只查询 &lt;code class=&quot;inline-code&quot;&gt;YsjxhProcess&lt;/code&gt; 是否已经运行，不会创建或启动驱动服务，也不会自动修改自身进程保护级别。如果确实需要在启动阶段加载驱动，可以在启动程序的同时按住 &lt;code class=&quot;inline-code&quot;&gt;Shift&lt;/code&gt;。程序会在进入界面前记录这一按键状态，随后执行驱动释放、服务启动、profile 配置和疏影自身保护。&lt;/p&gt;
&lt;p&gt;这套设计保留了快捷启动能力，同时为驱动异常提供了一个明确的安全回退入口：不按 Shift 即可进入纯用户态界面，继续查看日志、卸载服务或处理环境问题。&lt;/p&gt;
&lt;h2 id=&quot;每秒刷新但不打断操作&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#每秒刷新但不打断操作&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;每秒刷新，但不打断操作&lt;/h2&gt;
&lt;p&gt;“内核进程”页面可见时会每秒读取一次驱动进程快照。自动刷新最容易出现的问题，是列表不断跳回顶部，或者用户刚刚选中的进程在下一次刷新时丢失。&lt;/p&gt;
&lt;p&gt;疏影没有直接保存表格行号，而是保存选中进程的 PID，并使用当前顶部进程作为滚动锚点。刷新完成后再根据新的快照重新定位。这样即使进程数量和排序发生变化，界面也能尽量保持原来的操作上下文。离开“内核进程”页面后，定时驱动查询会停止，避免无意义的后台 IO。&lt;/p&gt;
&lt;h2 id=&quot;不猜测内核偏移&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#不猜测内核偏移&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;不猜测内核偏移&lt;/h2&gt;
&lt;p&gt;进程保护和部分进程状态依赖 Windows 内核中的未公开字段。这类实现最大的风险之一，是把某个系统版本的 &lt;code class=&quot;inline-code&quot;&gt;_EPROCESS&lt;/code&gt; 偏移直接套用到另一个版本。&lt;/p&gt;
&lt;p&gt;YsjxhProcess 的配置流程会读取当前 &lt;code class=&quot;inline-code&quot;&gt;ntoskrnl.exe&lt;/code&gt; 的机器类型、时间戳和映像大小，再与构建期生成的 profile 矩阵进行精确匹配。对于缺失数据，只允许在同一版本序列中使用“前后锚点完全一致”的桥接值；无法可靠确认的字段会被标记为不支持，而不是根据相邻版本猜测。&lt;/p&gt;
&lt;p&gt;偏移下发后，驱动还会在内核态检查 System PID、活动进程链表互指关系和保护字段布局。任何关键校验失败都会拒绝启用配置。这不能消除使用未公开结构的全部风险，但可以把明显错误挡在真正修改内核状态之前。&lt;/p&gt;
&lt;h2 id=&quot;扩展驱动工具窗口&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#扩展驱动工具窗口&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;扩展驱动工具窗口&lt;/h2&gt;
&lt;p&gt;疏影的常用页面只保留经过约束的进程操作；需要诊断完整驱动能力时，可以打开独立的“扩展驱动工具”窗口。&lt;/p&gt;
&lt;p&gt;该窗口把驱动服务、进程状态操作、模块与规则、内核回调、路径操作、驱动查询和活动日志分区呈现。所有修改型操作都需要再次确认，危险按钮使用独立的错误色，查询与浏览操作则保持中性色。长状态信息会在顶部摘要中省略，并完整记录到日志区域。&lt;/p&gt;
&lt;p&gt;这些能力面向隔离环境中的驱动开发、故障定位和授权实验，不应在日常工作机或未知目标上使用。&lt;/p&gt;
&lt;h2 id=&quot;构建与签名顺序&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#构建与签名顺序&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;构建与签名顺序&lt;/h2&gt;
&lt;p&gt;项目同时包含用户态程序和 WDK 驱动，完整 Release 可以在 Visual Studio Developer PowerShell 中构建：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;powershell&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;powershell&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-powershell&quot;&gt;.\build-release.ps1&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;脚本会依次构建驱动、图形启动器、命令行工具和疏影主程序，最终输出位于 &lt;code class=&quot;inline-code&quot;&gt;dist&lt;/code&gt; 目录。&lt;/p&gt;
&lt;p&gt;如果需要对发布文件签名，顺序不能颠倒：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;冻结驱动版本
  → 签名最终 SYS
  → 将签名 SYS 重新嵌入疏影
  → 完成发布前二进制处理
  → 最后签名发布 EXE&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;任何发生在签名之后的二进制修改都会破坏对应签名。驱动能够在测试签名环境加载，也不代表它已经获得普通 Windows 和 Secure Boot 环境所要求的生产级 Microsoft 内核签名。&lt;/p&gt;
&lt;h2 id=&quot;开源致谢&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#开源致谢&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;开源致谢&lt;/h2&gt;
&lt;p&gt;感谢 &lt;a href=&quot;https://github.com/KSwordDEV/KSword&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;KSwordDEV/KSword&lt;/a&gt; 项目带来的开源、实用的 ARK 工具，同时感谢该项目源码对本项目驱动设计与实现的启发。&lt;/p&gt;
&lt;p&gt;优秀的系统工具不仅提供了可用功能，也展示了用户态与内核态如何划分职责、如何组织协议、如何处理动态数据，以及如何在高风险能力周围建立必要的验证与边界。疏影在开发过程中从这些经验中受益良多。&lt;/p&gt;
&lt;p&gt;同时，项目使用到的第三方库、SDK 和工具仍分别遵循其原有许可证。引用和学习不等于抹去来源，清晰记录依赖与启发来源也是工程工作的一部分。&lt;/p&gt;
&lt;h2 id=&quot;写在最后&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#写在最后&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;写在最后&lt;/h2&gt;
&lt;p&gt;疏影目前仍在持续迭代，但它的定位已经很明确：这是一个建立在 Weeback 静态分析结果之上的专项破解工具，而不是通用系统管理平台。安装路径、对象进程、数据库结构、字段变换和驱动操作都围绕这一目标设计。&lt;/p&gt;
&lt;p&gt;凭据字段部分最关键的结论来自 IDA 中的 &lt;code class=&quot;inline-code&quot;&gt;sub_4CB0D0&lt;/code&gt;：除 &lt;code class=&quot;inline-code&quot;&gt;0xB3&lt;/code&gt; 自身保持不变外，其余输入字节都与 &lt;code class=&quot;inline-code&quot;&gt;0xB3&lt;/code&gt; 异或。把这一结论与 SQLite 字段读取、进程管理和驱动能力组合起来，才形成了现在的疏影。后续工作仍需要把高风险能力限制在清晰的前置条件内，并为失败操作保留日志与恢复路径。&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>从黑盒到可交互画面：极域 V6.0 连续投屏与远程操控协议逆向</title>
    <link href="https://blog.xn--9kq396ceqaq4si9m.cn/post/%E4%BB%8E%E9%BB%91%E7%9B%92%E5%88%B0%E5%8F%AF%E4%BA%A4%E4%BA%92%E7%94%BB%E9%9D%A2%E6%9E%81%E5%9F%9F-v60-%E8%BF%9E%E7%BB%AD%E6%8A%95%E5%B1%8F%E4%B8%8E%E8%BF%9C%E7%A8%8B%E6%93%8D%E6%8E%A7%E5%8D%8F%E8%AE%AE%E9%80%86%E5%90%91"/>
    <id>https://blog.xn--9kq396ceqaq4si9m.cn/post/%E4%BB%8E%E9%BB%91%E7%9B%92%E5%88%B0%E5%8F%AF%E4%BA%A4%E4%BA%92%E7%94%BB%E9%9D%A2%E6%9E%81%E5%9F%9F-v60-%E8%BF%9E%E7%BB%AD%E6%8A%95%E5%B1%8F%E4%B8%8E%E8%BF%9C%E7%A8%8B%E6%93%8D%E6%8E%A7%E5%8D%8F%E8%AE%AE%E9%80%86%E5%90%91</id>
    <published>2026-10-05T19:14:00+08:00</published>
    <updated>2026-10-15T16:40:05+08:00</updated>
    <summary type="html">该文逆向极域 V6.0 连续投屏与远控协议。监看由 UDP 信令触发，4806/TCP 传输 H.264/JPEG 分片画面，独立报文回传光标；远控通过 COMD‑MCMD 开启输入通道，28 字节报文实现鼠标控制，键盘功能实验性未闭环。总结逆向踩坑：TCP 流重组、魔数小端序、YUV 色度修正、区分多层证据，实现增加会话限流、异常防护。仅限授权环境研究。</summary>
    <content type="html">&lt;h1 id=&quot;从黑盒到可交互画面极域-v60-连续投屏与远程操控协议逆向&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#从黑盒到可交互画面极域-v60-连续投屏与远程操控协议逆向&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;从黑盒到可交互画面：极域 V6.0 连续投屏与远程操控协议逆向&lt;/h1&gt;
&lt;blockquote&gt;&lt;p&gt;本文记录 &lt;code class=&quot;inline-code&quot;&gt;2026.07.31 研究预览版&lt;/code&gt;中连续屏幕观看与远程操控链路的逆向过程。结论来自 IDA Pro 静态分析、官方教师端/学生端真实流量对照、逐字节重放和运行日志验证。本文只讨论隔离实验环境中的协议研究，不应被用于未经授权的监控或控制。&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&quot;摘要&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#摘要&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;摘要&lt;/h2&gt;
&lt;p&gt;极域 V6.0 的“观看学生屏幕”和“远程控制学生”不是一个简单的 UDP 命令，也不是把截图循环发送回来。完整链路至少跨越三类通道：&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;教师端先经 &lt;code class=&quot;inline-code&quot;&gt;5512/UDP&lt;/code&gt; 的 &lt;code class=&quot;inline-code&quot;&gt;MESS feature=8&lt;/code&gt; 通知学生端启动桌面发送功能；&lt;/li&gt;&lt;li&gt;教师端连接学生端 &lt;code class=&quot;inline-code&quot;&gt;4806/TCP&lt;/code&gt;，发送 &lt;code class=&quot;inline-code&quot;&gt;SHCO&lt;/code&gt; 选择 UMSP channel 10，再从 &lt;code class=&quot;inline-code&quot;&gt;TKPC&lt;/code&gt; 中重组 &lt;code class=&quot;inline-code&quot;&gt;HHRF&lt;/code&gt;/&lt;code class=&quot;inline-code&quot;&gt;HJRF&lt;/code&gt; 桌面记录；&lt;/li&gt;&lt;li&gt;进入控制模式时，教师端再用 &lt;code class=&quot;inline-code&quot;&gt;COMD&lt;/code&gt; 事务承载 &lt;code class=&quot;inline-code&quot;&gt;MCMD&lt;/code&gt;，让学生端在指定 UDP 端口启动模拟输入接收器；鼠标和键盘事件通过固定 28 字节输入包发送。&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;截至当前版本，连续观看、H.264/JPEG 解封装、色度修正、&lt;code class=&quot;inline-code&quot;&gt;SPUC&lt;/code&gt; 光标解析以及远程鼠标移动/点击已经在测试环境验证。键盘只验证到教师端捕获和 &lt;code class=&quot;inline-code&quot;&gt;kind=16&lt;/code&gt; 发包，学生端是否最终完成 &lt;code class=&quot;inline-code&quot;&gt;SendInput&lt;/code&gt; 仍不稳定，因此仍是实验性功能。&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;能力&lt;/th&gt;&lt;th&gt;当前证据&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;4806/TCP 建连与 SHCO 选路&lt;/td&gt;&lt;td&gt;已验证&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;TKPC 分片重组&lt;/td&gt;&lt;td&gt;已验证&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;HHRF/H.264、HJRF/JPEG 解析&lt;/td&gt;&lt;td&gt;已验证&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;U/V 色度平面修正&lt;/td&gt;&lt;td&gt;已验证&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;SPUC 远端光标解析&lt;/td&gt;&lt;td&gt;已验证&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;MCMD mode=2 建立控制&lt;/td&gt;&lt;td&gt;已验证&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;28 字节鼠标包&lt;/td&gt;&lt;td&gt;移动与点击已验证&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;kind=16 键盘包&lt;/td&gt;&lt;td&gt;捕获与发包已验证，学生端执行未稳定验证&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;hr&gt;
&lt;h2 id=&quot;一、先建立正确的系统模型&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#一、先建立正确的系统模型&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;一、先建立正确的系统模型&lt;/h2&gt;
&lt;p&gt;最初最容易犯的错误，是把“投屏”理解成缩略图协议 &lt;code class=&quot;inline-code&quot;&gt;LANT/TNAL&lt;/code&gt; 的高频版本。抓包很快就能否定这个假设：点击官方教师端的“监看”后，学生端除了继续保活，还会开放或使用 &lt;code class=&quot;inline-code&quot;&gt;4806/TCP&lt;/code&gt;；真正的连续画面主要出现在这条 TCP 流中。&lt;/p&gt;
&lt;p&gt;远程控制同样不是直接向 &lt;code class=&quot;inline-code&quot;&gt;4705/UDP&lt;/code&gt; 塞一个 &lt;code class=&quot;inline-code&quot;&gt;WM_MOUSEMOVE&lt;/code&gt;。官方流程会先复用已经建立的桌面观看会话，然后通过通用命令事务启动一个独立的模拟输入通道。&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;mermaid&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;mermaid&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-mermaid&quot;&gt;sequenceDiagram
    participant T as 第三方教师端
    participant S as 极域学生端

    T-&amp;gt;&amp;gt;S: TCP connect probe :4806（只探测）
    T-&amp;gt;&amp;gt;S: MESS feature=8 / start（5512/UDP）
    T-&amp;gt;&amp;gt;S: TCP connect :4806
    T-&amp;gt;&amp;gt;S: SHCO / channel 10
    S--&amp;gt;&amp;gt;T: TKPC / channel 10 / 桌面分片
    S--&amp;gt;&amp;gt;T: HHRF(H.264) 或 HJRF(JPEG)
    T-&amp;gt;&amp;gt;S: COMD transaction → MCMD mode=2
    Note over S: BeginSimulate，监听指定 UDP 端口
    T-&amp;gt;&amp;gt;S: 28-byte mouse input
    S--&amp;gt;&amp;gt;T: SPUC cursor record
    T-&amp;gt;&amp;gt;S: 28-byte kind=16 keyboard input（实验性）&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;这个模型解释了几个看似无关的现象：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;只发送 feature 8，不连接 TCP，不会得到可显示的连续画面；&lt;/li&gt;&lt;li&gt;直接发输入包时，学生端没有对应 UDP 接收器，数据只会被操作系统丢弃；&lt;/li&gt;&lt;li&gt;从 &lt;code class=&quot;inline-code&quot;&gt;view&lt;/code&gt; 切换到 &lt;code class=&quot;inline-code&quot;&gt;control&lt;/code&gt; 时重启 H.264 解码器，容易永久黑屏，因为新解码器没有收到此前的 SPS/PPS/IDR；&lt;/li&gt;&lt;li&gt;本地鼠标与学生端鼠标短暂错位并非只有坐标算法问题，还包含编码、网络、显示和 &lt;code class=&quot;inline-code&quot;&gt;SPUC&lt;/code&gt; 回传延迟。&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&quot;二、在-ida-中如何找到入口&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#二、在-ida-中如何找到入口&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;二、在 IDA 中如何找到入口&lt;/h2&gt;
&lt;h3 id=&quot;21-不要只搜索可见字符串&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#21-不要只搜索可见字符串&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;2.1 不要只搜索可见字符串&lt;/h3&gt;
&lt;p&gt;这类老式 C/C++ 网络库常把 FourCC 写成 32 位立即数。文件里的字节顺序是人眼可读的 &lt;code class=&quot;inline-code&quot;&gt;SHCO&lt;/code&gt;，反汇编中却可能出现：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;wire bytes: 53 48 43 4F  -&amp;gt; &amp;quot;SHCO&amp;quot;
IDA imm32 : 0x4F434853

wire bytes: 54 4B 50 43  -&amp;gt; &amp;quot;TKPC&amp;quot;
IDA imm32 : 0x43504B54&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;原因是 x86 使用小端序。仅在 Strings 窗口里搜索 &lt;code class=&quot;inline-code&quot;&gt;SHCO&lt;/code&gt; 很可能什么也找不到，应该同时搜索对应的立即数，然后查看交叉引用。&lt;/p&gt;
&lt;p&gt;本次逆向中最有效的一组锚点是：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;线索&lt;/th&gt;&lt;th&gt;作用&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x4F434853&lt;/code&gt;&lt;/td&gt;&lt;td&gt;定位 UMSP channel 选择包 &lt;code class=&quot;inline-code&quot;&gt;SHCO&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x43504B54&lt;/code&gt;&lt;/td&gt;&lt;td&gt;定位 UMSP 数据包 &lt;code class=&quot;inline-code&quot;&gt;TKPC&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x46524848&lt;/code&gt;&lt;/td&gt;&lt;td&gt;定位 &lt;code class=&quot;inline-code&quot;&gt;HHRF&lt;/code&gt; H.264 桌面记录&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x46524A48&lt;/code&gt;&lt;/td&gt;&lt;td&gt;定位 &lt;code class=&quot;inline-code&quot;&gt;HJRF&lt;/code&gt; JPEG 桌面记录&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;MCMD&lt;/code&gt;&lt;/td&gt;&lt;td&gt;定位监看/控制模式切换结构&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;SPUC&lt;/code&gt;&lt;/td&gt;&lt;td&gt;定位光标状态记录&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x2321347C&lt;/code&gt;&lt;/td&gt;&lt;td&gt;定位模拟输入包分发器&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;常量 &lt;code class=&quot;inline-code&quot;&gt;4806&lt;/code&gt;、channel &lt;code class=&quot;inline-code&quot;&gt;10&lt;/code&gt;&lt;/td&gt;&lt;td&gt;从通用传输库缩小到桌面通道&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;h3 id=&quot;22-从网络-api-反推对象边界&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#22-从网络-api-反推对象边界&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;2.2 从网络 API 反推对象边界&lt;/h3&gt;
&lt;p&gt;打开 &lt;code class=&quot;inline-code&quot;&gt;LibBaseTrans.dll&lt;/code&gt; 后，先建立导入函数关系：&lt;code class=&quot;inline-code&quot;&gt;connect&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;send&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;recv&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;WSARecv&lt;/code&gt;、线程创建、临界区和缓冲区复制。不要急着给每个函数命名，先回答三个问题：&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;哪个对象持有 socket？&lt;/li&gt;&lt;li&gt;哪个循环读取 12 字节头并按长度字段切包？&lt;/li&gt;&lt;li&gt;哪个分支在 payload 起始位置读取 channel id？&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;从 &lt;code class=&quot;inline-code&quot;&gt;0x43504B54&lt;/code&gt; 的交叉引用向上回溯，可以看到一个典型的“版本 + magic + payload length”检查；继续向下跟踪，payload 的首个 &lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt; 被当作 channel。channel 10 随后进入桌面数据处理对象，而其他 channel 被分派给不同业务。&lt;/p&gt;
&lt;p&gt;在 IDA 中可以先做以下重命名，之后伪代码会清晰很多：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;sub_xxx_connect     -&amp;gt; umsp_connect
sub_xxx_read_loop   -&amp;gt; umsp_recv_loop
sub_xxx_dispatch    -&amp;gt; dispatch_umsp_channel
sub_xxx_channel10   -&amp;gt; handle_desktop_fragment
sub_xxx_record      -&amp;gt; handle_desktop_record&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;名字不必一开始就完全正确。关键是让“传输层、分片层、记录层、编解码层”不再混在同一张调用图里。&lt;/p&gt;
&lt;h3 id=&quot;23-从-feature-分发器找到-617-字节参数块&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#23-从-feature-分发器找到-617-字节参数块&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;2.3 从 feature 分发器找到 617 字节参数块&lt;/h3&gt;
&lt;p&gt;在学生端的 MESS 处理路径中，feature id &lt;code class=&quot;inline-code&quot;&gt;8&lt;/code&gt; 会进入远程观看分支。这个分支不是只读一个布尔值，而是复制一个较大的参数对象。把官方教师端报文和伪代码中的复制长度对照后，可以确定：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;内层 feature payload 总长为 617 字节；&lt;/li&gt;&lt;li&gt;前 12 字节是 &lt;code class=&quot;inline-code&quot;&gt;length / feature / flags&lt;/code&gt;；&lt;/li&gt;&lt;li&gt;中间 604 字节是远程观看参数；&lt;/li&gt;&lt;li&gt;最后还有 1 字节尾部填充。&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;不要把参数块里的端口直接当成学生端 &lt;code class=&quot;inline-code&quot;&gt;4806/TCP&lt;/code&gt;。其中两个端口属于教师会话/桌面监控端点；学生端的 TCP 服务端口是另一层连接目标。这两个概念混用，会构造出长度正确但状态错误的请求。&lt;/p&gt;
&lt;h3 id=&quot;24-从-mcmd-跟到模拟输入&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#24-从-mcmd-跟到模拟输入&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;2.4 从 MCMD 跟到模拟输入&lt;/h3&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;MCMD&lt;/code&gt; 位于通用 &lt;code class=&quot;inline-code&quot;&gt;COMD&lt;/code&gt; 事务内部。沿 &lt;code class=&quot;inline-code&quot;&gt;MCMD&lt;/code&gt; 分支继续跟踪，可以看到 mode 分派以及模拟输入初始化路径。当前观察到的行为是：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;mode=0&lt;/code&gt;：Share，双方可操作；&lt;/li&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;mode=2&lt;/code&gt;：Control Student，启动模拟输入并额外进入学生端本地输入锁定路径；&lt;/li&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;mode=1&lt;/code&gt;：本项目用于停止当前模拟输入会话。&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;再从输入接收线程向下跟踪，固定 magic &lt;code class=&quot;inline-code&quot;&gt;0x2321347C&lt;/code&gt; 是很强的定位点。分发器读取紧随其后的 &lt;code class=&quot;inline-code&quot;&gt;kind&lt;/code&gt;，然后按鼠标或键盘结构解释剩余 20 字节。&lt;/p&gt;
&lt;p&gt;逆向时必须继续跟到系统调用边界。看到 UDP &lt;code class=&quot;inline-code&quot;&gt;recvfrom&lt;/code&gt; 并不表示控制已经生效，真正需要确认的是后续是否构造 &lt;code class=&quot;inline-code&quot;&gt;INPUT&lt;/code&gt;、是否调用 &lt;code class=&quot;inline-code&quot;&gt;SendInput&lt;/code&gt;、调用发生在哪个 Windows Session/desktop，以及本地 Hook 是否会再次拦截注入事件。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;三、用抓包给反汇编定类型&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#三、用抓包给反汇编定类型&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;三、用抓包给反汇编“定类型”&lt;/h2&gt;
&lt;p&gt;IDA 告诉我们代码可能怎样解释内存，抓包则告诉我们线上实际发送了什么。两者必须互相约束。&lt;/p&gt;
&lt;p&gt;建议只在隔离测试网中采集，并把一次操作拆成单变量实验：&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;只打开“观看屏幕”，不移动鼠标；&lt;/li&gt;&lt;li&gt;只切换到“远程控制”，不输入；&lt;/li&gt;&lt;li&gt;只移动一次鼠标；&lt;/li&gt;&lt;li&gt;只按一次左键；&lt;/li&gt;&lt;li&gt;只按一个普通字母键；&lt;/li&gt;&lt;li&gt;分别停止控制和停止观看。&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Wireshark 初始过滤器：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;udp.port == 4705 || udp.port == 5512 || tcp.port == 4806&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;找到对应 TCP stream 后，再单独查看：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;tcp.stream eq &amp;lt;n&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;抓包分析时不要依赖 TCP segment 边界。一次 &lt;code class=&quot;inline-code&quot;&gt;recv&lt;/code&gt; 可能拿到半个 UMSP 包，也可能一次拿到多个包。正确做法是维护流缓冲区，只有当缓冲区至少包含 12 字节头，并且达到 &lt;code class=&quot;inline-code&quot;&gt;12 + payload_len&lt;/code&gt; 后才取出一包。&lt;/p&gt;
&lt;h3 id=&quot;31-差分比对比猜字段更快&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#31-差分比对比猜字段更快&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;3.1 差分比对比猜字段更快&lt;/h3&gt;
&lt;p&gt;对 MCMD 和输入包尤其适合做差分：固定所有条件，只改变一个操作。例如把鼠标从画面左上移动到右下，比较两包中变化的 4 字节字段；连续点击左键，观察 &lt;code class=&quot;inline-code&quot;&gt;0x0201&lt;/code&gt; 与 &lt;code class=&quot;inline-code&quot;&gt;0x0202&lt;/code&gt; 的成对出现；滚轮则会让 data 字段变化。&lt;/p&gt;
&lt;p&gt;字段命名按证据逐步升级：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;unknown_08
  -&amp;gt; changes_with_x
  -&amp;gt; normalized_x
  -&amp;gt; normalized_x_u16_range_in_u32&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;不要因为某次值恰好等于屏幕像素，就立即命名为 &lt;code class=&quot;inline-code&quot;&gt;pixel_x&lt;/code&gt;。本协议鼠标坐标实际使用 &lt;code class=&quot;inline-code&quot;&gt;0..65535&lt;/code&gt; 归一化范围，窗口尺寸和远端编码尺寸只是映射输入。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;四、观看请求mess-feature-8&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#四、观看请求mess-feature-8&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;四、观看请求：MESS feature 8&lt;/h2&gt;
&lt;p&gt;当前实现构造的 feature payload 如下。所有多字节整数均为小端；IP 地址保持网络序原始字节。&lt;/p&gt;
&lt;h3 id=&quot;41-feature-8-内层结构&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#41-feature-8-内层结构&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;4.1 feature 8 内层结构&lt;/h3&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;偏移&lt;/th&gt;&lt;th&gt;大小&lt;/th&gt;&lt;th&gt;当前解释&lt;/th&gt;&lt;th&gt;观察值&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x000&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;payload length&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;617&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x004&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;feature id&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;8&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x008&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;start flags&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x80000000&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x00C&lt;/code&gt;&lt;/td&gt;&lt;td&gt;604&lt;/td&gt;&lt;td&gt;remote-view params&lt;/td&gt;&lt;td&gt;见下表&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x268&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;tail padding&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;604 字节参数块中，已经通过官方流量和代码路径确认或稳定观察到的字段：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;参数内偏移&lt;/th&gt;&lt;th&gt;大小&lt;/th&gt;&lt;th&gt;含义&lt;/th&gt;&lt;th&gt;当前值&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x00&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;RemoteWithVoice&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x04&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;教师 IP&lt;/td&gt;&lt;td&gt;network order&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x08&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;教师会话端口&lt;/td&gt;&lt;td&gt;当前频道端口&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x0A&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;教师 IP（第二端点）&lt;/td&gt;&lt;td&gt;network order&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x0E&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;桌面监控端口&lt;/td&gt;&lt;td&gt;当前频道端口&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x24&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;NetworkType&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;1&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x28&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;ShowMonitorControlMessage&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;1&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x2C&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;MaxSendSpeed&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;20480&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x30&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;RepairMode&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;1&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x34&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;MaxPacketSize&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;1440&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x38&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;FrameLimit&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;25&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x3C&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;CaptureQuality&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;75&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x40&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;TcpCommMode&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;1&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x44&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;学生 IP&lt;/td&gt;&lt;td&gt;network order&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x48&lt;/code&gt;&lt;/td&gt;&lt;td&gt;12&lt;/td&gt;&lt;td&gt;未完全命名的三元组&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;5, 12, 16&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;最后一组三元组虽然已经稳定复现，但在没有进一步交叉引用证据前不应强行解释其业务名称。保留“已知偏移 + 已知值 + 未知语义”比写一个听起来合理的名字更有研究价值。&lt;/p&gt;
&lt;p&gt;停止观看使用另一种短结构：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;u32 length  = 13
u32 feature = 0
u32 flags   = 0
u8  tail    = 0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&quot;42-正确启动时序&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#42-正确启动时序&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;4.2 正确启动时序&lt;/h3&gt;
&lt;p&gt;当前稳定时序是：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;TCP connect probe 4806（立即关闭，不发 SHCO）
    -&amp;gt; MESS feature 8 start
    -&amp;gt; 单次连接 4806/TCP
    -&amp;gt; 立即发送 SHCO channel 10
    -&amp;gt; 从第一条 H.264 记录开始喂给同一个解码器&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;探测步骤只检查 TCP 是否监听，不启动编码器，也不发送 &lt;code class=&quot;inline-code&quot;&gt;SHCO&lt;/code&gt;。正式启动后不能在失败时高频重试：学生端编码器和内部线程存在状态，重复 feature 请求或并发 TCP 会话可能导致学生端异常退出。当前实现限制每个 IP 同时只有一个观看会话，并在失败后冷却 60 秒。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;五、umspshco、tkpc-与-channel-10&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#五、umspshco、tkpc-与-channel-10&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;五、UMSP：SHCO、TKPC 与 channel 10&lt;/h2&gt;
&lt;h3 id=&quot;51-shco-选择包&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#51-shco-选择包&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;5.1 SHCO 选择包&lt;/h3&gt;
&lt;p&gt;连接 &lt;code class=&quot;inline-code&quot;&gt;4806/TCP&lt;/code&gt; 后，教师端发送 20 字节选择包：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;偏移&lt;/th&gt;&lt;th&gt;类型&lt;/th&gt;&lt;th&gt;值&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x00&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;&lt;/td&gt;&lt;td&gt;version &lt;code class=&quot;inline-code&quot;&gt;0x00010000&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x04&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x4F434853&lt;/code&gt;，线上为 &lt;code class=&quot;inline-code&quot;&gt;SHCO&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x08&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;&lt;/td&gt;&lt;td&gt;body length &lt;code class=&quot;inline-code&quot;&gt;8&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x0C&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;&lt;/td&gt;&lt;td&gt;selector/op，观察值 &lt;code class=&quot;inline-code&quot;&gt;1&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x10&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;&lt;/td&gt;&lt;td&gt;desktop channel &lt;code class=&quot;inline-code&quot;&gt;10&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;这里的 channel 10 是业务复用编号，不是 TCP/UDP 端口。&lt;/p&gt;
&lt;h3 id=&quot;52-tkpc-数据包&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#52-tkpc-数据包&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;5.2 TKPC 数据包&lt;/h3&gt;
&lt;p&gt;学生端返回的 UMSP 包使用 12 字节公共头：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;偏移&lt;/th&gt;&lt;th&gt;类型&lt;/th&gt;&lt;th&gt;说明&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x00&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;&lt;/td&gt;&lt;td&gt;version，预期 &lt;code class=&quot;inline-code&quot;&gt;0x00010000&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x04&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x43504B54&lt;/code&gt;，线上为 &lt;code class=&quot;inline-code&quot;&gt;TKPC&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x08&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;&lt;/td&gt;&lt;td&gt;payload length&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x0C&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;&lt;/td&gt;&lt;td&gt;channel id，桌面为 &lt;code class=&quot;inline-code&quot;&gt;10&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x10&lt;/code&gt;&lt;/td&gt;&lt;td&gt;bytes&lt;/td&gt;&lt;td&gt;channel payload&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;代码或符号中可能把它写作 &lt;code class=&quot;inline-code&quot;&gt;TCPK&lt;/code&gt;，但线上字节是 &lt;code class=&quot;inline-code&quot;&gt;TKPC&lt;/code&gt;。逆向协议时应始终区分“源码/反编译变量名”和“wire bytes”，否则 Wireshark 搜索与代码常量会互相对不上。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;六、桌面分片重组&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#六、桌面分片重组&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;六、桌面分片重组&lt;/h2&gt;
&lt;p&gt;channel 10 的 payload 不是直接的 H.264 NAL，而是先经过一层 12 字节桌面分片：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;+0x00  u32 frame_seq
+0x04  u32 fragment_offset
+0x08  u32 record_total_size
+0x0C  bytes fragment_data&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;重组器按 &lt;code class=&quot;inline-code&quot;&gt;frame_seq&lt;/code&gt; 保存状态，以 &lt;code class=&quot;inline-code&quot;&gt;record_total_size&lt;/code&gt; 分配缓冲区，然后把每个 fragment 写入指定 offset。实现时至少要处理：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;TCP 读取边界与 UMSP 包边界不一致；&lt;/li&gt;&lt;li&gt;同一分片重复到达；&lt;/li&gt;&lt;li&gt;分片乱序；&lt;/li&gt;&lt;li&gt;新 frame_seq 到来时旧帧仍未完成；&lt;/li&gt;&lt;li&gt;offset 或 length 越界；&lt;/li&gt;&lt;li&gt;恶意或损坏的 total size 导致大内存分配。&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;当前实现给每帧维护一份 &lt;code class=&quot;inline-code&quot;&gt;seen&lt;/code&gt; 位图，只把第一次出现的字节计入 &lt;code class=&quot;inline-code&quot;&gt;received&lt;/code&gt;，避免重复分片使计数提前达到 total。最多同时保留四个未完成帧，并将桌面记录大小限制在 &lt;code class=&quot;inline-code&quot;&gt;0x241800&lt;/code&gt;。&lt;/p&gt;
&lt;p&gt;一个重要踩坑是：并非所有完整记录都大于 64 字节。&lt;code class=&quot;inline-code&quot;&gt;SPUC&lt;/code&gt; 光标记录只有 16 字节。如果在分片层直接用“total &lt; 64”判定非法，就会把光标状态误报为坏帧。正确做法是先完成通用重组，再在记录层按 magic 和长度分流。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;七、hhrfhjrf-桌面记录&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#七、hhrfhjrf-桌面记录&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;七、HHRF/HJRF 桌面记录&lt;/h2&gt;
&lt;p&gt;视频类记录包含一个 64 字节头：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;偏移&lt;/th&gt;&lt;th&gt;大小&lt;/th&gt;&lt;th&gt;说明&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x00&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;magic：&lt;code class=&quot;inline-code&quot;&gt;HHRF&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;HJRF&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;HMRF&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x04&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;declared record size&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x08&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;timestamp&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x0C&lt;/code&gt;&lt;/td&gt;&lt;td&gt;16&lt;/td&gt;&lt;td&gt;encoded rect：left/top/right/bottom&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x1C&lt;/code&gt;&lt;/td&gt;&lt;td&gt;16&lt;/td&gt;&lt;td&gt;visible rect：left/top/right/bottom&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x2C&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;frame type&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x30&lt;/code&gt;&lt;/td&gt;&lt;td&gt;16&lt;/td&gt;&lt;td&gt;尚未完全命名的字段&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x40&lt;/code&gt;&lt;/td&gt;&lt;td&gt;variable&lt;/td&gt;&lt;td&gt;编码 payload&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;magic 对应关系：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;0x46524848 -&amp;gt; wire &amp;quot;HHRF&amp;quot; -&amp;gt; H.264 Annex-B
0x46524A48 -&amp;gt; wire &amp;quot;HJRF&amp;quot; -&amp;gt; JPEG
0x46524D48 -&amp;gt; wire &amp;quot;HMRF&amp;quot; -&amp;gt; legacy/兼容记录&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;日志中的一个真实样本为：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;H264 frame=1 seq=11 record=623 declared=623
encoded=(0,0,1728,928) visible=(0,0,1718,918)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;这说明编码尺寸和实际可见尺寸并不总相同。直接按 encoded rect 展示会在边缘出现填充区域，所以解码后还需要按 visible rect 裁剪。&lt;/p&gt;
&lt;h3 id=&quot;71-为什么请求真实-h264-时容易黑屏&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#71-为什么请求真实-h264-时容易黑屏&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;7.1 为什么请求真实 H.264 时容易“黑屏”&lt;/h3&gt;
&lt;p&gt;H.264 是有状态码流。解码器通常需要先看到 SPS、PPS 和 IDR，才能解释后续 P/B 帧。下面几种做法都会造成只有数据、没有画面：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;TCP 建连太晚，错过码流初始化；&lt;/li&gt;&lt;li&gt;先用一个播放器观看，切换 control 时杀掉播放器再启动另一个；&lt;/li&gt;&lt;li&gt;把多次观看留下的半段 &lt;code class=&quot;inline-code&quot;&gt;.h264&lt;/code&gt; 直接拼在一起；&lt;/li&gt;&lt;li&gt;将 UMSP/桌面记录头误写进 H.264 payload；&lt;/li&gt;&lt;li&gt;按 TCP recv 块直接喂解码器，破坏了上层记录边界。&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;当前实现从第一帧开始固定使用 bundled FFmpeg，&lt;code class=&quot;inline-code&quot;&gt;view -&amp;gt; control&lt;/code&gt; 只改变窗口交互状态，不重启解码进程。可选裸流也按会话时间戳独立保存，避免把上一次的不完整码流接到新会话前面。&lt;/p&gt;
&lt;h3 id=&quot;72-为什么画面颜色会错&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#72-为什么画面颜色会错&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;7.2 为什么画面颜色会错&lt;/h3&gt;
&lt;p&gt;拿到画面后，最明显的问题曾是整体色相不对：本应为蓝色的区域显示成另一种颜色。几何内容正确、亮度基本正确而色相系统性错误，通常不是 RGB/BGR 顺序问题，而是 YUV 色度平面顺序问题。&lt;/p&gt;
&lt;p&gt;对同一帧分别尝试常见转换后，可以确认极域这条 H.264 链路的 U/V 平面需要交换。FFmpeg 过滤器为：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;shuffleplanes=0:2:1:3&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;然后再按可见尺寸裁剪：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;shuffleplanes=0:2:1:3,crop=&amp;lt;visible_w&amp;gt;:&amp;lt;visible_h&amp;gt;:0:0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;这里选择在显示管线修正，而不改写保存的 H.264 裸流。这样原始证据仍可用于后续协议分析，同时实时窗口显示正确颜色。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;八、spuc远端光标不是画面的一部分&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#八、spuc远端光标不是画面的一部分&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;八、SPUC：远端光标不是画面的一部分&lt;/h2&gt;
&lt;p&gt;光标状态使用独立的 16 字节记录：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;偏移&lt;/th&gt;&lt;th&gt;类型&lt;/th&gt;&lt;th&gt;说明&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x00&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4 bytes&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;SPUC&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x04&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;&lt;/td&gt;&lt;td&gt;record size，预期 &lt;code class=&quot;inline-code&quot;&gt;16&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x08&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;&lt;/td&gt;&lt;td&gt;timestamp&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x0C&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;&lt;/td&gt;&lt;td&gt;packed position&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;位置打包方式：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;x = packed_position &amp;amp; 0xFFFF
y = packed_position &amp;gt;&amp;gt; 16&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;实际控制窗口中有三个“鼠标位置”：&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;本机系统指针；&lt;/li&gt;&lt;li&gt;刚刚发送给学生端的预测位置；&lt;/li&gt;&lt;li&gt;学生端通过 &lt;code class=&quot;inline-code&quot;&gt;SPUC&lt;/code&gt; 回传的确认位置。&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;如果三者同时显示，用户会看到两个指针互相追赶。因此投屏区域隐藏本机系统指针；发送鼠标事件后的短时间内显示本地预测位置，约 180 ms 后切回 &lt;code class=&quot;inline-code&quot;&gt;SPUC&lt;/code&gt; 确认位置。这个策略不能消除网络和编码延迟，但能减少操作感上的跳变。&lt;/p&gt;
&lt;p&gt;画面显示可能经过缩放，坐标必须基于实际图像区域，而不是整个窗口或屏幕：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;normalized_x = round(local_x * 65535 / (display_width  - 1))
normalized_y = round(local_y * 65535 / (display_height - 1))&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;预测光标绘制回源画面时，再从 &lt;code class=&quot;inline-code&quot;&gt;0..65535&lt;/code&gt; 映射到 encoded width/height。忽略这两次映射，会在窗口缩放后产生越来越明显的位置偏差。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;九、远控建立comd-事务中的-mcmd&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#九、远控建立comd-事务中的-mcmd&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;九、远控建立：COMD 事务中的 MCMD&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;MCMD&lt;/code&gt; 不能作为裸 UDP 报文发送，它是通用 &lt;code class=&quot;inline-code&quot;&gt;COMD&lt;/code&gt; transaction 的 payload。COMD 外层负责版本、事务 GUID、超时、发送者和 payload 长度；学生端先进入事务分发器，再把 MCMD 交给监看/控制模块。&lt;/p&gt;
&lt;p&gt;当前 MCMD 内层固定为 53 字节：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;偏移&lt;/th&gt;&lt;th&gt;大小&lt;/th&gt;&lt;th&gt;说明&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x00&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;inner length &lt;code class=&quot;inline-code&quot;&gt;53&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x04&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;feature/category &lt;code class=&quot;inline-code&quot;&gt;8&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x08&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;flags &lt;code class=&quot;inline-code&quot;&gt;0&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x0C&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;magic &lt;code class=&quot;inline-code&quot;&gt;MCMD&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x10&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;mode：&lt;code class=&quot;inline-code&quot;&gt;0&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;1&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;2&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x14&lt;/code&gt;&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;学生 IP，网络序字节&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x18&lt;/code&gt;&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;学生端输入监听 UDP 端口&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x1A&lt;/code&gt;&lt;/td&gt;&lt;td&gt;27&lt;/td&gt;&lt;td&gt;保留/零填充&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;项目默认从 &lt;code class=&quot;inline-code&quot;&gt;49152..65535&lt;/code&gt; 随机选择一个高位端口。使用固定端口虽然方便抓包，但学生端异常退出后旧线程或状态可能仍占用它；随机端口更适合反复调试。&lt;/p&gt;
&lt;p&gt;MCMD 发出后不能立即发送第一条输入。学生端需要创建接收线程并完成 &lt;code class=&quot;inline-code&quot;&gt;BeginSimulate&lt;/code&gt; 初始化。当前实现保守等待约 350 ms；这不是协议字段，而是从实际时序中得到的工程性保护。&lt;/p&gt;
&lt;p&gt;为了避免学生端进入“有控制状态、没有画面会话”的不完整状态，&lt;code class=&quot;inline-code&quot;&gt;control&lt;/code&gt; 只在 4806/TCP 已经连接后发送 MCMD。停止时发送 &lt;code class=&quot;inline-code&quot;&gt;mode=1&lt;/code&gt; 并关闭本地 UDP sender。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;十、28-字节模拟输入包&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#十、28-字节模拟输入包&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;十、28 字节模拟输入包&lt;/h2&gt;
&lt;p&gt;所有输入事件使用相同外壳：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;+0x00  u32 magic = 0x2321347C
+0x04  u32 kind
+0x08  u8  payload[20]
total = 28 bytes&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;线上 magic 的小端字节是：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;7C 34 21 23&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;固定总长非常重要。多一个字节或少一个字节都可能让学生端接收线程丢包，或者让后续字段错位。&lt;/p&gt;
&lt;h3 id=&quot;101-鼠标kind1&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#101-鼠标kind1&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;10.1 鼠标：kind=1&lt;/h3&gt;
&lt;p&gt;鼠标 payload 是五个 &lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;payload 偏移&lt;/th&gt;&lt;th&gt;字段&lt;/th&gt;&lt;th&gt;说明&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x00&lt;/code&gt;&lt;/td&gt;&lt;td&gt;message&lt;/td&gt;&lt;td&gt;Windows 鼠标消息&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x04&lt;/code&gt;&lt;/td&gt;&lt;td&gt;x&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0..65535&lt;/code&gt; 归一化坐标&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x08&lt;/code&gt;&lt;/td&gt;&lt;td&gt;y&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0..65535&lt;/code&gt; 归一化坐标&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x0C&lt;/code&gt;&lt;/td&gt;&lt;td&gt;data&lt;/td&gt;&lt;td&gt;滚轮等附加数据&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x10&lt;/code&gt;&lt;/td&gt;&lt;td&gt;swapped&lt;/td&gt;&lt;td&gt;键位交换/保留状态&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;已验证的 message：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;动作&lt;/th&gt;&lt;th&gt;值&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;move&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x0200&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;left down / up&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x0201&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;0x0202&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;right down / up&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x0204&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;0x0205&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;middle down / up&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x0207&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;0x0208&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;wheel&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x020A&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;鼠标移动和点击在当前学生端环境已经观察到实际执行结果，因此证据链不仅停留在“教师端 sendto 成功”。&lt;/p&gt;
&lt;h3 id=&quot;102-键盘kind16仍是实验性&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#102-键盘kind16仍是实验性&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;10.2 键盘：kind=16，仍是实验性&lt;/h3&gt;
&lt;p&gt;当前根据反汇编字段访问和教师端行为构造的 20 字节 payload：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;payload 偏移&lt;/th&gt;&lt;th&gt;类型&lt;/th&gt;&lt;th&gt;说明&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x00&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u16&lt;/code&gt;&lt;/td&gt;&lt;td&gt;scan code&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x02&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u16&lt;/code&gt;&lt;/td&gt;&lt;td&gt;virtual key&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x04&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;u32&lt;/code&gt;&lt;/td&gt;&lt;td&gt;flags&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;+0x08&lt;/code&gt;&lt;/td&gt;&lt;td&gt;12 bytes&lt;/td&gt;&lt;td&gt;zero/reserved&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;当前 flags：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;bit 0    = extended key
bit 7    = key up&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;普通按下为 &lt;code class=&quot;inline-code&quot;&gt;flags=0&lt;/code&gt;，释放为 &lt;code class=&quot;inline-code&quot;&gt;flags=0x80&lt;/code&gt;；扩展键按下/释放再或上 &lt;code class=&quot;inline-code&quot;&gt;0x01&lt;/code&gt;。&lt;/p&gt;
&lt;p&gt;Tk 的键盘事件会受输入法和焦点影响，尤其在中文输入法状态下，部分按键不会按预期到达 Tk。因此控制窗口额外使用 &lt;code class=&quot;inline-code&quot;&gt;WH_KEYBOARD_LL&lt;/code&gt; 获取 Windows 提供的 VK、扫描码、扩展键标志以及 key down/up，并拦截 Alt、Windows 键，防止这些键先作用于教师机本地桌面。&lt;/p&gt;
&lt;p&gt;但是，“Hook 日志出现”和“学生端收到有效键盘输入”之间仍有多层边界。当前只能确认：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;本地物理按键
  -&amp;gt; WH_KEYBOARD_LL 捕获成功
  -&amp;gt; kind=16 的 28 字节包构造成功
  -&amp;gt; UDP sendto 成功
  -x-&amp;gt; 学生端解析/SendInput/目标应用收到字符：尚未稳定证明&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;可能影响学生端最终执行的因素包括：学生端所在 Windows Session、当前 input desktop、UAC 安全桌面、接收线程权限、学生端本地 Hook、扫描码/VK 组合、扩展键标志以及注入事件过滤。没有接收端 ACK 时，教师端日志不能跨越这些边界作结论。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;十一、如何判断真的成功而不是日志看起来成功&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#十一、如何判断真的成功而不是日志看起来成功&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;十一、如何判断“真的成功”，而不是日志看起来成功&lt;/h2&gt;
&lt;p&gt;逆向远控最危险的误区是把 &lt;code class=&quot;inline-code&quot;&gt;sendto()&lt;/code&gt; 返回成功当成远端执行成功。建议把证据拆成六级：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;等级&lt;/th&gt;&lt;th&gt;证据&lt;/th&gt;&lt;th&gt;鼠标&lt;/th&gt;&lt;th&gt;键盘&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;A&lt;/td&gt;&lt;td&gt;教师端 UI/Hook 捕获事件&lt;/td&gt;&lt;td&gt;已验证&lt;/td&gt;&lt;td&gt;已验证&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;B&lt;/td&gt;&lt;td&gt;教师端构造并发送正确长度报文&lt;/td&gt;&lt;td&gt;已验证&lt;/td&gt;&lt;td&gt;已验证&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;C&lt;/td&gt;&lt;td&gt;抓包看到报文到达学生端&lt;/td&gt;&lt;td&gt;已验证&lt;/td&gt;&lt;td&gt;需持续复核&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;D&lt;/td&gt;&lt;td&gt;学生端接收器进入对应 kind 分支&lt;/td&gt;&lt;td&gt;已验证&lt;/td&gt;&lt;td&gt;尚缺稳定动态证据&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;E&lt;/td&gt;&lt;td&gt;学生端系统注入 API 成功&lt;/td&gt;&lt;td&gt;已验证实际效果&lt;/td&gt;&lt;td&gt;未稳定验证&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;F&lt;/td&gt;&lt;td&gt;目标桌面/应用收到输入&lt;/td&gt;&lt;td&gt;已验证&lt;/td&gt;&lt;td&gt;未稳定验证&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;如果要继续研究键盘，下一步不应继续盲改教师端字段，而应在授权测试机上对学生端接收分支做动态观测：&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;在 &lt;code class=&quot;inline-code&quot;&gt;recvfrom&lt;/code&gt; 返回后记录 28 字节缓冲区；&lt;/li&gt;&lt;li&gt;确认 magic、kind 和 payload 分支；&lt;/li&gt;&lt;li&gt;在 &lt;code class=&quot;inline-code&quot;&gt;SendInput&lt;/code&gt; 前检查构造出的 &lt;code class=&quot;inline-code&quot;&gt;INPUT&lt;/code&gt;；&lt;/li&gt;&lt;li&gt;记录 &lt;code class=&quot;inline-code&quot;&gt;SendInput&lt;/code&gt; 返回值和 &lt;code class=&quot;inline-code&quot;&gt;GetLastError&lt;/code&gt;；&lt;/li&gt;&lt;li&gt;确认线程所属 Session 与当前 input desktop；&lt;/li&gt;&lt;li&gt;最后再观察目标窗口是否收到键盘消息。&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;只有走完这条链，才能判断问题究竟是协议字段错误，还是 Windows 输入隔离与 Hook 策略导致。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;十二、几个真正耗时的坑&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#十二、几个真正耗时的坑&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;十二、几个真正耗时的坑&lt;/h2&gt;
&lt;h3 id=&quot;121-把-4806-与-feature-参数端口混为一谈&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#121-把-4806-与-feature-参数端口混为一谈&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;12.1 把 4806 与 feature 参数端口混为一谈&lt;/h3&gt;
&lt;p&gt;feature 参数里的教师端点不等于学生端 TCP 监听端口。包长和 IP 都正确时，这种错误特别难发现，因为学生端可能进入部分状态，却不产生正确桌面流。&lt;/p&gt;
&lt;h3 id=&quot;122-按-recv-边界解析-tcp&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#122-按-recv-边界解析-tcp&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;12.2 按 recv 边界解析 TCP&lt;/h3&gt;
&lt;p&gt;本地网络里一次 recv 经常“刚好”是一包，导致错误解析器看似可用。一旦包被拆分或合并，就出现随机 magic、超大 length 和画面断流。TCP 必须按字节流处理。&lt;/p&gt;
&lt;h3 id=&quot;123-把-16-字节-spuc-当坏视频帧&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#123-把-16-字节-spuc-当坏视频帧&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;12.3 把 16 字节 SPUC 当坏视频帧&lt;/h3&gt;
&lt;p&gt;早期解析器假设桌面记录至少 64 字节，日志中不断出现 &lt;code class=&quot;inline-code&quot;&gt;total=16&lt;/code&gt; 的“非法帧”。保留这批原始数据并查看 magic 后，才发现它是独立光标记录。&lt;/p&gt;
&lt;h3 id=&quot;124-在码流中途更换播放器&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#124-在码流中途更换播放器&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;12.4 在码流中途更换播放器&lt;/h3&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;view&lt;/code&gt; 能显示、&lt;code class=&quot;inline-code&quot;&gt;control&lt;/code&gt; 一切换就卡在“等待画面”，根因不是 MCMD，而是切换时重启了解码器。H.264 参数集已经在流开头发过，新解码器只能等待下一次可恢复点。&lt;/p&gt;
&lt;h3 id=&quot;125-把颜色问题误判为-rgbbgr&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#125-把颜色问题误判为-rgbbgr&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;12.5 把颜色问题误判为 RGB/BGR&lt;/h3&gt;
&lt;p&gt;如果交换 R/B 后肤色和亮度仍不合理，应检查 YUV 平面。当前链路需要交换 U/V，而不是在最终 RGB 图像上交换红蓝通道。&lt;/p&gt;
&lt;h3 id=&quot;126-本地指针、预测指针和远端指针混在一起&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#126-本地指针、预测指针和远端指针混在一起&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;12.6 本地指针、预测指针和远端指针混在一起&lt;/h3&gt;
&lt;p&gt;鼠标“不同步”不一定是包没生效。若本机系统指针可见，同时又绘制预测位置和 &lt;code class=&quot;inline-code&quot;&gt;SPUC&lt;/code&gt; 位置，视觉上必然出现错位。隐藏本地指针并定义明确的预测回退窗口后，问题才可测量。&lt;/p&gt;
&lt;h3 id=&quot;127-用错误的-comd-边界调-mcmd&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#127-用错误的-comd-边界调-mcmd&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;12.7 用错误的 COMD 边界调 MCMD&lt;/h3&gt;
&lt;p&gt;MCMD 是通用事务的 payload，不是 COMD 应用命令里的任意 cmdId。外层长度、GUID、事务字段或 payload offset 错一处，学生端通用分发器就可能走入完全不同的命令分支。调试时若出现与鼠标无关的窗口或系统提示，应先停止发送，重新核对事务边界，而不是继续猜键码。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;十三、实现中的防崩溃与可观测性设计&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#十三、实现中的防崩溃与可观测性设计&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;十三、实现中的防崩溃与可观测性设计&lt;/h2&gt;
&lt;p&gt;协议能跑通不等于实现足够稳。当前版本加入了以下约束：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;view_probe&lt;/code&gt; 只做 TCP connect 探测，不发送 feature 8 或 SHCO；&lt;/li&gt;&lt;li&gt;每个学生 IP 同时只允许一个 RemoteViewSession；&lt;/li&gt;&lt;li&gt;正式观看只进行一次 TCP 连接，不循环轰炸学生端；&lt;/li&gt;&lt;li&gt;连接/接收失败后发送停止 feature，并进入 60 秒冷却；&lt;/li&gt;&lt;li&gt;UMSP payload 和桌面 record 都有长度上限与越界检查；&lt;/li&gt;&lt;li&gt;未完成分片数量受限，重复字节不重复计数；&lt;/li&gt;&lt;li&gt;H.264 原始流按会话独立保存；&lt;/li&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;control&lt;/code&gt; 必须等待 TCP 会话 connected event；&lt;/li&gt;&lt;li&gt;MCMD 后等待接收线程初始化，再发送首个输入包；&lt;/li&gt;&lt;li&gt;远控可用 &lt;code class=&quot;inline-code&quot;&gt;TEACHER_ENABLE_REMOTE_CONTROL=0&lt;/code&gt; 紧急禁用；&lt;/li&gt;&lt;li&gt;日志区分“捕获”“发包”“远端 SPUC 反馈”，避免把不同证据混成一句成功。&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;建议保留的关键日志字段：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;[RemoteView] feature start / stop
[RemoteView] TCP connected, SHCO channel
[RemoteView] frame_seq / offset / total
[RemoteView] record magic / declared size / rect / frame type
[RemoteControl] MCMD mode / UDP endpoint
[RemoteControl] input count / kind / exact 28-byte hex
[RemoteControl] SPUC x / y / timestamp&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;日志必须限频。鼠标 move 可能达到每秒上百次，全量 INFO 不仅难读，还会反过来增加延迟；当前实现只详细记录前几包、关键按键和周期性样本。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;十四、当前结论与下一步&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#十四、当前结论与下一步&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;十四、当前结论与下一步&lt;/h2&gt;
&lt;p&gt;连续投屏链路已经形成闭环：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;IDA 定位 feature 8 和 UMSP
  -&amp;gt; 抓包确认 SHCO/TKPC/channel 10
  -&amp;gt; 重组桌面分片
  -&amp;gt; 识别 HHRF/HJRF/SPUC
  -&amp;gt; FFmpeg 解码、U/V 修正、visible rect 裁剪
  -&amp;gt; Pillow/Tk 内嵌交互窗口&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;远程鼠标也形成了从 MCMD 建立接收器到 28 字节输入包、学生端实际动作、SPUC 位置反馈的闭环。&lt;/p&gt;
&lt;p&gt;键盘尚未闭环。当前研究最重要的结论不是“再换一个键码试试”，而是已经明确缺失的证据位于学生端接收分支到 Windows 输入桌面之间。下一阶段应优先补动态观测和返回值证据，再决定是否修改 kind=16 字段。&lt;/p&gt;
&lt;p&gt;逆向协议真正有价值的部分，不是记住几个 magic 和 offset，而是把每个结论绑定到可重复的证据：反汇编交叉引用说明代码如何读，抓包说明线上如何写，日志说明我们的实现走到了哪一层，远端可见行为才说明功能最终生效。&lt;/p&gt;
&lt;p&gt;这也是本项目在 README 中坚持区分“已验证”“可用”“部分验证”和“实验性”的原因。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;附录-a协议层级速查&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#附录-a协议层级速查&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;附录 A：协议层级速查&lt;/h2&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;MESS feature 8 (5512/UDP)
└── 617-byte remote-view payload

4806/TCP
└── UMSP
    ├── SHCO: select channel 10
    └── TKPC
        └── channel 10
            └── desktop fragment: seq + offset + total
                ├── HHRF: H.264 Annex-B
                ├── HJRF: JPEG
                ├── HMRF: legacy record
                └── SPUC: cursor position

COMD transaction (4705/UDP)
└── MCMD mode 0/1/2 + student input UDP port
    └── 28-byte input packet
        ├── kind=1: mouse
        └── kind=16: keyboard (experimental)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;附录-b运行命令&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#附录-b运行命令&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;附录 B：运行命令&lt;/h2&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;text&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;view_probe &amp;lt;ip&amp;gt;       # 只探测 4806/TCP
view &amp;lt;ip&amp;gt;             # 启动连续观看
control &amp;lt;ip&amp;gt;          # 在观看会话上启用远控
control_stop &amp;lt;ip&amp;gt;     # 停止输入模拟
view_stop &amp;lt;ip&amp;gt;        # 停止桌面流&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;请先执行 &lt;code class=&quot;inline-code&quot;&gt;view_probe&lt;/code&gt;，并只在自己拥有管理权限或已获得明确授权的设备上测试。&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>我翻新了JiYu Trainer!!!部分重写一个停更五年的反电子教室软件 —— Dzjs Trainer v1.0.0</title>
    <link href="https://blog.xn--9kq396ceqaq4si9m.cn/post/%E6%88%91%E7%BF%BB%E6%96%B0%E4%BA%86jiyu-trainer%E9%83%A8%E5%88%86%E9%87%8D%E5%86%99%E4%B8%80%E4%B8%AA%E5%81%9C%E6%9B%B4%E4%BA%94%E5%B9%B4%E7%9A%84%E5%8F%8D%E7%94%B5%E5%AD%90%E6%95%99%E5%AE%A4%E8%BD%AF%E4%BB%B6-dzjs-trainer-v100"/>
    <id>https://blog.xn--9kq396ceqaq4si9m.cn/post/%E6%88%91%E7%BF%BB%E6%96%B0%E4%BA%86jiyu-trainer%E9%83%A8%E5%88%86%E9%87%8D%E5%86%99%E4%B8%80%E4%B8%AA%E5%81%9C%E6%9B%B4%E4%BA%94%E5%B9%B4%E7%9A%84%E5%8F%8D%E7%94%B5%E5%AD%90%E6%95%99%E5%AE%A4%E8%BD%AF%E4%BB%B6-dzjs-trainer-v100</id>
    <published>2026-10-05T17:51:43+08:00</published>
    <updated>2026-10-05T17:51:43+08:00</updated>
    <summary type="html">我翻新了JiYu Trainer!!!部分重写一个停更五年的反电子教室软件 —— Dzjs Trainer v1.0.0 我是云散皆星河。这篇文章讲讲我怎么把快乐的梦鱼的 JiYuTrainer，从 SSDT Hook 时代搬进内核回调时代。 为什么接手这个项目 2019 年，快乐的梦鱼（imengyu）写了 JiYuTrainer——一个让极域电子教室全屏…</summary>
    <content type="html">&lt;h1 id=&quot;我翻新了jiyu-trainer部分重写一个停更五年的反电子教室软件-dzjs-trainer-v100&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#我翻新了jiyu-trainer部分重写一个停更五年的反电子教室软件-dzjs-trainer-v100&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;我翻新了JiYu Trainer!!!部分重写一个停更五年的反电子教室软件 —— Dzjs Trainer v1.0.0&lt;/h1&gt;
&lt;blockquote&gt;&lt;p&gt;我是云散皆星河。这篇文章讲讲我怎么把快乐的梦鱼的 JiYuTrainer，从 SSDT Hook 时代搬进内核回调时代。&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&quot;为什么接手这个项目&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#为什么接手这个项目&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;为什么接手这个项目&lt;/h2&gt;
&lt;p&gt;2019 年，快乐的梦鱼（imengyu）写了 JiYuTrainer——一个让极域电子教室全屏广播失效的工具。被老师全屏广播时自动转成窗口模式：自己能操作，老师演示也照看。项目开源在 GitHub 上，MIT 协议，从 2019 年 5 月维护到 2021 年。&lt;/p&gt;
&lt;p&gt;然后他毕业了。2021 年 12 月 3 日，仓库归档，顶部一行字：&quot;已废弃。本项目将永远不再更新。&quot;&lt;/p&gt;
&lt;p&gt;我 fork 它的时候面对的现实是：原版驱动的核心是 &lt;strong&gt;SSDT Hook&lt;/strong&gt;——直接改写系统服务描述符表。这在 x86 时代是经典操作，但 x64 系统的 &lt;strong&gt;PatchGuard（内核补丁保护）&lt;/strong&gt; 会周期性校验内核关键结构，发现被篡改直接蓝屏。也就是说，原版的驱动方案在今天的 Win10/11 x64 上本身就是颗不定时炸弹。&lt;/p&gt;
&lt;p&gt;所以这不是&quot;fork 接着用&quot;的事。要让它活在 2026 年的机房里，驱动层必须重写。&lt;/p&gt;
&lt;p&gt;我联系了原作者，拿到了口头许可，在保留原项目贡献说明的基础上继续演进。这就是 Dzjs Trainer。&lt;/p&gt;
&lt;h2 id=&quot;一、驱动从-ssdt-hook-到内核回调&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#一、驱动从-ssdt-hook-到内核回调&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;一、驱动：从 SSDT Hook 到内核回调&lt;/h2&gt;
&lt;p&gt;新驱动（&lt;code class=&quot;inline-code&quot;&gt;JiYuTrainerDriver&lt;/code&gt;，x64 WDM）完全重写了。拦截能力不变，但实现全部换成操作系统官方提供的注册机制：&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;进程创建/退出通知&lt;/strong&gt;——&lt;code class=&quot;inline-code&quot;&gt;PsSetCreateProcessNotifyRoutineEx&lt;/code&gt;（&lt;code class=&quot;inline-code&quot;&gt;Monitor.c&lt;/code&gt;）。驱动随时知道哪个进程起了、哪个进程退了。受保护的 PID 对应的进程退出时，自动调 &lt;code class=&quot;inline-code&quot;&gt;KxUnProtectProcessWithPid&lt;/code&gt; 解除保护，不留悬空状态。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;句柄拦截&lt;/strong&gt;——&lt;code class=&quot;inline-code&quot;&gt;ObRegisterCallbacks&lt;/code&gt;（&lt;code class=&quot;inline-code&quot;&gt;Protection64.c&lt;/code&gt;）。注册进程/线程对象的 pre-operation 回调，在外部进程试图打开或复制受保护进程/线程句柄时，直接剥掉危险的访问权限。这是替代 SSDT Hook 的核心：不改系统表，只订阅系统事件，PatchGuard 无从下手。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;保护目标绑定&lt;/strong&gt;——&lt;code class=&quot;inline-code&quot;&gt;JdrvProtectionSetTarget&lt;/code&gt; 通过 &lt;code class=&quot;inline-code&quot;&gt;PsLookupProcessByProcessId&lt;/code&gt; 按 PID 绑定极域主进程，是用户态告诉驱动&quot;保护谁&quot;的入口。&lt;/p&gt;
&lt;h3 id=&quot;ioctl-通信协议&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#ioctl-通信协议&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;IOCTL 通信协议&lt;/h3&gt;
&lt;p&gt;用户态和驱动的通道是经典的 &lt;code class=&quot;inline-code&quot;&gt;DeviceIoControl&lt;/code&gt;，设备类型 &lt;code class=&quot;inline-code&quot;&gt;0x8338&lt;/code&gt;，全部 &lt;code class=&quot;inline-code&quot;&gt;METHOD_BUFFERED&lt;/code&gt;。&lt;code class=&quot;inline-code&quot;&gt;IoCtl.h&lt;/code&gt; 里定义了 14 个控制码：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;功能码&lt;/th&gt;&lt;th&gt;IOCTL&lt;/th&gt;&lt;th&gt;用途&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;0x800&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;CTL_QUERY_VERSION&lt;/code&gt;&lt;/td&gt;&lt;td&gt;查询驱动协议版本&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;0x801&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;CTL_INITPARAM&lt;/code&gt;&lt;/td&gt;&lt;td&gt;初始化参数&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;0x802&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;CTL_INITSELFPROTECT&lt;/code&gt;&lt;/td&gt;&lt;td&gt;开启驱动自保护&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;0x803&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;CTL_KILL_PROCESS&lt;/code&gt;&lt;/td&gt;&lt;td&gt;内核级杀进程&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;0x804/0x805&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;CTL_SUSPEND_PROCESS&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;CTL_RESUME_PROCESS&lt;/code&gt;&lt;/td&gt;&lt;td&gt;挂起/恢复进程&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;0x806/0x807&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;CTL_SHUTDOWN&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;CTL_REBOOT&lt;/code&gt;&lt;/td&gt;&lt;td&gt;关机/重启&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;0x808&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;CTL_CLIENT_QUIT&lt;/code&gt;&lt;/td&gt;&lt;td&gt;客户端退出通知&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;0x809&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;CTL_UNINIT&lt;/code&gt;&lt;/td&gt;&lt;td&gt;反初始化&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;0x80A&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;CTL_READ_EVENTS&lt;/code&gt;&lt;/td&gt;&lt;td&gt;读取内核事件队列&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;0x80B&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;CTL_HEARTBEAT&lt;/code&gt;&lt;/td&gt;&lt;td&gt;心跳保活&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;0x80C/0x80D&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;CTL_DRIVER_GUARD_CONFIG&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;CTL_DRIVER_GUARD_QUERY&lt;/code&gt;&lt;/td&gt;&lt;td&gt;驱动守卫配置/查询&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;主程序（&lt;code class=&quot;inline-code&quot;&gt;DriverLoader.cpp&lt;/code&gt;）启动一个事件监控线程循环读 &lt;code class=&quot;inline-code&quot;&gt;CTL_READ_EVENTS&lt;/code&gt;，把内核上报的事件搬回 UI；同时定时发 &lt;code class=&quot;inline-code&quot;&gt;CTL_HEARTBEAT&lt;/code&gt;，校验协议版本——驱动和主程序任何一边失联，另一边都能立刻察觉，不会出现&quot;驱动还在拦、程序已经死了&quot;的半死状态。&lt;/p&gt;
&lt;h3 id=&quot;卸载令牌ecdsa-p-256-签名&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#卸载令牌ecdsa-p-256-签名&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;卸载令牌：ECDSA P-256 签名&lt;/h3&gt;
&lt;p&gt;原版驱动装上去就下不来，这不是好设计。新版驱动卸载需要一枚&lt;strong&gt;签名的卸载令牌&lt;/strong&gt;（&lt;code class=&quot;inline-code&quot;&gt;UnloadToken64.c&lt;/code&gt;），流程是：&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;校验令牌结构：长度、size 字段、magic、version、action 字段，任何一项不符直接 &lt;code class=&quot;inline-code&quot;&gt;STATUS_INVALID_PARAMETER&lt;/code&gt;&lt;/li&gt;&lt;li&gt;对令牌头部（到 &lt;code class=&quot;inline-code&quot;&gt;signature&lt;/code&gt; 字段之前）计算 &lt;strong&gt;SHA-256&lt;/strong&gt;（内核里用 &lt;code class=&quot;inline-code&quot;&gt;BCryptHash&lt;/code&gt;，&lt;code class=&quot;inline-code&quot;&gt;BCRYPT_SHA256_ALGORITHM&lt;/code&gt;）&lt;/li&gt;&lt;li&gt;用编译进驱动的 &lt;strong&gt;ECDSA P-256 公钥&lt;/strong&gt;（&lt;code class=&quot;inline-code&quot;&gt;UnlockPublicKey.h&lt;/code&gt;）做 &lt;code class=&quot;inline-code&quot;&gt;BCryptVerifySignature&lt;/code&gt; 验签&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;密钥对由 &lt;code class=&quot;inline-code&quot;&gt;tools\New-DriverUnlockKeys.ps1&lt;/code&gt; 生成，令牌由 &lt;code class=&quot;inline-code&quot;&gt;tools\New-DriverUnlockToken.ps1&lt;/code&gt; 构造 payload、算 SHA-256、用私钥签名后输出 &lt;code class=&quot;inline-code&quot;&gt;.unlock&lt;/code&gt; 文件。&lt;strong&gt;私钥永不入库&lt;/strong&gt;——仓库里只有一个 &lt;code class=&quot;inline-code&quot;&gt;JiYuTrainerDriver.unlock.enc.sample&lt;/code&gt; 占位。也就是说，公开构建的驱动能装能跑，但只有持有私钥的发布者能生成合法的卸载令牌。这是&quot;谁发布、谁负责&quot;的信任链。&lt;/p&gt;
&lt;h2 id=&quot;二、hook-模块战场在-studentmain-进程内&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#二、hook-模块战场在-studentmain-进程内&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;二、Hook 模块：战场在 StudentMain 进程内&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;JiYuTrainerHooks.dll&lt;/code&gt; 是注入进极域学生端（&lt;code class=&quot;inline-code&quot;&gt;StudentMain.exe&lt;/code&gt;，也支持 &lt;code class=&quot;inline-code&quot;&gt;MasterHelper.exe&lt;/code&gt;）的 DLL，用 &lt;strong&gt;mhook&lt;/strong&gt; 做 inline hook。主程序（&lt;code class=&quot;inline-code&quot;&gt;TrainerWorker.cpp&lt;/code&gt;）定时刷新进程列表，定位到目标进程后注入，然后走心跳/控制握手。DLL 里还挂了一个 &lt;code class=&quot;inline-code&quot;&gt;WH_CBT&lt;/code&gt; 钩子盯着窗口事件。&lt;/p&gt;
&lt;p&gt;hook 的 API 面覆盖了极域的全部控制手段：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;strong&gt;窗口控制类&lt;/strong&gt;：&lt;code class=&quot;inline-code&quot;&gt;SetWindowPos&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;MoveWindow&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;DeferWindowPos&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;SetWindowLongA/W&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ShowWindow&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;SetForegroundWindow&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;BringWindowToTop&lt;/code&gt;——全屏广播转窗口、窗口置顶、黑屏安静的对抗都在这一层&lt;/li&gt;&lt;li&gt;&lt;strong&gt;输入类&lt;/strong&gt;：&lt;code class=&quot;inline-code&quot;&gt;SendInput&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;mouse_event&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;SetWindowsHookExA&lt;/code&gt;——防键盘鼠标锁定&lt;/li&gt;&lt;li&gt;&lt;strong&gt;执行类&lt;/strong&gt;：&lt;code class=&quot;inline-code&quot;&gt;CreateProcessA/W&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;WinExec&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ShellExecuteW/ExW&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ExitWindowsEx&lt;/code&gt;——拦截教师端远程下发的命令，用户可以逐条选择放行还是拒绝&lt;/li&gt;&lt;li&gt;&lt;strong&gt;通信类&lt;/strong&gt;：&lt;code class=&quot;inline-code&quot;&gt;DeviceIoControl&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;CreateFileA/W&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;FilterConnectCommunicationPort&lt;/code&gt;——监控极域自有驱动的通信&lt;/li&gt;&lt;li&gt;&lt;strong&gt;显示类&lt;/strong&gt;：&lt;code class=&quot;inline-code&quot;&gt;ChangeDisplaySettingsW&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;DwmEnableComposition&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;GetDesktopWindow&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;GetWindowDC&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;CreateDCW&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;BitBlt&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;h3 id=&quot;反监视三层屏幕捕获对抗&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#反监视三层屏幕捕获对抗&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;反监视：三层屏幕捕获对抗&lt;/h3&gt;
&lt;p&gt;这是整个项目里我花时间最多的部分。极域的&quot;打开看&quot;（教师端实时监视学生屏幕）有好几条捕获路径，得逐条堵：&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;路径一：DispFilter.dll 的 DXGI 捕获。&lt;/strong&gt; 用 IDA 逆向确认它只按序号导出：ordinal 1 是 &lt;code class=&quot;inline-code&quot;&gt;DispDXGIBitBlt&lt;/code&gt;（真正读桌面像素），ordinal 4 是 &lt;code class=&quot;inline-code&quot;&gt;DispDXGIGetScreenUpdate&lt;/code&gt;（只取脏矩形，结构体大小 0xC84、200 个 RECT）。&lt;code class=&quot;inline-code&quot;&gt;DispDXGIBitBlt&lt;/code&gt; 把 DXGI 桌面帧按 RGBA 逐行 memcpy 进调用方缓冲——我的钩子在原始函数返回后，把整块像素填成不透明黑（B=G=R=0, A=0xFF），教师端看到的就是纯黑一片。&lt;/p&gt;
&lt;p&gt;还有一个首帧空窗问题：StudentMain 是通过 &lt;code class=&quot;inline-code&quot;&gt;LibDeskMonitor::TDDeskCreateInstance → libTDDesk2&lt;/code&gt; 在&quot;打开看&quot;开始时才 &lt;code class=&quot;inline-code&quot;&gt;LoadLibraryW(&amp;quot;DispFilter.dll&amp;quot;)&lt;/code&gt; 动态加载它的。所以我同时钩了 &lt;code class=&quot;inline-code&quot;&gt;LoadLibraryW&lt;/code&gt;/&lt;code class=&quot;inline-code&quot;&gt;LoadLibraryExW&lt;/code&gt;——DispFilter 一被加载，捕获钩立即装上，不留空窗。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;路径二：LibDeskMonitor.dll 的 GDI 抓屏。&lt;/strong&gt; 它静态导入 &lt;code class=&quot;inline-code&quot;&gt;BitBlt&lt;/code&gt;/&lt;code class=&quot;inline-code&quot;&gt;StretchBlt&lt;/code&gt;，把源窗口 DC 拷进内存位图。之前试过钩 &lt;code class=&quot;inline-code&quot;&gt;GetDesktopWindow&lt;/code&gt;/&lt;code class=&quot;inline-code&quot;&gt;GetWindowDC&lt;/code&gt; 拦不住——它的源 DC 是 MFC &lt;code class=&quot;inline-code&quot;&gt;CWnd::GetDC&lt;/code&gt; 直接拿的，不走这几个 API。解法是直接改写 LibDeskMonitor 自身的 IAT：钩住它内部的 &lt;code class=&quot;inline-code&quot;&gt;BitBlt&lt;/code&gt;/&lt;code class=&quot;inline-code&quot;&gt;StretchBlt&lt;/code&gt;，捕获完成后用 &lt;code class=&quot;inline-code&quot;&gt;PatBlt(BLACKNESS)&lt;/code&gt; 把目标内存位图刷黑。还有一个细节：&lt;code class=&quot;inline-code&quot;&gt;libTDDesk2&lt;/code&gt; 要等最终 &lt;code class=&quot;inline-code&quot;&gt;GdiFlush&lt;/code&gt; 之后才提交捕获位图，所以我用 &lt;code class=&quot;inline-code&quot;&gt;thread_local&lt;/code&gt; 记录同线程最近一次捕获的目标 DC，等原始 flush 返回后再覆盖整张持久位图——刷早了会被真实画面盖回去。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;路径三：JPEG 编码流。&lt;/strong&gt; 极域用 LibJPEG20 的 &lt;code class=&quot;inline-code&quot;&gt;EncodeToJPEGBuffer&lt;/code&gt;（及 I422 变体）把帧编码后发走。这里我做了&lt;strong&gt;三层钩&lt;/strong&gt;：函数实现体 inline hook + 多模块 IAT patch + &lt;code class=&quot;inline-code&quot;&gt;GetProcAddress&lt;/code&gt; 拦截——因为它按序号导出、且被多个模块以不同方式引用，单层钩总会漏。卸载时逐个还原 IAT 槽位。&lt;/p&gt;
&lt;h3 id=&quot;信息流保护不只是涂黑&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#信息流保护不只是涂黑&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;信息流保护：不只是涂黑&lt;/h3&gt;
&lt;p&gt;反监视之外，v1.0.0 还加了&quot;替换&quot;能力——教师端看到的不是黑屏，而是你指定的图片或视频：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;图片路径：RGB24 缓存 + 顶向下 BGR24 DIB 双份像素，&lt;code class=&quot;inline-code&quot;&gt;StretchDIBits&lt;/code&gt; 直接画&lt;/li&gt;&lt;li&gt;视频路径（MP4/WMV）：独立 &lt;strong&gt;Media Foundation&lt;/strong&gt; 线程解码，捕获热路径只读已发布的当前帧，不做文件 I/O 不做解码——捕获是高频路径，这里卡一下教师端就掉帧了&lt;/li&gt;&lt;li&gt;并发安全：临界区 + 引用计数管理共享 DC 和像素缓冲，&quot;正在使用的 DC 不会被删除&quot;，旧缓冲进 pending 列表等引用归零再释放&lt;/li&gt;&lt;/ul&gt;
&lt;h2 id=&quot;三、发布链路把信任做成流程&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#三、发布链路把信任做成流程&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;三、发布链路：把&quot;信任&quot;做成流程&lt;/h2&gt;
&lt;p&gt;代码写完只是一半，另一半是让用户能验证拿到手的二进制没被掉包。&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;tools\Build-JiYuTrainerRelease.ps1&lt;/code&gt; 串起整个发布流程：&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;MSBuild 重编 x64 驱动&lt;/li&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;signtool sign /sha1 &amp;lt;指纹&amp;gt; /fd SHA256 /tr &amp;lt;时间戳服务器&amp;gt;&lt;/code&gt; 对驱动签名（含 RFC3161 时间戳）&lt;/li&gt;&lt;li&gt;&lt;code class=&quot;inline-code&quot;&gt;Get-AuthenticodeSignature&lt;/code&gt; 验证签名，提取证书 Subject 和 SHA-1 指纹&lt;/li&gt;&lt;li&gt;&lt;strong&gt;关键一步&lt;/strong&gt;：把签名者 Subject 和指纹写进 &lt;code class=&quot;inline-code&quot;&gt;JiYuTrainer\DriverSignerPin.h&lt;/code&gt;，编译进主程序——主程序加载驱动前会校验驱动签名者是不是发布者本人，防偷换&lt;/li&gt;&lt;li&gt;调 &lt;code class=&quot;inline-code&quot;&gt;Complete-DriverSigning.ps1&lt;/code&gt;：&lt;code class=&quot;inline-code&quot;&gt;Inf2Cat&lt;/code&gt; 生成 catalog，再对 catalog 做 SHA-256 签名&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;也就是说：驱动签名 → 签名者指纹固化进主程序 → 主程序运行时校验 → catalog 二次签名。四道锁，任何一环被替换，整条链路报警。&lt;/p&gt;
&lt;h2 id=&quot;四、周边工具箱&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#四、周边工具箱&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;四、周边工具箱&lt;/h2&gt;
&lt;p&gt;翻新过程中沉淀下来一批独立小工具，都在仓库里：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;strong&gt;GuardTerminator&lt;/strong&gt;：对付设了 &lt;code class=&quot;inline-code&quot;&gt;ProcessBreakOnTermination&lt;/code&gt;（进程信息类 29）保护进程的终结工具，测试驱动自保护时用来模拟&quot;敌人&quot;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;JiYuAvKernel / JiYuAvCtl / JiYuAvShared&lt;/strong&gt;：辅助驱动与控制端（&lt;code class=&quot;inline-code&quot;&gt;Driver.c&lt;/code&gt;/&lt;code class=&quot;inline-code&quot;&gt;Controller.c&lt;/code&gt;/&lt;code class=&quot;inline-code&quot;&gt;Scanner.c&lt;/code&gt;），配套 &lt;code class=&quot;inline-code&quot;&gt;Build-JiYuAv.ps1&lt;/code&gt; 和独立签名脚本，做模式扫描一类的事&lt;/li&gt;&lt;li&gt;&lt;strong&gt;SlayerAnalyzer / PhoneDialogProbe / ExitInputSimulator&lt;/strong&gt;：逆向分析和场景模拟用的小工具&lt;/li&gt;&lt;li&gt;&lt;strong&gt;DriverPublisherTests / JiYuAvPatternTests&lt;/strong&gt;：发布链路和模式匹配的测试工程&lt;/li&gt;&lt;/ul&gt;
&lt;h2 id=&quot;五、诚实的支持范围&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#五、诚实的支持范围&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;五、诚实的支持范围&lt;/h2&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;类型&lt;/th&gt;&lt;th&gt;状态&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;极域电子教室&lt;/td&gt;&lt;td&gt;持续维护&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;机房管理助手&lt;/td&gt;&lt;td&gt;已提供适配基础&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Gakataka&lt;/td&gt;&lt;td&gt;计划中&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;红蜘蛛&lt;/td&gt;&lt;td&gt;计划中&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Hook 模块里保留了 &lt;code class=&quot;inline-code&quot;&gt;jiYuVersions40&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;2016HH&lt;/code&gt; 的版本适配逻辑。但我不想虚标——计划中就是计划中，每个版本的内脏（DLL 名、导出序号、窗口类）都不一样，没实测过的平台绝不说&quot;支持&quot;。&lt;/p&gt;
&lt;h2 id=&quot;写在最后&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#写在最后&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;写在最后&lt;/h2&gt;
&lt;p&gt;原版 README 结尾，梦鱼说：&quot;如果您有其他功能需求，可以 fork 项目之后自己研究开发。&quot;&lt;/p&gt;
&lt;p&gt;我就是那个 fork 的人。五年后，SSDT Hook 换成了内核回调，裸驱动换成了带 ECDSA 卸载令牌和签名者锁定的发布链路，单一黑屏对抗换成了三层捕获钩加视频流替换。项目以 MIT 协议继续开源：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;GitHub：&lt;a href=&quot;https://github.com/yunsjxh/Dzjs-Trainer&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;&lt;a href=&quot;https://github.com/yunsjxh/Dzjs-Trainer&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;https://github.com/yunsjxh/Dzjs-Trainer&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;官网：&lt;a href=&quot;https://dzjstrainer.xn--9kq396ceqaq4si9m.cn/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;&lt;a href=&quot;https://dzjstrainer.xn--9kq396ceqaq4si9m.cn/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;https://dzjstrainer.xn--9kq396ceqaq4si9m.cn/&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;感谢 JiYuTrainer 原作者快乐的梦鱼；第三方组件 curl、mhook、MemoryModule、XZip/XUnZip、dnlib 各自遵循其许可证&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;最后照例强调：&lt;strong&gt;请仅在你拥有、管理或获得明确授权的设备与网络中使用本项目&lt;/strong&gt;。先在隔离测试环境验证，再做经授权的部署。工具没有立场，边界由使用者决定。&lt;/p&gt;
&lt;p&gt;欢迎 Issue，欢迎 PR。加个星星⭐就更好了。&lt;/p&gt;</content>
  </entry>
  <entry>
    <title>闲来无事,逆向一个银狐病毒</title>
    <link href="https://blog.xn--9kq396ceqaq4si9m.cn/post/%E9%97%B2%E6%9D%A5%E6%97%A0%E4%BA%8B%E9%80%86%E5%90%91%E4%B8%80%E4%B8%AA%E9%93%B6%E7%8B%90%E7%97%85%E6%AF%92"/>
    <id>https://blog.xn--9kq396ceqaq4si9m.cn/post/%E9%97%B2%E6%9D%A5%E6%97%A0%E4%BA%8B%E9%80%86%E5%90%91%E4%B8%80%E4%B8%AA%E9%93%B6%E7%8B%90%E7%97%85%E6%AF%92</id>
    <published>2026-10-05T17:21:57+08:00</published>
    <updated>2026-10-05T17:21:57+08:00</updated>
    <summary type="html">闲来无事,逆向一个银狐病毒 样本：chat-deepseek.exe，2,085,620 字节，x64，无签名。样本下载在最后面。 SHA256 68ae0cabadce8467534f8a41e9ca139b4b9a066aa20d154254793bb4eb9a6b17 分两段：先在宿主机上纯静态把文件拆开（这段没运行样本的任何代码），确认它会做什么之后…</summary>
    <content type="html">&lt;h1 id=&quot;闲来无事逆向一个银狐病毒&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#闲来无事逆向一个银狐病毒&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;闲来无事,逆向一个银狐病毒&lt;/h1&gt;
&lt;blockquote&gt;&lt;p&gt;样本：&lt;code class=&quot;inline-code&quot;&gt;chat-deepseek.exe&lt;/code&gt;，2,085,620 字节，x64，无签名。样本下载在最后面。&lt;/p&gt;
&lt;p&gt;SHA256 &lt;code class=&quot;inline-code&quot;&gt;68ae0cabadce8467534f8a41e9ca139b4b9a066aa20d154254793bb4eb9a6b17&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;分两段：先在宿主机上&lt;strong&gt;纯静态&lt;/strong&gt;把文件拆开（这段没运行样本的任何代码），确认它会做什么之后，再放进&lt;strong&gt;隔离虚拟机&lt;/strong&gt;里跑，抓运行态证据——包括所有走错的路。&lt;/p&gt;&lt;/blockquote&gt;
&lt;hr&gt;
&lt;h2 id=&quot;先别急着扔-ida把没反应拆成能验证的问题&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#先别急着扔-ida把没反应拆成能验证的问题&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;先别急着扔 IDA：把&quot;没反应&quot;拆成能验证的问题&lt;/h2&gt;
&lt;p&gt;拿到文件时唯一的线索是一句很含糊的话：&quot;看着像仿冒 DeepSeek 的东西，但双击之后什么都没有。&quot;&lt;/p&gt;
&lt;p&gt;&quot;什么都没有&quot;是最没用的一句话。它至少指四种完全不同的情况：进程没被创建、起来了但秒退、活着但什么都不做、在跑但被什么东西拦住了。四种的排查方向完全相反。所以第一步不是打开 IDA，而是把它翻译成几个&lt;strong&gt;可测量&lt;/strong&gt;的量：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;待测量&lt;/th&gt;&lt;th&gt;怎么测&lt;/th&gt;&lt;th&gt;后来的答案&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;进程有没有被创建、活了多久&lt;/td&gt;&lt;td&gt;Process Monitor 的 Create → Exit 时间&lt;/td&gt;&lt;td&gt;创建了，但&lt;strong&gt;亚秒级退出&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;有没有落文件&lt;/td&gt;&lt;td&gt;看约定路径下有没有产物&lt;/td&gt;&lt;td&gt;&lt;strong&gt;没落任何文件&lt;/strong&gt;（连日志都没有）&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;有没有出网&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;netstat&lt;/code&gt;、DNS 缓存&lt;/td&gt;&lt;td&gt;&lt;strong&gt;没有&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;退出方式&lt;/td&gt;&lt;td&gt;正常 &lt;code class=&quot;inline-code&quot;&gt;ret&lt;/code&gt;（退出码 0、无崩溃报告）还是异常崩溃（有 WER 日志）&lt;/td&gt;&lt;td&gt;&lt;strong&gt;干净的 ret&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;最后一行是关键。崩溃退出的话方向会是&quot;找 bug、找兼容性&quot;；而它是&lt;strong&gt;自己决定不干、正常返回&lt;/strong&gt;——直接指向&quot;内部有个判断把它拦下来了&quot;。后面所有&quot;推翻重来&quot;，本质都是某条测量结果和判断对不上。&lt;/p&gt;
&lt;h2 id=&quot;它到底有没有壳不要看节名要看三件事&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#它到底有没有壳不要看节名要看三件事&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;它到底有没有壳：不要看节名，要看三件事&lt;/h2&gt;
&lt;p&gt;第一次打开 PE，节表长这样：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;.boot      vsize=0x592    entropy=6.00      ← 节名像 Armadillo 的引导节
.text      vsize=0x19BB0  entropy=6.44
.pkcfg     vsize=0xA0     entropy=0.22      ← 魔数 ARMPKCFG
.rdata     vsize=0x1C0000 chars=0xE0000040  (RWX, 1.75MB)
.fptable   vsize=0x100    entropy=0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;.boot&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;.pkcfg&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;.fptable&lt;/code&gt; 是 Armadillo / SoftwarePassport 的招牌节名，加上 &lt;code class=&quot;inline-code&quot;&gt;ARMPKCFG&lt;/code&gt; 魔数，很容易一眼就下&quot;这是商业壳&quot;。但我吃过看节名判壳的亏，所以定了三条更硬的判据：&lt;strong&gt;熵、导入表能不能正常解析、函数的序言模式&lt;/strong&gt;。节名可以伪造，这三样不行。&lt;/p&gt;
&lt;p&gt;结果第一条就出人意料：&lt;strong&gt;三个内嵌模块反而是明文&lt;/strong&gt;。&lt;code class=&quot;inline-code&quot;&gt;.text&lt;/code&gt; 熵 6.44（正常 MSVC 代码水平），导入目录解析出 13 个 DLL / 293 个函数全部正常，RTTI 完整可读 35 个类名，跳转表 100 项目标全落在 &lt;code class=&quot;inline-code&quot;&gt;.text&lt;/code&gt; 内没损坏。我最初&quot;主控被加壳&quot;的悬念就此关掉——代码就在那儿，全都能读。&lt;/p&gt;
&lt;p&gt;同样，我对 &lt;code class=&quot;inline-code&quot;&gt;stub.exe&lt;/code&gt; 也误判过一次&quot;加壳&quot;：&lt;strong&gt;解析节表时把 &lt;code class=&quot;inline-code&quot;&gt;VirtualSize&lt;/code&gt; 当成了 &lt;code class=&quot;inline-code&quot;&gt;VirtualAddress&lt;/code&gt;&lt;/strong&gt;（字段顺序读反），导致 RVA→偏移错位、导入表解析落到全零区。改过来后：导入目录 &lt;code class=&quot;inline-code&quot;&gt;rva=0x206ac size=80&lt;/code&gt; 正常，&lt;code class=&quot;inline-code&quot;&gt;.text&lt;/code&gt; 熵 6.471，头部 &lt;code class=&quot;inline-code&quot;&gt;48 8b c4 48 89 58 08&lt;/code&gt; 是标准 MSVC x64 序言——&lt;strong&gt;明文，没壳&lt;/strong&gt;。这提醒我：&lt;strong&gt;工具给你一个输出，不代表那个输出是对的。&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;找字符串消费点我在这里踩了一个坑&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#找字符串消费点我在这里踩了一个坑&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;找字符串消费点，我在这里踩了一个坑&lt;/h2&gt;
&lt;p&gt;接下来要定位 &lt;code class=&quot;inline-code&quot;&gt;\deputies.bin&lt;/code&gt; 这个串在代码里被谁用。我先用最直观的办法：从函数起点线性反汇编整个 &lt;code class=&quot;inline-code&quot;&gt;.text&lt;/code&gt;，扫所有 RIP 相对引用。扫出来是——&lt;strong&gt;零引用&lt;/strong&gt;。&lt;/p&gt;
&lt;p&gt;一个明明存在于 &lt;code class=&quot;inline-code&quot;&gt;.rdata&lt;/code&gt; 里的字符串，居然没有任何代码引用？我回头查反汇编输出，发现从 &lt;code class=&quot;inline-code&quot;&gt;0x2630C&lt;/code&gt; 往后指令流整体&quot;错位&quot;了。&lt;code class=&quot;inline-code&quot;&gt;0x2630C&lt;/code&gt; 是一张&lt;strong&gt;跳转表&lt;/strong&gt;（switch 分派表），里面是纯数据；线性反汇编器把表里的数据当指令解析，从那里开始一路错到段尾——&lt;strong&gt;后面所有引用自然全扫不到&lt;/strong&gt;。&lt;/p&gt;
&lt;p&gt;改法是不再相信反汇编器，改&lt;strong&gt;字节级暴力扫描&lt;/strong&gt;：逐字节匹配 &lt;code class=&quot;inline-code&quot;&gt;48/4C 8D|8B&lt;/code&gt; + ModRM(&lt;code class=&quot;inline-code&quot;&gt;mod=00 rm=101&lt;/code&gt;) + disp32，&lt;code class=&quot;inline-code&quot;&gt;target = rva + 7 + disp&lt;/code&gt;；&lt;code class=&quot;inline-code&quot;&gt;call [rip+disp32]&lt;/code&gt; 匹配 &lt;code class=&quot;inline-code&quot;&gt;FF 15&lt;/code&gt;。同一字符串立刻扫出 30 多处引用。这条教训进了我的固定流程：&lt;strong&gt;先在字节层确认引用，再看反汇编&lt;/strong&gt;——反汇编是解释，字节才是事实。&lt;/p&gt;
&lt;h2 id=&quot;用已知明文抠出密钥&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#用已知明文抠出密钥&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;用已知明文抠出密钥&lt;/h2&gt;
&lt;p&gt;最关键的转折点，是发现它其实是个&quot;壳 + 加密载荷&quot;的封装结构。&lt;/p&gt;
&lt;p&gt;第二个 &lt;code class=&quot;inline-code&quot;&gt;.rdata&lt;/code&gt;（1.75MB，权限 RWX，&lt;code class=&quot;inline-code&quot;&gt;chars=0xE0000040&lt;/code&gt; 展开就是 &lt;code class=&quot;inline-code&quot;&gt;MEM_READ|MEM_WRITE|MEM_EXECUTE&lt;/code&gt;）最可疑——&lt;strong&gt;可写又可执行&lt;/strong&gt;，典型的&quot;运行时解密落地区&quot;。我按它的文件偏移整段读出来异或，在段内偏移 &lt;code class=&quot;inline-code&quot;&gt;0x4000D&lt;/code&gt; 处解出了一个合法 PE32+：ImageBase &lt;code class=&quot;inline-code&quot;&gt;0x180000000&lt;/code&gt;，入口 &lt;code class=&quot;inline-code&quot;&gt;0x526F0&lt;/code&gt;，821,760 字节。密钥是 8 个字节：&lt;code class=&quot;inline-code&quot;&gt;5A 3C 91 E7 2B 64 D8 0F&lt;/code&gt;。&lt;/p&gt;
&lt;p&gt;我不是&quot;猜到&quot;的。定位方式是找到解密循环本身——&lt;code class=&quot;inline-code&quot;&gt;sub_1400023D4&lt;/code&gt; 里 &lt;code class=&quot;inline-code&quot;&gt;mov al,[rax+r8+0x1c550]&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;xor [rdx+r8+0x29000],al&lt;/code&gt;，密钥表就摆在 &lt;code class=&quot;inline-code&quot;&gt;.rdata&lt;/code&gt; 的 &lt;code class=&quot;inline-code&quot;&gt;0x1C550&lt;/code&gt;，逐字节读出来即可。&lt;strong&gt;能读到循环，就不需要猜。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;同一把密钥顺手把 &lt;code class=&quot;inline-code&quot;&gt;.data 0x29000&lt;/code&gt; 起的一片数据解成了完整的编译期配置串——这张表后来比密钥本身有用得多。&lt;/p&gt;
&lt;h2 id=&quot;它到底能干什么从导出表和-rtti-反推作者思路&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#它到底能干什么从导出表和-rtti-反推作者思路&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;它到底能干什么：从导出表和 RTTI 反推作者思路&lt;/h2&gt;
&lt;p&gt;解出来的 &lt;code class=&quot;inline-code&quot;&gt;login.dll&lt;/code&gt; 只有 821KB，导出表只有 7 个函数，每个都很有信息量：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;ArmouryCapHelperW              armoury_beacon_start
ArmouryUCapHostW               armoury_beacon_stop
Main                           armoury_beacon_on_packet
armoury_beacon_on_conn_closed&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;这是&lt;strong&gt;恶意代码自己报出的名字&lt;/strong&gt;，和后面磁盘上的 &lt;code class=&quot;inline-code&quot;&gt;ArmouryLogin.log&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ArmouryStager.log&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;Roaming\Armoury&lt;/code&gt; 目录完全互证。&lt;code class=&quot;inline-code&quot;&gt;beacon&lt;/code&gt; 说明它是&lt;strong&gt;信标型 C2&lt;/strong&gt;（被动上线、心跳、回调驱动），而 &lt;code class=&quot;inline-code&quot;&gt;on_conn_closed&lt;/code&gt; 尤其关键——它意味着&quot;连接断开&quot;是&lt;strong&gt;预期内的常态事件&lt;/strong&gt;，后来直接解释了日志里的&quot;故障转移阶梯&quot;：那不是异常，是设计。&lt;/p&gt;
&lt;p&gt;RTTI 里有 &lt;code class=&quot;inline-code&quot;&gt;armoury::transport::ITransport&lt;/code&gt;（抽象基类）和 &lt;code class=&quot;inline-code&quot;&gt;TcpTransport&lt;/code&gt;（实现），配合 &lt;code class=&quot;inline-code&quot;&gt;std::function&lt;/code&gt; + &lt;code class=&quot;inline-code&quot;&gt;shared_ptr&lt;/code&gt;——这是&lt;strong&gt;面向接口的现代 C++17 框架&lt;/strong&gt;，不是 Gh0st 那种老式 C++。这个判断决定了后面归因不能乱套家族。&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;Main&lt;/code&gt; 那几个参数（host / port / proto / mark）的顺序我也没靠猜，而是&lt;strong&gt;从日志格式串反推&lt;/strong&gt;：&lt;code class=&quot;inline-code&quot;&gt;Main enter proto=%d port=%u host=%s mark=%s&lt;/code&gt;——格式串里的占位符顺序就是实参排布顺序。用&quot;日志长什么样&quot;反推&quot;函数签名是什么&quot;，是这时最省力的一招。&lt;/p&gt;
&lt;h2 id=&quot;命令表100-个槽位怎么逐个定性&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#命令表100-个槽位怎么逐个定性&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;命令表：100 个槽位怎么逐个定性&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;armoury_beacon_on_packet&lt;/code&gt; 是命令总入口：取 &lt;code class=&quot;inline-code&quot;&gt;packet[0]&lt;/code&gt;，判两个前置值，其余走跳转表——&lt;code class=&quot;inline-code&quot;&gt;TBL @ 0x2630C&lt;/code&gt;（100×u32）+ &lt;code class=&quot;inline-code&quot;&gt;IDX @ 0x26348&lt;/code&gt;（100×u8），索引 &lt;code class=&quot;inline-code&quot;&gt;= cmd - 0x88&lt;/code&gt;。&lt;/p&gt;
&lt;p&gt;解表不难，难的是&lt;strong&gt;给每个命令定性&lt;/strong&gt;。我用的方法不是读一遍逻辑，而是&quot;&lt;strong&gt;把调用链上的 API 按顺序排出来&lt;/strong&gt;&quot;——API 的调用顺序几乎自带语义。最典型的一次纠错是 &lt;code class=&quot;inline-code&quot;&gt;0xC8&lt;/code&gt;：一开始我看到包里有两个数值（默认 120 / 68），加上&quot;参数设置&quot;的联想，判成了&quot;运行参数设置&quot;。后来把它整条链的 API 排出来：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;GetDC → GetSystemMetrics×2 → CreateCompatibleDC → CreateCompatibleBitmap →
SelectObject → SetStretchBltMode → StretchBlt → GetDIBits → 清理&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;这是教科书级的截屏序列。而且 120×68 和上限 640×360 &lt;strong&gt;都是 16:9&lt;/strong&gt;——两个数字都是图像尺寸，不是时间间隔。于是 &lt;code class=&quot;inline-code&quot;&gt;0xC8&lt;/code&gt; 从&quot;参数设置&quot;改成&quot;&lt;strong&gt;按需截图，服务端可指定分辨率&lt;/strong&gt;&quot;。&lt;/p&gt;
&lt;p&gt;另一个硬结论是报文格式：&lt;code class=&quot;inline-code&quot;&gt;[0]=命令字节&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;[1..16]=16 字节 payload&lt;/code&gt;、后面跟几个定长字段，最小长度 0x1B。&lt;strong&gt;协议头第 1 字节就是命令号&lt;/strong&gt;——这条是从机器码里 &lt;code class=&quot;inline-code&quot;&gt;cmp byte[rcx],0x88&lt;/code&gt; 这种硬编码比较直接读出来的，没有推断成分。&lt;/p&gt;
&lt;h2 id=&quot;它在我机器上留下了什么靠静态串-落盘名对上号&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#它在我机器上留下了什么靠静态串-落盘名对上号&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;它在我机器上留下了什么：靠&quot;静态串 ↔ 落盘名&quot;对上号&lt;/h2&gt;
&lt;p&gt;接下来想知道它靠什么活着、重启后怎么回来。这段的推法不一样——不是从代码推行为，而是&lt;strong&gt;拿静态里解出的配置串，去运行态产物里找对应物&lt;/strong&gt;。那张编译期配置表里有一批长得像 ID 的串（&lt;code class=&quot;inline-code&quot;&gt;ARMAUTO1&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ARMVMS1&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ARMUAC0&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ARMGRD1&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ARMGID833B463E&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ARMGN10&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ARMPRS01&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ARMPIDA30BAE5E&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ARMSIDA30BAE5E&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ARMOBF1&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ARMSELP1&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ARMSCMAP&lt;/code&gt;）。&lt;/p&gt;
&lt;p&gt;当时它们只是一堆常量名。等我把运行态的注册表和计划任务拉出来，对上了：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;静态配置串&lt;/th&gt;&lt;th&gt;运行态对应物&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;ARMGID833B463E&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Run 键 &lt;strong&gt;&lt;code class=&quot;inline-code&quot;&gt;G-833B463E&lt;/code&gt;&lt;/strong&gt; → &lt;code class=&quot;inline-code&quot;&gt;…\Microsoft\833B463E\LeafChatHost.exe --arm-boot&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;ARMPIDA30BAE5E&lt;/code&gt;&lt;/td&gt;&lt;td&gt;计划任务 &lt;strong&gt;&lt;code class=&quot;inline-code&quot;&gt;\P-A30BAE5E&lt;/code&gt;&lt;/strong&gt; → &lt;code class=&quot;inline-code&quot;&gt;stub.exe --arm-payload &amp;quot;…payload.bin&amp;quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;ARMS1-%s-%lu&lt;/code&gt;&lt;/td&gt;&lt;td&gt;互斥标记文件 &lt;code class=&quot;inline-code&quot;&gt;ARMS1-y0YUmsuGTDqIgQTb-1&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;其中的 &lt;code class=&quot;inline-code&quot;&gt;A30BAE5E&lt;/code&gt;&lt;/td&gt;&lt;td&gt;释放目录 &lt;code class=&quot;inline-code&quot;&gt;%LOCALAPPDATA%\Microsoft\A30BAE5E\&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;这是整段分析里最舒服的一次——静态和动态第一次严丝合缝扣上。&lt;/strong&gt; 一个本来只是&quot;常量&quot;的字符串，突然告诉你它就是那几个持久化机制的名字，等于凭空拿到了一份作者的设计图。计划任务的 XML 也让规律更清楚：&lt;code class=&quot;inline-code&quot;&gt;CalendarTrigger&lt;/code&gt; + &lt;code class=&quot;inline-code&quot;&gt;Repetition PT1H&lt;/code&gt;（&lt;strong&gt;每小时重注入一次&lt;/strong&gt;）、&lt;code class=&quot;inline-code&quot;&gt;Hidden=true&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;StartBoundary&lt;/code&gt; 是落盘后 120 秒内的时间戳——&lt;strong&gt;它落地不到两分钟就把持久化做完了&lt;/strong&gt;。&lt;/p&gt;
&lt;p&gt;还有个细节值得单说：守护器文件名是 &lt;code class=&quot;inline-code&quot;&gt;LeafChatHost.exe&lt;/code&gt;，我差点把它当 IOC 写进报告。后来在投递器里翻到一张&lt;strong&gt;12 个名字的池子&lt;/strong&gt;：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;QuickNoteHelper  PhotoGlanceHost  SkySyncHost   PlayLiteHelper
DeskCalcHost     FileNestHelper   GuardPulseHost TunePadHelper
SnapCamHost      PageMarkHelper   LeafChatHost   PrefPanelHost&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;运行时随机挑一个当文件名，我拿这 12 个名字去公开情报里批量检索，&lt;strong&gt;零命中&lt;/strong&gt;。所以正确写法是：&lt;strong&gt;文件名不是 IOC&lt;/strong&gt;（&lt;code class=&quot;inline-code&quot;&gt;LeafChatHost.exe&lt;/code&gt; 只是这次抽到的），能当锚点的是&lt;strong&gt;路径形态&lt;/strong&gt;（&lt;code class=&quot;inline-code&quot;&gt;%LOCALAPPDATA%\Microsoft\&amp;lt;8位十六进制&amp;gt;\*.exe&lt;/code&gt;）和&lt;strong&gt;命令行参数&lt;/strong&gt;（&lt;code class=&quot;inline-code&quot;&gt;--arm-grd&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;--arm-src&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;--arm-boot&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;--arm-payload&lt;/code&gt;）。图省事把文件名当特征，检测规则下个月就失效。&lt;/p&gt;
&lt;p&gt;顺带一提，守它们的目录里有个 &lt;code class=&quot;inline-code&quot;&gt;target.path&lt;/code&gt;，90 字节。我一开始不知道它是什么，直到发现 &lt;strong&gt;90 = 44 个字符 × 2（UTF-16）+ 2 字节 BOM&lt;/strong&gt;——按 UTF-16LE 读出来，正好是那个桌面样本的完整路径。&lt;strong&gt;算术先对上了，语义才敢下结论。&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;它是怎么把自己塞进内存的&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#它是怎么把自己塞进内存的&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;它是怎么把自己塞进内存的&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;stub.exe&lt;/code&gt; 我只说了它是&quot;进程镂空投递器&quot;，做法值得展开，因为它解释了&quot;为什么杀进程没用&quot;。定性还是排 API 序列：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;NtAllocateVirtualMemory   NtWriteVirtualMemory   NtGetContextThread
NtSetContextThread        NtResumeThread         NtClose&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;再配上 &lt;code class=&quot;inline-code&quot;&gt;CreateProcessW&lt;/code&gt; 和一个字符串 &lt;code class=&quot;inline-code&quot;&gt;e%s\notepad.exe&lt;/code&gt;——顺序连起来就是完整的 &lt;strong&gt;RunPE（傀儡进程）&lt;/strong&gt;链：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;CreateProcessW(notepad.exe, CREATE_SUSPENDED)  ← 宿主挂起
  → NtAllocateVirtualMemory( RWX, size = payload + 0x20000 )
  → NtWriteVirtualMemory → NtSetContextThread( 改入口点 )
  → NtResumeThread    ← 跑起来的是 notepad，内容是载荷&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;为什么不直接 &lt;code class=&quot;inline-code&quot;&gt;CreateThread&lt;/code&gt;？&lt;/strong&gt; 因为镂空之后，进程在任务管理器里显示的是 &lt;code class=&quot;inline-code&quot;&gt;notepad.exe&lt;/code&gt;，模块列表里没有可疑 DLL，磁盘上也没有可执行文件——查杀软件按&quot;可疑进程名 / 可疑模块&quot;去匹配，什么都找不到。&lt;/p&gt;
&lt;p&gt;配套看那个被写进去的 &lt;code class=&quot;inline-code&quot;&gt;payload.bin&lt;/code&gt;（39,541 字节）：它&lt;strong&gt;不是 PE&lt;/strong&gt;，没有 &lt;code class=&quot;inline-code&quot;&gt;MZ&lt;/code&gt; 头，是一段纯 x64 位置无关 shellcode——入口三条指令 &lt;code class=&quot;inline-code&quot;&gt;sub rsp,0x38&lt;/code&gt; → 在栈上拼出 &lt;code class=&quot;inline-code&quot;&gt;&amp;quot;boot&amp;quot;&lt;/code&gt; → &lt;code class=&quot;inline-code&quot;&gt;lea rcx,[rsp+0x20]&lt;/code&gt; → &lt;code class=&quot;inline-code&quot;&gt;call&lt;/code&gt;，也就是说它自己会去找并加载 &lt;code class=&quot;inline-code&quot;&gt;a64.dll&lt;/code&gt;。&lt;strong&gt;&quot;投递器不落地可执行文件、载荷也不是 PE&quot;——这条链上每一步都在躲静态特征。&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;a64dll-里还藏着一整套无文件工具链&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#a64dll-里还藏着一整套无文件工具链&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;a64.dll 里还藏着一整套&quot;无文件&quot;工具链&lt;/h2&gt;
&lt;p&gt;真正联网的只有 &lt;code class=&quot;inline-code&quot;&gt;a64.dll&lt;/code&gt;。这一点是从导入表反过来确认的：&lt;code class=&quot;inline-code&quot;&gt;stub.exe&lt;/code&gt;（3 个 DLL / 95 函数）与守护器（2 个 DLL / 97 函数）&lt;strong&gt;都不导入 &lt;code class=&quot;inline-code&quot;&gt;WS2_32&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;WININET&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;WINHTTP&lt;/code&gt; 中的任何一个&lt;/strong&gt;；只有 &lt;code class=&quot;inline-code&quot;&gt;a64.dll&lt;/code&gt; 是 16 个 DLL / 301 个函数，网络、截屏、令牌、设备枚举一应俱全。&lt;strong&gt;&quot;守护器和投递器不联网&quot;是设计，不是被断网了。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;然后我在 &lt;code class=&quot;inline-code&quot;&gt;a64.dll&lt;/code&gt; 字符串里翻到一段很扎眼的东西——&lt;code class=&quot;inline-code&quot;&gt;powershell.exe … -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand&lt;/code&gt;，紧接着一段 Base64，解码后是&lt;strong&gt;内联 C# 代码&lt;/strong&gt;。四段脚本：① 单次截屏；② &lt;strong&gt;连续截屏&lt;/strong&gt;，超 1600×900 等比缩小、先写 &lt;code class=&quot;inline-code&quot;&gt;.tmp&lt;/code&gt; 再原子 &lt;code class=&quot;inline-code&quot;&gt;Copy&lt;/code&gt;，&lt;strong&gt;200 ms/帧（5 fps）&lt;/strong&gt;；③ 内联类 &lt;code class=&quot;inline-code&quot;&gt;ArmFg&lt;/code&gt; 取前台窗口标题 + 空闲秒数，&lt;strong&gt;每 500 ms&lt;/strong&gt; 写 &lt;code class=&quot;inline-code&quot;&gt;arm_fg_%u.txt&lt;/code&gt;；④ 内联类 &lt;code class=&quot;inline-code&quot;&gt;ArmWinQ&lt;/code&gt; 导出全部窗口信息到 &lt;code class=&quot;inline-code&quot;&gt;arm_winq_%u_%u.txt&lt;/code&gt;。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;为什么用 PowerShell 而不是写 C++？&lt;/strong&gt; 因为脚本是 &lt;code class=&quot;inline-code&quot;&gt;-EncodedCommand&lt;/code&gt; 传进去的，&lt;strong&gt;命令行里只有一串 Base64&lt;/strong&gt;，磁盘上不留 &lt;code class=&quot;inline-code&quot;&gt;.ps1&lt;/code&gt;，进程树里也看不到脚本内容。5 fps 连续截屏 + 每 500 ms 一次前台窗口/空闲采样，合起来就是&quot;&lt;strong&gt;他在看什么、有没有在操作&lt;/strong&gt;&quot;——社工诈骗最需要的情报。&lt;/p&gt;
&lt;p&gt;还有一条业务线索，藏在同目录的 &lt;code class=&quot;inline-code&quot;&gt;FILTER&lt;/code&gt; 文件里（2,940 字节，UTF-16），是一张两列对照表：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;signal → SL      telegram → TG      safeW → SW      WhatsApp → WA&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;一份即时通讯软件的监控/劫持名单。&lt;/strong&gt; 结合前面的浏览器扩展注入串 &lt;code class=&quot;inline-code&quot;&gt;ArmouryIntercept&lt;/code&gt; 和 &lt;code class=&quot;inline-code&quot;&gt;Chrome / Edge / Brave&lt;/code&gt; 的扩展目录路径，变现路径就清楚了：&lt;strong&gt;盯着 IM，找机会冒充本人去骗联系人&lt;/strong&gt;——技术分析到这里，第一次看到&quot;它图什么&quot;。&lt;/p&gt;
&lt;h2 id=&quot;c2-到底在哪先排除再下结论&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#c2-到底在哪先排除再下结论&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;C2 到底在哪：先排除，再下结论&lt;/h2&gt;
&lt;p&gt;到这时我已有完整的代码骨架，却始终没找到最该有的东西——&lt;strong&gt;C2 地址&lt;/strong&gt;。先假设它写得比较直接，做了七轮搜索，每轮换一种&quot;藏法&quot;：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;通道&lt;/th&gt;&lt;th&gt;我假设它藏成什么样&lt;/th&gt;&lt;th&gt;结果&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;明文直搜 &lt;code class=&quot;inline-code&quot;&gt;macio&lt;/code&gt;、IP 的 8 种编码（原样/反转/UTF-16/十六进制/点分十进制）&lt;/td&gt;&lt;td&gt;明文或编过码&lt;/td&gt;&lt;td&gt;&lt;strong&gt;0 命中&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;重复密钥 XOR 的 crib-drag（6 crib × 周期 1–32 × 全文件每偏移）&lt;/td&gt;&lt;td&gt;被 XOR 加密&lt;/td&gt;&lt;td&gt;唯一&quot;命中&quot;解出 &lt;code class=&quot;inline-code&quot;&gt;mmmm…&lt;/code&gt; 噪声 → &lt;strong&gt;假阳性&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;单字节加法/减法混淆、单字节 XOR（各全 255 密钥）&lt;/td&gt;&lt;td&gt;简单混淆&lt;/td&gt;&lt;td&gt;&lt;strong&gt;0 命中&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;a64.dll&lt;/code&gt; 高熵区 / 版本资源 / 构建配置表&lt;/td&gt;&lt;td&gt;小段密文 / 写在资源里&lt;/td&gt;&lt;td&gt;全是&lt;strong&gt;查表数据&lt;/strong&gt;，无相关字段&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;七轮全空之后，反而不该继续硬搜，而是回头看代码里那些&quot;看起来在配置网络&quot;的地方。&lt;code class=&quot;inline-code&quot;&gt;a64.dll&lt;/code&gt; 里有一段协议配置块——&lt;code class=&quot;inline-code&quot;&gt;&amp;quot;ARPLWire&amp;quot;&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;&amp;quot;/arpl/ws&amp;quot;&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;&amp;quot;AFR2&amp;quot;&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;&amp;quot;ArmouryFrameV2-AUTH&amp;quot;&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;&amp;quot;ArmouryFrameV2-ENC&amp;quot;&lt;/code&gt;，以及一句日志格式串：&lt;code class=&quot;inline-code&quot;&gt;Main enter proto=%d port=%u host=%s mark=%s&lt;/code&gt;。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;inline-code&quot;&gt;host&lt;/code&gt; 是 &lt;code class=&quot;inline-code&quot;&gt;Main&lt;/code&gt; 的入参。&lt;/strong&gt; 也就是说，这个样本从设计上就不带 C2——它等着&lt;strong&gt;外面的人把地址递进来&lt;/strong&gt;（通过 &lt;code class=&quot;inline-code&quot;&gt;deputies.bin&lt;/code&gt; 配置、或 &lt;code class=&quot;inline-code&quot;&gt;armoury_beacon_start&lt;/code&gt; 的入参结构体）。这也解释了为什么&quot;下载/更新&quot;通道一直在报 &lt;code class=&quot;inline-code&quot;&gt;pullfail&lt;/code&gt;：&lt;strong&gt;它在拿到配置之前，本来就无事可做。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;所以&quot;没见过的东西&quot;和&quot;不存在的东西&quot;要分开。&lt;code class=&quot;inline-code&quot;&gt;45.64.52.179&lt;/code&gt; 是存在的，只是不在文件里——&lt;strong&gt;它是从外部投递进来的&lt;/strong&gt;。这条&quot;排除得出外置&quot;的结论，正好把注意力推向文件里唯一一块还没打开的地方：&lt;strong&gt;末尾那 50,932 字节&lt;/strong&gt;。&lt;/p&gt;
&lt;h2 id=&quot;为什么没反应我推翻了四次&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#为什么没反应我推翻了四次&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&quot;为什么没反应&quot;——我推翻了四次&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;第一次。&lt;/strong&gt; 我在静态里全量核对了经典反 VM 手法：&lt;code class=&quot;inline-code&quot;&gt;GetSystemFirmwareTable&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;GlobalMemoryStatus&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;IsDebuggerPresent&lt;/code&gt;、CPUID hypervisor leaf、各种 MAC OUI……&lt;strong&gt;全部 0 命中&lt;/strong&gt;。那些 &lt;code class=&quot;inline-code&quot;&gt;VMware / VirtualBox / WireGuard&lt;/code&gt; 字符串我也追到了消费点，发现它们是&lt;strong&gt;网卡打分器的扣分项&lt;/strong&gt;（给虚拟网卡扣 90 分，满分 120），只影响排序，&lt;strong&gt;没有任何退出/自杀逻辑&lt;/strong&gt;。于是第一版结论是：没有反 VM，只有 5 个&quot;静默闸门&quot;，最可能是环境变量 &lt;code class=&quot;inline-code&quot;&gt;ARMOURY_ENABLE_TRANSPORT_LAYER&lt;/code&gt; 没设。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;第二次（被实测打脸）。&lt;/strong&gt; 实测结果是 &lt;code class=&quot;inline-code&quot;&gt;C:\Windows\Temp\ArmouryLogin.log&lt;/code&gt; &lt;strong&gt;根本不生成&lt;/strong&gt;——第一版说的&quot;传输层/C2 问题&quot;完全错了。重查发现两件事：一是程序真的起来了，跑到 &lt;code class=&quot;inline-code&quot;&gt;sub_2010&lt;/code&gt; 尾部是一个 &lt;strong&gt;&lt;code class=&quot;inline-code&quot;&gt;Sleep(0x36EE80)&lt;/code&gt; = 1 小时&lt;/strong&gt;的死循环；二是 &lt;code class=&quot;inline-code&quot;&gt;login.dll::Main&lt;/code&gt; 要求 &lt;strong&gt;5 个非空参数&lt;/strong&gt;（前置 &lt;code class=&quot;inline-code&quot;&gt;test rdx,rdx&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;test r8,r8&lt;/code&gt; / … 任一为空就 &lt;code class=&quot;inline-code&quot;&gt;je&lt;/code&gt; 直接返回），双击时宿主传参不满足，所以&quot;写日志&quot;那行&lt;strong&gt;从来没被执行过&lt;/strong&gt;。这版结论：它不是&quot;能双击跑的完整木马&quot;，而是需要特定 loader / 参数才&quot;活&quot;的组件。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;第三次（我把样本真的跑起来，推翻了第二版）。&lt;/strong&gt; 我在 VMware 里跑，&lt;strong&gt;亚秒级静默退出&lt;/strong&gt;，任务管理器都看不见。重查启动链，在 &lt;code class=&quot;inline-code&quot;&gt;sub_2010&lt;/code&gt; 前 0x60 字节里找到了真正的卡点：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;asm&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;asm&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-asm&quot;&gt;0x2047  cmp  byte[0x29016], &amp;#039;1&amp;#039;    ; 配置开关 ARMVMS
0x2050  call sub_54A8              ; ★ 反 VM/沙箱 多因子打分
0x2057  jne  0x2062                ; al==1 → 落进退出块
0x2062  xor  eax,eax
0x2064  jmp  0x2359                ; ← 直接返回&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;sub_54A8&lt;/code&gt; 是打分子函数。在 VMware 里，注册表键 &lt;code class=&quot;inline-code&quot;&gt;SOFTWARE\VMware, Inc.\VMware Tools&lt;/code&gt; 和进程 &lt;code class=&quot;inline-code&quot;&gt;vmtoolsd.exe&lt;/code&gt; &lt;strong&gt;必然命中&lt;/strong&gt;，得分达阈值就直接返回 1 → 静默 &lt;code class=&quot;inline-code&quot;&gt;ret&lt;/code&gt; 退出。&lt;strong&gt;&quot;任务管理器看不到进程、日志不生成、无网络、无持久化&quot;——现象全部吻合。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;第四次（反汇编精化）。&lt;/strong&gt; 我把 &lt;code class=&quot;inline-code&quot;&gt;sub_54A8&lt;/code&gt; 逐条拆开，发现之前的&quot;4 个因子&quot;理解错了：那几个传进去的 10 / 9 / 10 / 7 &lt;strong&gt;是数组长度，不是权重&lt;/strong&gt;——真实规模是 &lt;strong&gt;8 路检测、其中 4 路是数组、共 36 个检查项&lt;/strong&gt;。同时发现&quot;第二道门&quot;&lt;code class=&quot;inline-code&quot;&gt;sub_4ADC&lt;/code&gt; 开头 &lt;code class=&quot;inline-code&quot;&gt;cmp byte[0x2901E],&amp;#039;1&amp;#039;&lt;/code&gt;（配置 &lt;code class=&quot;inline-code&quot;&gt;ARMUAC0&lt;/code&gt;，实测 &lt;code class=&quot;inline-code&quot;&gt;&amp;#039;0&amp;#039;&lt;/code&gt;），条件不成立就直接走到&quot;放行&quot;出口，&lt;strong&gt;它天然放行&lt;/strong&gt;。结论：&lt;strong&gt;唯一的阻断点就是那个打分器。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;定案（单字节差分）。&lt;/strong&gt; 最后我用桌面上另一个版本的样本做差分——两个文件&lt;strong&gt;只差 1 个字节&lt;/strong&gt;：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;文件偏移 0x27616    原始样本 0xE9  →  变体 0xE8
用同一把密钥解出：   ARMVMS1        →  ARMVMS0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;一个字节，虚拟机检测开关就关掉了——这也证明那张编译期配置表不是&quot;清单&quot;，而是&lt;strong&gt;运行时读取的功能开关板&lt;/strong&gt;。&lt;/p&gt;
&lt;p&gt;这四次推翻里我做对的只有一件事：&lt;strong&gt;每轮结论都写清楚&quot;怎么证伪&quot;&lt;/strong&gt;——所以每被推翻一次，下一次的起点都更靠后、更精确。&lt;/p&gt;
&lt;p&gt;顺手一提，打补丁还有个坑。两道 &lt;code class=&quot;inline-code&quot;&gt;jne&lt;/code&gt; 的&lt;strong&gt;极性是相反的&lt;/strong&gt;：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;asm&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;span class=&quot;code-lang&quot;&gt;asm&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class=&quot;language-asm&quot;&gt;0x2057  jne 0x2062   ; al==1 → 跳到退出块      → 这一道可以 NOP
0x2060  jne 0x2069   ; al==1 → 跳到继续分支    → 这一道 NOP 就完蛋&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;第二道是&quot;通过才跳转&quot;，如果我按第一道的思路把它也 NOP 掉，控制流会顺序落进退出块，&lt;strong&gt;反而保证退出&lt;/strong&gt;；正确做法是改成无条件跳转（&lt;code class=&quot;inline-code&quot;&gt;75 07&lt;/code&gt; → &lt;code class=&quot;inline-code&quot;&gt;EB 07&lt;/code&gt;，只动一个字节）。这种&quot;看起来对称、实际方向相反&quot;的地方，是补丁最容易翻车的位置。&lt;/p&gt;
&lt;h2 id=&quot;去-vm-里抓-c2先学会不把噪声当证据&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#去-vm-里抓-c2先学会不把噪声当证据&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;去 VM 里抓 C2：先学会不把噪声当证据&lt;/h2&gt;
&lt;p&gt;绕过了反 VM、样本在 VM 里上线之后，接下来是拿到它到底连谁。&lt;code class=&quot;inline-code&quot;&gt;netstat -an&lt;/code&gt; 出来一串 ESTABLISHED。&lt;strong&gt;如果直接按 IP 排序，&lt;code class=&quot;inline-code&quot;&gt;175.12.122.167&lt;/code&gt; 会排在头号嫌疑&lt;/strong&gt;——175.0.0.0/8 是中国段，看着最可疑。但我坚持做了一步&quot;逐 PID 映射进程名&quot;：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;PID&lt;/th&gt;&lt;th&gt;进程&lt;/th&gt;&lt;th&gt;对端&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;8140&lt;/td&gt;&lt;td&gt;&lt;strong&gt;chat-deepseek.switch.exe&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;45.64.52.179:443&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;9380&lt;/td&gt;&lt;td&gt;&lt;strong&gt;chat-deepseek.switch.exe&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;45.64.52.179:443&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;7428&lt;/td&gt;&lt;td&gt;SearchApp.exe&lt;/td&gt;&lt;td&gt;175.12.122.167:443&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;6892&lt;/td&gt;&lt;td&gt;WinStore.App.exe&lt;/td&gt;&lt;td&gt;23.199.2.97:443&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;那个&quot;头号嫌疑&quot;其实是 &lt;strong&gt;Windows 搜索索引器&lt;/strong&gt;。而 &lt;code class=&quot;inline-code&quot;&gt;45.64.52.179&lt;/code&gt; 独占两条连接，&lt;strong&gt;两条都来自样本自身&lt;/strong&gt;。铁律一条：&lt;strong&gt;不映射到进程名的 IP 排序，全是噪声。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;有了 IP 还要拿域名。查 DNS 缓存时又踩了一个坑：&lt;code class=&quot;inline-code&quot;&gt;ipconfig /displaydns&lt;/code&gt; 里 &lt;code class=&quot;inline-code&quot;&gt;findstr &amp;quot;Record Name&amp;quot;&lt;/code&gt; 零命中，我一度以为&quot;DNS 缓存是空的&quot;。真相是——&lt;strong&gt;中文 Windows 的表头是「记录名称」，不是英文&lt;/strong&gt;。改成 &lt;code class=&quot;inline-code&quot;&gt;Get-DnsClientCache&lt;/code&gt; 按 IP 反查（语言无关），立刻拿到：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;Entry : jd.macio-china.com
Data  : 45.64.52.179&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;C2 = &lt;code class=&quot;inline-code&quot;&gt;jd.macio-china.com&lt;/code&gt; → &lt;code class=&quot;inline-code&quot;&gt;45.64.52.179:443&lt;/code&gt;。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;顺手验证了一件事：两个进程 PPID 相同、命令行相同 → 是&lt;strong&gt;兄弟进程&lt;/strong&gt;而非父子派生（排除了&quot;loader 注入子体&quot;的常规模型）；域名归属放到最后归因一节。&lt;/p&gt;
&lt;h2 id=&quot;日志把我静态里下的协议判断推翻了&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#日志把我静态里下的协议判断推翻了&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;日志把我静态里下的协议判断推翻了&lt;/h2&gt;
&lt;p&gt;拿到 C2 之后，我一度很有把握地判定协议是 &lt;strong&gt;WSS（WebSocket over TLS）&lt;/strong&gt;：内存里挖到了 RFC6455 的魔数 GUID &lt;code class=&quot;inline-code&quot;&gt;258EAFA5-E914-47DA-95CA-C5AB0DC85B11&lt;/code&gt;，还有 &lt;code class=&quot;inline-code&quot;&gt;Sec-WebSocket-Key&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;Upgrade: websocket&lt;/code&gt;，以及 &lt;code class=&quot;inline-code&quot;&gt;websocket.dll&lt;/code&gt; 和 SChannel 相关串。看起来板上钉钉。然后 VM 里取到了两份&lt;strong&gt;明文日志&lt;/strong&gt;（&lt;code class=&quot;inline-code&quot;&gt;ArmouryLogin.log&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;ArmouryStager.log&lt;/code&gt;）：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;dial host=jd.macio-china.com port=443 proto=0 tmo=12000
dial OK port=443 tcp via=direct&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;三个字把上面的判断推翻了：&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;strong&gt;&lt;code class=&quot;inline-code&quot;&gt;proto=0&lt;/code&gt;&lt;/strong&gt; —— 全程固定为 0。真走 WS/TLS 会是 1/2/3。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;code class=&quot;inline-code&quot;&gt;tcp via=direct&lt;/code&gt;&lt;/strong&gt; —— 拨号层明确报的是 &lt;strong&gt;tcp&lt;/strong&gt;，不是 tls、不是 ws。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&lt;code class=&quot;inline-code&quot;&gt;dial OK&lt;/code&gt; 到 &lt;code class=&quot;inline-code&quot;&gt;send_login&lt;/code&gt; 之间没有握手步骤&lt;/strong&gt;，全程 203ms，没有 TLS 往返开销。&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;再加一个反证：我早先用裸 IP 去做 TLS 握手，对端&lt;strong&gt;直接断开&lt;/strong&gt;——现在解释通了，&lt;strong&gt;因为那上面根本不是 TLS 服务&lt;/strong&gt;。&lt;/p&gt;
&lt;p&gt;最终定性：&lt;strong&gt;&lt;code class=&quot;inline-code&quot;&gt;443&lt;/code&gt; 端口上跑的是裸 TCP + 自研 ARPLWire 帧 + 自研加密&lt;/strong&gt;（&lt;code class=&quot;inline-code&quot;&gt;ArmouryFrameV2-AUTH&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;ArmouryFrameV2-ENC&lt;/code&gt; 两阶段帧，魔数 &lt;code class=&quot;inline-code&quot;&gt;AFR2&lt;/code&gt;）。WS / SChannel 的代码&lt;strong&gt;编译在内但默认关闭&lt;/strong&gt;——这正是 &lt;code class=&quot;inline-code&quot;&gt;transport_disabled&lt;/code&gt; 的含义。&lt;strong&gt;防御意义很大&lt;/strong&gt;：443 上没有 TLS，基于 JA3 / 证书的检测手段&lt;strong&gt;全部失效&lt;/strong&gt;；选 443 就是为了混进 HTTPS 流量，又不吃 TLS 检测。日志还顺手给了故障转移阶梯：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;443 (tmo=12000) 失败 → 80 (tmo=5000) 失败 → backoff=200 → 回 443&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;所以封禁时 443 和 80 要一起拦，只封 443 它会掉到 80。&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;破解打包器从一把小钥匙到全域密钥律&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#破解打包器从一把小钥匙到全域密钥律&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;破解打包器：从一把小钥匙到全域密钥律&lt;/h2&gt;
&lt;p&gt;线索来自磁盘：样本跑起来后在磁盘上落了三个文件——&lt;code class=&quot;inline-code&quot;&gt;a64.dll&lt;/code&gt;（821,760 B）、&lt;code class=&quot;inline-code&quot;&gt;a64u.dll&lt;/code&gt;（&lt;strong&gt;与 a64.dll 同 SHA256，说明更新槽没被写入&lt;/strong&gt;），以及同样大小但头部是 &lt;code class=&quot;inline-code&quot;&gt;7D 6A&lt;/code&gt;（不是 &lt;code class=&quot;inline-code&quot;&gt;4D 5A&lt;/code&gt;）的 &lt;code class=&quot;inline-code&quot;&gt;a64&lt;/code&gt;。同尺寸 + 明文可得 ⇒ &lt;strong&gt;直接算密钥流&lt;/strong&gt;：&lt;code class=&quot;inline-code&quot;&gt;keystream = a64 XOR a64.dll&lt;/code&gt;。手工核算前几行：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;a64.dll:  4D 5A 90 00 03 00 00 00 04 00 00 00  | FF FF 00 00 B8 00 …
a64    :  7D 6A F0 89 86 9D A3 A5 73 84 74 30  | 9F 76 85 9D 1B A5 …
XOR    :  30 30 60 89 85 9D A3 A5 77 84 74 30  | 60 89 85 9D A3 A5 …
                              └──── 周期 10 ────┘&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;从偏移 2 起出现周期 10 的重复。这是&lt;strong&gt;已知明文攻击&lt;/strong&gt;，不需要知道任何算法。&lt;/p&gt;
&lt;p&gt;回到投递器本体。第二个 &lt;code class=&quot;inline-code&quot;&gt;.rdata&lt;/code&gt;（那 1.75MB RWX 节）我按 256KB / 1MB / 256KB / 256KB 切成四个槽，逐个看占用长度：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;槽&lt;/th&gt;&lt;th&gt;节内偏移&lt;/th&gt;&lt;th&gt;实际占用&lt;/th&gt;&lt;th&gt;减去 13 后&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x040000&lt;/code&gt;&lt;/td&gt;&lt;td&gt;821,773&lt;/td&gt;&lt;td&gt;&lt;strong&gt;821,760&lt;/strong&gt; ← a64.dll&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x140000&lt;/code&gt;&lt;/td&gt;&lt;td&gt;168,461&lt;/td&gt;&lt;td&gt;&lt;strong&gt;168,448&lt;/strong&gt; ← 守护器&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;&lt;code class=&quot;inline-code&quot;&gt;0x180000&lt;/code&gt;&lt;/td&gt;&lt;td&gt;144,397&lt;/td&gt;&lt;td&gt;&lt;strong&gt;144,384&lt;/strong&gt; ← stub&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;三个槽&quot;多出来的部分&quot;都精确等于 13 字节。围绕这 13 字节，我纠正了自己两次：&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;第一，它不是二进制结构，是 NUL 结尾的 ASCII 角色标签。&lt;/strong&gt; 我一开始当成&quot;长度/校验字段&quot;穷举，一无所获；换成用同一把密钥直接解这 13 字节，得到可读英文：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;槽1 → loginpattern\0     （a64.dll，C2 主体）
槽2 → guardpattern\0     （守护器）
槽3 → stubpattern\0+     （进程镂空注入器）&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;inline-code&quot;&gt;.text&lt;/code&gt; 里还有独立的交叉引用可以证实：&lt;code class=&quot;inline-code&quot;&gt;0x626A–0x629A&lt;/code&gt; 逐字节比对槽 2 的首地址和 &lt;code class=&quot;inline-code&quot;&gt;&amp;#039;g&amp;#039;,&amp;#039;u&amp;#039;,&amp;#039;a&amp;#039;,&amp;#039;r&amp;#039;,&amp;#039;d&amp;#039;,&amp;#039;p&amp;#039;&lt;/code&gt;，&lt;code class=&quot;inline-code&quot;&gt;0x62DE–0x630E&lt;/code&gt; 比对槽 3 和 &lt;code class=&quot;inline-code&quot;&gt;&amp;#039;s&amp;#039;,&amp;#039;t&amp;#039;,&amp;#039;u&amp;#039;,&amp;#039;b&amp;#039;,&amp;#039;p&amp;#039;,&amp;#039;a&amp;#039;&lt;/code&gt;。加载函数在 &lt;code class=&quot;inline-code&quot;&gt;+13&lt;/code&gt; 处取址——和标签长度完全吻合。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;第二，&quot;每个模块一套密钥&quot;是错的，真相是一把钥匙统治整个文件。&lt;/strong&gt; 我原以为三个模块各自从相位 0 开始异或，推广验证后的规律是：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;plain[file_off] = cipher[file_off] ^ KEY8[ (file_off + 3) mod 8 ]
KEY8 = 64 D8 0F 5A 3C 91 E7 2B&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;之所以会看成&quot;每模块相位 0&quot;，是因为三个模块的 raw 起点 &lt;code class=&quot;inline-code&quot;&gt;0x6A000&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;0x16A000&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;0x1AA000&lt;/code&gt; &lt;strong&gt;刚好都 ≡ 0 (mod 8)&lt;/strong&gt;，偏移量恰好被吸收成了相位 3。最强旁证是：这条规律在&lt;strong&gt;完全不同的节&lt;/strong&gt;（&lt;code class=&quot;inline-code&quot;&gt;.data&lt;/code&gt; 配置表，偏移 &lt;code class=&quot;inline-code&quot;&gt;0x27600&lt;/code&gt;）上也成立——同一把密钥解出 8 条语义完整的配置串。这不可能是巧合。&lt;/p&gt;
&lt;p&gt;最后是&lt;strong&gt;第四份载荷&lt;/strong&gt;。那个 256KB 的槽 0 我一开始当成&quot;稀疏工作区&quot;跳过（每 4096 字节只有 ~617 个非零字节）。直到把&quot;非零字节总数&quot;算出来：&lt;strong&gt;39,464&lt;/strong&gt;——和 &lt;code class=&quot;inline-code&quot;&gt;payload.bin&lt;/code&gt; 明文的 &lt;strong&gt;39,541&lt;/strong&gt; 只差 77。追下去发现它就是用&lt;strong&gt;另一把独立密钥&lt;/strong&gt;（&lt;code class=&quot;inline-code&quot;&gt;2C 30 FE F5 74 5F EA 42 A4 23 EE 49 6A 82 96 73&lt;/code&gt;，16 字节）加密的 &lt;code class=&quot;inline-code&quot;&gt;payload.bin&lt;/code&gt;，布局是 &lt;strong&gt;64 段 × 618 字节、步长 4043、首段起点 3425&lt;/strong&gt;，有效载荷率只有 15.1%。&lt;/p&gt;
&lt;p&gt;这里我踩过一次陷阱：一开始用&quot;过滤掉所有零字节&quot;的办法还原，得到 39,464 字节——&lt;strong&gt;错了&lt;/strong&gt;。因为密文里有 &lt;strong&gt;77 个字节恰好等于 &lt;code class=&quot;inline-code&quot;&gt;0x00&lt;/code&gt;&lt;/strong&gt;，和间隙的填充零在视觉上无法区分，会被一起滤掉；必须按&lt;strong&gt;段几何&lt;/strong&gt;（固定起点 + 固定长度）重建。改过来后，重建结果与原始槽 0 &lt;strong&gt;逐字节相同&lt;/strong&gt;，SHA256 精确等于 VM 侧那份 &lt;code class=&quot;inline-code&quot;&gt;payload.bin&lt;/code&gt;。把 39KB shellcode 切成 64 段散布在 256KB 里，意图很明显：&lt;strong&gt;让文件里不存在任何 ≥618 字节的连续 shellcode 片段&lt;/strong&gt;，废掉字节序列特征码。&lt;/p&gt;
&lt;h2 id=&quot;overlay解不开的时候把边界划清楚也是结论&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#overlay解不开的时候把边界划清楚也是结论&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;overlay：解不开的时候，把边界划清楚也是结论&lt;/h2&gt;
&lt;p&gt;前面&quot;C2 外置&quot;那段把注意力推到了最后一块没打开的地方：文件末尾有 &lt;strong&gt;50,932 字节不属于任何节&lt;/strong&gt;（算法：文件总长减去最后一个节的结束偏移，算术自证）。它前 8 个字节是标准 PNG 签名 &lt;code class=&quot;inline-code&quot;&gt;89 50 4E 47 0D 0A 1A 0A&lt;/code&gt;——看起来像图片。但它&lt;strong&gt;第 9 个字节起就破坏了 PNG 结构&lt;/strong&gt;：规范要求紧接着是 &lt;code class=&quot;inline-code&quot;&gt;00 00 00 0D&lt;/code&gt; + &lt;code class=&quot;inline-code&quot;&gt;IHDR&lt;/code&gt;，实测完全不符；解析 chunk 长度得到 &lt;code class=&quot;inline-code&quot;&gt;len=321167813&lt;/code&gt;（非法），没有 IHDR 也没有 IEND。所以那 8 字节只是&lt;strong&gt;明写的诱饵魔数&lt;/strong&gt;。&lt;/p&gt;
&lt;p&gt;接下来大量排除，一共试了 &lt;strong&gt;11 条路径&lt;/strong&gt;：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;攻击&lt;/th&gt;&lt;th&gt;结果&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;单字节 XOR / 周期 1–16 重复密钥 XOR（用已知 IHDR 反推）&lt;/td&gt;&lt;td&gt;密钥互不一致；或解出的 comp/filter/interlace 非 0 → 排除&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;IoC 逐周期扫（p 到 1024）+ ECB 重复 16 字节块&lt;/td&gt;&lt;td&gt;全落在随机基线；3,183 块重复 &lt;strong&gt;0&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;zlib/gzip/bz2/lzma（off 0–23）、RC4 × 46 密钥、复刻多态引擎、模块密钥 8 相位、K16 全 16 相位&lt;/td&gt;&lt;td&gt;全失败；K16 解完熵仍 7.99645&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;统计量给出了终局答案：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;body = 50,924 B（去掉 8 字节魔数）
entropy = 7.99636   真随机期望 = 7.99639      ← 差 3×10⁻⁵
chi²    = 256.0  (df=255, 临界值 293 @p=0.05)  ← 教科书级均匀&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;它统计上不可区分于真随机。&lt;/strong&gt; 到这里我没有假装把它解开，而是给了一个有边界的结论：它要么是强加密（密钥运行时派生），要么就是&lt;strong&gt;纯随机填充&lt;/strong&gt;——后者的话，那 8 字节 PNG 魔数就是纯粹的诱饵。我倾向&quot;随机填充&quot;：这个 builder 在所有&lt;strong&gt;已知&lt;/strong&gt;的加密环节都只用弱 XOR，overlay 如果真是关键配置，没理由独独升级密码强度；而且全文检索不到任何引用 &lt;code class=&quot;inline-code&quot;&gt;50932 / 0x1F0C00&lt;/code&gt; 这个尺寸的代码。&lt;strong&gt;但在拿到第二份同源样本做差分之前，我不把这条写成结论。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;这段看着像&quot;没做完&quot;，其实是我最有把握写进报告的部分之一：&lt;strong&gt;知道自己卡在哪条边界上、并能证明这条边界在哪，比给一个含糊的&quot;应该是加密配置吧&quot;有价值得多。&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;归因基础设施能定代码血统不能硬套&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#归因基础设施能定代码血统不能硬套&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;归因：基础设施能定，代码血统不能硬套&lt;/h2&gt;
&lt;p&gt;归因我拆成两层，用完全不同的证据标准。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;基础设施层：证据很硬。&lt;/strong&gt; C2 域名注册商是 &lt;strong&gt;Gname.com&lt;/strong&gt;（IANA 1923，长期位居恶意域名注册量榜首）；域名注册于 2026-06-07、只有 4 个月；&lt;code class=&quot;inline-code&quot;&gt;macio-china.com&lt;/code&gt; 仿冒 &lt;code class=&quot;inline-code&quot;&gt;macio.com.cn&lt;/code&gt;，子域 &lt;code class=&quot;inline-code&quot;&gt;jd.&lt;/code&gt; 再仿冒京东；&lt;code class=&quot;inline-code&quot;&gt;crt.sh&lt;/code&gt; 返回空（零证书透明度记录，说明它从不申请公开 CA 证书，与&quot;TLS 握手被拒&quot;互相印证）。和 ReliaQuest《Silver Fox》报告对一遍：&lt;strong&gt;Typosquatting、Gname.com、子域承载 C2、短命新域名、无公开证书、香港 IDC 托管——六项全部吻合。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;代码血统层：我给不出，而且我拒绝硬套。&lt;/strong&gt; 我逐条复核最初&quot;像银狐&quot;的依据：有没有 Gh0st 源码痕迹？&lt;strong&gt;0 条&lt;/strong&gt;。RTTI 显示的是 &lt;code class=&quot;inline-code&quot;&gt;armoury::transport::ITransport&lt;/code&gt; + C++17 的 &lt;code class=&quot;inline-code&quot;&gt;std::function&lt;/code&gt;/lambda/&lt;code class=&quot;inline-code&quot;&gt;shared_ptr&lt;/code&gt;——和 Gh0st 系那种&quot;无命名空间、类名形如 &lt;code class=&quot;inline-code&quot;&gt;CClientSocket&lt;/code&gt;&quot;的老式 C++ 完全对不上；内部命名 &quot;Armoury&quot; 在公开情报里也查不到任何归因。所以我的写法是：&lt;strong&gt;代码层是一个自研的 C++17 远控框架，对外宣称代号 Armoury，与已知家族无代码同源证据；基础设施层高度符合银狐生态。&lt;/strong&gt; 我会把它交给 CNCERT 做代码比对，而不是自己拍板说&quot;这就是银狐&quot;。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;中间还有一次必须做的证伪。&lt;/strong&gt; 公开情报里确实有三个 &quot;Armoury&quot;：微软的检测名 &lt;code class=&quot;inline-code&quot;&gt;Trojan:Win32/Armoury&lt;/code&gt;，安天的 ArmouryLoader（x86、劫持华硕 Armoury Crate 的 &lt;code class=&quot;inline-code&quot;&gt;ArmouryA.dll&lt;/code&gt;、用 OpenCL/GPU 解密），以及 Zscaler 记录的 CoffeeLoader 的 &quot;Armoury&quot; 壳。名字撞得很厉害。我做了五个阴性检测：&lt;code class=&quot;inline-code&quot;&gt;OpenCL&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;clCreateBuffer&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ASUS&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;ArmouryA&lt;/code&gt;、&lt;code class=&quot;inline-code&quot;&gt;freeBuffer&lt;/code&gt;——5 个文件里&lt;strong&gt;全部 0 命中&lt;/strong&gt;；而且本样本是 &lt;strong&gt;x64 原生&lt;/strong&gt;（不是 x86），注入手法是 &lt;code class=&quot;inline-code&quot;&gt;Nt*&lt;/code&gt; 进程镂空 + &lt;code class=&quot;inline-code&quot;&gt;notepad.exe&lt;/code&gt;（没有天堂之门/系统调用号搜索）。&lt;strong&gt;结论：命名碰撞，非同源，归因时不能合并。&lt;/strong&gt; 偷懒把两个 &quot;Armoury&quot; 当成一家，整个归因就毁了。&lt;/p&gt;
&lt;p&gt;顺带说个容易被当成&quot;归因铁证&quot;的东西：三个模块里都有个叫 &lt;code class=&quot;inline-code&quot;&gt;.fptable&lt;/code&gt; 的节，我一度想拿它当家族锚点——但它在所有模块里&lt;strong&gt;都是 512 字节全零&lt;/strong&gt;，而且多个&lt;strong&gt;互不相关&lt;/strong&gt;的恶意家族里都有同名同形的空节。那是构建工具链留下的，不是团伙留下的：&lt;strong&gt;能当&quot;狩猎 pivot&quot;，不能当归因。&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;收尾把样本和补丁做成一个能安全复现的释放器&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#收尾把样本和补丁做成一个能安全复现的释放器&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;收尾：把样本和补丁做成一个能安全复现的释放器&lt;/h2&gt;
&lt;p&gt;分析写完了，但东西交不出去。手上有&lt;strong&gt;五个文件&lt;/strong&gt;：原始样本 + 四个补丁版（&lt;code class=&quot;inline-code&quot;&gt;switch&lt;/code&gt; 1 字节 / &lt;code class=&quot;inline-code&quot;&gt;nop&lt;/code&gt; 3 字节 / &lt;code class=&quot;inline-code&quot;&gt;kill&lt;/code&gt; 5 字节 / &lt;code class=&quot;inline-code&quot;&gt;all&lt;/code&gt; 9 字节）。直接扔文件夹有两个问题：&lt;strong&gt;误触&lt;/strong&gt;（手滑双击就真跑了）、&lt;strong&gt;留不住&lt;/strong&gt;（本机实时防护会在落盘后约 1 秒内按&lt;strong&gt;内容特征&lt;/strong&gt;删掉，改后缀也没用）。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;打包：&lt;/strong&gt; AES-256 压缩包，口令 &lt;code class=&quot;inline-code&quot;&gt;infected&lt;/code&gt;。坑在于&lt;strong&gt;必须在内存里拼完再写出去&lt;/strong&gt;——先落一个临时明文文件再压缩的话，实时防护会在压缩途中把它删掉，包就残缺了。流程：读原文件 → 校验 SHA-256 → 内存里 &lt;code class=&quot;inline-code&quot;&gt;writestr&lt;/code&gt; → 一次写出 → 再从内存回读逐条比对。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;自包含启动器：&lt;/strong&gt; 解压出来还是五个独立文件，照样被吃；干脆把五个样本作为 &lt;strong&gt;RCDATA 资源&lt;/strong&gt;塞进一个 EXE（成品 10,467,328 字节），运行时再释放，&lt;strong&gt;磁盘上不存在&quot;单独的样本文件&quot;&lt;/strong&gt;。核心是&lt;strong&gt;三道关&lt;/strong&gt;：① 免责声明默认按钮是「&lt;strong&gt;不同意，退出&lt;/strong&gt;」，回车即放弃且不释放任何文件；② 默认勾着「&lt;strong&gt;仅释放到磁盘，不要运行&lt;/strong&gt;」；③ 取消安全选项后才出现的最后确认。&lt;strong&gt;手滑双击不会跑起来。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;几个细节：释放文件&lt;strong&gt;保持原名&lt;/strong&gt;（样本从自身路径推导守护参数，改名会改行为）；&lt;strong&gt;防自覆盖&lt;/strong&gt;（启动器若叫 &lt;code class=&quot;inline-code&quot;&gt;chat-deepseek.exe&lt;/code&gt;，自动转存 &lt;code class=&quot;inline-code&quot;&gt;payload\&lt;/code&gt;）；&lt;strong&gt;被杀软删掉要说清楚&lt;/strong&gt;（&lt;code class=&quot;inline-code&quot;&gt;Sleep(1200)&lt;/code&gt; 后核对大小，对不上就弹「被实时防护拦截」）。另外留了两个模式：&lt;code class=&quot;inline-code&quot;&gt;--verify&lt;/code&gt; &lt;strong&gt;不写盘、不执行&lt;/strong&gt;，只从内存资源算 SHA-256；&lt;code class=&quot;inline-code&quot;&gt;--extract &amp;lt;目录&amp;gt;&lt;/code&gt; 纯命令行释放。&lt;strong&gt;&lt;code class=&quot;inline-code&quot;&gt;--verify&lt;/code&gt; 和做静态分析的纪律是同一个思路：证明字节是对的，但一个字节都不落地、也绝不运行。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;先拿无害测试载荷（只弹一个消息框）跑通全链路——不同意→不释放、仅释放不运行、真启动、改名自覆盖、&lt;code class=&quot;inline-code&quot;&gt;--verify&lt;/code&gt;/&lt;code class=&quot;inline-code&quot;&gt;--extract&lt;/code&gt; 哈希核对，七个场景全过才换真实样本重建。&lt;/strong&gt; 构建坑：&lt;code class=&quot;inline-code&quot;&gt;windres&lt;/code&gt; 要加 &lt;code class=&quot;inline-code&quot;&gt;-c 65001&lt;/code&gt;（否则中文目录名按 CP936 解码找不到）、&lt;code class=&quot;inline-code&quot;&gt;.rc&lt;/code&gt; 必须写 &lt;code class=&quot;inline-code&quot;&gt;#define IDR_PAYLOAD_*&lt;/code&gt;（否则被当字符串资源名）、链接 &lt;code class=&quot;inline-code&quot;&gt;-municode -mwindows -static -lbcrypt -lshell32&lt;/code&gt;。顺手还写了个只读的本机 IOC 排查脚本——每条判据都是从前面那些分析结论来的。&lt;/p&gt;
&lt;p&gt;交付物：&lt;/p&gt;
&lt;div class=&quot;code-block&quot; data-lang=&quot;&quot;&gt;&lt;div class=&quot;code-head&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;code-copy&quot; data-copy aria-label=&quot;复制代码&quot;&gt;复制&lt;/button&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;银狐样本启动器.exe  10,467,328 B  sha256 10c91cc3cd88c6a375d5dbcf427b2dcde4ab436ef1a131b5a5818c1b4f46cdb5
样本包.zip          4,594,752 B   sha256 595589ebf36b332b032877288d616da42bf36c684f98784bc747669e94ddafd6  （AES-256，口令 infected）&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;五个变体哈希在包里和 &lt;code class=&quot;inline-code&quot;&gt;--verify&lt;/code&gt; 报告里是同一组（&lt;code class=&quot;inline-code&quot;&gt;68ae0cab…&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;8879984a…&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;31620c4b…&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;30927d0a…&lt;/code&gt; / &lt;code class=&quot;inline-code&quot;&gt;bd93e88f…&lt;/code&gt;），两处对得上。&lt;/p&gt;
&lt;h2 id=&quot;复盘这几条纪律是踩出来的&quot; class=&quot;md-heading&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;#复盘这几条纪律是踩出来的&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;复盘：这几条纪律是踩出来的&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;一、读到最后一章再下判断。&lt;/strong&gt; 这份分析里&quot;为什么双击没反应&quot;被推翻了四次，&quot;协议是什么&quot;&quot;各模块是不是一套密钥&quot;&quot;高熵区是不是密文&quot;各被推翻过一次。只读前三分之一就写总结，写出来的东西会全错。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;二、工具会给你&quot;看起来正常&quot;的错误答案。&lt;/strong&gt; 线性反汇编遇跳转表会静默失步，把&quot;30 处引用&quot;报成&quot;零引用&quot;；把 &lt;code class=&quot;inline-code&quot;&gt;VirtualSize&lt;/code&gt; 读成 &lt;code class=&quot;inline-code&quot;&gt;VirtualAddress&lt;/code&gt; 会让导入表解析落到空区，然后你判&quot;它加壳了&quot;。工具不报错不代表它是对的——&lt;strong&gt;最终以字节为准&lt;/strong&gt;。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;三、高熵不等于密文，随机也不等于随机。&lt;/strong&gt; 字节表可以熵 7.9；真随机要用 χ² 和熵的偏离度验。反过来，我一直以为的高熵密文最后发现是 8 字节短周期 XOR——&lt;strong&gt;&quot;高熵 ⇒ 强加密&quot;这个直觉在本案被实证推翻了。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;四、搜到 2 字节魔数先算随机期望命中数。&lt;/strong&gt; &lt;code class=&quot;inline-code&quot;&gt;4D 5A&lt;/code&gt; 在 1.75MB 里的随机期望命中约 28 处——单次命中就是噪声级别。判据必须是长串或整文件哈希。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;五、不映射进程名的 IP 排序全是噪声。&lt;/strong&gt; 那个中国段 IP 一度是头号嫌疑，实际是 Windows 自带进程。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;六、能当 IOC 的东西，先问&quot;它会不会变&quot;。&lt;/strong&gt; 文件名从 12 个里随机抽，真正的锚点是路径形态和命令行参数。同理，静态串与运行态产物对得上号（&lt;code class=&quot;inline-code&quot;&gt;ARMGID833B463E&lt;/code&gt; ↔ &lt;code class=&quot;inline-code&quot;&gt;G-833B463E&lt;/code&gt;）才是最强证据——&lt;strong&gt;这种互证我遇到四五次。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;七、操作系统会骗你，是因为它没说英文。&lt;/strong&gt; 中文 Windows 的 &lt;code class=&quot;inline-code&quot;&gt;ipconfig /displaydns&lt;/code&gt; 表头是「记录名称」；PowerShell 5.1 不支持三元运算符；&lt;code class=&quot;inline-code&quot;&gt;.ps1&lt;/code&gt; 双击默认不执行。每个都能让你得出错误结论或浪费一整天。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;八、取证产物不要落在受快照管辖的盘上。&lt;/strong&gt; 我在虚拟机里跑完采集、打完快照后做硬盘还原，&lt;code class=&quot;inline-code&quot;&gt;C:\forensics&lt;/code&gt; 连同产物一起被回滚吃掉了——白做一遍。&lt;strong&gt;每跑完一个阶段立刻外传。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;九、交付物也要设计&quot;防误触&quot;和&quot;防被吃&quot;。&lt;/strong&gt; 样本直接放文件夹里，可能被误双击，也会被实时防护&lt;strong&gt;悄无声息删掉&lt;/strong&gt;。所以做成了&quot;内存里打包 + 内嵌 EXE + 默认选项偏安全&quot;的释放器——&lt;strong&gt;默认值不是随手定的，它是最后一道防线。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;最后一句实话：这份分析能推进到 C2 和归因，靠的不是某个聪明方法，而是&lt;strong&gt;每次得出结论后都逼自己写清楚&quot;什么证据能推翻它&quot;&lt;/strong&gt;。每一条被推翻的结论，都是下一次更精确的起点。真正拿到手的，都是被推翻到只剩骨架后还站着的那些。&lt;/p&gt;
&lt;p&gt;样本下载:&lt;a href=&quot;https://wwaux.lanzoul.com/b00jflpl5i&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;&lt;a href=&quot;https://wwaux.lanzoul.com/b00jflpl5i&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;https://wwaux.lanzoul.com/b00jflpl5i&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;密码:4a97&lt;/p&gt;</content>
  </entry>
</feed>