补充
ACProtect V1.21专业版主程序的修复
偶的《ACProtect V1.21专业版主程序的脱壳》一文,想必大家都已经看过了。
有人可能会问:为什么有2个函数修复不了?而且也没有去修复呢?这里我将要告诉大家为什么。
1.消除代码替换暗桩(即ACPr中的Code Replace)
用W32Dasm打开dump出来的文件反汇编,然后搜索call 006(壳的代码位于006d4000以上) 就会发现许多代码暗桩都是call 006d540c,为此经过分析该段代码后修改如下:
006D540C push ebp
006D540D mov ebp,esp
006D540F pushad
006D5410 mov esi,006D56E2
006D5415 mov ebx,dword ptr ss:[ebp+4]
006D5418 xor ecx,ecx
006D541A lods dword ptr ds:[esi]
006D541B add eax,00400000
006D5420 cmp eax,ebx
006D5422 nop
006D5423 nop
006D5424 je short Acp.006D542C
006D5426 inc ecx
006D5427 jmp 006D541A
006D542C mov edi,006D85C2
006D5431 mov eax,0A
006D5436 mul ecx
006D5438 add edi,eax
006D543A mov ecx,0A
006D543F mov al,byte ptr ds:[edi]
006D5441 xor al,6D
006D5443 stos byte ptr es:[edi]
006D5444 loopd short 006D543F
006D5446 sub edi,0A
006D5449 mov dword ptr ds:[06d4000],edi
006D544F sub edi,ebx
006D5451 mov dword ptr ds:[ebx-4],edi
006D5454 popad
006D5455 pop ebp
006D5456 jmp dword ptr ds:[06d4000]
偶本想写段代码直接把原来的代码还原到CALL的位置,因为长度都是5字节,但由于要用反汇编识别垃圾代码比较麻烦所以作摆。
2.跨平台问题
经过第一步修复,虽然在你dump时的操作系统下可以运行,但不能跨平台。比如偶的在win2k下运行没问题,但是到win98出错。于是再次进行跟踪分析,原来存在数据暗桩即共享壳中数据。原理是:在壳中对部分API函数取地址并在前面加标示识别,然后在主程序中通过搜索标示找到该部分函数的地址再进行调用。由于脱壳后,API地址仍然是原来的没有随着系统的变化而变化所以出错。该段取API地址代码位于壳06e369a处,现修改如下:
006E369A call 006E1460
006E369F lea eax,dword ptr ss:[ebp+40D5E7]
006E36A5 mov ebx,eax
006E36A7 push eax
006E36A8 push eax
006E36A9 jmp 006E36C0
006E36AB nop
006E36AC nop
006E36AD nop
006E36AE nop
006E36AF nop
006E36B0 nop
006E36B1 nop
006E36B2 nop
006E36B3 nop
006E36B4 nop
006E36B5 nop
006E36B6 nop
006E36B7 nop
006E36B8 nop
006E36B9 nop
006E36BA nop
006E36BB nop
006E36BC nop
006E36BD nop
006E36BE nop
006E36BF nop
006E36C0 pop eax ;
006E36C1 call dword ptr ds:[691194]
006E36C7 jmp 006E36E0
006E36C9 nop
006E36CA nop
006E36CB nop
......
006E36E0 or eax,eax
006E36E2 jnz 006E3721
006E36E4 retn
006E36E5 nop
006E36E6 nop
006E36E7 nop
......
006E3721 mov ebx,eax
006E3723 mov dword ptr ss:[ebp+4023F0],eax
006E3729 mov eax,0040D5F4
006E372E mov edx,0040D763
006E3733 call 006E148A
006E3738 mov eax,0040D600
006E373D mov edx,0040D767
006E3742 call 006E148A
006E3747 mov eax,0040D60B
006E374C mov edx,0040D77B
006E3751 call 006E148A
006E3756 mov eax,0040D61F
006E375B mov edx,0040D77F
006E3760 call 006E148A
006E3765 mov eax,0040D638
006E376A mov edx,0040D783
006E376F call 006E148A
006E3774 mov eax,0040D647
006E3779 mov edx,0040D787
006E377E call 006E148A
006E3783 mov eax,0040D655
006E3788 mov edx,0040D78B
006E378D call 006E148A
006E3792 mov eax,0040D661
006E3797 mov edx,0040D78F
006E379C call 006E148A
006E37A1 mov eax,Acp.0040D66D
006E37A6 mov edx,Acp.0040D793
006E37AB call Acp.006E148A
006E37B0 mov eax,Acp.0040D67E
006E37B5 mov edx,Acp.0040D7AB
006E37BA call Acp.006E148A
006E37BF mov eax,Acp.0040D690
006E37C4 mov edx,Acp.0040D7AF
006E37C9 call Acp.006E148A
006E37CE mov eax,Acp.0040D69C
006E37D3 mov edx,Acp.0040D7B3
006E37D8 call Acp.006E148A
006E37DD mov eax,Acp.0040D6A5
006E37E2 mov edx,Acp.0040D7B7
006E37E7 call Acp.006E148A
006E37EC mov eax,Acp.0040D6AF
006E37F1 mov edx,Acp.0040D7BB
006E37F6 call Acp.006E148A
006E37FB mov eax,Acp.0040D6BB
006E3800 mov edx,Acp.0040D7BF
006E3805 call Acp.006E148A
006E380A mov eax,Acp.0040D6C8
006E380F mov edx,Acp.0040D7C3
006E3814 call Acp.006E148A
006E3819 mov eax,Acp.0040D6E1
006E381E mov edx,Acp.0040D7CB
006E3823 call Acp.006E148A
006E3828 mov eax,Acp.0040D6F2
006E382D mov edx,Acp.0040D7CF
006E3832 call Acp.006E148A
006E3837 mov eax,Acp.0040D703
006E383C mov edx,Acp.0040D7D3
006E3841 call Acp.006E148A
006E3846 mov eax,Acp.0040D803
006E384B mov edx,Acp.0040D7FF
006E3850 call Acp.006E148A
006E3855 lea eax,dword ptr ss:[ebp+40D714]
006E385B mov ebx,eax
006E385D push eax
006E385E push eax
006E385F nop
006E3860 nop
006E3861 nop
006E3862 nop
006E3863 nop
006E3864 nop
006E3865 nop
006E3866 nop
006E3867 nop
006E3868 nop
006E3869 nop
006E386A nop
006E386B nop
006E386C nop
006E386D nop
006E386E nop
006E386F nop
006E3870 nop
006E3871 nop
006E3872 nop
006E3873 nop
006E3874 nop
006E3875 nop
006E3876 pop eax
006E3877 call dword ptr ds:[691194]
006E387D jmp short Acp.006E3896
006E387F nop
006E3880 nop
006E3881 nop
......
006E3896 or eax,eax
006E3898 jnz short Acp.006E38D7
006E389A retn
006E389B nop
006E389C nop
006E389D nop
......
006E38D7 mov ebx,eax
006E38D9 mov dword ptr ss:[ebp+4023F4],eax
006E38DF mov eax,Acp.0040D71F
006E38E4 mov edx,Acp.0040D76B
006E38E9 call Acp.006E148A
006E38EE mov eax,Acp.0040D72B
006E38F3 mov edx,Acp.0040D76F
006E38F8 call Acp.006E148A
006E38FD mov eax,Acp.0040D73A
006E3902 mov edx,Acp.0040D773
006E3907 call Acp.006E148A
006E390C mov eax,Acp.0040D748
006E3911 mov edx,Acp.0040D777
006E3916 call Acp.006E148A
006E391B retn
006E148A push ebx
006E148B push eax
006E148C push edx
006E148D add eax,ebp
006E148F push eax
006E1490 push ebx
006E1491 push eax
006E1492 mov eax,dword ptr ss:[ebp+41A614]
006E1498 nop
006E1499 nop
006E149A nop
006E149B nop
006E149C nop
006E149D nop
006E149E nop
006E149F nop
006E14A0 nop
006E14A1 nop
006E14A2 nop
006E14A3 nop
006E14A4 nop
006E14A5 nop
006E14A6 nop
006E14A7 nop
006E14A8 nop
006E14A9 pop eax ;
006E14AA call dword ptr ds:[691190]
006E14B0 jmp short Acp.006E14C9
006E14B2 nop
006E14B3 nop
006E14B4 nop
......
006E14C9 pop edx
006E14CA mov dword ptr ss:[ebp+edx],eax
006E14CE pop eax ;
006E14CF pop ebx ;
006E14D0 retn
3.调用壳SDK的修复
在IAT修复时有2个函数没有修复,这2个函数都是指向MessageBoxA,看ACPr说明原来用作SDK接口。
程序对该函数调用相应也是2处:00407830和00407838.都指向壳代码006e084d.如果不修复直接指向原来的USer32.dll那么主程序总是显示未注册版而且对程序加壳后也显示未注册,很不爽。偶在6d4010处写入不分代码,然后修改407830和407838代码跳转到006d4010:
00407830:jmp 006d4010
00407838:jmp 006d4010
006D4010 cmp dword ptr ss:[esp+4],-1
006D4015 jnz 006D4023
006D4017 cmp dword ptr ss:[esp+8],0
006D401C je 006D4023
006D401E jmp 006E084D
006D4023 jmp dword ptr ds:[691588] ;JMP到user32.MessageBoxA
这样处理后只能算基本可以了。但还是有点问题,由于要浪费很多时间就不进一步处理了。
4.部分数据校验:
主程序的入口必须是2D4000
IMAGESIZE必须是:2F537A
因为数据校验代码部分是动态还原后执行的,不便修改该部分代码。
入口代码:
006D4000:PUSHAD
CALL 006E369A
POPAD
JMP 004CC210
