【目 标】:在DFCG里下了一个别人加壳后的CRACKME
【工 具】:OllyDbg v1.1(DIY Version)
【任 务】:不脱壳通过注入代码,破程序。
【操作平台】:Windows 2003 server
【作 者】: LOVEBOOM[DFCG][FCG][US]
【相关链接】: 自己去上网搜搜
【简要说明】: 这次挑了个别人加壳后的目标来操作,这样做可以防止我知道代码而去直接定位到相关位置进行修改。这个CrackME加上了全部的保护选项,这也算是ARM里很好的保护,我个人认为如果没有用个SDK话,这种保护是最强的了。【详细过程】: 因为之前我已经写过了一篇这样的文章,所以我这次不会写的那么详细。如果你想了解更多,可以先看看我的上一篇文章。载入目标通过copymem2的脱壳方法,可以定位到程序的关键代码,把代码改为NOP就可以破解成功。003A2AF6 90 NOP003A2AF7 90 NOP此时计算从起始位置到003a2af6处距离为:B86
记下PATCH ①为:003a2af6 重新有Copmem2脱壳的方法可以很快定位到关键代码:0041ABFA . 8945 E0 MOV DWORD PTR SS:[EBP-20],EAX0041ABFD > 837D E0 00 CMP DWORD PTR SS:[EBP-20],00041AC01 . 75 11 JNZ SHORT 0041AC14 ECX=00019C06 0041ABFA E8 014C0200 CALL 0043F800加密后为:97 96 8F 8D CA
记下PATCH ②为:41ABFA通过SetFilePointer的方法定位到:00AA0877 3341 24 XOR EAX,DWORD PTR DS:[ECX+24]00AA087A 3345 DC XOR EAX,DWORD PTR SS:[EBP-24] Stack SS:[0012D6F4]=A5989495 ;crc 值
记下CRC值:A5989495,起始处的距离为:20877记下PATCH ③为:00aa0877通过搜索定位到可以patch 3的地址,因为patch 3是动态申请和动态解压出来的代码。搜索到以下地址:00408334 |. 833D A0524400>CMP DWORD PTR DS:[4452A0],00040833B |. 0F85 54010000 JNZ 00408495
记下PATCH ④为:00408334第一个patch 点在以下代码处已经解压出来:004238C1 . 50 PUSH EAX ; |Buffer => 003A1F70004238C2 . 8B4D EC MOV ECX,DWORD PTR SS:[EBP-14] ; |004238C5 . 51 PUSH ECX ; |Address ECX==00010F3F 004238C1 - E9 7ABF0100 JMP 0043F840加密后为:33 3D 46 D8 5C 第5 个patch点已经出来了,因为这里有几次还原数据,所以要加条进行判断。
记下PATCH ⑤为:004238c0分析完,开始写代码:0043F7EE 0000 ADD BYTE PTR DS:[EAX],AL0043F7F0 0000 ADD BYTE PTR DS:[EAX],AL ; 这里保存动态申请的地址0043F7F2 0000 ADD BYTE PTR DS:[EAX],AL0043F7F4 0000 ADD BYTE PTR DS:[EAX],AL0043F7F6 0090 90909090 ADD BYTE PTR DS:[EAX+90909090],DL0043F7FC 90 NOP0043F7FD 90 NOP0043F7FE 90 NOP0043F7FF 90 NOP0043F800 50 PUSH EAX ; Patch 2 处的代码0043F801 A3 F0F74300 MOV DWORD PTR DS:[43F7F0],EAX ; 保存地址信息0043F806 B8 34834000 MOV EAX,004083340043F80B 53 PUSH EBX0043F80C BB 65F84300 MOV EBX,0043F8650043F811 2BD8 SUB EBX,EAX0043F813 83EB 05 SUB EBX,50043F816 C600 E8 MOV BYTE PTR DS:[EAX],0E8 ; 修改 patch 4的代码0043F819 8958 01 MOV DWORD PTR DS:[EAX+1],EBX0043F81C 5B POP EBX0043F81D 8D4424 04 LEA EAX,DWORD PTR SS:[ESP+4]0043F821 8328 05 SUB DWORD PTR DS:[EAX],50043F824 8B00 MOV EAX,DWORD PTR DS:[EAX] ; 还原并执行原代码0043F826 C700 8945E083 MOV DWORD PTR DS:[EAX],83E045890043F82C C640 04 7D MOV BYTE PTR DS:[EAX+4],7D0043F830 58 POP EAX0043F831 C3 RETN0043F832 90 NOP0043F833 90 NOP0043F834 90 NOP0043F835 90 NOP0043F836 90 NOP0043F837 90 NOP0043F838 90 NOP0043F839 90 NOP0043F83A 90 NOP0043F83B 90 NOP0043F83C 90 NOP0043F83D 90 NOP0043F83E 90 NOP0043F83F 90 NOP0043F840 817D EC 0010400>CMP DWORD PTR SS:[EBP-14],00401000 ; patch 5处的代码0043F847 75 0C JNZ SHORT 0043F855 ; 这里判断是否解压出patch 1的正确代码0043F849 50 PUSH EAX0043F84A 05 860B0000 ADD EAX,0B860043F84F 66:C700 9090 MOV WORD PTR DS:[EAX],9090 ; 如果代码已经完全解码了,那么patch 10043F854 58 POP EAX0043F855 50 PUSH EAX ; 执行壳代码0043F856 8B4D EC MOV ECX,DWORD PTR SS:[EBP-14]0043F859 51 PUSH ECX0043F85A - E9 6740FEFF JMP 004238C60043F85F 90 NOP0043F860 90 NOP0043F861 90 NOP0043F862 90 NOP0043F863 90 NOP0043F864 90 NOP0043F865 50 PUSH EAX ; patch 4处的代码0043F866 A1 F0F74300 MOV EAX,DWORD PTR DS:[43F7F0]0043F86B 05 77080200 ADD EAX,208770043F870 53 PUSH EBX0043F871 BB 9AF84300 MOV EBX,0043F89A ; 修改patch 30043F876 2BD8 SUB EBX,EAX0043F878 83EB 05 SUB EBX,50043F87B C600 E8 MOV BYTE PTR DS:[EAX],0E80043F87E 8958 01 MOV DWORD PTR DS:[EAX+1],EBX0043F881 5B POP EBX0043F882 8D4424 04 LEA EAX,DWORD PTR SS:[ESP+4]0043F886 8328 05 SUB DWORD PTR DS:[EAX],50043F889 8B00 MOV EAX,DWORD PTR DS:[EAX] ; 还原并执行原代码0043F88B C700 833DA052 MOV DWORD PTR DS:[EAX],52A03D830043F891 C640 04 44 MOV BYTE PTR DS:[EAX+4],440043F895 58 POP EAX0043F896 C3 RETN0043F897 90 NOP0043F898 90 NOP0043F899 90 NOP0043F89A 50 PUSH EAX ; patch 3处的代码0043F89B C745 DC 959498A>MOV DWORD PTR SS:[EBP-24],A5989495 ; 写入原CRC值0043F8A2 8D4424 04 LEA EAX,DWORD PTR SS:[ESP+4]0043F8A6 8328 05 SUB DWORD PTR DS:[EAX],50043F8A9 8B00 MOV EAX,DWORD PTR DS:[EAX]0043F8AB C700 33412433 MOV DWORD PTR DS:[EAX],33244133 ; 还原并执行原壳代码0043F8B1 C640 04 45 MOV BYTE PTR DS:[EAX+4],450043F8B5 58 POP EAX0043F8B6 C3 RETN写完后保存再运行就成功了。这篇文章写的很简单,很乱,其实这个壳的code injection也就是这么简单容易的:-)
Greetz: Fly.Jingulong,yock,tDasm.David.hexer,hmimys,ahao.UFO(brother).alan(sister).all of my friends and you!By loveboom[DFCG][FCG][US]Email:loveboom#163.comDate:2005-5-12 16:25
本文地址:http://com.8s8s.com/it/it21913.htm