[ASM] Find Kernel Base Address (XP,Vista,7 - x86, x64)

Iniciado por The Swash, 1 Mayo 2011, 18:31 PM

0 Miembros y 1 Visitante están viendo este tema.

The Swash

Código (asm) [Seleccionar]
mov eax, fs:[030h]
mov eax, [eax + 0ch]
mov eax, [eax + 0ch]
mov eax, [eax]
mov eax, [eax]
mov eax, [eax + 018h]


Bueno leyendo un poco acerca de la PEB y entendiendo como localizaban el BaseAddress de kernel32, recordé que había un código que hicieron rehicieron y mejor dicho xD, bueno ese código dejo de funcionar en 7 donde se agrego Kernelbase.dll y obligó a cambiar el código. Tras pruebas mi código se baso en buscar el orden de carga de las librerías, y ese orden se respeta desde XP hasta 7 tanto en 64 como 32 bits. ;)

Un agradecimiento a Lord, y ya implementaré un método genérico  :P.
Saludos!

[Zero]


"El Hombre, en su orgullo, creó a Dios a su imagen y semejanza.”
Nietzsche

The Swash

#2
Código genérico:
Código (asm) [Seleccionar]
.386    
.model flat, stdcall
option casemap:none
assume fs:nothing

.data
var1 db 'k',0,'e',0,'r',0,'n',0,'e',0,'l',0,'3',0,'2',0
var2 db 'K',0,'E',0,'R',0,'N',0,'E',0,'L',0,'3',0,'2',0

.code
start:
mov eax, fs:[030h]
mov eax, [eax + 0ch]
mov eax, [eax + 0ch]
xor edx, edx
mov esi, 0Fh

KERNEL:
mov eax, [eax]
mov ebx, [eax + 030h]

CMPSTR1:
mov cl, byte ptr [ebx + edx]
cmp byte ptr [offset var1 + edx], cl
jnz CMPSTR2
inc edx
cmp edx, esi
jz EXIT
jmp CMPSTR1

CMPSTR2:
mov cl, byte ptr [ebx + edx]
cmp byte ptr [offset var2 + edx], cl
jnz KERNEL
inc edx
cmp edx, esi
jz EXIT
jmp CMPSTR1

EXIT:
mov eax, [eax + 018h]

end start


Código con filtro:
Código (asm) [Seleccionar]
mov eax, fs:[030h]
mov eax, [eax + 0ch]
mov eax, [eax + 0ch]
KERNEL:
mov eax, [eax]
mov ebx, [eax + 030h]
mov ecx, 00320033h
cmp ecx, [ebx + 0ch]
JNZ KERNEL
mov eax, [eax + 018h]