Created
November 6, 2019 16:35
-
-
Save ivanvza/2de8e28774acffa79e3237daea7433bf to your computer and use it in GitHub Desktop.
DLL to capture proc send recv via detours
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef int(WSAAPI* tWSA)(SOCKET, const char*, int, int); | |
tWSA oSend = nullptr; | |
tWSA oRecv = nullptr; | |
int WSAAPI hkSend(SOCKET s, const char * buff, int len, int flags) | |
{ | |
printf("[SENT]\nLen: %d\nData (hex): "); | |
for (int i == 0; i < len; ++i) | |
printf("%02X ", (byte)buff[i]); | |
printf("----------------\n"); | |
return oSend(s, buff, len, flags); | |
} | |
int WSAAPI hkRecv(SOCKET s, const char * buff, int size, int flags) | |
{ | |
int ret = oRecv(s, buff, size, flags); | |
printf("[RECIEVED]\nLen: %d\nData (hex): "); | |
for (int i == 0; i < ret; ++i) | |
printf("%02X ", (byte)buff[i]); | |
printf("----------------\n"); | |
return ret; | |
} | |
int init() | |
{ | |
HMODULE ws32 = LoadLibraryA("Ws2_32.dll"); | |
FARPROC Send = GetProcAddress(ws32, "send"); | |
FARPROC Recv = GetProcAddress(ws32, "recv"); | |
oSend = reinterpret_cast<tWSA1>(Detour(Send, hkSend, 5)); | |
oRecv = reinterpret_cast<tWSA1>(Detour(Recv, hkRecv, 5)); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment