今天朋友让我帮破解一个软件,打开一看是ZP加壳的,所以就做了个教程给他看,我是用系统只带的记事本程序加壳 实例: 我们用Zprotect加壳工具给系统记事本加壳,然后用查壳工具查壳: 加壳后运行如下 需要我们注册才能运行软件,那怎么办呢?首先我们想到的就是找版主花钱注册,如果不想花钱就只能破解注册机制,由于它是用Zprotect加的壳,所以只要我们把Zprotect壳脱掉就自动破解了它的注册机制。 我们OD载入: 01015CC2 > E801000000 call NOTEPAD_.01015CC8 OD入口 01015CC7 ^ EB 87 jmp short NOTEPAD_.01015C50 01015CC9 04 24 add al,0x24 01015CCB 8D80 88F5FFFF lea eax,dword ptr ds:[eax-0xA78] 01015CD1 870424 xchg dword ptr ss:[esp],eax 01015CD4 ^ E9 76F5FFFF jmp NOTEPAD_.0101524F 01015CD9 A2 37A658E9 mov byte ptr ds:[0xE958A637],al 01015CDE BD F9FFFFB0 mov ebp,0xB0FFFFF9 01015CE3 2967 83 sub dword ptr ds:[edi-0x7D],esp 01015CE6 65:FC cld 01015CE8 00E9 add cl,ch 01015CEA ^ 7F F9 jg short NOTEPAD_.01015CE5 F9直接运行程序然后F12暂停,接着点OD上面的K键如下: 77D56D7D > 8BFF mov edi,edi 来到这里F2下断点 77D56D7F 55 push ebp 77D56D80 8BEC mov ebp,esp 77D56D82 6A 02 push 0x2 77D56D84 FF75 18 push dword ptr ss:[ebp+0x18] 77D56D87 FF75 14 push dword ptr ss:[ebp+0x14] 77D56D8A FF75 10 push dword ptr ss:[ebp+0x10] 77D56D8D FF75 0C push dword ptr ss:[ebp+0xC] 77D56D90 FF75 08 push dword ptr ss:[ebp+0x8] 77D56D93 E8 38DCFCFF calluser32.DialogBoxIndirectParamAorW 77D56D98 5D pop ebp ;user32.77D19418 77D56D99 C2 1400 retn 0x14 重载程序运行: 01015CC2 > E8 01000000 call NOTEPAD_.01015CC8 F7步进 01015CC7 ^ EB 87 jmp short NOTEPAD_.01015C50 01015CC9 04 24 add al,0x24 01015CCB 8D80 88F5FFFF lea eax,dword ptr ds:[eax-0xA78] 01015CD1 870424 xchg dword ptr ss:[esp],eax 01015CD4 ^ E9 76F5FFFF jmp NOTEPAD_.0101524F 01015CC8 870424 xchg dword ptr ss:[esp],eax 来到这里接着F8单步 01015CCB 8D80 88F5FFFF lea eax,dword ptr ds:[eax-0xA78] 01015CD1 870424 xchg dword ptr ss:[esp],eax 01015CD4 ^ E9 76F5FFFF jmp NOTEPAD_.0101524F 01015CD9 A2 37A658E9 mov byte ptr ds:[0xE958A637],al 01015CDE BD F9FFFFB0 mov ebp,0xB0FFFFF9 01015CE3 2967 83 sub dword ptr ds:[edi-0x7D],esp 0101524F 60 pushad 接着F8单步 01015250 E9 B6060000 jmp NOTEPAD_.0101590B 在这里我们下ESP定律 01015255 8361 93 89 and dword ptr ds:[ecx-0x6D],-0x77 01015259 45 inc ebp F9运行: 0087C7E8 ^\E9 84A0FFFF jmp 00876871 F8单步 0087C7ED AF scas dword ptr es:[edi] 0087C7EE 3AB3 7053E802 cmp dh,byte ptr ds:[ebx+0x2E85370] 00876871 C3 retn 这里F8单步就返回到程序OEP地址了 00876872 E9 03670000 jmp 0087CF7A 00876877 8122 FFFFFF9F and dword ptr ds:[edx],0x9FFFFFFF 0100739D 6A db 6A ; CHAR 'j' 0100739E 70 db 70 ; CHAR 'p' 0100739F 68 db 68 ; CHAR 'h' 010073A0 98 db 98 010073A1 18 db 18 010073A2 00 db 00 010073A3 01 db 01 010073A4 E8 db E8 010073A5 BF db BF 010073A6 01 db 01 010073A7 00 db 00 010073A8 00 db 00 010073A9 33 db 33 ; CHAR '3' 010073AA DB db DB 如果出现这种情况就在OD里面右键—分析—从模块中删除分析 0100739D 6A 70 push 0x70 这里就是程序的OEP地址(记录下这个地址一会有用) 0100739F 68 98180001 push NOTEPAD_.01001898 010073A4 E8 BF010000 call NOTEPAD_.01007568 010073A9 33DB xor ebx,ebx 010073AB 53 push ebx 010073AC 8B3D CC100001 mov edi,dword ptr ds:[0x10010CC] ; NOTEPAD_.01014240 010073B2 FFD7 call edi 010073B4 66:8138 4D5A cmp word ptr ds:[eax],0x5A4D 010073B9 75 1F jnz short NOTEPAD_.010073DA OEP地址:0100739D Zprotect壳对IAT进行了加密,所以现在我们需要找IAT启始位置和结束位置 Ctrl+B 二进制查找FF15或FF25 这样我们就得到IAT的地址 iat 起始地址 :01001000 iat 结束地址: :01001344 然后查找 0100739D 6A 70 push 0x70 0100739F 68 98180001 push NOTEPAD_.01001898 010073A4 E8 BF010000 callNOTEPAD_.01007568 010073A9 33DB xor ebx,ebx 010073AB 53 push ebx 010073AC 8B3D CC100001 mov edi,dword ptr ds:[0x10010CC] ; NOTEPAD_.01014240 010073B2 FFD7 call edi 010073B4 66:8138 4D5A cmp word ptr ds:[eax],0x5A4D 010073B9 75 1F jnz short NOTEPAD_.010073DA 010073BB 8B48 3C mov ecx,dword ptr ds:[eax+0x3C] 010073BE 03C8 add ecx,eax 010073C0 8139 50450000 cmp dword ptr ds:[ecx],0x4550 010073C6 75 12 jnz short NOTEPAD_.010073DA 010073C8 0FB741 18 movzx eax,word ptr ds:[ecx+0x18] 010073CC 3D 0B010000 cmp eax,0x10B 010073D1 74 1F je short NOTEPAD_.010073F2 010073D3 3D 0B020000 cmp eax,0x20B 010073D8 74 05 je short NOTEPAD_.010073DF 010073DA 895D E4 mov dword ptr ss:[ebp-0x1C],ebx 010073DD EB 27 jmp short NOTEPAD_.01007406 010073DF 83B9 84000000 0>cmp dword ptrds:[ecx+0x84],0xE 010073E6 ^ 76 F2 jbe short NOTEPAD_.010073DA 010073E8 33C0 xor eax,eax 010073EA 3999 F8000000 cmp dword ptr ds:[ecx+0xF8],ebx 010073F0 EB 0E jmp short NOTEPAD_.01007400 010073F2 8379 74 0E cmp dword ptr ds:[ecx+0x74],0xE 010073F6 ^ 76 E2 jbe short NOTEPAD_.010073DA 010073F8 33C0 xor eax,eax 010073FA 3999 E8000000 cmp dword ptr ds:[ecx+0xE8],ebx 01007400 0F95C0 setne al 01007403 8945 E4 mov dword ptr ss:[ebp-0x1C],eax 01007406 895D FC mov dword ptr ss:[ebp-0x4],ebx 01007409 6A 02 push 0x2 0100740B FF15 38130001 call dword ptr ds:[0x1001338] 这里右键跟随 ; 010140B4 68 22DD9028 push 0x2890DD22 010140B9 E9 86060000 jmp NOTEPAD_.01014744 这里右键跟随 010140BE A8 2C test al,0x2C 01014744 - E9 F3E083FF jmp 0085283C 这里右键跟随 01014749 1000 adc byte ptr ds:[eax],al 0101474B 0063 00 add byte ptr ds:[ebx],ah 0085283C 60 pushad 0085283D FF7424 20 push dword ptr ss:[esp+0x20] ; kernel32.7C839AB0 00852841 E8 DCF8FFFF call 00852122 这里右键跟随 00852846 61 popad 00852847 C3 retn 00852122 A1 44668500 mov eax,dword ptr ds:[0x856644] 00852127 8078 34 00 cmp byte ptr ds:[eax+0x34],0x0 0085212B 74 57 je short 00852184 0085212D FF15 E8108400 call dword ptr ds:[0x8410E8] ; kernel32.GetTickCount 00852133 8BC8 mov ecx,eax 00852135 2B0D 10658500 sub ecx,dword ptr ds:[0x856510] 0085213B 81F9 88130000 cmp ecx,0x1388 00852141 76 41 jbe short 00852184 00852143 FF35 14658500 push dword ptr ds:[0x856514] 00852149 A3 10658500 mov dword ptr ds:[0x856510],eax 0085214E FF15 58108400 call dword ptr ds:[0x841058] ; kernel32.ResumeThread 00852154 833D 9C6C8500 0>cmp dword ptrds:[0x856C9C],0x3 0085215B 7C 08 jl short 00852165 0085215D 6A 00 push 0x0 0085215F FF15EC108400 call dword ptrds:[0x8410EC] ;kernel32.ExitProcess 00852165 803D 90668500 0>cmp byte ptrds:[0x856690],0x0 0085216C 74 08 je short 00852176 0085216E FF05 9C6C8500 inc dword ptr ds:[0x856C9C] 00852174 EB 07 jmp short 0085217D 00852176 8325 9C6C8500 0>and dword ptrds:[0x856C9C],0x0 0085217D C605 90668500 0>mov byte ptrds:[0x856690],0x1 00852184 56 push esi 00852185 FF7424 08 push dword ptr ss:[esp+0x8] 00852189 FF152C658500 call dword ptr ds:[0x85652C] 记录下这个地址 0085218F 8BF0 mov esi,eax 00852191 A1 646C8500 mov eax,dword ptr ds:[0x856C64] 00852196 2B05 606C8500 sub eax,dword ptr ds:[0x856C60] 0085219C C1F8 02 sar eax,0x2 call dword ptrds:[0x85652C] 二进制黏贴如下代码: B8 00 30 47 00 8B 1883 FB 00 74 36 80 3B 68 75 40 8B 4B 01 50 51 FF 15 2C 65 B4 00 8B F0 A1 64 6CB4 00 2B 05 60 6C B4 00 C1 F8 02 3B F0 72 05 E8 E9 6A 8E FF A1 60 6C B4 00 8B04 B0 5F 57 89 07 58 83 C0 04 3D F4 36 47 00 72 B9 E9 74 39 49 FF 66 81 3B 5060 75 EA 80 7B 02 68 75 E4 8B 4B 03 EB B1 修改后如下如下: 01007604 B8 00100001 mov eax,NOTEPAD_.01001000 这里修改IAT起始地址,并新建EIP 01007609 8B18 mov ebx,dword ptr ds:[eax] 0100760B 83FB 00 cmp ebx,0x0 0100760E 74 36 je short NOTEPAD_.01007646 01007610 803B 68 cmp byte ptr ds:[ebx],0x68 01007613 75 40 jnz short NOTEPAD_.01007655 01007615 8B4B 01 mov ecx,dword ptr ds:[ebx+0x1] 01007618 50 push eax 01007619 51 push ecx 0100761A FF15 2C658500 call dword ptr ds:[0x85652C] 这里修改CALL的数值 01007620 8BF0 mov esi,eax 01007622 A1 646C8500 mov eax,dword ptr ds:[0x856C64] 这里修改CALL的数值 01007627 2B05 606C8500 sub eax,dword ptr ds:[0x856C60] 这里修改CALL的数值 0100762D C1F8 02 sar eax,0x2 01007630 3BF0 cmp esi,eax 01007632 72 05 jb short NOTEPAD_.01007639 01007634 E8 E96A8EFF call 008EE122 01007639 A1 606C8500 mov eax,dword ptr ds:[0x856C60] 这里修改CALL的数值 0100763E 8B04B0 mov eax,dword ptr ds:[eax+esi*4] 01007641 5F pop edi ;kernel32.7C81776F 01007642 57 push edi 01007643 8907 mov dword ptr ds:[edi],eax 01007645 58 pop eax ;kernel32.7C81776F 01007646 83C0 04 add eax,0x4 01007649 3D 44130001 cmp eax,NOTEPAD_.01001344 这里修改IAT结束地址 0100764E ^ 72 B9 jb short NOTEPAD_.01007609 01007650 ^ E9 48FDFFFF jmp NOTEPAD_.010073 这里修改OEP地址 并下F2断点 01007655 66:813B 5060 cmp word ptr ds:[ebx],0x6050 0100765A ^ 75 EA jnz short NOTEPAD_.01007646 0100765C 807B 02 68 cmp byte ptr ds:[ebx+0x2],0x68 01007660 ^ 75 E4 jnz short NOTEPAD_.01007646 01007662 8B4B 03 mov ecx,dword ptr ds:[ebx+0x3] 01007665 ^ EB B1 jmp short NOTEPAD_.01007618 注意:CALL地址只取前2位数值替换如: 0100761A FF15 2C65B400 call dword ptr ds:[0xB4652C] 替换为: 0100761A FF15 2C658500 call dword ptr ds:[0x85652C] 全部修改好后,删除除(01007650)外所有断点,F9运行 01007650 ^ E9 48FDFFFF jmp NOTEPAD_.010073 断在这里,然后单步到OEP 0100739D 6A 70 push 0x70 到这里就是全部解密完成的OEP 0100739F 68 98180001 push NOTEPAD_.01001898 010073A4 E8 BF010000 call NOTEPAD_.01007568 010073A9 33DB xor ebx,ebx ;NOTEPAD_.010143B4 010073AB 53 push ebx ;NOTEPAD_.010143B4 010073AC 8B3D CC100001 mov edi,dword ptr ds:[0x10010CC] ; kernel32.GetModuleHandleA 010073B2 FFD7 call edi ;NOTEPAD_.01001340 010073B4 66:8138 4D5A cmp word ptr ds:[eax],0x5A4D 010073B9 75 1F jnz short NOTEPAD_.010073DA 然后进行脱壳,运行程序,发现不会再提示注册框了,到此ZP壳就算完全脱壳结束 欢迎大家关注我的微信公众平台,让我们在这里一起交流学习 微信公众平台:XKLW8071
|