[Asm] 纯文本查看 复制代码
assume fs:nothing
xor ecx,ecx
mov eax,fs:[30h]
mov eax,[eax + 0ch]
mov esi,[eax + 1ch]
next_module:
mov eax,[esi+08h]
mov edi,[esi+20h]
mov esi,[esi]
cmp [edi+12*2],cx
jnz next_module
;****************************************************************************************
mov edx,eax ;eax保存着KERNEL32基址 ,xp win7 64位通杀
mov eax,(IMAGE_DOS_HEADER ptr [edx]).e_lfanew ;得到IMAGE_NT_HEADERS地址
mov eax,(IMAGE_NT_HEADERS ptr [edx + eax]).OptionalHeader.DataDirectory.VirtualAddress ;得到导出表RVA
add eax,edx ;导出表在内存的实际地址
assume eax:ptr IMAGE_EXPORT_DIRECTORY
mov esi,[eax].AddressOfNames
add esi,edx
push 00007373h ;在堆栈中构造GetProcAddress
push 65726464h
push 41636F72h
push 50746547h
push esp
xor ecx,ecx
.repeat
mov edi,[esi]
add edi,edx
push esi
mov esi,[esp + 4]
push ecx
mov ecx,0fh ;GetProcAddress的长度,包括0
repz cmpsb
.break .if ZERO? ;找到跳出循环
pop ecx
pop esi
add esi,4
inc ecx
.until ecx >= [eax].NumberOfNames
pop ecx
mov esi,[eax].AddressOfNameOrdinals
add esi,edx
movzx ecx,word ptr [esi + ecx*2] ;取出序数
mov esi,[eax].AddressOfFunctions
assume eax:nothing
add esi,edx
mov esi,[esi + ecx*4]
add esi,edx ;得到GetProcAddress地址
mov edi,edx
push 00000000
push 41797261h ;在栈中构造LoadLibraryA
push 7262694Ch
push 64616F4Ch
push esp
push edx
call esi ;调用GetProcAddress获取LoadLibraryc地址
;mov edx,ebx
call _kernel32
db 'kernel32.dll',0
_kernel32:
pop ebx
push ebx
call eax
; mov edi,eax
call _GetPri
db 'GetPrivateProfileStringA',0
_GetPri:
pop ebx
push ebx
push eax
call esi
call _keyName
db '.\Key.ini',0
_keyName:
pop ebx
push ebx; ini名字
push 256h;缓冲区大小
call _xbuf
_xbuf:
pop ebx
add ebx,50h
push ebx;缓冲区地址
push 0
call _strLic
db 'Lic',0
_strLic:
pop ebx
push ebx ;lic存放名字
call _strName
db '授权文件',0
_strName:
pop ebx
push ebx;ini配置部分名字
call eax;Call API获取配置文件里面的key
mov eax,[esp-0Ch]
call _Callvm
nop
db 0FFh,25h,11h,22h,33h,44h;这里用来后期修改,vmp的api地址
_Callvm:
nop
pop ebx
push eax
call ebx
nop
push 00401000h ;修改为原来程序的oep地址,可以用jmp xx
retn