首页
社区
课程
招聘
“调戏”OD
2006-5-26 21:23 4263

“调戏”OD

2006-5-26 21:23
4263
【文章标题】: “调戏”OD
【文章作者】: layper
【作者邮箱】: layper2002@yahoo.com.cn
【作者主页】: www.sy135.com
【下载地址】: 自己搜索下载
【编写语言】: Borland C++ 1999
【使用工具】: IDA,OD
【作者声明】: 只是感兴趣,没有其他目的。失误之处敬请诸位大侠赐教!
--------------------------------------------------------------------------------
【详细过程】
  平常我们都是用OD来调试其他软件的,可以说OD就是我们的左右手,非常强大。今天我试试看看它的编程思

路,学习学习。呵呵,
  别问我有什么用,自己想吧。:)
  呵呵,由于本人知识有限,如有错漏,请多包涵。
  OD是用Borland C++写的,在C++反编译中,IDA的强大是不容质疑的,用IDA再结合OD进行调试,牛!

  .text:00401000 start           proc near
  .text:00401000                 jmp     short sub_401012  ;C++ builder的入口形式
  .text:00401000 start           endp
  
  .text:00401012 sub_401012      proc near               ; CODE XREF: startj,普及一下IDA知识,""

表示从那里跳来的:)
  .text:00401012
  .text:00401012 ;  函数块在.text:004AD208 大小 00000183字节
  .text:00401012
  .text:00401012                 mov     eax, TlsIndex   ;Tls索引,在OD中显示为0
  .text:00401017                 shl     eax, 2          ;
  .text:0040101A                 mov     dword_4B011F, eax
  .text:0040101F                 push    edx             ;edx=7C92EB94

(ntdll.KiFastSystemCallRet)
  .text:00401020                 push    0               ; lpModuleName
  .text:00401022                 call    GetModuleHandleA ;默认模块
  .text:00401027                 mov     edx, eax
  .text:00401029                 call    nullsub_3        ;nullsub_3,nullsub_2,nullsub_4都只是一

个retn,这个是不是编译时的垃圾,请高手解释一下
  .text:0040102E                 pop     edx              ;edx=7C92EB94

(ntdll.KiFastSystemCallRet)
  .text:0040102F                 call    nullsub_2
  .text:00401034                 call    nullsub_4
  .text:00401039                 push    0
  .text:0040103B                 call    __ExceptInit     ;初始化Except
  .text:00401040                 pop     ecx             ;与前面的push    0结合就是ecx清0
  .text:00401041                 push    offset off_4B00C4
  .text:00401046                 push    0               ; lpModuleName
  .text:00401048                 call    GetModuleHandleA
  .text:0040104D                 mov     dword_4B0123, eax  ;eax=00400000 (Ollydbg.00400000),

ASCII "MZP",text开始地址
  .text:00401052                 push    0
  .text:00401054                 jmp     __startup   ;跳到startup
  .text:00401054 sub_401012      endp
  
  .text:004AD208 __startup:                              ; CODE XREF: sub_401012+42j到这里
  .text:004AD208                 push    ebp
  .text:004AD209                 mov     ebp, esp
  .text:004AD20B                 add     esp, 0FFFFFFF4h
  .text:004AD20E                 push    ebx
  .text:004AD20F                 push    esi
  .text:004AD210                 push    edi
  .text:004AD211                 mov     esi, [ebp+8]
  .text:004AD214                 mov     eax, [esi+10h]
  .text:004AD217                 and     eax, 1  ;eax=1
  .text:004AD21A                 mov     dword_4CC8DC, eax
  .text:004AD21F                 call    __fpreset ;重新初使化浮点数学程序包
  .text:004AD224                 mov     edx, [esi+20h]
  .text:004AD227                 push    edx
  .text:004AD228                 mov     ecx, [esi+1Ch]
  .text:004AD22B                 push    ecx
  .text:004AD22C                 call    __initmatherr
  .text:004AD231                 add     esp, 8
  .text:004AD234                 mov     eax, [esi+28h]
  .text:004AD237                 push    eax
  .text:004AD238                 call    __initfmode ;初始化fmode
  .text:004AD23D                 pop     ecx
  .text:004AD23E                 mov     edx, [esi+44h]
  .text:004AD241                 push    edx
  .text:004AD242                 call    __initfileinfo ;初始化文件信息
  .text:004AD247                 pop     ecx
  .text:004AD248                 mov     dword_50A658, 1
  .text:004AD252                 mov     dword_50A65C, esi
  .text:004AD258                 lea     ecx, [ebp-8]
  .text:004AD25B                 mov     dword_50A644, ecx
  .text:004AD261                 call    __InitDefaultHander ;初始化默认句柄
  .text:004AD266                 call    GetEnvironmentStrings ;为包含了当前环境字串设置的一个内

存块分配和返回一个句柄。
  .text:004AD26B                 mov     dword_50A634, eax   ;eax=00565258, (ASCII "=::=::\")
  .text:004AD270                 call    GetCommandLineA ;获得指向当前命令行缓冲区的一个指针
  .text:004AD275                 mov     dword_50A630, eax ;这个指针竟然是路径,eax=00561EE0,

(ASCII ""D:\lai1\Ollydbg[1]\flyODBG\flyODBG\Ollydbg.exe"")
  .text:004AD27A                 mov     eax, [esi+30h]
  .text:004AD27D                 push    eax
  .text:004AD27E                 mov     edx, [esi+2Ch]
  .text:004AD281                 push    edx
  .text:004AD282                 call    __init_wild_handlers ;初始化其他句柄
  .text:004AD287                 add     esp, 8
  .text:004AD28A                 mov     ecx, [esi+40h]  
  .text:004AD28D                 push    ecx
  .text:004AD28E                 mov     eax, [esi+3Ch]
  .text:004AD291                 push    eax
  .text:004AD292                 mov     edx, [esi+38h]
  .text:004AD295                 push    edx
  .text:004AD296                 mov     ecx, [esi+34h]
  .text:004AD299                 push    ecx
  .text:004AD29A                 call    __init_setargv_handlers
  .text:004AD29F                 add     esp, 10h
  .text:004AD2A2                 call    sub_4AD0C0  ;竟然是eax清零
  .text:004AD2A7                 mov     edi, eax
  .text:004AD2A9                 test    eax, eax
  .text:004AD2AB                 jz      short loc_4AD2E7  ;跳走了

  .text:004AD2E7 loc_4AD2E7:                             ; CODE XREF: sub_401012+AC299j 跳到这里
  .text:004AD2E7                 push    0
  .text:004AD2E9                 push    offset dword_50A658
  .text:004AD2EE                 call    sub_4AD0C8
  .text:004AD2F3                 add     esp, 8
  .text:004AD2F6                 test    byte ptr [esi+10h], 1  ;ds:[004B00D4]=01
  .text:004AD2FA                 jz      short loc_4AD363   
  .text:004AD2FC                 mov     ebx, dword_50A630   ;ds:[0050A630]=00561EE0, (ASCII                

                        ;""D:\lai1\Ollydbg[1]\flyODBG\flyODBG\Ollydbg.exe"")
  .text:004AD302                 jmp     short loc_4AD305  ;跳走
  .text:004AD304 ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
.text:004AD304
.text:004AD304 loc_4AD304:                             ; CODE XREF: sub_401012+AC2F7j
.text:004AD304                                         ; sub_401012+AC2FBj
.text:004AD304                 inc     ebx
.text:004AD305
.text:004AD305 loc_4AD305:                             ; CODE XREF: sub_401012+AC2F0j
.text:004AD305                 mov     al, [ebx]       ;第一为"""放入al
.text:004AD307                 cmp     al, 20h
.text:004AD309                 jz      short loc_4AD304
.text:004AD30B                 cmp     al, 9
.text:004AD30D                 jz      short loc_4AD304
.text:004AD30F                 cmp     byte ptr [ebx], 22h  ;是否是"
.text:004AD312                 jnz     short loc_4AD319   ;不是则跳
.text:004AD314                 mov     dl, 22h          ;dl="
.text:004AD316                 inc     ebx              ;移到下一位
.text:004AD317                 jmp     short loc_4AD31E ;跳走
.text:004AD319 ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
.text:004AD319
.text:004AD319 loc_4AD319:                             ; CODE XREF: sub_401012+AC300j
.text:004AD319                 mov     dl, 20h
.text:004AD31B                 jmp     short loc_4AD31E
.text:004AD31D ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
.text:004AD31D
.text:004AD31D loc_4AD31D:                             ; CODE XREF: sub_401012+AC318j
.text:004AD31D                 inc     ebx
.text:004AD31E
.text:004AD31E loc_4AD31E:                             ; CODE XREF: sub_401012+AC305j
.text:004AD31E                                         ; sub_401012+AC309j
.text:004AD31E                 mov     al, [ebx]       ;逐位放入al
.text:004AD320                 test    al, al          ;是否为空
.text:004AD322                 jz      short loc_4AD32C
.text:004AD324                 cmp     dl, al          ;是否为"""
.text:004AD326                 jz      short loc_4AD32C  ;是则跳
.text:004AD328                 cmp     al, 9
.text:004AD32A                 jnz     short loc_4AD31D
.text:004AD32C
.text:004AD32C loc_4AD32C:                             ; CODE XREF: sub_401012+AC310j
.text:004AD32C                                         ; sub_401012+AC314j
.text:004AD32C                 cmp     byte ptr [ebx], 22h  ;再次比较
.text:004AD32F                 jnz     short loc_4AD335
.text:004AD331                 inc     ebx            ;移向下一位
.text:004AD332                 jmp     short loc_4AD335 ;跳走
.text:004AD334 ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
.text:004AD334
.text:004AD334 loc_4AD334:                             ; CODE XREF: sub_401012+AC32Bj
.text:004AD334                                         ; sub_401012+AC32Fj
.text:004AD334                 inc     ebx
.text:004AD335
.text:004AD335 loc_4AD335:                             ; CODE XREF: sub_401012+AC31Dj
.text:004AD335                                         ; sub_401012+AC320j
.text:004AD335                 mov     al, [ebx]       ;ds:[00561F10]=00,al=22 ('"')
.text:004AD337                 test    al, al          ;al=0
.text:004AD339                 jz      short loc_4AD33F ;跳走
.text:004AD33B                 cmp     al, 20h
.text:004AD33D                 jz      short loc_4AD334
.text:004AD33F
.text:004AD33F loc_4AD33F:                             ; CODE XREF: sub_401012+AC327j
.text:004AD33F                 cmp     al, 9
.text:004AD341                 jz      short loc_4AD334
.text:004AD343                 call    sub_4AD38C  ;获得进程信息
.text:004AD348                 push    eax
.text:004AD349                 push    ebx
.text:004AD34A                 push    0
.text:004AD34C                 push    0               ; lpModuleName
.text:004AD34E                 call    GetModuleHandleA ;获取默认句柄
.text:004AD353                 push    eax
.text:004AD354                 call    dword ptr [esi+18h]  ;这个里面就是WinMain了
.text:004AD357                 add     esp, 10h
.text:004AD35A                 push    eax             ; status
.text:004AD35B                 call    _exit          ;退出
.text:004AD360 ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
.text:004AD360                 pop     ecx
.text:004AD361                 jmp     short loc_4AD384
.text:004AD363 ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
.text:004AD363
.text:004AD363 loc_4AD363:                             ; CODE XREF: sub_401012+AC2E8j
.text:004AD363                 mov     edx, dword_50A62C
.text:004AD369                 push    edx
.text:004AD36A                 mov     ecx, dword_50A628
.text:004AD370                 push    ecx
.text:004AD371                 mov     eax, dword_50A624
.text:004AD376                 push    eax
.text:004AD377                 call    dword ptr [esi+18h]
.text:004AD37A                 add     esp, 0Ch
.text:004AD37D                 push    eax             ; status
.text:004AD37E                 call    _exit
.text:004AD383 ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
.text:004AD383                 pop     ecx
.text:004AD384
.text:004AD384 loc_4AD384:                             ; CODE XREF: sub_401012+AC34Fj
.text:004AD384                 pop     edi
.text:004AD385                 pop     esi
.text:004AD386                 pop     ebx
.text:004AD387                 mov     esp, ebp
.text:004AD389                 pop     ebp
.text:004AD38A                 retn
.text:004AD38A ; END OF FUNCTION CHUNK FOR sub_401012

总结一下上面的分析:
1、典型的C++ builder入口。
2、TlsIndex为空。
3、跳转到__startup后主要进行各种初始化工作,并且对OD路径进行检验。
4、在__startup中获得进程信息后,用call    dword ptr [esi+18h]引用主函数模块。

呵呵,没什么技术含量,这些代码谁都看得懂。
--------------------------------------------------------------------------------
【版权声明】: 本文原创于看雪技术论坛, 转载请注明作者并保持文章的完整, 谢谢!

                                                       2006年05月25日 23:36:49

[培训]《安卓高级研修班(网课)》月薪三万计划

收藏
点赞0
打赏
分享
最新回复 (2)
雪    币: 153
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
verybigbug 2006-5-26 21:34
2
0
不是对OD路径进行检验,这些是标准的CRT的入口。
雪    币: 305
活跃值: (347)
能力值: ( LV12,RANK:370 )
在线值:
发帖
回帖
粉丝
layper 9 2006-5-26 21:36
3
0
谢谢指教!!又学了一招!!呵呵
游客
登录 | 注册 方可回帖
返回