Die Überschrift sollte alles sagen, hier mal kurz meine vorgehensweise:
1. Aktuelle Position im Speicher finden. (delta offset)
2. kernel32.dll ImageBase Adresse finden.
3. Und dann finde ich die Funktionsadressen (scanning Export Directory Table).
und hier die Funktion die APIs findet:
Wie schaffe ich es code- UND datensegment in den Adressraum der kernel32.dll jedes Processes zu laden ?
Nen codeschnipsel würd mich freuen...
1. Aktuelle Position im Speicher finden. (delta offset)
2. kernel32.dll ImageBase Adresse finden.
3. Und dann finde ich die Funktionsadressen (scanning Export Directory Table).
Code:
;find kernel32.dll image base address. * * *xor * * * *eax, eax * * * * * * * * * * * * * * * *ASSUME * * FS:NOTHING * *mov * * eax,fs:[eax+30h] * * * * * * * * * *test * *eax,eax * * * * * * * * * * * * * * * *js * * * * __kernel_9X * * * * * * * * * * * * __kernel_NT: * *mov * * eax,[eax+0Ch] * * * * * * * * * * * *mov * * esi,[eax+1Ch] * * * * * * * * * * * *lodsd * * * * * * * * * * * * * * * * * * * *mov * * eax,[eax+8h] * * * * * * * * * * * *jmp * * __kernel_finish * * * * * * * * __kernel_9X: * *mov * * * *byte ptr[ebx+winNT], 0 *;we are at a win9X machine * *mov * * eax, [eax+34h] * *lea * * eax, [eax+7Ch] * *mov * * eax, [eax+3Ch] * * * * * * * * __kernel_finish: *; EAX == kernel32.dll image base address
Code:
GetFuncAddr PROC ;search for function address by scannig Export Directory Table. pushad mov ebp, [esp+28h] mov eax, [ebp+3Ch] mov edx, [ebp+eax+78h] add edx, ebp mov ecx, [edx+18h] mov ebx, [edx+20h] add ebx, ebp GFA_loop: jecxz GFA_notfound dec ecx mov esi, [ebx+ecx*4] add esi, ebp GFA_compute_hash: xor edi, edi xor eax, eax cld GFA_compute_hash_again: lodsb test al, al jz GFA_compute_hash_finished ror edi, 0Dh add edi, eax jmp GFA_compute_hash_again GFA_compute_hash_finished: GFA_compare: cmp edi, [esp+24h] jnz GFA_loop mov ebx, [edx+24h] add ebx, ebp mov cx, [ebx+2*ecx] mov ebx, [edx+1Ch] add ebx, ebp mov eax, [ebx+4*ecx] add eax, ebp mov [esp+1Ch], eax GFA_finish: popad ret 8 GFA_notfound: xor eax,eax mov [esp+1Ch], eax jmp GFA_finish GetFuncAddr ENDP
Nen codeschnipsel würd mich freuen...