IDA - 大型跳转表,分析中的缺失案例

逆向工程 艾达 二元分析 x86 静态分析
2021-07-10 21:49:49

我遇到了以下带有大量案例(160+)的跳转表。不过,IDA 分析中似乎缺少一些案例。例如,它从案例 22 -> 38 -> 91 中跳过,我总共可以看到大约 10 个案例。

国际开发协会

  1. 我可以期望所有 switch case 都占用顺序内存吗?有没有可能这些案例没有丢失,只是位于内存中的其他地方?
  2. 如果它们通常是连续的,那么 IDA 是否只是误解了这些案例?
  3. 谁能解释为什么有大量属于这个跳转表的案例,但我只看到少数几个?

周围的说明0052B970,它是位于屏幕截图正上方的 disasm:

.text:0052B932                loc_52B932:                             ; CODE XREF: sub_52B920+9↑j
.text:0052B932 8A 01                          mov     al, [ecx]
.text:0052B934 3C B5                          cmp     al, 0B5h
.text:0052B936 73 F3                          jnb     short loc_52B92B
.text:0052B938 0F B6 D0                       movzx   edx, al
.text:0052B93B 8B 04 95 E8 0A+                mov     eax, dword_730AE8[edx*4]
.text:0052B942 85 C0                          test    eax, eax
.text:0052B944 57                             push    edi
.text:0052B945 8B 7D 08                       mov     edi, [ebp+arg_0]
.text:0052B948 89 07                          mov     [edi], eax
.text:0052B94A 75 06                          jnz     short loc_52B952
.text:0052B94C 5F                             pop     edi
.text:0052B94D 5E                             pop     esi
.text:0052B94E 5D                             pop     ebp
.text:0052B94F C2 04 00                       retn    4
.text:0052B952                ; ---------------------------------------------------------------------------
.text:0052B952
.text:0052B952                loc_52B952:                             ; CODE XREF: sub_52B920+2A↑j
.text:0052B952 85 C0                          test    eax, eax
.text:0052B954 53                             push    ebx
.text:0052B955 0F 8D DC 01 00+                jge     loc_52BB37
.text:0052B95B 8D 42 EA                       lea     eax, [edx-16h]  ; switch 158 cases
.text:0052B95E 3D 9D 00 00 00                 cmp     eax, 9Dh
.text:0052B963 0F 87 C8 01 00+                ja      loc_52BB31      ; jumptable 0052B970 default case
.text:0052B969 0F B6 80 80 BB+                movzx   eax, ds:byte_52BB80[eax]
.text:0052B970 FF 24 85 44 BB+                jmp     ds:off_52BB44[eax*4] ; switch jump
.text:0052B977                ; ---------------------------------------------------------------------------
.text:0052B977
.text:0052B977                loc_52B977:                             ; CODE XREF: sub_52B920+50↑j
.text:0052B977                                                        ; DATA XREF: .text:off_52BB44↓o
.text:0052B977 83 FE 0D                       cmp     esi, 0Dh        ; jumptable 0052B970 case 22
.text:0052B97A 72 4A                          jb      short loc_52B9C6
.text:0052B97C 0F B7 49 01                    movzx   ecx, word ptr [ecx+1]
.text:0052B980 5B                             pop     ebx
.text:0052B981 89 0F                          mov     [edi], ecx
.text:0052B983 5F                             pop     edi
.text:0052B984 B8 01 00 00 00                 mov     eax, 1
.text:0052B989 5E                             pop     esi
.text:0052B98A 5D                             pop     ebp
.text:0052B98B C2 04 00                       retn    4

谢谢。

1个回答

这是所谓的稀疏切换表的一个例子 - 大范围的案例值,其中有差距。您可以看到它如何首先通过索引字节表来确定案例索引,然后使用地址表中的索引跳转到处理程序。所以缺失值是正常的和预期的;它们由默认情况处理。

您可以在本系列文章中查看 Rolf 对编译器开关实现及其变体的研究:

https://www.msreverseengineering.com/blog/2014/6/23/switch-as-binary-search-part-0