![]() |
GetCraftedPacket() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Public Function |
Declared in: TCPCrafter.h |
char * GetCraftedPacket( unsigned short usSourcePort, unsigned long ulDestinationAddress, const char* pBuffer, unsigned long ulBufferSize, unsigned short usDestinationPort, unsigned short& usTotalSize) const;
Get the memory of a crafted packet (returns an allocated packet)
try { //Let's try our first attack LPTCPHeader lpHead; //Header length int iHeaderLength; iHeaderLength=TCPHeaderLength; //Create the header lpHead=ConstructTCPHeader(usSourcePort, usDestinationPort, iHeaderLength); //Protect it std::auto_ptr<TCPHeader> pProtection(lpHead); //Our total length int iTotalLength; iTotalLength=iHeaderLength+ulBufferSize; //Allocate the buffer char* pNewBuffer; pNewBuffer=new char[iTotalLength]; //Protect it CArray_ptr<char> pBufferProtection(pNewBuffer); //Copy the header memcpy(pNewBuffer, lpHead, iHeaderLength); //Copy the data if (ulBufferSize) //Copy the data memcpy(pNewBuffer+iHeaderLength, pBuffer, ulBufferSize); //Calculate the checksum lpHead->usChecksum=CalculatePseudoChecksum(pNewBuffer, iTotalLength, ulDestinationAddress, iTotalLength); //Last change to the header FinalTCPHeader(lpHead); //Copy the header memcpy(pNewBuffer, lpHead, iHeaderLength); //Send the data char* pNewData; pNewData=CIPCrafter::GetCraftedPacket(this, ulDestinationAddress, pNewBuffer, iTotalLength, usTotalSize); //Exit return pNewData; } ERROR_HANDLER_RETURN("GetCraftedPacket",NULL)
![]() |
Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003. |