首页
社区
课程
招聘
[求助]IDA F5的问题
发表于: 2021-1-19 21:00 3194

[求助]IDA F5的问题

2021-1-19 21:00
3194

IDA F5的问题

用VB写个最简单的程序,之所以用vb,是因为我只知道用vb写的程序很大几率会出现这个问题.

1
2
3
Private Sub Command1_Click()
    MsgBox "F5 Error"
End Sub

编译后用ida打开,设定显示SP追踪.可见并没有任何SP问题.

 

为了F5更加精确,我对涉及到的几个函数做了定义

1
2
3
int __stdcall rtcMsgBox(Variant_t* pPropt,int nType,Variant_t* pTitle,Variant_t* pHelpFile,Variant_t* pContex);
Variant_t *__fastcall _vbaVarDup(Variant_t *pDst, Variant_t *Src);
int __cdecl _vbaFreeVarList(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
.text:03F621D0     sub_3F621D0     proc near               ; CODE XREF: sub_3F61758:loc_3F61760↑j
.text:03F621D0
.text:03F621D0     Src             = Variant_t ptr -64h
.text:03F621D0     pContex         = Variant_t ptr -54h
.text:03F621D0     pHelpFile       = Variant_t ptr -44h
.text:03F621D0     pTitle          = Variant_t ptr -34h
.text:03F621D0     pDst            = Variant_t ptr -24h
.text:03F621D0     var_14          = dword ptr -14h
.text:03F621D0     var_C           = dword ptr -0Ch
.text:03F621D0     var_8           = dword ptr -8
.text:03F621D0     var_4           = dword ptr -4
.text:03F621D0     arg_0           = dword ptr  8
.text:03F621D0
.text:03F621D0 000                 push    ebp
.text:03F621D1 004                 mov     ebp, esp
.text:03F621D3 004                 sub     esp, 0Ch
.text:03F621D6 010                 push    offset __vbaExceptHandler
.text:03F621DB 014                 mov     eax, large fs:0
.text:03F621E1 014                 push    eax
.text:03F621E2 018                 mov     large fs:0, esp
.text:03F621E9 018                 sub     esp, 88h
.text:03F621EF 0A0                 push    ebx
.text:03F621F0 0A4                 push    esi
.text:03F621F1 0A8                 push    edi
.text:03F621F2 0AC                 mov     [ebp+var_C], esp
.text:03F621F5 0AC                 mov     [ebp+var_8], offset dword_3F61108
.text:03F621FC 0AC                 mov     eax, [ebp+arg_0]
.text:03F621FF 0AC                 mov     ecx, eax
.text:03F62201 0AC                 and     ecx, 1
.text:03F62204 0AC                 mov     [ebp+var_4], ecx
.text:03F62207 0AC                 and     al, 0FEh
.text:03F62209 0AC                 push    eax
.text:03F6220A 0B0                 mov     [ebp+arg_0], eax
.text:03F6220D 0B0                 mov     edx, [eax]
.text:03F6220F 0B0                 call    dword ptr [edx+4]
.text:03F62212 024                 mov     ecx, 80020004h
.text:03F62217 024                 xor     esi, esi
.text:03F62219 024                 mov     [ebp+pContex.Data], ecx
.text:03F6221C 024                 mov     eax, 0Ah
.text:03F62221 024                 mov     [ebp+pHelpFile.Data], ecx
.text:03F62224 024                 mov     [ebp+pTitle.Data], ecx
.text:03F62227 024                 mov     dword ptr [ebp+pTitle.varType], esi
.text:03F6222A 024                 mov     dword ptr [ebp+pHelpFile.varType], esi
.text:03F6222D 024                 mov     dword ptr [ebp+pContex.varType], esi
.text:03F62230 024                 mov     dword ptr [ebp+Src.varType], esi
.text:03F62233 024                 lea     edx, [ebp+Src]  ; Src
.text:03F62236 024                 lea     ecx, [ebp+pDst] ; pDst
.text:03F62239 024                 mov     dword ptr [ebp+pDst.varType], esi
.text:03F6223C 024                 mov     dword ptr [ebp+pContex.varType], eax
.text:03F6223F 024                 mov     dword ptr [ebp+pHelpFile.varType], eax
.text:03F62242 024                 mov     dword ptr [ebp+pTitle.varType], eax
.text:03F62245 024                 mov     [ebp+Src.Data], offset aF5Error ; "F5 Error"
.text:03F6224C 024                 mov     dword ptr [ebp+Src.varType], 8
.text:03F62253 024                 call    ds:__vbaVarDup
.text:03F62259 024                 lea     eax, [ebp+pContex]
.text:03F6225C 024                 lea     ecx, [ebp+pHelpFile]
.text:03F6225F 024                 push    eax             ; pContex
.text:03F62260 028                 lea     edx, [ebp+pTitle]
.text:03F62263 028                 push    ecx             ; pHelpFile
.text:03F62264 02C                 push    edx             ; pTitle
.text:03F62265 030                 lea     eax, [ebp+pDst]
.text:03F62268 030                 push    esi             ; nType
.text:03F62269 034                 push    eax             ; pPropt
.text:03F6226A 038                 call    ds:rtcMsgBox
.text:03F62270 024                 lea     ecx, [ebp+pContex]
.text:03F62273 024                 lea     edx, [ebp+pHelpFile]
.text:03F62276 024                 push    ecx             ; _DWORD
.text:03F62277 028                 lea     eax, [ebp+pTitle]
.text:03F6227A 028                 push    edx             ; _DWORD
.text:03F6227B 02C                 lea     ecx, [ebp+pDst]
.text:03F6227E 02C                 push    eax             ; _DWORD
.text:03F6227F 030                 push    ecx             ; _DWORD
.text:03F62280 034                 push    4               ; _DWORD
.text:03F62282 038                 call    ds:__vbaFreeVarList
.text:03F62288 038                 add     esp, 14h
.text:03F6228B 024                 mov     [ebp+var_4], esi
.text:03F6228E
.text:03F6228E     loc_3F6228E:                            ; DATA XREF: .text:03F6110C↑o
.text:03F6228E 024                 push    offset loc_3F622B2
.text:03F62293 028                 jmp     short loc_3F622B1
.text:03F62295    
; ---------------------------------------------------------------------------
.text:03F62295
.text:03F62295     loc_3F62295:                            ; DATA XREF: .text:03F61114↑o
.text:03F62295 000                 lea     edx, [ebp+pContex]
.text:03F62298 000                 lea     eax, [ebp+pHelpFile]
.text:03F6229B 000                 push    edx             ; _DWORD
.text:03F6229C 004                 lea     ecx, [ebp+pTitle]
.text:03F6229F 004                 push    eax             ; _DWORD
.text:03F622A0 008                 lea     edx, [ebp+pDst]
.text:03F622A3 008                 push    ecx             ; _DWORD
.text:03F622A4 00C                 push    edx             ; _DWORD
.text:03F622A5 010                 push    4               ; _DWORD
.text:03F622A7 014                 call    ds:__vbaFreeVarList
.text:03F622AD 014                 add     esp, 14h
.text:03F622B0 000                 retn
.text:03F622B1    
; ---------------------------------------------------------------------------
.text:03F622B1
.text:03F622B1     loc_3F622B1:                            ; CODE XREF: sub_3F621D0+C3↑j
.text:03F622B1 028                 retn
.text:03F622B2    
; ---------------------------------------------------------------------------
.text:03F622B2
.text:03F622B2     loc_3F622B2:                            ; CODE XREF: sub_3F621D0:loc_3F622B1↑j
.text:03F622B2                                             ; DATA XREF: sub_3F621D0:loc_3F6228E↑o
.text:03F622B2 024                 mov     eax, [ebp+arg_0]
.text:03F622B5 024                 push    eax
.text:03F622B6 028                 mov     ecx, [eax]
.text:03F622B8 028                 call    dword ptr [ecx+8]
.text:03F622BB 024                 mov     eax, [ebp+var_4]
.text:03F622BE 024                 mov     ecx, [ebp+var_14]
.text:03F622C1 024                 pop     edi
.text:03F622C2 020                 pop     esi
.text:03F622C3 01C                 mov     large fs:0, ecx
.text:03F622CA 01C                 pop     ebx
.text:03F622CB 018                 mov     esp, ebp
.text:03F622CD 004                 pop     ebp
.text:03F622CE 000                 retn    4
.text:03F622CE     sub_3F621D0     endp

但是,F5后上边会出现一行错误提示,百度,谷歌,ida的官网我都去搜过,没有结果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// bad sp value at call has been detected, the output may be wrong!
int __stdcall sub_3F621D0(IDispatch *a1)
{
  IDispatch *v1; // eax
  int v3; // [esp-44h] [ebp-A8h] BYREF
  Variant_t Src; // [esp+0h] [ebp-64h] BYREF
  Variant_t pContex; // [esp+10h] [ebp-54h] BYREF
  Variant_t pHelpFile; // [esp+20h] [ebp-44h] BYREF
  Variant_t pTitle; // [esp+30h] [ebp-34h] BYREF
  Variant_t pDst; // [esp+40h] [ebp-24h] BYREF
  int *v9; // [esp+58h] [ebp-Ch]
  int *v10; // [esp+5Ch] [ebp-8h]
  int v11; // [esp+60h] [ebp-4h]
  IDispatch *v12; // [esp+6Ch] [ebp+8h]
 
  v9 = &v3;
  v10 = &dword_3F61108;
  v1 = a1;
  v11 = a1 & 1;
  LOBYTE(v1) = a1 & 0xFE;
  v12 = v1;
  v1->lpVtbl->AddRef(v1);
  pContex.Data = -2147352572;
  pHelpFile.Data = -2147352572;
  *&pContex.varType = 10;
  *&pHelpFile.varType = 10;
  Src.Data = L"F5 Error";
  *&Src.varType = 8;
  _vbaVarDup(&pDst, &Src);
  rtcMsgBox(&pDst, 0, &pTitle, &pHelpFile, &pContex);
  _vbaFreeVarList(4, &pDst, &pTitle, &pHelpFile, &pContex);
  v11 = 0;
  v12->lpVtbl->Release(v12);
  return v11;
}

PS,下ida的信息栏出现几个函数的错误提示

1
2
3
3F62253: bad sp value at call
3F6226A: bad sp value at call
3F62282: bad sp value at call

可能有的人会因为误以为以下代码的问题,因为有类似的文章专门讨论这种ida看不懂的花指令,不过我觉得不是一回事,为了彻底消除这种隐患我改掉了,让他直接跳

1
2
3
4
5
6
7
8
9
10
11
.text:03F6228E     loc_3F6228E:                            ; DATA XREF: .text:03F6110C↑o
.text:03F6228E 024                 push    offset loc_3F622B2
.text:03F62293 028                 jmp     short loc_3F622B1
 
 
.text:03F6228E 024                 jmp     short loc_3F622B2
.text:03F6228E    
; ---------------------------------------------------------------------------
.text:03F62290 024                 db  22h ; "
.text:03F62291 024                 db 0F6h
.text:03F62292 024                 db    3

再按F5,问题依旧.

 

这到底是什么原因??


[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 0
支持
分享
最新回复 (5)
雪    币: 1519
活跃值: (2127)
能力值: ( LV3,RANK:35 )
在线值:
发帖
回帖
粉丝
2
vb 是.net程序吧,没用ida逆向过.net
.net不应该是把代码翻译成中间语言码?
2021-1-19 21:03
0
雪    币: 2466
活跃值: (4561)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
Chords vb 是.net程序吧,没用ida逆向过.net .net不应该是把代码翻译成中间语言码?
vb是pcode或者汇编吧,c#是.net
2021-1-19 21:17
0
雪    币: 2286
活跃值: (6663)
能力值: ( LV7,RANK:102 )
在线值:
发帖
回帖
粉丝
4

能F5出来代码就行了,IDA本身对VB的支持就不太行。
有可能是VB导入函数声明错误导致的堆栈不平衡,也有可能是IDA的bug。

那种push addr,然后ret的指令IDA好像并不怎么支持
这个没怎么管过,所以也不太了解

最后于 2021-1-19 21:25 被fjqisba编辑 ,原因:
2021-1-19 21:21
0
雪    币: 188
活跃值: (341)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
Chords vb 是.net程序吧,没用ida逆向过.net .net不应该是把代码翻译成中间语言码?
是VB6,你可以选pcode,也可以选native编译,这个实例是native的
2021-1-19 21:32
0
雪    币: 188
活跃值: (341)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
fjqisba 能F5出来代码就行了,IDA本身对VB的支持就不太行。有可能是VB导入函数声明错误导致的堆栈不平衡,也有可能是IDA的bug。那种push addr,然后ret的指令IDA好像并不怎么支持这个没怎么管 ...
对的,有文章介绍过,所有,我也有考虑改掉了,但是没有用,
不要局限于vb6啦,原因开篇我也说了,因为我不知道怎么用c语言复现这个问题.,程然你看到现在的这个f5确实没什么问题,但是我也见过有问题的.对于软件制作者来说,这个bug可以利用对抗菜鸟级的f5,对于破解着来说,客服了可以更加安逸的逆向.
2021-1-19 21:37
0
游客
登录 | 注册 方可回帖
返回
//