TITAN-Softwork-Solutions/RESX

GitHub: TITAN-Softwork-Solutions/RESX

一款基于 Rust 构建的 Windows 二进制逆向工程 CLI 工具包,提供快速反汇编、PDB 符号解析、控制流恢复、恶意样本分类与 hook 检测等能力。

Stars: 0 | Forks: 0

RESX

Windows 二进制分析与逆向工程工具包

RESX 专为快速的终端优先逆向分析而构建:导出表、基于 PDB 的符号、针对性反汇编、伪 C 代码重建、CFG 恢复、switch-table 分析、调用者追踪、PE 检查、YARA 以及分类分析。 ## 构建 ``` cargo build --release ``` ## 版本与更新 ``` resx version resx update ``` `resx update` 用于 git 检出。它会对 `origin` 的当前分支执行快进拉取。 PDB 下载会在磁盘上进行缓存,并且符号枚举会在进程内被复用。当您想绕过这两者并强制重新加载符号时,请使用 `--reload`。 ## 核心命令 ``` resx dump resx dump --at resx dump --ordinal resx cfg resx intelli [function] resx peinfo resx sections resx eat resx iat resx syms resx pechk resx priority resx callers resx locate resx locate-sym resx yara ``` ## 为什么它的读取方式与众不同 - 它从导出表和枚举的 PDB 符号中解析内部目标,而不是停留在导出表上。 - 它可以恢复结构化的 switch 调度器,而不是仅仅给您留下一个 `jmp r9`。 - 它可以在一次遍历中显示反汇编、调用图、CFG 边以及伪 C 代码。 - 它将 `intelli` 作为一等分类命令公开,而不是将其隐藏在某个标志之后。 - 它的设计旨在对真实的 Windows 内部机制工作有所帮助,而不仅仅是“导出后就退出”。 ## 展示 ### 内核符号解析 ``` > resx dump ntoskrnl.exe KiSystemCall64 --cfg text --funcs --recomp [+] Found: \\?\C:\Windows\System32\ntoskrnl.exe [*] Architecture: x64 | ImageBase: 0x140000000 [*] Exports: 3389 [*] Not found in EAT, trying PDB symbols... [+] KiSystemCall64 @ RVA 0x006BDE40 (from enumerated PDB symbols) ntoskrnl.exe!KiSystemCall64 [RVA 0x006BDE40, VA 0x1406BDE40] 006BDE40 0F 01 F8 SWAPGS 006BDE43 65 48 89 24 25 10 00 00 00 MOV gs:[10h],rsp 006BDE4C 65 48 8B 24 25 A8 01 00 00 MOV rsp,gs:[1A8h] 006BDE55 6A 2B PUSH 2Bh 006BDE57 65 FF 34 25 10 00 00 00 PUSH qword ptr gs:[10h] 006BDE5F 41 53 PUSH r11 ... API Call Map for KiSystemCall64 [37 call site(s)]: 0x6BE0A9 CALL KiFlushBhbDuringTrapEntryOrExit [internal] 0x6BE136 CALL KiSynchronizeUserIsolationDomainExit [internal] 0x6BE150 CALL KiSaveDebugRegisterState [internal] 0x6BE166 CALL PsSyscallProviderDispatch [internal] 0x6BE183 CALL KiExceptionDispatch [internal] ``` ### 作为真实命令的 Intelli 分类 ``` > resx intelli suspicious.dll WinMain --hookchk --cfg text --strings suspicious.dll!WinMain [RVA 0x00017A40, VA 0x0000000180017A40] mov rcx, qword ptr [rip+0x4C12] call qword ptr [rip+0x2130] ; WinHttpSendRequest Hook Indicators: entry starts with jump thunk in-memory prologue differs from disk at 5 offset(s) String References: https://api.example-c2.net/gate wss://cdn.example-c2.net/socket C:\Users\Public\svchost.dat Intelli Triage: [network] url (string) https://api.example-c2.net/gate [network] websocket (string) wss://cdn.example-c2.net/socket [filesystem] filepath (string) C:\Users\Public\svchost.dat [execution] process-launch (import) CreateProcessW ``` ### Switch 恢复而非原始的间接跳转 ``` > resx dump ntoskrnl.exe NtQuerySystemInformation --cfg text ntoskrnl.exe!NtQuerySystemInformation [RVA 0x00AE0FD0, VA 0x140AE0FD0] 00AE0FDD 8D 41 F8 LEA eax,[rcx-8] 00AE0FF0 3D F6 00 00 00 CMP eax,0F6h 00AE0FF5 77 53 JA short 0000000140AE104Ah 00AE1000 0F B6 84 01 80 10 AE 00 MOVZX eax,byte ptr [rcx+rax+0AE1080h] 00AE1008 44 8B 8C 81 70 10 AE 00 MOV r9d,[rcx+rax*4+0AE1070h] 00AE1010 4C 03 C9 ADD r9,rcx 00AE1013 41 FF E1 JMP r9 Switch Map: Selector : SystemInformationClass (SYSTEM_INFORMATION_CLASS) Params : 4 Prototype: SYSTEM_INFORMATION_CLASS SystemInformationClass, PVOID SystemInformation, ULONG SystemInformationLength, PULONG ReturnLength Bias : 0x8 MaxIndex : 0xF6 Targets : 4 Remap : RVA 0x00AE1080 Table : RVA 0x00AE1070 NtQuerySystemInformation+0x49 [RVA 0x00AE1019] When : SystemProcessorPerformanceInformation (0x8), SystemInterruptInformation (0x17), 0x2A, 0x3D, 0x53, 0x64, 0x6C, 0x8D NtQuerySystemInformation+0x7A [RVA 0x00AE104A] When : 0x9..0x16, 0x18..0x20, SystemExceptionInformation (0x21), 0x22..0x24 SystemRegistryQuotaInformation (0x25), 0x26..0x29, 0x2B..0x2C, SystemLookasideInformation (0x2D) 0x2E..0x3C, 0x3E..0x48, 0x4A..0x52, 0x54..0x63, 0x65..0x66 SystemCodeIntegrityInformation (0x67), 0x68..0x6A, 0x6D..0x78, 0x7A..0x85 SystemPolicyInformation (0x86), 0x87..0x8C, 0x8E..0xB3, 0xB5..0xD1, 0xD4..0xDD 0xDF..0xE6, 0xE8..0xED, 0xF1..0xFB, SystemBasicProcessInformation (0xFC) SystemHandleCountInformation (0xFD) ``` ### 保留真实条件的反编译器输出 ``` NTSTATUS __fastcall KiSystemCall64( void* param_1, void* param_2, void* param_3, void* param_4 ) { if ((*(KeSmapEnabled) & 0xFF) == 0) goto label_006BDEBF; if ((ss::*(rbp+0xF0) & 0x1) == 0) goto label_006BDEBF; ... if ((edx & 0x2) == 0) goto label_006BE09E; ... if (*(rbx+0x3) == 0) goto label_006BE198; ... result = KiExceptionDispatch(); } ``` ### CFG 与恢复的边 ``` Control Flow Graph: blocks: 3 entry : block_00AE0FD0 block_00AE0FF7: [6 insn] range 0x00AE0FF7..0x00AE1013 0x00AE1000 movzx eax,byte ptr [rcx+rax+0AE1080h] 0x00AE1008 mov r9d,[rcx+rax*4+0AE1070h] 0x00AE1010 add r9,rcx 0x00AE1013 jmp r9 edges: [switch] switch -> block_00AE1019 (8 case(s): 0x8, 0x17, 0x2A, 0x3D, +4 more) [switch] switch -> block_00AE102C (1 case(s): 0x49) [switch] switch -> block_00AE1039 (8 case(s): 0x6B, 0x79, 0xB4, 0xD2..0xD3, +4 more) [switch] switch -> block_00AE104A (many case(s): 0x9..0x16, 0x18..0x29, 0x2B..0x3C, ...) ``` ### 符号诊断 ``` > resx syms ntoskrnl.exe --verbose [*] Module loaded: ntoskrnl.exe [*] RSDS PDB: ntkrnlmp.pdb [*] Symbol URL: http://msdl.microsoft.com/download/symbols/ntkrnlmp.pdb//ntkrnlmp.pdb [*] Cache path: C:\Users\\AppData\Local\resx\symbols\ntkrnlmp.pdb\\ntkrnlmp.pdb [*] Loaded symbols: type=pdb ``` ## 快速示例 ``` resx dump ntdll.dll NtOpenProcess --cfg text --hookchk resx intelli suspicious.dll resx intelli suspicious.dll WinMain --hookchk --cfg text --strings resx dump ntoskrnl.exe KiSystemCall64 --cfg text --funcs --recomp resx dump ntoskrnl.exe NtQuerySystemInformation --cfg text resx callers .\blackbird.sys BLACKBIRDNtAllocateVirtualMemoryHookStub --depth 2 resx syms ntoskrnl.exe --verbose resx yara suspicious.dll .\rules\triage.yar ``` ## 注意事项 - 语义化的 switch 标签在可用时来源于已解析的 SDK 元数据。在没有 SDK 的情况下,结构化的 switch 恢复依然有效。 - `intelli` 是启用了分类功能的 `dump` 命令的别名,因此它也接受常规的 dump 侧选项。 - `locate` / `locate-sym` 默认返回优先级集内的所有匹配项。 - `callers` 默认扫描优先级集。 - 当您希望将 `locate` 或 `callers` 的扫描范围扩大到优先级集之外时,请使用 `--include-dir` 和 `--include-image`。 - `resx priority` 会打开生成的优先级配置 JSON。可以在其中编辑优先级目录、确切名称、前缀和正则表达式。 - `--edrchk` 默认仅与已加载到内存中的镜像进行比较。RESX 不提供真正的沙箱/容器。`--unsafe-map-image` 会重新启用将磁盘上的镜像映射到当前进程的旧有回退机制,对于不受信任的样本应将其视为不安全的。 - `resx update` 需要具有已配置 `origin` 的 git 检出。 - 使用 `resx help` 或 `resx --example` 以获取实时的命令帮助。 完整命令概览请参见 `COMMANDS.md`。
标签:DAST, DNS信息、DNS暴力破解, PE文件解析, Rust语言, Wayback Machine, Windows二进制分析, YARA规则, 二进制安全, 云安全监控, 云资产清单, 伪C代码生成, 函数定位, 反汇编, 可视化界面, 导入表分析, 导出表分析, 恶意软件分析, 控制流图恢复, 符号解析, 网络安全, 逆向工程, 通知系统, 隐私保护, 静态分析