Retail products


Traffic interception SDK

Control every TCP/IP network connection

  • Route connections via proxy
  • Redirect connections and modify the data
  • Block connections and applications
SSL interception SDK

View SSL in plaintext and modify it

  • View the SSL stream decrypted in plaintext
  • Redirect SSL connection and modify decrypted data
  • Browser shows "SSL lock" without warnings

Documentation


CIPCrafter Class Reference

#include <IPCrafter.h>

Inheritance diagram for CIPCrafter:
Collaboration diagram for CIPCrafter:

List of all members.


Public Member Functions

char * GetCraftedPacket (const CSpoofSocket *pSocket, unsigned long ulDestinationAddress, const char *pBuffer, unsigned short usBufferSize, unsigned short &usTotalSize) const
void SetUseDefaultChecksum (BOOL bDefault)
void SetChecksum (unsigned short usChecksum)
void SetDefault ()
void SetTypeOfService (unsigned char ucTypeOfService)
void SetHeaderLength (unsigned char ucHeaderLength)
void SetIdentification (unsigned short usIdentification)
void SetFragmentationFlags (unsigned short usFragmentationFlags)
 CIPCrafter ()
virtual ~CIPCrafter ()

Protected Member Functions

LPIpHeader ConstructCraftedIPHeader (unsigned char ucProtocol, unsigned short usFragmentationFlags, unsigned char ucTTL, unsigned short usIdentification, unsigned char ucHeaderLength) const

Protected Attributes

unsigned short m_usFragmentationFlags
unsigned short m_usIdentification
unsigned char m_ucHeaderLength
unsigned char m_ucTypeOfService
unsigned short m_usChecksum
BOOL m_DefaultChecksum

Private Types

enum  _LogPriority { lpDebug, lpMessage, lpCritical, lpError }
typedef enum
CErrorHandler::_LogPriority 
LogPriority

Private Member Functions

int GetSystemLastError () const
int GetLastError () const
virtual void NotifyShutdown ()
void RegisterShutdown (CSpoofBase *pBase)
void SetLastError (const std::string &rMethod) const
void SetLastError (const std::string &, int iErrorCode) const
void SetLocalLog (CErrorLog *pLog)
const std::string & GetClassName () const
void WriteMessage (const std::string &rMethod, const std::string &rMessage, LogPriority aPriority=lpMessage)
void WriteMessage (const std::string &rMethod, const std::string &rMessage, DWORD dwAdditionalData, LogPriority aPriority=lpMessage)
virtual void ReportError (const std::string &rMethod) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage, DWORD dwAdditionalData) const
virtual void ReportError (const std::string &rMethod, int iErrorCode) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage, int iErrorCode) const
virtual void ReportErrorOS (const std::string &rMethod, const std::string &rMessage) const
void SetName (const std::string &rName) const

Static Private Member Functions

static int GetErrorCode ()
static BOOL IsInitialized ()
static unsigned long StringToLong (const std::string &rAddress)
static char FAR * LongToString (unsigned long ulAddr)
static std::string LongToStdString (unsigned long ulAddr)
static BOOL InitializeSockets (BOOL bMultiThreaded=TRUE, unsigned long ulNumberOfThreads=10)
static BOOL InitializeSocketsNoMap (BOOL bMultiThreaded=TRUE, unsigned long ulNumberOfThreads=10)
static BOOL ShutdownSockets ()
static unsigned long GetNumberOfThreads ()
static BOOL IsMultiThreaded ()
static CGenericCriticalSectionGetGlobalCriticalSection ()
static std::string GetCurrentDateTime ()
static std::string ErrorCodeToString (DWORD dwErrorCode)
static void SetLog (CErrorLog *pLog)
static void WriteStaticMessage (const std::string &rClass, const std::string &rMethod, const std::string &rMessage, LogPriority aPriority=lpMessage)
static void WriteStaticMessage (const std::string &rClass, const std::string &rMethod, const std::string &rMessage, DWORD dwAdditionalData, LogPriority aPriority=lpMessage)
static void ReportStaticError (const std::string &rClass, const std::string &rMethod)
static void ReportStaticError (const std::string &rClass, const std::string &rMethod, const std::string &rMessage)
static void ReportStaticError (const std::string &rClass, const std::string &rMethod, const std::string &rMessage, DWORD dwAdditionalData)

Static Private Attributes

static CGenericCriticalSectionm_pCSection = NULL

Detailed Description

Definition at line 52 of file IPCrafter.h.


Constructor & Destructor Documentation

CIPCrafter::CIPCrafter (  ) 

Definition at line 53 of file IPCrafter.cpp.

00053                        : CSpoofBase()
00054 {
00055     try
00056     {
00057         //Set our name
00058         SetName(CIPCrafter_Class);
00059 
00060         //Set the default data
00061         SetDefault();
00062     }
00063     ERROR_HANDLER("CIPCrafter")
00064 }

CIPCrafter::~CIPCrafter (  )  [virtual]

Definition at line 66 of file IPCrafter.cpp.

00067 {
00068 }


Member Function Documentation

LPIpHeader CIPCrafter::ConstructCraftedIPHeader ( unsigned char  ucProtocol,
unsigned short  usFragmentationFlags,
unsigned char  ucTTL,
unsigned short  usIdentification,
unsigned char  ucHeaderLength 
) const [protected]

Definition at line 115 of file IPCrafter.cpp.

00120 {
00121     try
00122     {
00123         //Get the original header
00124         LPIpHeader lpHead;
00125 
00126         //Check what header length to pass
00127         unsigned char ucLength;
00128 
00129         if (m_ucHeaderLength==IPCRAFTER_DEFAULT_HEADER_SIZE)
00130             ucLength=ucHeaderLength;
00131         else
00132             ucLength=m_ucHeaderLength;
00133 
00134         //Get the header
00135         lpHead=CSpoofSocket::ConstructStaticIPHeader(ucProtocol,
00136                                                      m_usFragmentationFlags,
00137                                                      ucTTL,
00138                                                      m_usIdentification,
00139                                                      ucLength);
00140 
00141         //Check we have it
00142         if (!lpHead)
00143             return NULL;
00144 
00145         //Set the type of service
00146         //Precedence
00147         lpHead->ucTypeOfService=m_ucTypeOfService;
00148 
00149         //Done
00150         return lpHead;
00151     }
00152     ERROR_HANDLER_RETURN("ConstructCraftedIPHeader",NULL)
00153 }

char * CIPCrafter::GetCraftedPacket ( const CSpoofSocket pSocket,
unsigned long  ulDestinationAddress,
const char *  pBuffer,
unsigned short  usBufferSize,
unsigned short &  usTotalSize 
) const

Definition at line 155 of file IPCrafter.cpp.

00160 {
00161     try
00162     {
00163         //Check if the length is too big
00164         if (IpHeaderLength+(long)usBufferSize>65535)
00165         {
00166             //Report it
00167             ReportError("GetCraftedPacket","Packet can't be greater then 65k!");
00168 
00169             //Exit
00170             return NULL;
00171         }
00172 
00173         //Header length
00174         unsigned char ucHeaderLength=IpHeaderLength;
00175 
00176         if (pSocket->HasOptions())
00177             ucHeaderLength+=pSocket->GetOptions()->GetBufferLength();
00178         
00179         //First construct the packet
00180         LPIpHeader lpHead=pSocket->ConstructIPHeader(pSocket->GetProtocol(),
00181                                                      IpFragFlag_DONT_FRAG,
00182                                                      pSocket->GetTTL(),
00183                                                      (unsigned short)GetCurrentProcessId(),
00184                                                      ucHeaderLength);
00185 
00186         //Set the address
00187         pSocket->SetIPHeaderAddress(lpHead,
00188                                     pSocket->GetSourceAddress(),
00189                                     ulDestinationAddress);
00190 
00191         //Now add some more options
00192         unsigned short usTotalLength;
00193         usTotalLength=ucHeaderLength+usBufferSize;
00194 
00195         //Set the header
00196         lpHead->usTotalLength=htons(usTotalLength);
00197 
00198         //Need to construct a new packet
00199         char* pNewBuf;
00200         pNewBuf=new char[usTotalLength];
00201 
00202         //Copy two buffers
00203         memcpy(pNewBuf,
00204                lpHead,
00205                IpHeaderLength);
00206 
00207         //Do we need to copy options ?
00208         if (pSocket->HasOptions())
00209             memcpy(pNewBuf+IpHeaderLength,
00210                    pSocket->GetOptions()->GetBuffer(),
00211                    pSocket->GetOptions()->GetBufferLength());
00212 
00213         //Only if not null
00214         if (pBuffer)
00215             memcpy(pNewBuf+ucHeaderLength,
00216                    pBuffer,
00217                    usBufferSize);
00218         
00219         //Calculate the checksum
00220         lpHead->usChecksum=pSocket->CalculateChecksum((unsigned short*)pNewBuf,
00221                                                       ucHeaderLength);
00222 
00223         //Alert everyone this is the final header
00224         pSocket->FinalIPHeader(lpHead);
00225 
00226         //Recopy the ip
00227         memcpy(pNewBuf,
00228                lpHead,
00229                IpHeaderLength);
00230             
00231         //Set the total size
00232         usTotalSize=usTotalLength;
00233 
00234         //Return to the user
00235         return pNewBuf;
00236     }
00237     ERROR_HANDLER_RETURN("GetCraftedPacket",NULL)
00238 }

void CIPCrafter::SetChecksum ( unsigned short  usChecksum  ) 

Definition at line 105 of file IPCrafter.cpp.

00106 {
00107     m_usChecksum=usChecksum;
00108 }

void CIPCrafter::SetDefault (  ) 

Definition at line 90 of file IPCrafter.cpp.

00091 {
00092     try
00093     {
00094         m_usFragmentationFlags=IpFragFlag_DONT_FRAG;
00095         m_usIdentification=(unsigned short)GetCurrentProcessId();
00096         m_ucHeaderLength=IPCRAFTER_DEFAULT_HEADER_SIZE; //Default size
00097         m_ucTypeOfService=IpService_ROUTINE;
00098 
00099         //Default checksum used
00100         m_DefaultChecksum=TRUE;
00101     }
00102     ERROR_HANDLER("SetDefault")
00103 }

void CIPCrafter::SetFragmentationFlags ( unsigned short  usFragmentationFlags  ) 

Definition at line 70 of file IPCrafter.cpp.

00071 {
00072     m_usFragmentationFlags=usFragmentationFlags;
00073 }

void CIPCrafter::SetHeaderLength ( unsigned char  ucHeaderLength  ) 

Definition at line 80 of file IPCrafter.cpp.

00081 {
00082     m_ucHeaderLength=ucHeaderLength;
00083 }

void CIPCrafter::SetIdentification ( unsigned short  usIdentification  ) 

Definition at line 75 of file IPCrafter.cpp.

00076 {
00077     m_usIdentification=usIdentification;
00078 }

void CIPCrafter::SetTypeOfService ( unsigned char  ucTypeOfService  ) 

Definition at line 85 of file IPCrafter.cpp.

00086 {
00087     m_ucTypeOfService=ucTypeOfService;
00088 }

void CIPCrafter::SetUseDefaultChecksum ( BOOL  bDefault  ) 

Definition at line 110 of file IPCrafter.cpp.

00111 {
00112     m_DefaultChecksum=bDefault;
00113 }


Member Data Documentation

Definition at line 102 of file IPCrafter.h.

unsigned char CIPCrafter::m_ucHeaderLength [protected]

Definition at line 97 of file IPCrafter.h.

unsigned char CIPCrafter::m_ucTypeOfService [protected]

Definition at line 98 of file IPCrafter.h.

unsigned short CIPCrafter::m_usChecksum [protected]

Definition at line 101 of file IPCrafter.h.

unsigned short CIPCrafter::m_usFragmentationFlags [protected]

Definition at line 95 of file IPCrafter.h.

unsigned short CIPCrafter::m_usIdentification [protected]

Definition at line 96 of file IPCrafter.h.


The documentation for this class was generated from the following files: