this is a windows App (through VC++)
i have an application written in C which is a basic packet sniffer. (it wasnt written by me)
for my purposes i have modified it to look for IPs that are banned and send via a pipe (CreateNamedPipe) to my particular program.
this is all well and good... however i have learned that the program i am sending data too can be crashed by a mal-formed packet
unfortunately i have no access to the network code (as this is a game engine code) and can only "see" the malformed packet.
question time: im using <winsock2.h> and im clearly intercepting the packets (because if i set a breakpoint in my sniffer my server doesnt crash) is it possible to DROP a packet?
i can provide a copy of the logger and a copy of the program that is crashing it, if neccessary. but basically this is my code (theres obviously a bit more to it but i dont want to clutter the thread)
now in checkFilter i can look at the protocol, packet type etc etc....
but i need to see if the packet is too big
i have an application written in C which is a basic packet sniffer. (it wasnt written by me)
for my purposes i have modified it to look for IPs that are banned and send via a pipe (CreateNamedPipe) to my particular program.
this is all well and good... however i have learned that the program i am sending data too can be crashed by a mal-formed packet
unfortunately i have no access to the network code (as this is a game engine code) and can only "see" the malformed packet.
question time: im using <winsock2.h> and im clearly intercepting the packets (because if i set a breakpoint in my sniffer my server doesnt crash) is it possible to DROP a packet?
i can provide a copy of the logger and a copy of the program that is crashing it, if neccessary. but basically this is my code (theres obviously a bit more to it but i dont want to clutter the thread)
Code:
WSABUF wsb;
char rcvbuf[MAX_IP_SIZE];
wsb.buf = rcvbuf;
while (bThreadActive) {
wsb.len = MAX_IP_SIZE;
memset(wsb.buf, 0x0, MAX_IP_SIZE);
GetPacket(&wsb);
CheckFilter(rcvbuf);
}
int GetPacket(WSABUF *wbuf)
{
DWORD dwBytesRet = 0, dwFlags = 0;
if (SOCKET_ERROR == WSARecv(sock, wbuf, 1, &dwBytesRet, &dwFlags, NULL, NULL))
fprintf(stderr,"WSARecv failed. Code %u\n",WSAGetLastError());
wbuf->len=dwBytesRet;
return 0;
}
now in checkFilter i can look at the protocol, packet type etc etc....
but i need to see if the packet is too big
Code:
dwPktLen = (DWORD)ntohs(*(WORD *)(wsb + 2))[code]
and drop/delete it if it is.
hope someone can help
If somethings hard to do, its not worth doing - Homer Simpson