- UID
- 66114
注册时间2010-4-1
阅读权限30
最后登录1970-1-1
龙战于野
TA的每日心情 | 慵懒 2019-3-12 17:25 |
---|
签到天数: 3 天 [LV.2]偶尔看看I
|
本帖最后由 whypro 于 2010-5-23 13:28 编辑
由于上一篇文章太长没法缩进(懒得用鼠标!),所以另起一贴来说yC 逆着看。
其中的 call CryptFile 函数尤为重要!(因为yoda's Crypter加壳软件核心算法都在函数CryptFile中)
对应反汇编如下:
00402B1E |> \57 push edi
00402B1F |. FF75 08 push dword ptr ss:[ebp+8]
00402B22 |. 68 54104000 push yC.00401054
00402B27 |. E8 D4EBFFFF call yC.00401700
进入 call yC.00401700 后如下:
00401700 /$ 55 push ebp
00401701 |. 8BEC mov ebp,esp
00401703 |. E8 CB100000 call yC.004027D3 ; 随机种子
00401708 |. 6A 00 push 0 ; /hTemplateFile = NULL
0040170A |. 68 80000000 push 80 ; |Attributes = NORMAL
0040170F |. 6A 03 push 3 ; |Mode = OPEN_EXISTING
00401711 |. 6A 00 push 0 ; |pSecurity = NULL
00401713 |. 6A 03 push 3 ; |ShareMode = FILE_SHARE_READ|FILE_SHARE_WRITE
00401715 |. 68 000000C0 push C0000000 ; |Access = GENERIC_READ|GENERIC_WRITE
0040171A |. FF75 08 push dword ptr ss:[ebp+8] ; |FileName
0040171D |. E8 2A140000 call <jmp.&KERNEL32.CreateFileA> ; \CreateFileA
00401722 |. 83F8 FF cmp eax,-1
00401725 |. 0F84 79030000 je yC.00401AA4
0040172B |. A3 84114000 mov dword ptr ds:[401184],eax
00401730 |. 6A 00 push 0 ; /pFileSizeHigh = NULL
00401732 |. FF35 84114000 push dword ptr ds:[401184] ; |hFile = NULL
00401738 |. E8 1B140000 call <jmp.&KERNEL32.GetFileSize> ; \GetFileSize
0040173D |. 0BC0 or eax,eax
0040173F |. 75 10 jnz short yC.00401751
00401741 |. FF35 84114000 push dword ptr ds:[401184] ; /hObject = NULL
00401747 |. E8 FA130000 call <jmp.&KERNEL32.CloseHandle> ; \CloseHandle
0040174C |. E9 61030000 jmp yC.00401AB2
00401751 |> A3 68114000 mov dword ptr ds:[401168],eax
00401756 |. A1 68114000 mov eax,dword ptr ds:[401168]
0040175B |. 83C0 60 add eax,60
0040175E |. 05 E6090000 add eax,9E6
00401763 |. 0305 EC154000 add eax,dword ptr ds:[4015EC]
00401769 |. A3 6C114000 mov dword ptr ds:[40116C],eax
0040176E |. 50 push eax ; /MemSize
0040176F |. 6A 40 push 40 ; |Flags = GPTR
00401771 |. E8 F4130000 call <jmp.&KERNEL32.GlobalAlloc> ; \GlobalAlloc
00401776 |. 0BC0 or eax,eax
00401778 |. 75 10 jnz short yC.0040178A
0040177A |. FF35 84114000 push dword ptr ds:[401184] ; /hObject = NULL
00401780 |. E8 C1130000 call <jmp.&KERNEL32.CloseHandle> ; \CloseHandle
00401785 |. E9 0C030000 jmp yC.00401A96
0040178A |> A3 64114000 mov dword ptr ds:[401164],eax
0040178F |. 6A 00 push 0 ; /pOverlapped = NULL
00401791 |. 68 5C114000 push yC.0040115C ; |pBytesRead = yC.0040115C
00401796 |. FF35 68114000 push dword ptr ds:[401168] ; |BytesToRead = 0
0040179C |. FF35 64114000 push dword ptr ds:[401164] ; |Buffer = NULL
004017A2 |. FF35 84114000 push dword ptr ds:[401184] ; |hFile = NULL
004017A8 |. E8 C9130000 call <jmp.&KERNEL32.ReadFile> ; \ReadFile
对应源码为
CALL InitRandom
;----- MAP THE FILE -----
invoke CreateFile,szFname,GENERIC_WRITE + GENERIC_READ,FILE_SHARE_WRITE + FILE_SHARE_READ,\
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
cmp eax,INVALID_HANDLE_VALUE
jz FileErr
mov hFile,eax
invoke GetFileSize,hFile,0
.IF eax == 0
push hFile
call CloseHandle
jmp FsizeErr
.ENDIF
mov dwFsize,eax
mov eax,dwFsize
add eax,IT_SIZE
add eax,DEPACKER_CODE_SIZE
add eax,ALIGN_CORRECTION
mov dwOutPutSize,eax
push eax
push GMEM_FIXED + GMEM_ZEROINIT
call GlobalAlloc
.IF eax == NULL
push hFile
call CloseHandle
jmp MemErr
.ENDIF
mov pMem,eax
invoke ReadFile,hFile,pMem,dwFsize,offset dwBytesRead,NULL
下面讲解一下关键函数!
1.call yC.004027D3 函数调用了
GetTickCount 用来返回机器启动后的毫秒数,然后用变量存了起来!相当于c语言中的
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main ()
{
printf ("First number: %d\n", rand() % 100);
srand ( time(NULL) );
printf ("Random number: %d\n", rand() % 100);
srand ( 1 );
printf ("Again the first number: %d\n", rand() %100);
return 0;
}
2.CreateFile->GetFileSize->GlobalAlloc->ReadFile
总体来说这几个api就是把文件导入到内存中。 |
评分
-
查看全部评分
|