![]() |
GetCraftedPacket() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Public Function |
Declared in: TCPCrafter.h |
Declaration
char * GetCraftedPacket(
unsigned short usSourcePort,
unsigned long ulDestinationAddress,
const char* pBuffer,
unsigned long ulBufferSize,
unsigned short usDestinationPort,
unsigned short& usTotalSize) const;
DescriptionGet the memory of a crafted packet (returns an allocated packet)
Function Body
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)
See Also
This web site was generated
using Surveyor V4.50.811.1. Click
here
for more information. |
Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003. |