elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Ingresar Registrarse
29 Agosto 2008, 23:07  



  Mostrar Mensajes
Páginas: 1 [2] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... 123
16  Programación / Programación C/C++ / Re: Hook DeviceIoControl en: 15 Julio 2008, 00:35
Te paso un codigo de un Sniffer que hice para para IOCTL's, hookea ZwDeviceIoControlFile (Comunicación con el driver) y la API ZwCreateFile (Para establecer contacto).

Código
#include "ntddk.h"
 
#pragma pack(1)
typedef struct ServiceDescriptorEntry {
       unsigned int *ServiceTableBase;
       unsigned int *ServiceCounterTableBase;
       unsigned int NumberOfServices;
       unsigned char *ParamTableBase;
} ServiceDescriptorTableEntry_t, *PServiceDescriptorTableEntry_t;
#pragma pack()
 
__declspec(dllimport)  ServiceDescriptorTableEntry_t KeServiceDescriptorTable;
#define SYSTEMSERVICE(_function)  KeServiceDescriptorTable.ServiceTableBase[ *(PULONG)((PUCHAR)_function+1)]
 
UNICODE_STRING  Dev,lnk;
 
PMDL  g_pmdlSystemCall;
PVOID *MappedSystemCallTable;
#define SYSCALL_INDEX(_Function) *(PULONG)((PUCHAR)_Function+1)
#define HOOK_SYSCALL(_Function, _Hook, _Orig )  \
      _Orig = (PVOID) InterlockedExchange( (PLONG) &MappedSystemCallTable[SYSCALL_INDEX(_Function)], (LONG) _Hook)
 
#define UNHOOK_SYSCALL(_Function, _Hook, _Orig )  \
      InterlockedExchange( (PLONG) &MappedSystemCallTable[SYSCALL_INDEX(_Function)], (LONG) _Hook)
 
NTSYSAPI NTSTATUS NTAPI ZwDeviceIoControlFile(IN HANDLE  FileHandle,IN HANDLE  Event,IN PIO_APC_ROUTINE  ApcRoutine,IN PVOID  ApcContext,OUT PIO_STATUS_BLOCK  IoStatusBlock,IN ULONG  IoControlCode,IN PVOID  InputBuffer,IN ULONG  InputBufferLength,OUT PVOID  OutputBuffer,IN ULONG  OutputBufferLength);
NTSYSAPI NTSTATUS NTAPI ZwCreateFile(OUT PHANDLE  FileHandle,IN ACCESS_MASK  DesiredAccess,IN POBJECT_ATTRIBUTES  ObjectAttributes,OUT PIO_STATUS_BLOCK  IoStatusBlock,IN PLARGE_INTEGER  AllocationSize  OPTIONAL,IN ULONG  FileAttributes,IN ULONG  ShareAccess,IN ULONG  CreateDisposition,IN ULONG  CreateOptions,IN PVOID  EaBuffer  OPTIONAL,IN ULONG  EaLength);
 
typedef NTSTATUS (*typeZwDeviceIoControlFile)(IN HANDLE  FileHandle,IN HANDLE  Event,IN PIO_APC_ROUTINE  ApcRoutine,IN PVOID  ApcContext,OUT PIO_STATUS_BLOCK  IoStatusBlock,IN ULONG  IoControlCode,IN PVOID  InputBuffer,IN ULONG  InputBufferLength,OUT PVOID  OutputBuffer,IN ULONG  OutputBufferLength);
typedef NTSTATUS (*typeZwCreateFile)(OUT PHANDLE  FileHandle,IN ACCESS_MASK  DesiredAccess,IN POBJECT_ATTRIBUTES  ObjectAttributes,OUT PIO_STATUS_BLOCK  IoStatusBlock,IN PLARGE_INTEGER  AllocationSize  OPTIONAL,IN ULONG  FileAttributes,IN ULONG  ShareAccess,IN ULONG  CreateDisposition,IN ULONG  CreateOptions,IN PVOID  EaBuffer  OPTIONAL,IN ULONG  EaLength);
 
typeZwDeviceIoControlFile ZwDeviceIoControlFileIni;
typeZwCreateFile ZwCreateFileIni;
 
 
NTSTATUS ZwDeviceIoControlFileRep(IN HANDLE  FileHandle,IN HANDLE  Event,IN PIO_APC_ROUTINE  ApcRoutine,IN PVOID  ApcContext,OUT PIO_STATUS_BLOCK  IoStatusBlock,IN ULONG  IoControlCode,IN PVOID  InputBuffer,IN ULONG  InputBufferLength,OUT PVOID  OutputBuffer,IN ULONG  OutputBufferLength)
{
 
  NTSTATUS ntStatus;
  HANDLE pid;
  int PID;
  int e;
 
  pid = PsGetCurrentProcessId();
  PID = (int)pid;
  DbgPrint("---------------------------------");
  DbgPrint("Hook DeviceIoControl");
  DbgPrint("Aplicacion que lo llama: %i",PID);
  DbgPrint("Handle: 0%x",FileHandle);
  DbgPrint("IoControlCode: %i",IoControlCode);
  DbgPrint("Parametros: %s (0x%x)",&InputBuffer,InputBuffer);
  DbgPrint("Longitud: %i",InputBufferLength);
  DbgPrint("---------------------------------");
 
  ntStatus = ((typeZwDeviceIoControlFile)(ZwDeviceIoControlFileIni)) (FileHandle,Event,ApcRoutine,ApcContext,IoStatusBlock,IoControlCode,InputBuffer,InputBufferLength,OutputBuffer,OutputBufferLength);
  return ntStatus;
}
 
NTSTATUS ZwCreateFileRep(OUT PHANDLE  FileHandle,IN ACCESS_MASK  DesiredAccess,IN POBJECT_ATTRIBUTES  ObjectAttributes,OUT PIO_STATUS_BLOCK  IoStatusBlock,IN PLARGE_INTEGER  AllocationSize  OPTIONAL,IN ULONG  FileAttributes,IN ULONG  ShareAccess,IN ULONG  CreateDisposition,IN ULONG  CreateOptions,IN PVOID  EaBuffer  OPTIONAL,IN ULONG  EaLength)
{
NTSTATUS ntStatus;
ANSI_STRING strf;
HANDLE pid;
   int PID;
 
RtlUnicodeStringToAnsiString(&strf,ObjectAttributes->ObjectName,TRUE);
   pid = PsGetCurrentProcessId();
   PID = (int)pid;
   DbgPrint("---------------------------------");
   DbgPrint("Hook CreateFile");
   DbgPrint("Aplicacion que lo llama: %i",PID);
DbgPrint("Archivo: %s",strf.Buffer);
DbgPrint("---------------------------------");
 
ntStatus = ((typeZwCreateFile)(ZwCreateFileIni))(FileHandle,DesiredAccess,ObjectAttributes,IoStatusBlock, AllocationSize,FileAttributes, ShareAccess, CreateDisposition, CreateOptions, EaBuffer, EaLength);
return ntStatus;
 
 
 
}
 
VOID OnUnload(IN PDRIVER_OBJECT DriverObject)
{
  DbgPrint("Descargando driver...");
 
  UNHOOK_SYSCALL(ZwDeviceIoControlFile, ZwDeviceIoControlFileIni, ZwDeviceIoControlFileRep);
  UNHOOK_SYSCALL(ZwCreateFile, ZwCreateFileIni, ZwCreateFileRep);
  if(g_pmdlSystemCall)
  {
     MmUnmapLockedPages(MappedSystemCallTable, g_pmdlSystemCall);
     IoFreeMdl(g_pmdlSystemCall);
  }
}
 
 
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING theRegistryPath)
{
   NTSTATUS s = STATUS_SUCCESS;
 
DriverObject->DriverUnload=OnUnload;
DbgPrint("+++++++++++++++++++++++++++++");
DbgPrint("+     IOCTL Sniffer         +");
DbgPrint("+       By Hendrix          +");
DbgPrint("++++++++++++++++++++++++++++");
 
 
  ZwDeviceIoControlFileIni =(typeZwDeviceIoControlFile)(SYSTEMSERVICE(ZwDeviceIoControlFile));
 
  g_pmdlSystemCall = MmCreateMdl(NULL, KeServiceDescriptorTable.ServiceTableBase, KeServiceDescriptorTable.NumberOfServices*4);
  if(!g_pmdlSystemCall)
     return STATUS_UNSUCCESSFUL;
 
  MmBuildMdlForNonPagedPool(g_pmdlSystemCall);
 
  g_pmdlSystemCall->MdlFlags = g_pmdlSystemCall->MdlFlags | MDL_MAPPED_TO_SYSTEM_VA;
 
  MappedSystemCallTable = MmMapLockedPages(g_pmdlSystemCall, KernelMode);
 
  HOOK_SYSCALL(ZwDeviceIoControlFile, ZwDeviceIoControlFileRep, ZwDeviceIoControlFileIni);
  HOOK_SYSCALL(ZwCreateFile, ZwCreateFileRep, ZwCreateFileIni);
 
  return s;
}

Si alguien se anima a crearle una GUI que me avise  :D
17  Seguridad Informática / Análisis y Diseño de Malware / Re: Anti sXe en: 14 Julio 2008, 23:21
Confirmado, reparando la SYSENTER el sXe ni se cosca, puedo reparar la SSDT sin que cante, pero el sistema se vuelve inestable (al presionar Ctrl+Alt+Sup me sale un error, al ir a inicio/Ejecutar, escribo notepad y a veces me da error, otas sale con apariencia de 9x y otras me funciona). En fin, no se porque se me vuelve inestable, si alguien consigue sacar algo de porque se vuelve inestable que lo exponga  ;)

Un Saludo  :)
18  Seguridad Informática / Análisis y Diseño de Malware / Re: Anti sXe en: 14 Julio 2008, 19:31
Cuando tengas codigo postealo/pasalo  ;)

El driver con el que hago pruebas no lo e posteado, el del post solo deshookea un api de la SSDT para petar el sXe.

Un Saludo  :)
19  Seguridad Informática / Análisis y Diseño de Malware / Re: Anti sXe en: 14 Julio 2008, 18:34
Los ejemplos que e visto sobre SYSENTER funcionan con un jmp y no con un call, asi que supongo que sera con un jmp.

Lo de inestable tambien me pasa cuando lo restauro con el RU  :-\
20  Seguridad Informática / Análisis y Diseño de Malware / Re: Anti sXe en: 14 Julio 2008, 13:56
Mek, haber si me lo puedes mirar, con el RU deshookeo el hook a SYSENTER y al hacerlo el PC se me vuelve "loco", el firefox no me habre webs, ni me deja terminar procesos, etc.

Eliminando el hook a SYSENTER puedo deshabilitar todo el sXe sin que se queje.

Un Saludo  :)
21  Seguridad Informática / Análisis y Diseño de Malware / Re: Falsificar process id en: 14 Julio 2008, 08:08
Se podria sacar desde la eprocess, cojes la eprocess del sistema y vas saltando con una estructura que tiene la eprocess hacia el siguiente proceso. Si no esta modificado el proceso va a salir hay  :)

Un Saludo  ;)
22  Seguridad Informática / Análisis y Diseño de Malware / Re: +++ScanLix 1.0 +++[Scaner de virus 10AVs] [+] [BATCH Versión] en: 12 Julio 2008, 22:06
No revivas posts tan antiguos ;)
23  Seguridad Informática / Análisis y Diseño de Malware / Re: Anti sXe en: 12 Julio 2008, 13:20
injecta la dll y escondela o posiblemente la detecte y se cierre.

No se en que estructura se guardan las Dll's cargadas en la eproc, la sabes????
24  Seguridad Informática / Análisis y Diseño de Malware / Re: Anti sXe en: 12 Julio 2008, 13:10
Descarto lo de parchear la Dll, ya que supongo que la Dll es quien maneja todo el cotarro, y si nos la cargamos el servidor nos daria una patada, voy a intentar conjelar el sXe unos segundos, inyectar una Dll y volverlo a arrancar.

De momento pude sacar el pid del hl a partir de DKOM, ya que el sXe hookeaba la API requerida para consultar los procesos (podrian haber deslinkeado el proceso con DKOM, pero ni eso  :xD).

Voy a ver si con el codigo que me paso Mek puedo deshookear todas las Dll's, ya que desde el metodo que yo uso no se puede.

Un Saludo  :)
25  Seguridad Informática / Análisis y Diseño de Malware / Re: Falsificar process id en: 12 Julio 2008, 13:07
Lympex y yo le damos a esto de las estructuras unos dias que no parabamos  :xD :xD

Lo gracioso es cuando se le pone como PID = 4  :rolleyes: :rolleyes: :rolleyes: :xD

Un Saludo  :)
26  Programación / Programación General / Re: Más Instrucciones de los PIC en: 12 Julio 2008, 12:20
Yo para PIC's solo e usado C...Asi que no te puedo ayudar mucho  :-\

Gracias pro los links, estan interesantes  :)
27  Forums Generales / Sugerencias y dudas sobre el Foro / Re: Topic ASM en: 12 Julio 2008, 12:16
Yo solo recuerdo alguna vez haber bromeado con eso.. :¬¬

Seguro???  :xD :xD :xD ;D ;)

Pues se deja en General  ;)
28  Programación / Programación General / Re: Visual C vs Delphi en: 11 Julio 2008, 23:46
E usado los 3 que se nombraron (C/C++, Delphi y Pascal), aunque de estos 3 actualmente solo uso C/C++  ;)
29  Programación / Programación General / Re: Visual C vs Delphi en: 11 Julio 2008, 23:12
Delphi (Pascal seguro) tambien  ;)
30  Seguridad Informática / Análisis y Diseño de Malware / Re: Anti sXe en: 11 Julio 2008, 22:24
el cod utiliza el pb, yo estuve jugando con el y es bastante kbron.

De momento voy a mirar de parchear el sXe cliente para que no se cierre el juego al ser descargado.

Luego si quieres nos ponemos con el pb, son praticas bastante divertidas  :D
Páginas: 1 [2] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... 123




Consolas     La Web de Goku     MilW0rm     MundoDivx

Hispabyte     Truzone     TodoReviews     ZonaPhotoshop

hard-h2o modding    Foros de ayuda    Yashira.org    Videojuegos    indetectables.net   

Noticias Informatica    Seguridad Informática    ADSL    Foros en español    eNYe Sec

Todas las webs afiliadas están libres de publicidad engañosa.

Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC